[antlr-interest] Unreachable production
Darach Ennis
darach at gmail.com
Sun Mar 30 14:19:24 PDT 2008
Hi Andrei,
You can make ID and QW 'fragment' rules as follows to get rid of the
warning:
grammar Name;
start: wordList ;
wordList: '[' Name (',' Name)* ']';
Name: ID | QW;
fragment ID: ('a'..'z'|'A'..'Z')+ ;
fragment QW: '"' ('a'..'z'|'A'..'Z') (' '|'a'..'z'|'A'..'Z')*
('a'..'z'|'A'..'Z') '"';
WS: (' '|'\t' |'\r'|'\n')+ {skip();} ;
Regards,
Darach.
On Sun, Mar 30, 2008 at 9:02 PM, <andrei.majidian at bt.com> wrote:
> Hi
>
> I am trying the Interpreter for the following grammar Name.g
>
> _____________________________________________
> grammar Name;
>
> start: wordList ;
>
> wordList: '[' Name (',' Name)* ']';
>
> Name: ID | QW;
>
> ID: ('a'..'z'|'A'..'Z')+ ;
> QW: '"' ('a'..'z'|'A'..'Z') (' '|'a'..'z'|'A'..'Z')*
> ('a'..'z'|'A'..'Z') '"';
> WS: (' '|'\t' |'\r'|'\n')+ {skip();} ;
> ____________________________________________________
>
> With the following input:
>
> ["wild animal", "friendly", timid]
>
> It gave me the following Warning in the console
>
> "[21:52:57] warning(208): Name.g:10:1: The following token definitions are
> unreachable: ID,QW
> [21:52:57] Interpreting…"
>
> What does this mean? The parse-tree is correctly produced. I don't
> understand the warning.
>
> Thanks
>
> Andrei
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080330/42a02834/attachment.html
More information about the antlr-interest
mailing list