I am trying to learn ANTLR by writing grammars (I use eclipse with ANTLR plugins) and everything will be fine until I encounter an error:
NoViableAltException: line 0:-1 no viable alternative at input '<EOF>'
When I try to check the args parser rule,
typedident : (INT|CHAR) IDENT; args : (typedident ( COMMA typedident)*)?;
An identifier is a letter followed by any character, it works, I tested it. typedident also works for the test.
I use input int a12q2efwe, char a12eqdsf (completely random) and the tree seems accurate in the interpreter, the only problem is that args has four branches instead of 3, typedident, comma, typedident, and then the error in the last.
Any help would be greatly appreciated.
Thanks.
source share