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
 *------------------------------------------------------------------*/
      
parse: loop;

loop: noloop LOOPSTART loop LOOPEND loop
    | noloop
    ;
   
noloop: (~( LOOPSTART | LOOPEND ))*
      ;

/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/

LOOPSTART: '%{';
LOOPEND: '}%';



However, the "match not" is not working.

"X" results in
    line 1:0 no viable alternative at character 'X'

"%{X}%" results in
    line 1:2 no viable alternative at character 'X'


If I replace the match-not part with a dummy 'X'*, then the grammar 
works (or atleast the mentioned tests run through). There is very 
limited documentation on the "match not", does anyone have a suggestion 
for me?

Tom


NB: if this works I will introduce a third token; an %{ with an id in 
between, written like: %id$

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to