[antlr-interest] A very simple grammar problem.

Kenneth Domino kenneth.domino at domemtech.com
Thu Mar 6 09:45:16 PST 2008


Hi,

I seem to be phasing out.  I thought that this grammar should work, but it doesn't:

grammar test_not_ok;

a : 'A' a
  | 'A'
  ;

$ java org.antlr.Tool test_not_ok.g
ANTLR Parser Generator  Version 3.0.1 (August 13, 2007)  1989-2007
warning(138): test_not_ok.g:0:0: grammar test_not_ok: no start rule (no rule can
 obviously be followed by EOF)
warning(201): test_not_ok.g:3:3: The following alternatives are unreachable: 2


But, this one works, which specifies the same language if I'm not wrong:

grammar test_ok;

a : b
  ;

b : 'A' b
  | 'A'
  ;

The only difference is the extra production at the top.
Do I have to manually augment all my grammars with an EOF rule (S->... to S' -> S EOF)
or something else? What am I doing wrong here?

Ken Domino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080306/24261d1c/attachment.html 


More information about the antlr-interest mailing list