1 grammar t026actions; 2 options { 3 language = Python; 4 } 5 6 @lexer::init { 7 self.foobar = 'attribute;' 8 } 9 10 prog 11 @init { 12 self.capture('init;') 13 } 14 @after { 15 self.capture('after;') 16 } 17 : IDENTIFIER EOF 18 ; 19 catch [ RecognitionException, exc ] { 20 self.capture('catch;') 21 raise 22 } 23 finally { 24 self.capture('finally;') 25 } 26 27 28 IDENTIFIER 29 : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* 30 { 31 # a comment 32 self.capture('action;') 33 self.capture('\%r \%r \%r \%r \%r \%r \%r \%r;' \% ($text, $type, $line, $pos, $index, $channel, $start, $stop)) 34 if True: 35 self.capture(self.foobar) 36 } 37 ; 38 39 WS: (' ' | '\n')+; 40