I'm trying to match something that has the same beginning but different thing in the end as for example:
'+' something+
'+' | '-' | '/' | '*' something something somethingDifferentAtTheEnd
and my code for the following is:
something: // rule for something here
rule1: '+' something+
rule2: OPERATOR something something somethingDifferentAtTheEnd
ruleForSomethingDifferent: // goes here
OPERATOR: '+' | '-' | '/' | '*'
The problem is I can't get this to work, I always seem to get 'extraneous input' error when I pass rule2 that starts with a '+' (its trying to match the first one and fails because there's a 'somethingDifferentAtTheEnd' but it doesnt fall to the 2nd rule..