On Aug 4, 2009, at 3:08 PM, michael wrote:
> 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 probably will not work, as LOOPSTART and LOOPEND consist of two
characters, not only one.
For example, in "%{}%" the first % will match NOLOOP, leaving an
unbalanced string.
I had also problems with not, although I only used lexer rules (see my
post Strange Lexing behavior).
Cheers,
Steven
>
> this should match all other characters, then use this token in your
> parser
> rules...
>
> allthough Ihave not tried it...
>
> cheers
> Michael
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---