1grammar t026actions;
2options {
3  language =Cpp;
4}
5
6@lexer::includes
7{
8#include "UserTestTraits.hpp"
9}
10@lexer::namespace
11{ Antlr3Test }
12
13@parser::includes {
14#include "UserTestTraits.hpp"
15}
16@parser::namespace
17{ Antlr3Test }
18
19@lexer::init {
20    self.foobar = 'attribute;'
21}
22
23prog
24@init {
25    self.capture('init;')
26}
27@after {
28    self.capture('after;')
29}
30    :   IDENTIFIER EOF
31    ;
32    catch [ RecognitionException as exc ] {
33        self.capture('catch;')
34        raise
35    }
36    finally {
37        self.capture('finally;')
38    }
39
40
41IDENTIFIER
42    : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
43        {
44            # a comment
45          self.capture('action;')
46            self.capture('{!r} {!r} {!r} {!r} {!r} {!r} {!r} {!r};'.format($text, $type, $line, $pos, $index, $channel, $start, $stop))
47            if True:
48                self.capture(self.foobar)
49        }
50    ;
51
52WS: (' ' | '\n')+;
53