1 grammar t030specialStates; 2 options { 3 language = Python; 4 } 5 6 @init { 7 self.cond = True 8 } 9 10 @members { 11 def recover(self, input, re): 12 # no error recovery yet, just crash! 13 raise re 14 } 15 16 r 17 : ( {self.cond}? NAME 18 | {not self.cond}? NAME WS+ NAME 19 ) 20 ( WS+ NAME )? 21 EOF 22 ; 23 24 NAME: ('a'..'z') ('a'..'z' | '0'..'9')+; 25 NUMBER: ('0'..'9')+; 26 WS: ' '+; 27