Reputation: 145
Given following grammar:
grammar minimal;
rule: '(' rule_name body ')';
rule_name : NAME;
body : '(' AT NAME ')';
AT : 'at';
NAME: LETTER ANY_CHAR*;
fragment LETTER: 'a' .. 'z' | 'A' .. 'Z';
fragment ANY_CHAR: LETTER | '0' .. '9' | '-' | '_';
WHITESPACE: ( ' ' | '\t' | '\r' | '\n' )+ -> skip;
How can I match (at (at bar)) with at as a valid function name without getting conflicts with the AT token from body without rearranging the grammar?
Upvotes: 1
Views: 338
Reputation: 6001
To remove the conflict and preserve the intended token type:
rule_name : ( NAME | AT ) -> type(NAME) ;
Upvotes: 1