[antlr-interest] nondeterminism help

Omry Yadan omry at yadan.net
Tue Feb 6 00:28:44 PST 2007


Hi all,
my grammar need to tell the difference between a line of code, that can 
be anything, and a directive - that starts with //#
example for a line:
public class foo extends bar{

example for a directive:
//# if blah=8

each line can end with a EOL or EOF.

I want to first line to match the rule code and the second to match the 
rule directive
I tried to do something like:

code : (.)*;

line :
(
   (
       (PREFIX) => PREFIX ((conditaional expression) | nonconditional)
       |
       code
   )
   (EOL)?
);

I have two problems:
1. my code rule gives an error when it encounter "{" : line 1:17: 
unexpected char: '{'
2. I get the following warning: nondeterminism upon k==1:EOL between alt 
1 and exit branch of block

any ideas?


More information about the antlr-interest mailing list