[antlr-interest] fragments..
Gavin Lambert
antlr at mirality.co.nz
Mon Mar 26 05:23:54 PDT 2007
At 22:20 26/03/2007, Tobias Pape wrote:
>BinarySelector :
[...]
>( Equal ) =>
> Equal {$type=Equal;}
[...]
>fragment Equal : '=' ;
[...]
>My problem is, when I change the Equal Rule, to be
non-Fragment,
>antlr warns me about Token Equal not beeing accessible.
>--------
>h248:~/dev/parsertest tobias$ antlr_ SOM.g
>no such locale file org/antlr/tool/templates/messages/languages/
>de.stg retrying with English locale
>ANTLR Parser Generator Version 3.0b7 (??, 2007) 1989-2007
>warning(208): SOM.g:461:1: The following token definitions are
>unreachable: Equal
>--------
>weird, huh?
Not really, that makes sense. It *is* inaccessible, because the
BinarySelector rule will match it first. You should probably list
your 'primitive' tokens first, giving them the chance to match and
output first, and most of them probably shouldn't be fragments,
since you're actually trying to output them. (You shouldn't use
{$type = x;} for any x that is a fragment.)
Actually I don't really see the point of the whole BinarySelector
rule. It seems too disconnected to be a useful rule. Especially
since it doesn't even seem to be an output token in itself.
More information about the antlr-interest
mailing list