1grammar t050decorate; 2options { 3 language = Python3; 4} 5 6@header { 7 def logme(func): 8 def decorated(self, *args, **kwargs): 9 self.events.append('before') 10 try: 11 return func(self, *args, **kwargs) 12 finally: 13 self.events.append('after') 14 15 return decorated 16} 17 18@parser::init { 19self.events = [] 20} 21 22document 23@decorate { 24 @logme 25} 26 : IDENTIFIER 27 ; 28 29IDENTIFIER: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*; 30