[antlr-interest] Problem using predicates in V3
Terence Parr
parrt at cs.usfca.edu
Sun Feb 11 13:46:17 PST 2007
On Feb 11, 2007, at 1:38 PM, Dr. Hartmut Kocher wrote:
>
> No it doesn't work. I appended the C# code (which ist he same for
> Java).
>
> Here's the rule:
>
> ID : ('abc' DIGIT) => 'abc' | ('a'..'z'|'A'..'Z')
> ('a'..'z'|'A'..'Z'|'_'|'0'..'9')+ ;
>
> If you look at the code, you see that it correctly checks for the
> predicate.
> It then matches the string, but this does not emit a token!
> Instead it emits a token at the end of the ID rule, with type ID.
>
> This is the part I don't understand, or where a bug might hide...
Oh, i think you have to set the type. $type = ABC_KEYWORD; ID is
just matching stuff and yep, it matches. It has no idea you mean it
to be the keyword. This was a quirk of v2 that it tested every token
against the literals table.
Ter
More information about the antlr-interest
mailing list