[antlr-interest] Preventing longest match in the lexer
A Z
asicaddress at gmail.com
Fri Apr 8 11:52:44 PDT 2011
Hello all,
Is there a way to force 'match first' among a group of tokens? In the code
below, if 'undef(' or 'undef ' is found, it matches DIR_MACRO regardless of
the predicate. I can see why it would do this, but I'm trying to find a way
to match the DIR_UNDEF rule without resorting to combining the two rules and
manually modify the token type.
DIR_UNDEF :
'`undef'
SLSpace+ var0=SimpleIdent;
DIR_MACRO :
'`' var0=SimpleIdent
(
{cond1(var0) == true}? =>
| {cond2(var0) == true}? => Args
| //Both conditionals false
);
fragment Args : ' '* '(' ;
More information about the antlr-interest
mailing list