[antlr-interest] 'match not' not working

michael micha-1 at fantasymail.de
Tue Aug 4 06:08:39 PDT 2009


Am Dienstag, 4. August 2009 14:52:40 schrieb Tom:
> I have a pretty simply grammar to construct; it must find balanced
> tokens in a stream. For example:
>     aaa %{ bbb }% ccc
>
> These may be nested:
>     aaa %{ aaa %{ bbb }% ccc }% ccc
>
> or not present at all:
>     aaa
>
> or consequtive:
>     aaa %{ bbb }% ccc %{ bbb }% ccc
>
> So all a need to do is find the tokens with non-tokens in between. This
> is the grammar I expected that would do that:
>
> /*------------------------------------------------------------------
>  * PARSER RULES
>  *------------------------------------------------------------------*/
>
> noloop: (~( LOOPSTART | LOOPEND ))*
>       ;

this combination of scanner rules, negation and parser rule is not easy to get 
to work.

Have you tried to add a lexer rule:

NOLOOP: (~( LOOPSTART | LOOPEND ))*;

this should match all other characters, then use this token in your parser 
rules...

allthough Ihave not tried it...

cheers
 Michael



More information about the antlr-interest mailing list