I can not understand a "NoViableAltException"exception when I compile my Tree grammar.
Here's a little piece of my grammar with the rule that gives me problems:
keyword_controls_sub
: expression (MB_COMA expression)* -> ^(MATCH_STATEMENT expression)+
;
Which generates a tree like:
+-----------------+
| |
| ROOT |
| |
+-----------------+
|
|
+-------------------------------------+
| | |
+------------------+ +-----------------+ +-----------------+
| | | | | |
| MATCH_STATEMENT | | MATCH_STATEMENT | | MATCH_STATEMENT |
| | | | | |
+------------------+ +-----------------+ +-----------------+
| | |
+-------------------+ +-----------------+ +-----------------+
| | | | | |
| expression | | expression | | expression |
| | | | | |
+-------------------+ +-----------------+ +-----------------+
And the rule in my TreeGrammar that causes the exception:
keyword_controls_sub
: ^(MATCH_STATEMENT expression)+
;
Specifically, the ANTLR compiler returns the following errors:
error 100: syntax error: antlr: NoViableAltException(79@[])
error 100: syntax error: assign.types: NoViableAltException(0@[])
node from line 2482:10 no viable alternative at input '+'
error 100: syntax error: buildnfa: NoViableAltException(0@[])
error 100: syntax error: codegen: NoViableAltException(0@[])
error 100: syntax error: antlr.print: NoViableAltException(0@[])
error 100: syntax error: antlr.print: NoViableAltException(0@[])
If I change the tree grammar to:
keyword_controls_sub
: ^(MATCH_STATEMENT expression+)
;
There are no compiler errors, but I think that it is not correct, since in this case there would only be one MATCH_STATEMENT block.
Note: I'm using ANTLR3 C Runtime.
Thanks in advance.