为什么ANTLR无法正确识别令牌? 我认为问题与"会员访问者"有一个ID和" CustomMethodCall"也是统治。
语法
**statement
: varDeclaration
| customMethodCall;
customMethodCall : (memberAccessor '.)? ID L_PAREN expressionList R_PAREN;
memberAcessorPart
: ID
| 'this'
| ID '.getAt' L_PAREN expression R_PAREN
| ID arrayGet:
| ID L_PAREN expressionList R_PAREN;
memberAccessor
: memberAcessorPart (ACESSAR memberAcessorPart)*;
**
protected override void ReportNoViableAlternative (Parser recognizer, NoViableAltException e) {
string[] expected = new String[e.GetExpectedTokens ().Count];
int[] expectedInts = e.GetExpectedTokens ().ToArray ();
for (int i = 0; i < expected.Length; i++) {
if (expectedInts[i] == -1) expected[i] = "<EOF>";
else expected[i] = PortuProParser.DefaultVocabulary.GetDisplayName (expectedInts[i]);
}
string c = PortuProParser.DefaultVocabulary.GetDisplayName (e.StartToken.Type);
if (expected.ToList ().IndexOf (c) == -1)
throw new PortuProException (e.StartToken.Line, e.StartToken.Column, "Entrada desconhecida. '" + e.StartToken.Text + "'\n\nEsperado: '" + string.Join (", ", expected) + "'");
}
我已经上过&#39; c&#39; &#39; ID&#39;以及&#39; ID&#39;预期作为代币。