[antlr-interest] A very simple grammar problem.
Terence Parr
parrt at cs.usfca.edu
Tue Mar 11 10:39:54 PDT 2008
Technically not. in 2nd example 'a' can be followed by EOF not in
first since it's recursive; the warning says it can't decide to
include EOF. fi you allowe EOF it's not ambig.
Ter
On Mar 6, 2008, at 9:45 AM, Kenneth Domino wrote:
> 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/20080311/52188be7/attachment.html
More information about the antlr-interest
mailing list