[antlr-interest] Matching compound keywords in the lexer
Jim Idle
jimi at temporal-wave.com
Fri Nov 25 14:07:28 PST 2011
You don't need the tokens def. just the lexer fragment.
Jim
On Nov 25, 2011, at 12:54, Bart Kiers <bkiers at gmail.com> wrote:
> Hi Franck,
>
> On Fri, Nov 25, 2011 at 9:47 PM, franck102 <franck102 at yahoo.com> wrote:
>
>> ...
>
> containOperator : CONTAINS_TEXT | CONTAINS_MATCH
>>
>> CONTAINS_TEXT
>> : 'contains' WS+ ( 'match' { $type=CONTAINS_MATCH }
>> | 'text' )
>> ;
>>
>> // CONTAINS_MATCH:; // causes "token definitions can never be matched"
>> error
>>
>>
> Add CONTAINS_MATCH to your @tokens{...} and create an empty fragment rule
> called CONTAINS_MATCH to silence the warning:
>
> -----------------------------
>
> tokens {
> CONTAINS_MATCH;
> }
>
> ...
>
> CONTAINS_TEXT
> : 'contains' WS+ ( 'match' CONTAINS_MATCH
> | 'text' )
> ;
>
> ...
>
> fragment CONTAINS_MATCH : ;
>
> -----------------------------
>
> Regards,
>
> Bart.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list