[antlr-interest] empty alternatives erroneously consume tokens

Michael Brade brade at informatik.uni-muenchen.de
Thu Mar 2 05:02:51 PST 2006

On Thursday 02 March 2006 11:31, Alexey Demakov wrote:
> 2. _tokenSet_68 contains all tokens that can be after cont() rule.
> So, if it is full grammar, _tokenSet_68 is empty. It causes
> line 7:1: unexpected token: null
> 3. Try to add EOF at the end of c_expression() rule:
> c_expression : (c_atom|c_bracket_exp|c_prefix_exp) cont EOF;
> I'm sure it will solve the problem.
Thanks for the answer, it made me realize the problem! EOF did not help, but 
the key is indeed the FOLLOW set: if I embed the c_expression rule within 
another rule that is not recursive, e.g.
   expression: c_expression;

and thus has an empty follow set, then it works :)

Thanks a lot,
Michael Brade;                 KDE Developer, Student of Computer Science
  |-mail: echo brade !#|tr -d "c oh"|s\e\d 's/e/\@/2;s/$/.org/;s/bra/k/2'
  °--web: http://www.kde.org/people/michaelb.html

KDE 4: Beyond Your Expectations
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20060302/1046329b/attachment.bin

More information about the antlr-interest mailing list