Rules .. (range) inside the parser mean something other than the internal rules of the lexer. Inside lexer rules, this means: βfrom char X to char Yβ, and inside the parser rule, it corresponds to βfrom token M to token Nβ. And since you made the rule t2> the parser rule, it does not do what you think it does (and this requires an error message).
Solution: make number lexer rule (so write it: number ):
grammar Robot; file : command+; command : (delay | type | move | Click | RClick) ; delay : 'wait' Number ';'; type : 'type' Id ';'; move : 'move' Number ',' Number ';'; Click : 'click' ; RClick : 'rlick' ; Id : ('a'..'z'|'A'..'Z')+ ; Number : ('0'..'9')+ ; WS : (' ' | '\t' | '\r' | '\n') { skip();} ;
And, as you can see, I also used the id , click and rclick lexer rclick . If you donβt know what the difference between parser and lexer rules is, tell me about it and I will add an explanation for this answer.
source share