[antlr-interest] How to remove this kind of warning
Gavin Lambert
antlr at mirality.co.nz
Fri Sep 5 07:26:47 PDT 2008
At 02:15 6/09/2008, Ronghui Yu wrote:
>I would like to have it as a lexer rule, but in my parser, there
>is a Floating_Point_Constant like
>
>Floating_Point_Constant:
> ('0'..'9')+ '.' ('0'..'9')* ('e'|'E')?;
[...]
>This rule can deal with both cases well, but I need to define a
>token IP_Address first, then comes the story.
>If I define two rules for floating point and ip address
>respectively, seems one of them doesn't work properly.
You need to declare the IP_Address rule as a fragment, so it's not
a top-level output candidate:
fragment IP_Address: '0';
(The actual contents of this rule don't really matter, except that
they can't be empty. It's sometimes helpful from a readability
perspective to make it look kind of like what it really will be
matching, but all that'll end up doing is increasing the code
size, since it'll never actually be called.)
More information about the antlr-interest
mailing list