Home | History | Annotate | Download | only in tests
      1 grammar t050decorate;
      2 options {
      3   language = Python;
      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 {
     19 self.events = []
     20 }
     21 
     22 document
     23 @decorate {
     24     @logme
     25 }
     26     : IDENTIFIER
     27     ;
     28 
     29 IDENTIFIER: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
     30