I'm making a grammar that knows how to parse coordinates, such as:

4,5


It knows about offsets, like:

+2,-8

It should parse adding coordinates together:

4,5+5,9

However, it seems to see the '+' and from there predict the next token to be
an offset, despite the fact there is not '+'|'-' before the '9'.

Here's the grammar I think should work (I made k large enough to show it's
not helping, no matter how large):

grammar Test;

main    :  COORD '+' COORD
           |    OFFSET
           ;

COORD options{k=7;} :    '0'..'9'+  ',' '0'..'9'+
    ;

OFFSET options{k=7;} :    ('+'|'-') '0'..'9'+  ',' ('-'|'+') '0'..'9'+
    ;

WS  :   ( ' '
        | '\t'
        | '\r'
        | '\n'
        ) {$channel=HIDDEN;}
    ;


What am I missing?

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