[antlr-interest] please help on lexer rules antlr v3
Terence Parr
parrt at cs.usfca.edu
Wed Sep 27 11:49:51 PDT 2006
On Sep 27, 2006, at 6:50 AM, Michiel Vermandel wrote:
>
> Hi,
>
> I have the following two rules in my lexer.
>
> DIRECTIVE: '--' (TAB | SPACE)* ('axi.locate' | 'axi.reject');
>
> // Single-line comments
> SL_COMMENT: '--' (~('\n'|'\r'))* ('\n'|'\r'('\n')?) { channel=99; };
>
> the general idea is that
>
> -- axi.locate
> -- axi.reject
>
> are compiler directives,
>
> -- followed by anything else
>
> is a comment.
>
> now (obviously :-/ ) everything starting with -- is consumed by the
> SL_COMMENT rule.
LL(*) should handle this, but if not, then just do
SL_COMMENT : '--' DIRECTIVE | ... ;
fragment DIRECTIVE : ... (TAB | SPACE)* ('axi.locate' | 'axi.reject') ;
Ter
More information about the antlr-interest
mailing list