[antlr-interest] How to create a rule that matches fast everything!!!
Gavin Lambert
antlr at mirality.co.nz
Wed Feb 11 01:29:56 PST 2009
At 22:09 11/02/2009, Liviu U wrote:
>Is there a way to specify:
>
>rule
>: BEGIN ANY* END;
>?
Either:
rule
: BEGIN .* END
;
Or (more explicitly):
rule
: BEGIN (~END)* END
;
(ANTLR is normally smart enough to compile the first as if it were
the second, provided that your end-phrase is inline and fairly
simple.)
Note however that at parser level this will still create tokens
for everything between BEGIN and END. If you don't want to do
that, then you'll have to create a lexer rule that smooshes
everything into one token -- but then that'll take out all of
them, not just at one particular context level.
More information about the antlr-interest
mailing list