From ef49021c8b5e84e409b2a52b7cf7de59fda18348 Mon Sep 17 00:00:00 2001
From: Robert van der Hulst
Date: Wed, 15 Mar 2017 10:15:43 +0100
Subject: [PATCH] Fixed portability problems in C# target. Also cleaned up
some XML doc comments
---
contributors.txt | 3 +-
.../CSharp/Antlr4.Runtime/AntlrInputStream.cs | 2 +-
.../runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs | 2 +-
.../Antlr4.Runtime/Atn/ATNDeserializer.cs | 2 +-
.../CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs | 9 +-
.../Antlr4.Runtime/Atn/AmbiguityInfo.cs | 2 +-
.../Atn/ContextSensitivityInfo.cs | 2 +-
.../Antlr4.Runtime/Atn/EpsilonTransition.cs | 4 +-
.../CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs | 2 +-
.../CSharp/Antlr4.Runtime/Atn/ILexerAction.cs | 2 +-
.../CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs | 8 +-
.../Antlr4.Runtime/Atn/LexerATNSimulator.cs | 92 +++++++++----------
.../Antlr4.Runtime/Atn/ParserATNSimulator.cs | 90 +++++++++---------
.../Antlr4.Runtime/Atn/PredicateEvalInfo.cs | 4 +-
.../Antlr4.Runtime/Atn/PredictionMode.cs | 18 ++--
.../Antlr4.Runtime/IParserErrorListener.cs | 2 +-
16 files changed, 125 insertions(+), 119 deletions(-)
diff --git a/contributors.txt b/contributors.txt
index 395f8269c..0c35f8e0d 100644
--- a/contributors.txt
+++ b/contributors.txt
@@ -140,4 +140,5 @@ YYYY/MM/DD, github id, Full name, email
2017/02/26, jvasileff, John Vasileff, john@vasileff.com
2017/03/08, harry-tallbelt, Igor Vysokopoyasny, harry.tallbelt@gmail.com
2017/03/09, teverett, Tom Everett, tom@khubla.com
-2017/03/03, chund, Christian Hund, christian.hund@gmail.com
\ No newline at end of file
+2017/03/03, chund, Christian Hund, christian.hund@gmail.com
+2017/03/15, robertvanderhulst, Robert van der Hulst, robert@xsharp.eu
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrInputStream.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrInputStream.cs
index 56942a0ff..b0a9cb261 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrInputStream.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrInputStream.cs
@@ -287,7 +287,7 @@ namespace Antlr4.Runtime
///
/// Alternative to
- ///
+ ///
/// which treats the input as a series of Unicode code points,
/// instead of a series of UTF-16 code units.
///
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs
index 1063aff58..b7dc29643 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs
@@ -104,7 +104,7 @@ namespace Antlr4.Runtime.Atn
/// If
///
/// is
- ///
+ ///
/// , the set of tokens will not include what can follow
/// the rule surrounding
///
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs
index 871862804..875c3b45a 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs
@@ -583,7 +583,7 @@ namespace Antlr4.Runtime.Atn
///
/// states in the specified ATN to set
/// the
- ///
+ ///
/// field to the
/// correct value.
///
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs
index 0beb44dc4..36c453c13 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs
@@ -75,7 +75,14 @@ namespace Antlr4.Runtime.Atn
throw new Exception("This ATN simulator does not support clearing the DFA.");
}
- public PredictionContextCache getSharedContextCache()
+ protected void ConsoleWriteLine(string format, params object[] arg)
+ {
+#if !PORTABLE
+ System.Console.WriteLine(format, arg);
+#endif
+ }
+
+ public PredictionContextCache getSharedContextCache()
{
return sharedContextCache;
}
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs
index 8d65c590a..a7be1f056 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs
@@ -20,7 +20,7 @@ namespace Antlr4.Runtime.Atn
/// determine that the SLL conflict is truly an ambiguity. For example, if none
/// of the ATN configurations in the conflicting SLL configuration set have
/// traversed a global follow transition (i.e.
- ///
+ ///
/// is
///
/// for all
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs
index df4eac784..4c5abea62 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs
@@ -23,7 +23,7 @@ namespace Antlr4.Runtime.Atn
/// the two-stage parsing strategy to improve parsing performance for that
/// input.
///
- ///
+ ///
///
/// 4.3
public class ContextSensitivityInfo : DecisionEventInfo
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs
index 25e260e24..e1ee4337f 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs
@@ -27,8 +27,8 @@ namespace Antlr4.Runtime.Atn
/// the rule index of a precedence rule for which this transition is
/// returning from, where the precedence value is 0; otherwise, -1.
///
- ///
- ///
+ ///
+ ///
/// 4.4.1
public int OutermostPrecedenceReturn
{
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs
index 22e805869..67a982dc6 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs
@@ -33,7 +33,7 @@ namespace Antlr4.Runtime.Atn
///
/// The final simulator state reached during prediction
/// prior to reaching the
- ///
+ ///
/// state
///
/// The input token stream
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs
index 83330322d..ad5ec127b 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs
@@ -46,7 +46,7 @@ namespace Antlr4.Runtime.Atn
/// , do not check the input index during their execution.
/// Actions like this are position-independent, and may be stored more
/// efficiently as part of the
- ///
+ ///
/// .
///
///
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs
index 71895262b..e83f64509 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs
@@ -184,7 +184,7 @@ namespace Antlr4.Runtime.Atn
/// If
///
/// is
- ///
+ ///
/// and
///
/// or the end of the rule containing
@@ -194,7 +194,7 @@ namespace Antlr4.Runtime.Atn
/// is added to the result set. If
///
/// is not
- ///
+ ///
/// and
///
/// is
@@ -213,7 +213,7 @@ namespace Antlr4.Runtime.Atn
///
///
/// The outer context, or
- ///
+ ///
/// if
/// the outer context should not be used.
///
@@ -250,7 +250,7 @@ namespace Antlr4.Runtime.Atn
/// outermost context is reached. This parameter has no effect if
///
/// is
- ///
+ ///
/// .
///
protected internal virtual void Look(ATNState s, ATNState stopState, PredictionContext ctx, IntervalSet look, HashSet lookBusy, BitSet calledRuleStack, bool seeThruPreds, bool addEOF)
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs
index bb4f8b29e..6da407f8a 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs
@@ -12,11 +12,9 @@ namespace Antlr4.Runtime.Atn
/// "dup" of ParserInterpreter
public class LexerATNSimulator : ATNSimulator
{
-#if !PORTABLE
public readonly bool debug = false;
public readonly bool dfa_debug = false;
-#endif
public static readonly int MIN_DFA_EDGE = 0;
@@ -64,7 +62,9 @@ namespace Antlr4.Runtime.Atn
this.recog = recog;
}
- public void CopyState(LexerATNSimulator simulator)
+
+
+ public void CopyState(LexerATNSimulator simulator)
{
this.charPositionInLine = simulator.charPositionInLine;
this.thisLine = simulator.thisLine;
@@ -117,13 +117,11 @@ namespace Antlr4.Runtime.Atn
protected int MatchATN(ICharStream input)
{
ATNState startState = atn.modeToStartState[mode];
-
- if (debug)
+ if (debug)
{
- Console.WriteLine("matchATN mode " + mode + " start: " + startState);
+ ConsoleWriteLine("matchATN mode " + mode + " start: " + startState);
}
-
- int old_mode = mode;
+ int old_mode = mode;
ATNConfigSet s0_closure = ComputeStartState(input, startState);
bool suppressEdge = s0_closure.hasSemanticContext;
@@ -136,24 +134,21 @@ namespace Antlr4.Runtime.Atn
}
int predict = ExecATN(input, next);
-
- if (debug)
+ if (debug)
{
- Console.WriteLine("DFA after matchATN: " + decisionToDFA[old_mode].ToString());
+ ConsoleWriteLine("DFA after matchATN: " + decisionToDFA[old_mode].ToString());
}
-
- return predict;
+ return predict;
}
protected int ExecATN(ICharStream input, DFAState ds0)
{
- //System.out.println("enter exec index "+input.index()+" from "+ds0.configs);
- if (debug)
- {
- Console.WriteLine("start state closure=" + ds0.configSet);
+ //System.out.println("enter exec index "+input.index()+" from "+ds0.configs);
+ if (debug)
+ {
+ ConsoleWriteLine("start state closure=" + ds0.configSet);
}
-
- if (ds0.isAcceptState)
+ if (ds0.isAcceptState)
{
// allow zero-length tokens
CaptureSimState(prevAccept, input, ds0);
@@ -165,29 +160,28 @@ namespace Antlr4.Runtime.Atn
while (true)
{ // while more work
- if (debug)
- {
- Console.WriteLine("execATN loop starting closure: " + s.configSet);
+ if (debug)
+ {
+ ConsoleWriteLine("execATN loop starting closure: " + s.configSet);
}
-
- // As we move src->trg, src->trg, we keep track of the previous trg to
- // avoid looking up the DFA state again, which is expensive.
- // If the previous target was already part of the DFA, we might
- // be able to avoid doing a reach operation upon t. If s!=null,
- // it means that semantic predicates didn't prevent us from
- // creating a DFA state. Once we know s!=null, we check to see if
- // the DFA state has an edge already for t. If so, we can just reuse
- // it's configuration set; there's no point in re-computing it.
- // This is kind of like doing DFA simulation within the ATN
- // simulation because DFA simulation is really just a way to avoid
- // computing reach/closure sets. Technically, once we know that
- // we have a previously added DFA state, we could jump over to
- // the DFA simulator. But, that would mean popping back and forth
- // a lot and making things more complicated algorithmically.
- // This optimization makes a lot of sense for loops within DFA.
- // A character will take us back to an existing DFA state
- // that already has lots of edges out of it. e.g., .* in comments.
- DFAState target = GetExistingTargetState(s, t);
+ // As we move src->trg, src->trg, we keep track of the previous trg to
+ // avoid looking up the DFA state again, which is expensive.
+ // If the previous target was already part of the DFA, we might
+ // be able to avoid doing a reach operation upon t. If s!=null,
+ // it means that semantic predicates didn't prevent us from
+ // creating a DFA state. Once we know s!=null, we check to see if
+ // the DFA state has an edge already for t. If so, we can just reuse
+ // it's configuration set; there's no point in re-computing it.
+ // This is kind of like doing DFA simulation within the ATN
+ // simulation because DFA simulation is really just a way to avoid
+ // computing reach/closure sets. Technically, once we know that
+ // we have a previously added DFA state, we could jump over to
+ // the DFA simulator. But, that would mean popping back and forth
+ // a lot and making things more complicated algorithmically.
+ // This optimization makes a lot of sense for loops within DFA.
+ // A character will take us back to an existing DFA state
+ // that already has lots of edges out of it. e.g., .* in comments.
+ DFAState target = GetExistingTargetState(s, t);
if (target == null)
{
target = ComputeTargetState(input, s, t);
@@ -245,7 +239,7 @@ namespace Antlr4.Runtime.Atn
DFAState target = s.edges[t - MIN_DFA_EDGE];
if (debug && target != null)
{
- Console.WriteLine("reuse state " + s.stateNumber + " edge to " + target.stateNumber);
+ ConsoleWriteLine("reuse state " + s.stateNumber + " edge to " + target.stateNumber);
}
return target;
@@ -329,7 +323,7 @@ namespace Antlr4.Runtime.Atn
if (debug)
{
- Console.WriteLine("testing " + GetTokenName(t) + " at " + c.ToString(recog, true));
+ ConsoleWriteLine("testing " + GetTokenName(t) + " at " + c.ToString(recog, true));
}
int n = c.state.NumberOfTransitions;
@@ -363,7 +357,7 @@ namespace Antlr4.Runtime.Atn
{
if (debug)
{
- Console.WriteLine("ACTION " + lexerActionExecutor);
+ ConsoleWriteLine("ACTION " + lexerActionExecutor);
}
// seek to after last char in token
@@ -417,7 +411,7 @@ namespace Antlr4.Runtime.Atn
{
if (debug)
{
- Console.WriteLine("closure(" + config.ToString(recog, true) + ")");
+ ConsoleWriteLine("closure(" + config.ToString(recog, true) + ")");
}
if (config.state is RuleStopState)
@@ -426,10 +420,10 @@ namespace Antlr4.Runtime.Atn
{
if (recog != null)
{
- Console.WriteLine("closure at " + recog.RuleNames[config.state.ruleIndex] + " rule stop " + config);
+ ConsoleWriteLine("closure at " + recog.RuleNames[config.state.ruleIndex] + " rule stop " + config);
}
else {
- Console.WriteLine("closure at rule stop " + config);
+ ConsoleWriteLine("closure at rule stop " + config);
}
}
@@ -529,7 +523,7 @@ namespace Antlr4.Runtime.Atn
PredicateTransition pt = (PredicateTransition)t;
if (debug)
{
- Console.WriteLine("EVAL rule " + pt.ruleIndex + ":" + pt.predIndex);
+ ConsoleWriteLine("EVAL rule " + pt.ruleIndex + ":" + pt.predIndex);
}
configs.hasSemanticContext = true;
if (EvaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative))
@@ -688,7 +682,7 @@ namespace Antlr4.Runtime.Atn
if (debug)
{
- Console.WriteLine("EDGE " + p + " -> " + q + " upon " + ((char)t));
+ ConsoleWriteLine("EDGE " + p + " -> " + q + " upon " + ((char)t));
}
lock (p)
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs
index e203a2331..835109446 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs
@@ -284,8 +284,8 @@ namespace Antlr4.Runtime.Atn
this.parser = parser;
this.decisionToDFA = decisionToDFA;
// DOTGenerator dot = new DOTGenerator(null);
- // Console.WriteLine(dot.getDOT(atn.rules.get(0), parser.getRuleNames()));
- // Console.WriteLine(dot.getDOT(atn.rules.get(1), parser.getRuleNames()));
+ // ConsoleWriteLine(dot.getDOT(atn.rules.get(0), parser.getRuleNames()));
+ // ConsoleWriteLine(dot.getDOT(atn.rules.get(1), parser.getRuleNames()));
}
public override void Reset()
@@ -306,7 +306,7 @@ namespace Antlr4.Runtime.Atn
{
if (debug || debug_list_atn_decisions)
{
- Console.WriteLine("adaptivePredict decision " + decision +
+ ConsoleWriteLine("adaptivePredict decision " + decision +
" exec LA(1)==" + GetLookaheadName(input) +
" line " + input.LT(1).Line + ":" + input.LT(1).Column);
}
@@ -341,7 +341,7 @@ namespace Antlr4.Runtime.Atn
if (outerContext == null) outerContext = ParserRuleContext.EmptyContext;
if (debug || debug_list_atn_decisions)
{
- Console.WriteLine("predictATN decision " + dfa.decision +
+ ConsoleWriteLine("predictATN decision " + dfa.decision +
" exec LA(1)==" + GetLookaheadName(input) +
", outerContext=" + outerContext.ToString(parser));
}
@@ -373,7 +373,7 @@ namespace Antlr4.Runtime.Atn
int alt = ExecATN(dfa, s0, input, index, outerContext);
if (debug)
- Console.WriteLine("DFA after predictATN: " + dfa.ToString(parser.Vocabulary));
+ ConsoleWriteLine("DFA after predictATN: " + dfa.ToString(parser.Vocabulary));
return alt;
}
finally
@@ -421,14 +421,14 @@ namespace Antlr4.Runtime.Atn
{
if (debug || debug_list_atn_decisions)
{
- Console.WriteLine("execATN decision " + dfa.decision +
+ ConsoleWriteLine("execATN decision " + dfa.decision +
" exec LA(1)==" + GetLookaheadName(input) +
" line " + input.LT(1).Line + ":" + input.LT(1).Column);
}
DFAState previousD = s0;
- if (debug) Console.WriteLine("s0 = " + s0);
+ if (debug) ConsoleWriteLine("s0 = " + s0);
int t = input.LA(1);
@@ -467,7 +467,7 @@ namespace Antlr4.Runtime.Atn
BitSet conflictingAlts = D.configSet.conflictingAlts;
if (D.predicates != null)
{
- if (debug) Console.WriteLine("DFA state has preds in DFA sim LL failover");
+ if (debug) ConsoleWriteLine("DFA state has preds in DFA sim LL failover");
int conflictIndex = input.Index;
if (conflictIndex != startIndex)
{
@@ -477,7 +477,7 @@ namespace Antlr4.Runtime.Atn
conflictingAlts = EvalSemanticContext(D.predicates, outerContext, true);
if (conflictingAlts.Cardinality() == 1)
{
- if (debug) Console.WriteLine("Full LL avoided");
+ if (debug) ConsoleWriteLine("Full LL avoided");
return conflictingAlts.NextSetBit(0);
}
@@ -489,7 +489,7 @@ namespace Antlr4.Runtime.Atn
}
}
- if (dfa_debug) Console.WriteLine("ctx sensitive state " + outerContext + " in " + D);
+ if (dfa_debug) ConsoleWriteLine("ctx sensitive state " + outerContext + " in " + D);
bool fullCtx = true;
ATNConfigSet s0_closure =
ComputeStartState(dfa.atnStartState, outerContext, fullCtx);
@@ -587,7 +587,7 @@ namespace Antlr4.Runtime.Atn
if (debug)
{
ICollection altSubSets = PredictionMode.GetConflictingAltSubsets(reach.configs);
- Console.WriteLine("SLL altSubSets=" + altSubSets +
+ ConsoleWriteLine("SLL altSubSets=" + altSubSets +
", configs=" + reach +
", predict=" + predictedAlt + ", allSubsetsConflict=" +
PredictionMode.AllSubsetsConflict(altSubSets) + ", conflictingAlts=" +
@@ -656,7 +656,7 @@ namespace Antlr4.Runtime.Atn
{
if (debug || debug_list_atn_decisions)
{
- Console.WriteLine("execATNWithFullContext " + s0);
+ ConsoleWriteLine("execATNWithFullContext " + s0);
}
bool fullCtx = true;
bool foundExactAmbig = false;
@@ -667,7 +667,7 @@ namespace Antlr4.Runtime.Atn
int predictedAlt;
while (true)
{ // while more work
- // Console.WriteLine("LL REACH "+GetLookaheadName(input)+
+ // ConsoleWriteLine("LL REACH "+GetLookaheadName(input)+
// " from configs.size="+previous.size()+
// " line "+input.LT(1)Line+":"+input.LT(1).Column);
reach = ComputeReachSet(previous, t, fullCtx);
@@ -695,13 +695,13 @@ namespace Antlr4.Runtime.Atn
ICollection altSubSets = PredictionMode.GetConflictingAltSubsets(reach.configs);
if (debug)
{
- Console.WriteLine("LL altSubSets=" + altSubSets +
+ ConsoleWriteLine("LL altSubSets=" + altSubSets +
", predict=" + PredictionMode.GetUniqueAlt(altSubSets) +
", ResolvesToJustOneViableAlt=" +
PredictionMode.ResolvesToJustOneViableAlt(altSubSets));
}
- // Console.WriteLine("altSubSets: "+altSubSets);
+ // ConsoleWriteLine("altSubSets: "+altSubSets);
// System.err.println("reach="+reach+", "+reach.conflictingAlts);
reach.uniqueAlt = GetUniqueAlt(reach);
// unique prediction?
@@ -785,7 +785,7 @@ namespace Antlr4.Runtime.Atn
protected virtual ATNConfigSet ComputeReachSet(ATNConfigSet closure, int t, bool fullCtx)
{
if (debug)
- Console.WriteLine("in computeReachSet, starting closure: " + closure);
+ ConsoleWriteLine("in computeReachSet, starting closure: " + closure);
if (mergeCache == null)
{
@@ -809,7 +809,7 @@ namespace Antlr4.Runtime.Atn
// First figure out where we can reach on input t
foreach (ATNConfig c in closure.configs)
{
- if (debug) Console.WriteLine("testing " + GetTokenName(t) + " at " + c.ToString());
+ if (debug) ConsoleWriteLine("testing " + GetTokenName(t) + " at " + c.ToString());
if (c.state is RuleStopState)
{
@@ -1275,7 +1275,7 @@ namespace Antlr4.Runtime.Atn
// nonambig alts are null in altToPred
if (nPredAlts == 0) altToPred = null;
- if (debug) Console.WriteLine("getPredsForAmbigAlts result " + Arrays.ToString(altToPred));
+ if (debug) ConsoleWriteLine("getPredsForAmbigAlts result " + Arrays.ToString(altToPred));
return altToPred;
}
@@ -1302,7 +1302,7 @@ namespace Antlr4.Runtime.Atn
return null;
}
- // Console.WriteLine(Arrays.toString(altToPred)+"->"+pairs);
+ // ConsoleWriteLine(Arrays.toString(altToPred)+"->"+pairs);
return pairs.ToArray();
}
@@ -1452,12 +1452,12 @@ namespace Antlr4.Runtime.Atn
bool predicateEvaluationResult = EvalSemanticContext(pair.pred, outerContext, pair.alt, fullCtx);
if (debug || dfa_debug)
{
- Console.WriteLine("eval pred " + pair + "=" + predicateEvaluationResult);
+ ConsoleWriteLine("eval pred " + pair + "=" + predicateEvaluationResult);
}
if (predicateEvaluationResult)
{
- if (debug || dfa_debug) Console.WriteLine("PREDICT " + pair.alt);
+ if (debug || dfa_debug) ConsoleWriteLine("PREDICT " + pair.alt);
predictions[pair.alt] = true;
if (!complete)
{
@@ -1533,7 +1533,7 @@ namespace Antlr4.Runtime.Atn
bool treatEofAsEpsilon)
{
if (debug)
- Console.WriteLine("closure(" + config.ToString(parser, true) + ")");
+ ConsoleWriteLine("closure(" + config.ToString(parser, true) + ")");
if (config.state is RuleStopState)
{
@@ -1552,7 +1552,7 @@ namespace Antlr4.Runtime.Atn
}
else {
// we have no context info, just chase follow links (if greedy)
- if (debug) Console.WriteLine("FALLING off rule " +
+ if (debug) ConsoleWriteLine("FALLING off rule " +
GetRuleName(config.state.ruleIndex));
Closure_(config, configSet, closureBusy, collectPredicates,
fullCtx, depth, treatEofAsEpsilon);
@@ -1583,7 +1583,7 @@ namespace Antlr4.Runtime.Atn
}
else {
// else if we have no context info, just chase follow links (if greedy)
- if (debug) Console.WriteLine("FALLING off rule " +
+ if (debug) ConsoleWriteLine("FALLING off rule " +
GetRuleName(config.state.ruleIndex));
}
}
@@ -1608,7 +1608,7 @@ namespace Antlr4.Runtime.Atn
configs.Add(config, mergeCache);
// make sure to not return here, because EOF transitions can act as
// both epsilon transitions and non-epsilon transitions.
- // if ( debug ) Console.WriteLine("added config "+configs);
+ // if ( debug ) ConsoleWriteLine("added config "+configs);
}
for (int i = 0; i < p.NumberOfTransitions; i++)
@@ -1656,7 +1656,7 @@ namespace Antlr4.Runtime.Atn
configs.dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method
newDepth--;
if (debug)
- Console.WriteLine("dips into outer ctx: " + c);
+ ConsoleWriteLine("dips into outer ctx: " + c);
}
else if (t is RuleTransition)
{
@@ -1895,7 +1895,7 @@ namespace Antlr4.Runtime.Atn
protected ATNConfig ActionTransition(ATNConfig config, ActionTransition t)
{
- if (debug) Console.WriteLine("ACTION edge " + t.ruleIndex + ":" + t.actionIndex);
+ if (debug) ConsoleWriteLine("ACTION edge " + t.ruleIndex + ":" + t.actionIndex);
return new ATNConfig(config, t.target);
}
@@ -1908,12 +1908,12 @@ namespace Antlr4.Runtime.Atn
{
if (debug)
{
- Console.WriteLine("PRED (collectPredicates=" + collectPredicates + ") " +
+ ConsoleWriteLine("PRED (collectPredicates=" + collectPredicates + ") " +
pt.precedence + ">=_p" +
", ctx dependent=true");
if (parser != null)
{
- Console.WriteLine("context surrounding pred is " +
+ ConsoleWriteLine("context surrounding pred is " +
parser.GetRuleInvocationStack());
}
}
@@ -1945,7 +1945,7 @@ namespace Antlr4.Runtime.Atn
c = new ATNConfig(config, pt.target);
}
- if (debug) Console.WriteLine("config from pred transition=" + c);
+ if (debug) ConsoleWriteLine("config from pred transition=" + c);
return c;
}
@@ -1958,12 +1958,12 @@ namespace Antlr4.Runtime.Atn
{
if (debug)
{
- Console.WriteLine("PRED (collectPredicates=" + collectPredicates + ") " +
+ ConsoleWriteLine("PRED (collectPredicates=" + collectPredicates + ") " +
pt.ruleIndex + ":" + pt.predIndex +
", ctx dependent=" + pt.isCtxDependent);
if (parser != null)
{
- Console.WriteLine("context surrounding pred is " +
+ ConsoleWriteLine("context surrounding pred is " +
parser.GetRuleInvocationStack());
}
}
@@ -1996,7 +1996,7 @@ namespace Antlr4.Runtime.Atn
c = new ATNConfig(config, pt.target);
}
- if (debug) Console.WriteLine("config from pred transition=" + c);
+ if (debug) ConsoleWriteLine("config from pred transition=" + c);
return c;
}
@@ -2005,7 +2005,7 @@ namespace Antlr4.Runtime.Atn
{
if (debug)
{
- Console.WriteLine("CALL rule " + GetRuleName(t.target.ruleIndex) +
+ ConsoleWriteLine("CALL rule " + GetRuleName(t.target.ruleIndex) +
", ctx=" + config.context);
}
@@ -2109,8 +2109,10 @@ namespace Antlr4.Runtime.Atn
*/
public void DumpDeadEndConfigs(NoViableAltException nvae)
{
- Console.Error.WriteLine("dead end configs: ");
- foreach (ATNConfig c in nvae.DeadEndConfigs.configs)
+#if !PORTABLE
+ System.Console.Error.WriteLine("dead end configs: ");
+#endif
+ foreach (ATNConfig c in nvae.DeadEndConfigs.configs)
{
String trans = "no edges";
if (c.state.NumberOfTransitions > 0)
@@ -2128,7 +2130,9 @@ namespace Antlr4.Runtime.Atn
trans = (not ? "~" : "") + "Set " + st.set.ToString();
}
}
- Console.Error.WriteLine(c.ToString(parser, true) + ":" + trans);
+#if !PORTABLE
+ System.Console.Error.WriteLine(c.ToString(parser, true) + ":" + trans);
+#endif
}
}
@@ -2188,7 +2192,7 @@ namespace Antlr4.Runtime.Atn
{
if (debug)
{
- Console.WriteLine("EDGE " + from + " -> " + to + " upon " + GetTokenName(t));
+ ConsoleWriteLine("EDGE " + from + " -> " + to + " upon " + GetTokenName(t));
}
if (to == null)
@@ -2214,7 +2218,7 @@ namespace Antlr4.Runtime.Atn
if (debug)
{
- Console.WriteLine("DFA=\n" + dfa.ToString(parser != null ? parser.Vocabulary : Vocabulary.EmptyVocabulary));
+ ConsoleWriteLine("DFA=\n" + dfa.ToString(parser != null ? parser.Vocabulary : Vocabulary.EmptyVocabulary));
}
return to;
@@ -2254,7 +2258,7 @@ namespace Antlr4.Runtime.Atn
D.configSet.IsReadOnly = true;
}
dfa.states.Put(D, D);
- if (debug) Console.WriteLine("adding new DFA state: " + D);
+ if (debug) ConsoleWriteLine("adding new DFA state: " + D);
return D;
}
}
@@ -2264,7 +2268,7 @@ namespace Antlr4.Runtime.Atn
if (debug || retry_debug)
{
Interval interval = Interval.Of(startIndex, stopIndex);
- Console.WriteLine("reportAttemptingFullContext decision=" + dfa.decision + ":" + configs +
+ ConsoleWriteLine("reportAttemptingFullContext decision=" + dfa.decision + ":" + configs +
", input=" + parser.TokenStream.GetText(interval));
}
if (parser != null)
@@ -2276,7 +2280,7 @@ namespace Antlr4.Runtime.Atn
if (debug || retry_debug)
{
Interval interval = Interval.Of(startIndex, stopIndex);
- Console.WriteLine("ReportContextSensitivity decision=" + dfa.decision + ":" + configs +
+ ConsoleWriteLine("ReportContextSensitivity decision=" + dfa.decision + ":" + configs +
", input=" + parser.TokenStream.GetText(interval));
}
if (parser != null) parser.ErrorListenerDispatch.ReportContextSensitivity(parser, dfa, startIndex, stopIndex, prediction, null /*configs*/);
@@ -2293,7 +2297,7 @@ namespace Antlr4.Runtime.Atn
if (debug || retry_debug)
{
Interval interval = Interval.Of(startIndex, stopIndex);
- Console.WriteLine("ReportAmbiguity " +
+ ConsoleWriteLine("ReportAmbiguity " +
ambigAlts + ":" + configs +
", input=" + parser.TokenStream.GetText(interval));
}
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs
index cf156be9f..f45448024 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs
@@ -16,7 +16,7 @@ namespace Antlr4.Runtime.Atn
/// This class represents profiling event information for semantic predicate
/// evaluations which occur during prediction.
///
- ///
+ ///
/// 4.3
public class PredicateEvalInfo : DecisionEventInfo
{
@@ -68,7 +68,7 @@ namespace Antlr4.Runtime.Atn
///
/// for more information.
///
- ///
+ ///
///
public PredicateEvalInfo(SimulatorState state, int decision, ITokenStream input, int startIndex, int stopIndex, SemanticContext semctx, bool evalResult, int predictedAlt)
: base(decision, state, input, startIndex, stopIndex, state.useContext)
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs
index ebb2ae479..6ba853354 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs
@@ -110,7 +110,7 @@ namespace Antlr4.Runtime.Atn
/// The hash code is only a function of the
///
/// and
- ///
+ ///
/// .
///
public override int GetHashCode(ATNConfig o)
@@ -234,7 +234,7 @@ namespace Antlr4.Runtime.Atn
/// (s, 1, x,
/// ), (s, 1, x', {p}), (s, 2, x'', {})}
/// If the configuration set has predicates (as indicated by
- ///
+ ///
/// ), this algorithm makes a copy of
/// the configurations to strip out all of the predicates so that a standard
///
@@ -353,12 +353,12 @@ namespace Antlr4.Runtime.Atn
/// and singleton subsets with
/// non-conflicting configurations. Two configurations conflict if they have
/// identical
- ///
+ ///
/// and
- ///
+ ///
/// values
/// but different
- ///
+ ///
/// value, e.g.
/// (s, i, ctx, _)
/// and
@@ -387,7 +387,7 @@ namespace Antlr4.Runtime.Atn
/// :
///
/// map[c] U= c.
- /// getAlt()
+ /// getAlt()
/// # map hash/equals uses s and x, not
/// alt and not pred
///
@@ -801,7 +801,7 @@ namespace Antlr4.Runtime.Atn
/// :
///
/// map[c] U= c.
- /// getAlt()
+ /// getAlt()
/// # map hash/equals uses s and x, not
/// alt and not pred
///
@@ -833,9 +833,9 @@ namespace Antlr4.Runtime.Atn
/// :
///
/// map[c.
- ///
+ ///
/// ] U= c.
- ///
+ ///
///
///
[return: NotNull]
diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs
index 35fdcbce1..c4763e1da 100644
--- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs
+++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs
@@ -33,7 +33,7 @@ namespace Antlr4.Runtime
/// viable alternatives identified by the prediction algorithm. When
///
/// is null, use
- ///
+ ///
/// to obtain the represented
/// alternatives from the
///