[antlr-interest] Problems with NoViableAltException on compile

Dave Brosius dbrosius at mebigfatguy.com
Sun Mar 11 09:34:21 PDT 2012


Greetings, i had a working antlr 3.4 grammer that i am trying to 
embellish, and am getting the exception below.

The grammer in question is kind of big so i pastebin'ed it here: 
http://pastebin.com/CVhFCCtB

The addition in question is just an alternative choice on line 614 of

     |   PIXELAVERAGE '(' expr, ',' expr ',' expr ')'
         {
             mv.visitInsn(Opcodes.POP);                     //don't mind 
this impl, it's just stubbed for now
             mv.visitInsn(Opcodes.POP);
             mv.visitInsn(Opcodes.POP);
             mv.visitInsn(Opcodes.DCONST_0);
         } ;

which to me is very similar to other blocks that work just fine. Without 
this section the code generates fine.

      [exec] error(100): /home/dave/dev/pixelle/etc/Pixelle.g:614:30: 
syntax error: antlr: NoViableAltException(62@[722:4: ( ( id ( ASSIGN | 
PLUS_ASSIGN ) ( atom | block ) ) (sub= ebnfSuffix[root_0,false] )? | a= 
atom (sub2= ebnfSuffix[$a.tree,false] )? | ebnf | FORCED_ACTION | ACTION 
| p= SEMPRED ( IMPLIES )? | t3= tree_ )])
      [exec] error(100): /home/dave/dev/pixelle/etc/Pixelle.g:614:30: 
syntax error: antlr: NoViableAltException(62@[722:4: ( ( id ( ASSIGN | 
PLUS_ASSIGN ) ( atom | block ) ) (sub= ebnfSuffix[root_0,false] )? | a= 
atom (sub2= ebnfSuffix[$a.tree,false] )? | ebnf | FORCED_ACTION | ACTION 
| p= SEMPRED ( IMPLIES )? | t3= tree_ )])
      [exec] error(100): /home/dave/dev/pixelle/etc/Pixelle.g:0:1: 
syntax error: assign.types: MismatchedTreeNodeException(0!=29)
      [exec] error(100): /home/dave/dev/pixelle/etc/Pixelle.g:0:: syntax 
error: assign.types: NoViableAltException(3@[])
      [exec] error(100): /home/dave/dev/pixelle/etc/Pixelle.g:0:1: 
syntax error: assign.types: MismatchedTreeNodeException(3!=28)
      [exec] error(10):  internal error: 
/home/dave/dev/pixelle/etc/Pixelle.g : java.util.NoSuchElementException: 
can't look backwards more than one token in this stream


Any idea what i'm doing wrong?



More information about the antlr-interest mailing list