Updated sharpen property annotations

This commit is contained in:
Sam Harwell 2013-02-16 15:23:03 -06:00
parent d676aa8c4c
commit 366da4e5d5
17 changed files with 274 additions and 205 deletions

View File

@ -477,7 +477,7 @@ namespace Antlr4.Runtime.Atn
{ {
if (dfa_debug && t >= 0) if (dfa_debug && t >= 0)
{ {
System.Console.Out.WriteLine("no edge for " + parser.GetTokenNames()[t]); System.Console.Out.WriteLine("no edge for " + parser.TokenNames[t]);
} }
int alt; int alt;
SimulatorState initialState = new SimulatorState(outerContext, s, state.useContext SimulatorState initialState = new SimulatorState(outerContext, s, state.useContext
@ -1475,7 +1475,7 @@ namespace Antlr4.Runtime.Atn
{ {
if (parser != null && index >= 0) if (parser != null && index >= 0)
{ {
return parser.GetRuleNames()[index]; return parser.RuleNames[index];
} }
return "<rule " + index + ">"; return "<rule " + index + ">";
} }
@ -1829,15 +1829,15 @@ namespace Antlr4.Runtime.Atn
{ {
return "EOF"; return "EOF";
} }
if (parser != null && parser.GetTokenNames() != null) if (parser != null && parser.TokenNames != null)
{ {
string[] tokensNames = parser.GetTokenNames(); string[] tokensNames = parser.TokenNames;
if (t >= tokensNames.Length) if (t >= tokensNames.Length)
{ {
System.Console.Error.WriteLine(t + " ttype out of range: " + Arrays.ToString(tokensNames System.Console.Error.WriteLine(t + " ttype out of range: " + Arrays.ToString(tokensNames
)); ));
System.Console.Error.WriteLine(((CommonTokenStream)((ITokenStream)parser.GetInputStream System.Console.Error.WriteLine(((CommonTokenStream)((ITokenStream)parser.InputStream
())).GetTokens()); )).GetTokens());
} }
else else
{ {
@ -2086,8 +2086,8 @@ namespace Antlr4.Runtime.Atn
{ {
Interval interval = Interval.Of(startIndex, stopIndex); Interval interval = Interval.Of(startIndex, stopIndex);
System.Console.Out.WriteLine("reportAttemptingFullContext decision=" + dfa.decision System.Console.Out.WriteLine("reportAttemptingFullContext decision=" + dfa.decision
+ ":" + initialState.s0.configs + ", input=" + ((ITokenStream)parser.GetInputStream + ":" + initialState.s0.configs + ", input=" + ((ITokenStream)parser.InputStream
()).GetText(interval)); ).GetText(interval));
} }
if (parser != null) if (parser != null)
{ {
@ -2103,8 +2103,8 @@ namespace Antlr4.Runtime.Atn
{ {
Interval interval = Interval.Of(startIndex, stopIndex); Interval interval = Interval.Of(startIndex, stopIndex);
System.Console.Out.WriteLine("reportContextSensitivity decision=" + dfa.decision System.Console.Out.WriteLine("reportContextSensitivity decision=" + dfa.decision
+ ":" + acceptState.s0.configs + ", input=" + ((ITokenStream)parser.GetInputStream + ":" + acceptState.s0.configs + ", input=" + ((ITokenStream)parser.InputStream
()).GetText(interval)); ).GetText(interval));
} }
if (parser != null) if (parser != null)
{ {
@ -2137,7 +2137,7 @@ namespace Antlr4.Runtime.Atn
// } // }
Interval interval = Interval.Of(startIndex, stopIndex); Interval interval = Interval.Of(startIndex, stopIndex);
System.Console.Out.WriteLine("reportAmbiguity " + ambigAlts + ":" + configs + ", input=" System.Console.Out.WriteLine("reportAmbiguity " + ambigAlts + ":" + configs + ", input="
+ ((ITokenStream)parser.GetInputStream()).GetText(interval)); + ((ITokenStream)parser.InputStream).GetText(interval));
} }
if (parser != null) if (parser != null)
{ {

View File

@ -484,9 +484,9 @@ namespace Antlr4.Runtime.Atn
// first char is '[', if more than that this isn't the first rule // first char is '[', if more than that this isn't the first rule
localBuffer.Append(' '); localBuffer.Append(' ');
} }
ATN atn = recognizer.GetATN(); ATN atn = recognizer.Atn;
ATNState s = atn.states[stateNumber]; ATNState s = atn.states[stateNumber];
string ruleName = recognizer.GetRuleNames()[s.ruleIndex]; string ruleName = recognizer.RuleNames[s.ruleIndex];
localBuffer.Append(ruleName); localBuffer.Append(ruleName);
} }
else else

View File

@ -56,8 +56,8 @@ namespace Antlr4.Runtime
/// </summary> /// </summary>
public override void Recover(Parser recognizer, RecognitionException e) public override void Recover(Parser recognizer, RecognitionException e)
{ {
for (ParserRuleContext context = recognizer.GetContext(); context != null; context for (ParserRuleContext context = recognizer.Context; context != null; context = (
= ((ParserRuleContext)context.Parent)) (ParserRuleContext)context.Parent))
{ {
context.exception = e; context.exception = e;
} }
@ -76,8 +76,8 @@ namespace Antlr4.Runtime
public override IToken RecoverInline(Parser recognizer) public override IToken RecoverInline(Parser recognizer)
{ {
InputMismatchException e = new InputMismatchException(recognizer); InputMismatchException e = new InputMismatchException(recognizer);
for (ParserRuleContext context = recognizer.GetContext(); context != null; context for (ParserRuleContext context = recognizer.Context; context != null; context = (
= ((ParserRuleContext)context.Parent)) (ParserRuleContext)context.Parent))
{ {
context.exception = e; context.exception = e;
} }

View File

@ -145,8 +145,8 @@ namespace Antlr4.Runtime
// ", lastErrorIndex="+ // ", lastErrorIndex="+
// lastErrorIndex+ // lastErrorIndex+
// ", states="+lastErrorStates); // ", states="+lastErrorStates);
if (lastErrorIndex == ((ITokenStream)recognizer.GetInputStream()).Index && lastErrorStates if (lastErrorIndex == ((ITokenStream)recognizer.InputStream).Index && lastErrorStates
!= null && lastErrorStates.Contains(recognizer.GetState())) != null && lastErrorStates.Contains(recognizer.State))
{ {
// uh oh, another error at same token index and previously-visited // uh oh, another error at same token index and previously-visited
// state in ATN; must be a case where LT(1) is in the recovery // state in ATN; must be a case where LT(1) is in the recovery
@ -157,12 +157,12 @@ namespace Antlr4.Runtime
// System.err.println("FAILSAFE consumes "+recognizer.getTokenNames()[recognizer.getInputStream().LA(1)]); // System.err.println("FAILSAFE consumes "+recognizer.getTokenNames()[recognizer.getInputStream().LA(1)]);
recognizer.Consume(); recognizer.Consume();
} }
lastErrorIndex = ((ITokenStream)recognizer.GetInputStream()).Index; lastErrorIndex = ((ITokenStream)recognizer.InputStream).Index;
if (lastErrorStates == null) if (lastErrorStates == null)
{ {
lastErrorStates = new IntervalSet(); lastErrorStates = new IntervalSet();
} }
lastErrorStates.Add(recognizer.GetState()); lastErrorStates.Add(recognizer.State);
IntervalSet followSet = GetErrorRecoverySet(recognizer); IntervalSet followSet = GetErrorRecoverySet(recognizer);
ConsumeUntil(recognizer, followSet); ConsumeUntil(recognizer, followSet);
} }
@ -186,17 +186,17 @@ namespace Antlr4.Runtime
/// </remarks> /// </remarks>
public virtual void Sync(Parser recognizer) public virtual void Sync(Parser recognizer)
{ {
ATNState s = recognizer.GetInterpreter().atn.states[recognizer.GetState()]; ATNState s = recognizer.Interpreter.atn.states[recognizer.State];
// System.err.println("sync @ "+s.stateNumber+"="+s.getClass().getSimpleName()); // System.err.println("sync @ "+s.stateNumber+"="+s.getClass().getSimpleName());
// If already recovering, don't try to sync // If already recovering, don't try to sync
if (errorRecoveryMode) if (errorRecoveryMode)
{ {
return; return;
} }
ITokenStream tokens = ((ITokenStream)recognizer.GetInputStream()); ITokenStream tokens = ((ITokenStream)recognizer.InputStream);
int la = tokens.La(1); int la = tokens.La(1);
// try cheaper subset first; might get lucky. seems to shave a wee bit off // try cheaper subset first; might get lucky. seems to shave a wee bit off
if (recognizer.GetATN().NextTokens(s).Contains(la) || la == IToken.Eof) if (recognizer.Atn.NextTokens(s).Contains(la) || la == IToken.Eof)
{ {
return; return;
} }
@ -245,7 +245,7 @@ namespace Antlr4.Runtime
public virtual void ReportNoViableAlternative(Parser recognizer, NoViableAltException public virtual void ReportNoViableAlternative(Parser recognizer, NoViableAltException
e) e)
{ {
ITokenStream tokens = ((ITokenStream)recognizer.GetInputStream()); ITokenStream tokens = ((ITokenStream)recognizer.InputStream);
string input; string input;
if (tokens != null) if (tokens != null)
{ {
@ -271,7 +271,7 @@ namespace Antlr4.Runtime
e) e)
{ {
string msg = "mismatched input " + GetTokenErrorDisplay(e.GetOffendingToken()) + string msg = "mismatched input " + GetTokenErrorDisplay(e.GetOffendingToken()) +
" expecting " + e.GetExpectedTokens().ToString(recognizer.GetTokenNames()); " expecting " + e.GetExpectedTokens().ToString(recognizer.TokenNames);
NotifyErrorListeners(recognizer, msg, e); NotifyErrorListeners(recognizer, msg, e);
} }
@ -279,7 +279,7 @@ namespace Antlr4.Runtime
public virtual void ReportFailedPredicate(Parser recognizer, FailedPredicateException public virtual void ReportFailedPredicate(Parser recognizer, FailedPredicateException
e) e)
{ {
string ruleName = recognizer.GetRuleNames()[recognizer._ctx.GetRuleIndex()]; string ruleName = recognizer.RuleNames[recognizer._ctx.GetRuleIndex()];
string msg = "rule " + ruleName + " " + e.Message; string msg = "rule " + ruleName + " " + e.Message;
NotifyErrorListeners(recognizer, msg, e); NotifyErrorListeners(recognizer, msg, e);
} }
@ -292,11 +292,11 @@ namespace Antlr4.Runtime
} }
recognizer._syntaxErrors++; recognizer._syntaxErrors++;
BeginErrorCondition(recognizer); BeginErrorCondition(recognizer);
IToken t = recognizer.GetCurrentToken(); IToken t = recognizer.CurrentToken;
string tokenName = GetTokenErrorDisplay(t); string tokenName = GetTokenErrorDisplay(t);
IntervalSet expecting = GetExpectedTokens(recognizer); IntervalSet expecting = GetExpectedTokens(recognizer);
string msg = "extraneous input " + tokenName + " expecting " + expecting.ToString string msg = "extraneous input " + tokenName + " expecting " + expecting.ToString
(recognizer.GetTokenNames()); (recognizer.TokenNames);
recognizer.NotifyErrorListeners(t, msg, null); recognizer.NotifyErrorListeners(t, msg, null);
} }
@ -308,10 +308,10 @@ namespace Antlr4.Runtime
} }
recognizer._syntaxErrors++; recognizer._syntaxErrors++;
BeginErrorCondition(recognizer); BeginErrorCondition(recognizer);
IToken t = recognizer.GetCurrentToken(); IToken t = recognizer.CurrentToken;
IntervalSet expecting = GetExpectedTokens(recognizer); IntervalSet expecting = GetExpectedTokens(recognizer);
string msg = "missing " + expecting.ToString(recognizer.GetTokenNames()) + " at " string msg = "missing " + expecting.ToString(recognizer.TokenNames) + " at " + GetTokenErrorDisplay
+ GetTokenErrorDisplay(t); (t);
recognizer.NotifyErrorListeners(t, msg, null); recognizer.NotifyErrorListeners(t, msg, null);
} }
@ -363,14 +363,13 @@ namespace Antlr4.Runtime
// if next token is what we are looking for then "delete" this token // if next token is what we are looking for then "delete" this token
public virtual bool SingleTokenInsertion(Parser recognizer) public virtual bool SingleTokenInsertion(Parser recognizer)
{ {
int currentSymbolType = ((ITokenStream)recognizer.GetInputStream()).La(1); int currentSymbolType = ((ITokenStream)recognizer.InputStream).La(1);
// if current token is consistent with what could come after current // if current token is consistent with what could come after current
// ATN state, then we know we're missing a token; error recovery // ATN state, then we know we're missing a token; error recovery
// is free to conjure up and insert the missing token // is free to conjure up and insert the missing token
ATNState currentState = recognizer.GetInterpreter().atn.states[recognizer.GetState ATNState currentState = recognizer.Interpreter.atn.states[recognizer.State];
()];
ATNState next = currentState.Transition(0).target; ATNState next = currentState.Transition(0).target;
ATN atn = recognizer.GetInterpreter().atn; ATN atn = recognizer.Interpreter.atn;
IntervalSet expectingAtLL2 = atn.NextTokens(next, PredictionContext.FromRuleContext IntervalSet expectingAtLL2 = atn.NextTokens(next, PredictionContext.FromRuleContext
(atn, recognizer._ctx)); (atn, recognizer._ctx));
// System.out.println("LT(2) set="+expectingAtLL2.toString(recognizer.getTokenNames())); // System.out.println("LT(2) set="+expectingAtLL2.toString(recognizer.getTokenNames()));
@ -384,7 +383,7 @@ namespace Antlr4.Runtime
public virtual IToken SingleTokenDeletion(Parser recognizer) public virtual IToken SingleTokenDeletion(Parser recognizer)
{ {
int nextTokenType = ((ITokenStream)recognizer.GetInputStream()).La(2); int nextTokenType = ((ITokenStream)recognizer.InputStream).La(2);
IntervalSet expecting = GetExpectedTokens(recognizer); IntervalSet expecting = GetExpectedTokens(recognizer);
if (expecting.Contains(nextTokenType)) if (expecting.Contains(nextTokenType))
{ {
@ -392,7 +391,7 @@ namespace Antlr4.Runtime
recognizer.Consume(); recognizer.Consume();
// simply delete extra token // simply delete extra token
// we want to return the token we're actually matching // we want to return the token we're actually matching
IToken matchedSymbol = recognizer.GetCurrentToken(); IToken matchedSymbol = recognizer.CurrentToken;
EndErrorCondition(recognizer); EndErrorCondition(recognizer);
// we know current token is correct // we know current token is correct
return matchedSymbol; return matchedSymbol;
@ -422,7 +421,7 @@ namespace Antlr4.Runtime
/// </remarks> /// </remarks>
protected internal virtual IToken GetMissingSymbol(Parser recognizer) protected internal virtual IToken GetMissingSymbol(Parser recognizer)
{ {
IToken currentSymbol = recognizer.GetCurrentToken(); IToken currentSymbol = recognizer.CurrentToken;
IntervalSet expecting = GetExpectedTokens(recognizer); IntervalSet expecting = GetExpectedTokens(recognizer);
int expectedTokenType = expecting.GetMinElement(); int expectedTokenType = expecting.GetMinElement();
// get any element // get any element
@ -433,15 +432,15 @@ namespace Antlr4.Runtime
} }
else else
{ {
tokenText = "<missing " + recognizer.GetTokenNames()[expectedTokenType] + ">"; tokenText = "<missing " + recognizer.TokenNames[expectedTokenType] + ">";
} }
IToken current = currentSymbol; IToken current = currentSymbol;
IToken lookback = ((ITokenStream)recognizer.GetInputStream()).Lt(-1); IToken lookback = ((ITokenStream)recognizer.InputStream).Lt(-1);
if (current.Type == IToken.Eof && lookback != null) if (current.Type == IToken.Eof && lookback != null)
{ {
current = lookback; current = lookback;
} }
return ConstructToken(((ITokenStream)recognizer.GetInputStream()).TokenSource, expectedTokenType return ConstructToken(((ITokenStream)recognizer.InputStream).TokenSource, expectedTokenType
, tokenText, current); , tokenText, current);
} }
@ -515,7 +514,7 @@ namespace Antlr4.Runtime
protected internal virtual IntervalSet GetErrorRecoverySet(Parser recognizer) protected internal virtual IntervalSet GetErrorRecoverySet(Parser recognizer)
{ {
ATN atn = recognizer.GetInterpreter().atn; ATN atn = recognizer.Interpreter.atn;
RuleContext ctx = recognizer._ctx; RuleContext ctx = recognizer._ctx;
IntervalSet recoverSet = new IntervalSet(); IntervalSet recoverSet = new IntervalSet();
while (ctx != null && ctx.invokingState >= 0) while (ctx != null && ctx.invokingState >= 0)
@ -536,13 +535,13 @@ namespace Antlr4.Runtime
public virtual void ConsumeUntil(Parser recognizer, IntervalSet set) public virtual void ConsumeUntil(Parser recognizer, IntervalSet set)
{ {
// System.err.println("consumeUntil("+set.toString(recognizer.getTokenNames())+")"); // System.err.println("consumeUntil("+set.toString(recognizer.getTokenNames())+")");
int ttype = ((ITokenStream)recognizer.GetInputStream()).La(1); int ttype = ((ITokenStream)recognizer.InputStream).La(1);
while (ttype != IToken.Eof && !set.Contains(ttype)) while (ttype != IToken.Eof && !set.Contains(ttype))
{ {
//System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]); //System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
// recognizer.getInputStream().consume(); // recognizer.getInputStream().consume();
recognizer.Consume(); recognizer.Consume();
ttype = ((ITokenStream)recognizer.GetInputStream()).La(1); ttype = ((ITokenStream)recognizer.InputStream).La(1);
} }
} }
} }

View File

@ -59,8 +59,8 @@ namespace Antlr4.Runtime.Dfa
} }
public DFASerializer(DFA dfa, Recognizer<object, object> parser) : this(dfa, parser public DFASerializer(DFA dfa, Recognizer<object, object> parser) : this(dfa, parser
!= null ? parser.GetTokenNames() : null, parser != null ? parser.GetRuleNames != null ? parser.TokenNames : null, parser != null ? parser.RuleNames : null
() : null, parser != null ? parser.GetATN() : null) , parser != null ? parser.Atn : null)
{ {
} }

View File

@ -43,8 +43,8 @@ namespace Antlr4.Runtime
{ {
string format = "reportAmbiguity d=%s: ambigAlts=%s, input='%s'"; string format = "reportAmbiguity d=%s: ambigAlts=%s, input='%s'";
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer
, dfa.decision), ambigAlts, ((ITokenStream)recognizer.GetInputStream()).GetText , dfa.decision), ambigAlts, ((ITokenStream)recognizer.InputStream).GetText(Interval
(Interval.Of(startIndex, stopIndex)))); .Of(startIndex, stopIndex))));
} }
public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int
@ -52,8 +52,8 @@ namespace Antlr4.Runtime
{ {
string format = "reportAttemptingFullContext d=%s, input='%s'"; string format = "reportAttemptingFullContext d=%s, input='%s'";
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer
, dfa.decision), ((ITokenStream)recognizer.GetInputStream()).GetText(Interval , dfa.decision), ((ITokenStream)recognizer.InputStream).GetText(Interval.Of(startIndex
.Of(startIndex, stopIndex)))); , stopIndex))));
} }
public override void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex public override void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex
@ -61,8 +61,8 @@ namespace Antlr4.Runtime
{ {
string format = "reportContextSensitivity d=%s, input='%s'"; string format = "reportContextSensitivity d=%s, input='%s'";
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer
, dfa.decision), ((ITokenStream)recognizer.GetInputStream()).GetText(Interval , dfa.decision), ((ITokenStream)recognizer.InputStream).GetText(Interval.Of(startIndex
.Of(startIndex, stopIndex)))); , stopIndex))));
} }
protected internal virtual string GetDecisionDescription(Parser recognizer, int decision protected internal virtual string GetDecisionDescription(Parser recognizer, int decision

View File

@ -63,9 +63,9 @@ namespace Antlr4.Runtime
public FailedPredicateException(Parser recognizer, string predicate, string message public FailedPredicateException(Parser recognizer, string predicate, string message
) : base(FormatMessage(predicate, message), recognizer, ((ITokenStream)recognizer ) : base(FormatMessage(predicate, message), recognizer, ((ITokenStream)recognizer
.GetInputStream()), recognizer._ctx) .InputStream), recognizer._ctx)
{ {
ATNState s = recognizer.GetInterpreter().atn.states[recognizer.GetState()]; ATNState s = recognizer.Interpreter.atn.states[recognizer.State];
AbstractPredicateTransition trans = (AbstractPredicateTransition)s.Transition(0); AbstractPredicateTransition trans = (AbstractPredicateTransition)s.Transition(0);
if (trans is PredicateTransition) if (trans is PredicateTransition)
{ {
@ -78,7 +78,7 @@ namespace Antlr4.Runtime
this.predicateIndex = 0; this.predicateIndex = 0;
} }
this.predicate = predicate; this.predicate = predicate;
this.SetOffendingToken(recognizer.GetCurrentToken()); this.SetOffendingToken(recognizer.CurrentToken);
} }
public virtual int GetRuleIndex() public virtual int GetRuleIndex()

View File

@ -46,9 +46,9 @@ namespace Antlr4.Runtime
private const long serialVersionUID = 1532568338707443067L; private const long serialVersionUID = 1532568338707443067L;
public InputMismatchException(Parser recognizer) : base(recognizer, ((ITokenStream public InputMismatchException(Parser recognizer) : base(recognizer, ((ITokenStream
)recognizer.GetInputStream()), recognizer._ctx) )recognizer.InputStream), recognizer._ctx)
{ {
this.SetOffendingToken(recognizer.GetCurrentToken()); this.SetOffendingToken(recognizer.CurrentToken);
} }
} }
} }

