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