On 09/28/2011 02:50 PM, jame vaalet wrote:
> hi,
> below is my tree grammar:
> 
> tokens
> {
> COMMA=',';
> LPAREN='(';
> RPAREN=')';
> 
> }
> 
> start : (NUMBER^ COMMA NUMBER)|WORD^;
> 
> WORD : ~(WHITESPACE|LPAREN|RPAREN)+ ;
> WHITESPACE : ('\t'|' '|'\r'|'\n'|'\u000C');
> NUMBER : DIGIT+;
> fragment DIGIT : '0'..'9' ;
> 
> 
> when my input is 1,2 which one is it gonna match ? WORD or (NUMBER^ COMMA
> NUMBER)

The former is a lexer rule, the latter a parser rule.  The lexer will
match as much as possible before the parser even runs.  If NUMBER COMMA
NUMBER needs to be parsed, then you need to re-define your WORD rule so
that it doesn't match it.

> I want this to be matched to latter by antlr i matching it with former..
> what am i missing here..


-- 
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://www.xlinuxcounter.net/)

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