View File

@ -147,7 +147,7 @@ namespace Antlr4.Runtime
_hitEOF = false; _hitEOF = false;
_mode = Antlr4.Runtime.Lexer.DefaultMode; _mode = Antlr4.Runtime.Lexer.DefaultMode;
_modeStack.Clear(); _modeStack.Clear();
GetInterpreter().Reset(); Interpreter.Reset();
} }
/// <summary> /// <summary>
@ -180,8 +180,8 @@ namespace Antlr4.Runtime
_token = null; _token = null;
_channel = IToken.DefaultChannel; _channel = IToken.DefaultChannel;
_tokenStartCharIndex = _input.Index; _tokenStartCharIndex = _input.Index;
_tokenStartCharPositionInLine = GetInterpreter().GetCharPositionInLine(); _tokenStartCharPositionInLine = Interpreter.GetCharPositionInLine();
_tokenStartLine = GetInterpreter().GetLine(); _tokenStartLine = Interpreter.GetLine();
_text = null; _text = null;
do do
{ {
@ -192,7 +192,7 @@ namespace Antlr4.Runtime
int ttype; int ttype;
try try
{ {
ttype = GetInterpreter().Match(_input, _mode); ttype = Interpreter.Match(_input, _mode);
} }
catch (LexerNoViableAltException e) catch (LexerNoViableAltException e)
{ {
@ -305,10 +305,13 @@ outer_break: ;
} }
} }
public override IIntStream GetInputStream() public override IIntStream InputStream
{
get
{ {
return _input; return _input;
} }
}
/// <summary> /// <summary>
/// By default does not support multiple emits per nextToken invocation /// By default does not support multiple emits per nextToken invocation
@ -365,7 +368,7 @@ outer_break: ;
{ {
get get
{ {
return GetInterpreter().GetLine(); return Interpreter.GetLine();
} }
} }
@ -373,18 +376,18 @@ outer_break: ;
{ {
get get
{ {
return GetInterpreter().GetCharPositionInLine(); return Interpreter.GetCharPositionInLine();
} }
} }
public virtual void SetLine(int line) public virtual void SetLine(int line)
{ {
GetInterpreter().SetLine(line); Interpreter.SetLine(line);
} }
public virtual void SetCharPositionInLine(int charPositionInLine) public virtual void SetCharPositionInLine(int charPositionInLine)
{ {
GetInterpreter().SetCharPositionInLine(charPositionInLine); Interpreter.SetCharPositionInLine(charPositionInLine);
} }
/// <summary>What is the index of the current character of lookahead?</summary> /// <summary>What is the index of the current character of lookahead?</summary>
@ -407,7 +410,7 @@ outer_break: ;
{ {
return _text; return _text;
} }
return GetInterpreter().GetText(_input); return Interpreter.GetText(_input);
} }
/// <summary> /// <summary>
@ -469,10 +472,13 @@ outer_break: ;
/// error reporting. The generated parsers implement a method /// error reporting. The generated parsers implement a method
/// that overrides this to point to their String[] tokenNames. /// that overrides this to point to their String[] tokenNames.
/// </remarks> /// </remarks>
public override string[] GetTokenNames() public override string[] TokenNames
{
get
{ {
return null; return null;
} }
}
/// <summary>Return a list of all Token objects in input char stream.</summary> /// <summary>Return a list of all Token objects in input char stream.</summary>
/// <remarks> /// <remarks>
@ -496,7 +502,7 @@ outer_break: ;
if (_input.La(1) != IIntStream.Eof) if (_input.La(1) != IIntStream.Eof)
{ {
// skip a char and try again // skip a char and try again
GetInterpreter().Consume(_input); Interpreter.Consume(_input);
} }
} }

View File

@ -283,19 +283,19 @@ namespace Antlr4.Runtime.Misc
if (diagnostics) if (diagnostics)
{ {
parser.AddErrorListener(new DiagnosticErrorListener()); parser.AddErrorListener(new DiagnosticErrorListener());
parser.GetInterpreter().SetPredictionMode(PredictionMode.LlExactAmbigDetection); parser.Interpreter.SetPredictionMode(PredictionMode.LlExactAmbigDetection);
} }
if (printTree || gui || psFile != null) if (printTree || gui || psFile != null)
{ {
parser.SetBuildParseTree(true); parser.BuildParseTree = true;
} }
if (Sll) if (Sll)
{ {
// overrides diagnostics // overrides diagnostics
parser.GetInterpreter().SetPredictionMode(PredictionMode.Sll); parser.Interpreter.SetPredictionMode(PredictionMode.Sll);
} }
parser.SetInputStream(tokens); parser.SetInputStream(tokens);
parser.SetTrace(trace); parser.Trace = trace;
try try
{ {
MethodInfo startRule = parserClass.GetMethod(startRuleName, (Type[])null); MethodInfo startRule = parserClass.GetMethod(startRuleName, (Type[])null);

View File

@ -68,8 +68,8 @@ namespace Antlr4.Runtime
private readonly IToken startToken; private readonly IToken startToken;
public NoViableAltException(Parser recognizer) : this(recognizer, ((ITokenStream) public NoViableAltException(Parser recognizer) : this(recognizer, ((ITokenStream)
recognizer.GetInputStream()), recognizer.GetCurrentToken(), recognizer.GetCurrentToken recognizer.InputStream), recognizer.CurrentToken, recognizer.CurrentToken, null
(), null, recognizer._ctx) , recognizer._ctx)
{ {
} }

View File

@ -48,13 +48,13 @@ namespace Antlr4.Runtime
{ {
public virtual void EnterEveryRule(ParserRuleContext ctx) public virtual void EnterEveryRule(ParserRuleContext ctx)
{ {
System.Console.Out.WriteLine("enter " + this._enclosing.GetRuleNames()[ctx.GetRuleIndex System.Console.Out.WriteLine("enter " + this._enclosing.RuleNames[ctx.GetRuleIndex
()] + ", LT(1)=" + this._enclosing._input.Lt(1).Text); ()] + ", LT(1)=" + this._enclosing._input.Lt(1).Text);
} }
public virtual void ExitEveryRule(ParserRuleContext ctx) public virtual void ExitEveryRule(ParserRuleContext ctx)
{ {
System.Console.Out.WriteLine("exit " + this._enclosing.GetRuleNames()[ctx.GetRuleIndex System.Console.Out.WriteLine("exit " + this._enclosing.RuleNames[ctx.GetRuleIndex
()] + ", LT(1)=" + this._enclosing._input.Lt(1).Text); ()] + ", LT(1)=" + this._enclosing._input.Lt(1).Text);
} }
@ -66,8 +66,8 @@ namespace Antlr4.Runtime
{ {
ParserRuleContext parent = (ParserRuleContext)((IRuleNode)node.Parent).RuleContext; ParserRuleContext parent = (ParserRuleContext)((IRuleNode)node.Parent).RuleContext;
IToken token = node.Symbol; IToken token = node.Symbol;
System.Console.Out.WriteLine("consume " + token + " rule " + this._enclosing.GetRuleNames System.Console.Out.WriteLine("consume " + token + " rule " + this._enclosing.RuleNames
()[parent.GetRuleIndex()] + " alt=" + parent.altNum); [parent.GetRuleIndex()] + " alt=" + parent.altNum);
} }
internal TraceListener(Parser _enclosing) internal TraceListener(Parser _enclosing)
@ -155,9 +155,9 @@ namespace Antlr4.Runtime
/// <summary>reset the parser's state</summary> /// <summary>reset the parser's state</summary>
public virtual void Reset() public virtual void Reset()
{ {
if (((ITokenStream)GetInputStream()) != null) if (((ITokenStream)InputStream) != null)
{ {
((ITokenStream)GetInputStream()).Seek(0); ((ITokenStream)InputStream).Seek(0);
} }
_errHandler.EndErrorCondition(this); _errHandler.EndErrorCondition(this);
_ctx = null; _ctx = null;
@ -165,7 +165,7 @@ namespace Antlr4.Runtime
_tracer = null; _tracer = null;
_precedenceStack.Clear(); _precedenceStack.Clear();
_precedenceStack.Push(0); _precedenceStack.Push(0);
ATNSimulator interpreter = GetInterpreter(); ATNSimulator interpreter = Interpreter;
if (interpreter != null) if (interpreter != null)
{ {
interpreter.Reset(); interpreter.Reset();
@ -181,7 +181,7 @@ namespace Antlr4.Runtime
/// <exception cref="Antlr4.Runtime.RecognitionException"></exception> /// <exception cref="Antlr4.Runtime.RecognitionException"></exception>
public virtual IToken Match(int ttype) public virtual IToken Match(int ttype)
{ {
IToken t = GetCurrentToken(); IToken t = CurrentToken;
if (t.Type == ttype) if (t.Type == ttype)
{ {
_errHandler.EndErrorCondition(this); _errHandler.EndErrorCondition(this);
@ -203,7 +203,7 @@ namespace Antlr4.Runtime
/// <exception cref="Antlr4.Runtime.RecognitionException"></exception> /// <exception cref="Antlr4.Runtime.RecognitionException"></exception>
public virtual IToken MatchWildcard() public virtual IToken MatchWildcard()
{ {
IToken t = GetCurrentToken(); IToken t = CurrentToken;
if (t.Type > 0) if (t.Type > 0)
{ {
_errHandler.EndErrorCondition(this); _errHandler.EndErrorCondition(this);
@ -244,15 +244,18 @@ namespace Antlr4.Runtime
/// somebody's children list. Contexts are then not candidates /// somebody's children list. Contexts are then not candidates
/// for garbage collection. /// for garbage collection.
/// </remarks> /// </remarks>
public virtual void SetBuildParseTree(bool buildParseTrees) public virtual bool BuildParseTree
{ {
this._buildParseTrees = buildParseTrees; get
}
public virtual bool GetBuildParseTree()
{ {
return _buildParseTrees; return _buildParseTrees;
} }
set
{
bool buildParseTrees = value;
this._buildParseTrees = buildParseTrees;
}
}
/// <summary>Trim the internal lists of the parse tree during parsing to conserve memory. /// <summary>Trim the internal lists of the parse tree during parsing to conserve memory.
/// </summary> /// </summary>
@ -262,29 +265,13 @@ namespace Antlr4.Runtime
/// <code>false</code> /// <code>false</code>
/// by default for a newly constructed parser. /// by default for a newly constructed parser.
/// </remarks> /// </remarks>
/// <param name="trimParseTrees"> /// <value>
/// ///
/// <code>true</code> /// <code>true</code>
/// to trim the capacity of the /// to trim the capacity of the
/// <see cref="ParserRuleContext.children">ParserRuleContext.children</see> /// <see cref="ParserRuleContext.children">ParserRuleContext.children</see>
/// list to its size after a rule is parsed. /// list to its size after a rule is parsed.
/// </param> /// </value>
public virtual void SetTrimParseTree(bool trimParseTrees)
{
if (trimParseTrees)
{
if (GetTrimParseTree())
{
return;
}
AddParseListener(Parser.TrimToSizeListener.Instance);
}
else
{
RemoveParseListener(Parser.TrimToSizeListener.Instance);
}
}
/// <returns> /// <returns>
/// ///
/// <code>true</code> /// <code>true</code>
@ -295,7 +282,9 @@ namespace Antlr4.Runtime
/// <see cref="TrimToSizeListener">TrimToSizeListener</see> /// <see cref="TrimToSizeListener">TrimToSizeListener</see>
/// during the parse process. /// during the parse process.
/// </returns> /// </returns>
public virtual bool GetTrimParseTree() public virtual bool TrimParseTree
{
get
{ {
if (_parseListeners == null) if (_parseListeners == null)
{ {
@ -303,7 +292,28 @@ namespace Antlr4.Runtime
} }
return _parseListeners.Contains(Parser.TrimToSizeListener.Instance); return _parseListeners.Contains(Parser.TrimToSizeListener.Instance);
} }
set
{
bool trimParseTrees = value;
if (trimParseTrees)
{
if (TrimParseTree)
{
return;
}
AddParseListener(Parser.TrimToSizeListener.Instance);
}
else
{
RemoveParseListener(Parser.TrimToSizeListener.Instance);
}
}
}
public virtual IList<IParseTreeListener> ParseListeners
{
get
{
// public void setTraceATNStates(boolean traceATNStates) { // public void setTraceATNStates(boolean traceATNStates) {
// this.traceATNStates = traceATNStates; // this.traceATNStates = traceATNStates;
// } // }
@ -311,10 +321,9 @@ namespace Antlr4.Runtime
// public boolean getTraceATNStates() { // public boolean getTraceATNStates() {
// return traceATNStates; // return traceATNStates;
// } // }
public virtual IList<IParseTreeListener> GetParseListeners()
{
return _parseListeners; return _parseListeners;
} }
}
/// <summary> /// <summary>
/// Provide a listener that gets notified about token matches, /// Provide a listener that gets notified about token matches,
@ -411,25 +420,34 @@ namespace Antlr4.Runtime
/// an error and next valid token match /// an error and next valid token match
/// See also reportError() /// See also reportError()
/// </remarks> /// </remarks>
public virtual int GetNumberOfSyntaxErrors() public virtual int NumberOfSyntaxErrors
{
get
{ {
return _syntaxErrors; return _syntaxErrors;
} }
}
public virtual IAntlrErrorStrategy GetErrorHandler() public virtual IAntlrErrorStrategy ErrorHandler
{
get
{ {
return _errHandler; return _errHandler;
} }
set
public virtual void SetErrorHandler(IAntlrErrorStrategy handler)
{ {
IAntlrErrorStrategy handler = value;
this._errHandler = handler; this._errHandler = handler;
} }
}
public override IIntStream GetInputStream() public override IIntStream InputStream
{
get
{ {
return _input; return _input;
} }
}
/// <summary>Set the token stream and reset the parser</summary> /// <summary>Set the token stream and reset the parser</summary>
public virtual void SetInputStream(ITokenStream input) public virtual void SetInputStream(ITokenStream input)
@ -447,14 +465,17 @@ namespace Antlr4.Runtime
/// Match needs to return the current input symbol, which gets put /// Match needs to return the current input symbol, which gets put
/// into the label for the associated token ref; e.g., x=ID. /// into the label for the associated token ref; e.g., x=ID.
/// </remarks> /// </remarks>
public virtual IToken GetCurrentToken() public virtual IToken CurrentToken
{
get
{ {
return _input.Lt(1); return _input.Lt(1);
} }
}
public virtual void NotifyErrorListeners(string msg) public virtual void NotifyErrorListeners(string msg)
{ {
NotifyErrorListeners(GetCurrentToken(), msg, null); NotifyErrorListeners(CurrentToken, msg, null);
} }
public virtual void NotifyErrorListeners(IToken offendingToken, string msg, RecognitionException public virtual void NotifyErrorListeners(IToken offendingToken, string msg, RecognitionException
@ -485,10 +506,10 @@ namespace Antlr4.Runtime
/// </remarks> /// </remarks>
public virtual IToken Consume() public virtual IToken Consume()
{ {
IToken o = GetCurrentToken(); IToken o = CurrentToken;
if (o.Type != Eof) if (o.Type != Eof)
{ {
((ITokenStream)GetInputStream()).Consume(); ((ITokenStream)InputStream).Consume();
} }
bool hasListener = _parseListeners != null && !_parseListeners.IsEmpty(); bool hasListener = _parseListeners != null && !_parseListeners.IsEmpty();
if (_buildParseTrees || hasListener) if (_buildParseTrees || hasListener)
@ -540,7 +561,7 @@ namespace Antlr4.Runtime
public virtual void EnterRule(ParserRuleContext localctx, int state, int ruleIndex public virtual void EnterRule(ParserRuleContext localctx, int state, int ruleIndex
) )
{ {
SetState(state); State = state;
_ctx = localctx; _ctx = localctx;
_ctx.start = _input.Lt(1); _ctx.start = _input.Lt(1);
if (_buildParseTrees) if (_buildParseTrees)
@ -556,7 +577,7 @@ namespace Antlr4.Runtime
public virtual void EnterLeftFactoredRule(ParserRuleContext localctx, int state, public virtual void EnterLeftFactoredRule(ParserRuleContext localctx, int state,
int ruleIndex) int ruleIndex)
{ {
SetState(state); State = state;
if (_buildParseTrees) if (_buildParseTrees)
{ {
ParserRuleContext factoredContext = (ParserRuleContext)_ctx.GetChild(_ctx.ChildCount ParserRuleContext factoredContext = (ParserRuleContext)_ctx.GetChild(_ctx.ChildCount
@ -585,7 +606,7 @@ namespace Antlr4.Runtime
{ {
TriggerExitRuleEvent(); TriggerExitRuleEvent();
} }
SetState(_ctx.invokingState); State = _ctx.invokingState;
_ctx = (ParserRuleContext)_ctx.parent; _ctx = (ParserRuleContext)_ctx.parent;
} }
@ -681,10 +702,13 @@ namespace Antlr4.Runtime
return null; return null;
} }
public virtual ParserRuleContext GetContext() public virtual ParserRuleContext Context
{
get
{ {
return _ctx; return _ctx;
} }
}
public override bool Precpred(RuleContext localctx, int precedence) public override bool Precpred(RuleContext localctx, int precedence)
{ {
@ -705,9 +729,9 @@ namespace Antlr4.Runtime
public virtual bool IsExpectedToken(int symbol) public virtual bool IsExpectedToken(int symbol)
{ {
// return getInterpreter().atn.nextTokens(_ctx); // return getInterpreter().atn.nextTokens(_ctx);
ATN atn = GetInterpreter().atn; ATN atn = Interpreter.atn;
ParserRuleContext ctx = _ctx; ParserRuleContext ctx = _ctx;
ATNState s = atn.states[GetState()]; ATNState s = atn.states[State];
IntervalSet following = atn.NextTokens(s); IntervalSet following = atn.NextTokens(s);
if (following.Contains(symbol)) if (following.Contains(symbol))
{ {
@ -747,9 +771,9 @@ namespace Antlr4.Runtime
/// </remarks> /// </remarks>
public virtual IntervalSet GetExpectedTokens() public virtual IntervalSet GetExpectedTokens()
{ {
ATN atn = GetInterpreter().atn; ATN atn = Interpreter.atn;
ParserRuleContext ctx = _ctx; ParserRuleContext ctx = _ctx;
ATNState s = atn.states[GetState()]; ATNState s = atn.states[State];
IntervalSet following = atn.NextTokens(s); IntervalSet following = atn.NextTokens(s);
// System.out.println("following "+s+"="+following); // System.out.println("following "+s+"="+following);
if (!following.Contains(IToken.Epsilon)) if (!following.Contains(IToken.Epsilon))
@ -778,11 +802,15 @@ namespace Antlr4.Runtime
public virtual IntervalSet GetExpectedTokensWithinCurrentRule() public virtual IntervalSet GetExpectedTokensWithinCurrentRule()
{ {
ATN atn = GetInterpreter().atn; ATN atn = Interpreter.atn;
ATNState s = atn.states[GetState()]; ATNState s = atn.states[State];
return atn.NextTokens(s); return atn.NextTokens(s);
} }
public virtual ParserRuleContext RuleContext
{
get
{
// /** Compute the set of valid tokens reachable from the current // /** Compute the set of valid tokens reachable from the current
// * position in the parse. // * position in the parse.
// */ // */
@ -792,10 +820,9 @@ namespace Antlr4.Runtime
// if ( s == null ) return null; // if ( s == null ) return null;
// return atn.nextTokens(s, ctx); // return atn.nextTokens(s, ctx);
// } // }
public virtual ParserRuleContext GetRuleContext()
{
return _ctx; return _ctx;
} }
}
/// <summary> /// <summary>
/// Return List<String> of the rule names in your parser instance /// Return List<String> of the rule names in your parser instance
@ -815,7 +842,7 @@ namespace Antlr4.Runtime
public virtual IList<string> GetRuleInvocationStack(RuleContext p) public virtual IList<string> GetRuleInvocationStack(RuleContext p)
{ {
string[] ruleNames = GetRuleNames(); string[] ruleNames = RuleNames;
IList<string> stack = new List<string>(); IList<string> stack = new List<string>();
while (p != null) while (p != null)
{ {
@ -841,7 +868,7 @@ namespace Antlr4.Runtime
for (int d = 0; d < _interp.atn.decisionToDFA.Length; d++) for (int d = 0; d < _interp.atn.decisionToDFA.Length; d++)
{ {
DFA dfa = _interp.atn.decisionToDFA[d]; DFA dfa = _interp.atn.decisionToDFA[d];
s.AddItem(dfa.ToString(GetTokenNames(), GetRuleNames())); s.AddItem(dfa.ToString(TokenNames, RuleNames));
} }
return s; return s;
} }
@ -860,16 +887,19 @@ namespace Antlr4.Runtime
System.Console.Out.WriteLine(); System.Console.Out.WriteLine();
} }
System.Console.Out.WriteLine("Decision " + dfa.decision + ":"); System.Console.Out.WriteLine("Decision " + dfa.decision + ":");
System.Console.Out.Write(dfa.ToString(GetTokenNames(), GetRuleNames())); System.Console.Out.Write(dfa.ToString(TokenNames, RuleNames));
seenOne = true; seenOne = true;
} }
} }
} }
public virtual string GetSourceName() public virtual string SourceName
{
get
{ {
return _input.SourceName; return _input.SourceName;
} }
}
/// <summary>A convenience method for use most often with template rewrites.</summary> /// <summary>A convenience method for use most often with template rewrites.</summary>
/// <remarks> /// <remarks>
@ -898,8 +928,22 @@ namespace Antlr4.Runtime
/// During a parse is sometimes useful to listen in on the rule entry and exit /// During a parse is sometimes useful to listen in on the rule entry and exit
/// events as well as token matches. This is for quick and dirty debugging. /// events as well as token matches. This is for quick and dirty debugging.
/// </remarks> /// </remarks>
public virtual void SetTrace(bool trace) public virtual bool Trace
{ {
get
{
foreach (object o in ParseListeners)
{
if (o is Parser.TraceListener)
{
return true;
}
}
return false;
}
set
{
bool trace = value;
if (!trace) if (!trace)
{ {
RemoveParseListener(_tracer); RemoveParseListener(_tracer);
@ -920,3 +964,4 @@ namespace Antlr4.Runtime
} }
} }
} }
}

View File

@ -80,7 +80,7 @@ namespace Antlr4.Runtime
this.ctx = ctx; this.ctx = ctx;
if (recognizer != null) if (recognizer != null)
{ {
this.offendingState = recognizer.GetState(); this.offendingState = recognizer.State;
} }
} }
@ -92,7 +92,7 @@ namespace Antlr4.Runtime
this.ctx = ctx; this.ctx = ctx;
if (recognizer != null) if (recognizer != null)
{ {
this.offendingState = recognizer.GetState(); this.offendingState = recognizer.State;
} }
} }

View File

@ -67,31 +67,46 @@ namespace Antlr4.Runtime
/// error reporting. The generated parsers implement a method /// error reporting. The generated parsers implement a method
/// that overrides this to point to their String[] tokenNames. /// that overrides this to point to their String[] tokenNames.
/// </remarks> /// </remarks>
public abstract string[] GetTokenNames(); public abstract string[] TokenNames
{
get;
}
public abstract string[] GetRuleNames(); public abstract string[] RuleNames
{
get;
}
/// <summary>For debugging and other purposes, might want the grammar name.</summary> /// <summary>For debugging and other purposes, might want the grammar name.</summary>
/// <remarks> /// <remarks>
/// For debugging and other purposes, might want the grammar name. /// For debugging and other purposes, might want the grammar name.
/// Have ANTLR generate an implementation for this method. /// Have ANTLR generate an implementation for this method.
/// </remarks> /// </remarks>
public abstract string GetGrammarFileName(); public abstract string GrammarFileName
{
get;
}
public virtual ATN GetATN() public virtual ATN Atn
{
get
{ {
return _interp.atn; return _interp.atn;
} }
}
public virtual ATNInterpreter GetInterpreter() public virtual ATNInterpreter Interpreter
{
get
{ {
return _interp; return _interp;
} }
set
public virtual void SetInterpreter(ATNInterpreter interpreter)
{ {
ATNInterpreter interpreter = value;
_interp = interpreter; _interp = interpreter;
} }
}
/// <summary>What is the error header, normally line/character position information?</summary> /// <summary>What is the error header, normally line/character position information?</summary>
public virtual string GetErrorHeader(RecognitionException e) public virtual string GetErrorHeader(RecognitionException e)
@ -190,11 +205,6 @@ namespace Antlr4.Runtime
{ {
} }
public int GetState()
{
return _stateNumber;
}
/// <summary> /// <summary>
/// Indicate that the recognizer has changed internal state that is /// Indicate that the recognizer has changed internal state that is
/// consistent with the ATN state passed in. /// consistent with the ATN state passed in.
@ -207,13 +217,24 @@ namespace Antlr4.Runtime
/// invoking rules. Combine this and we have complete ATN /// invoking rules. Combine this and we have complete ATN
/// configuration information. /// configuration information.
/// </remarks> /// </remarks>
public void SetState(int atnState) public int State
{ {
get
{
return _stateNumber;
}
set
{
int atnState = value;
// System.err.println("setState "+atnState); // System.err.println("setState "+atnState);
_stateNumber = atnState; _stateNumber = atnState;
} }
}
public abstract IIntStream InputStream
{
get;
}
// if ( traceATNStates ) _ctx.trace(atnState); // if ( traceATNStates ) _ctx.trace(atnState);
public abstract IIntStream GetInputStream();
} }
} }

View File

@ -198,8 +198,7 @@ namespace Antlr4.Runtime
/// <exception cref="Javax.Print.PrintException"></exception> /// <exception cref="Javax.Print.PrintException"></exception>
public virtual void Save(Parser parser, string fileName) public virtual void Save(Parser parser, string fileName)
{ {
IList<string> ruleNames = parser != null ? Arrays.AsList(parser.GetRuleNames()) : IList<string> ruleNames = parser != null ? Arrays.AsList(parser.RuleNames) : null;
null;
Save(ruleNames, fileName); Save(ruleNames, fileName);
} }
@ -209,8 +208,7 @@ namespace Antlr4.Runtime
public virtual void Save(Parser parser, string fileName, string fontName, int fontSize public virtual void Save(Parser parser, string fileName, string fontName, int fontSize
) )
{ {
IList<string> ruleNames = parser != null ? Arrays.AsList(parser.GetRuleNames()) : IList<string> ruleNames = parser != null ? Arrays.AsList(parser.RuleNames) : null;
null;
Save(ruleNames, fileName, fontName, fontSize); Save(ruleNames, fileName, fontName, fontSize);
} }
@ -282,7 +280,7 @@ namespace Antlr4.Runtime
public virtual string ToString<_T0>(Recognizer<_T0> recog, Antlr4.Runtime.RuleContext public virtual string ToString<_T0>(Recognizer<_T0> recog, Antlr4.Runtime.RuleContext
stop) stop)
{ {
string[] ruleNames = recog != null ? recog.GetRuleNames() : null; string[] ruleNames = recog != null ? recog.RuleNames : null;
IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null; IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null;
return ToString(ruleNamesList, stop); return ToString(ruleNamesList, stop);
} }

View File

@ -65,7 +65,7 @@ namespace Antlr4.Runtime.Tree
/// </remarks> /// </remarks>
public static string ToStringTree(ITree t, Parser recog) public static string ToStringTree(ITree t, Parser recog)
{ {
string[] ruleNames = recog != null ? recog.GetRuleNames() : null; string[] ruleNames = recog != null ? recog.RuleNames : null;
IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null; IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null;
return ToStringTree(t, ruleNamesList); return ToStringTree(t, ruleNamesList);
} }
@ -105,7 +105,7 @@ namespace Antlr4.Runtime.Tree
public static string GetNodeText(ITree t, Parser recog) public static string GetNodeText(ITree t, Parser recog)
{ {
string[] ruleNames = recog != null ? recog.GetRuleNames() : null; string[] ruleNames = recog != null ? recog.RuleNames : null;
IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null; IList<string> ruleNamesList = ruleNames != null ? Arrays.AsList(ruleNames) : null;
return GetNodeText(t, ruleNamesList); return GetNodeText(t, ruleNamesList);
} }

@ -1 +1 @@
Subproject commit 5cda16588918c8873c62abdeb9ce88e600e5d045 Subproject commit 6743730f698969a938bec3ec2c42c4728a97256c