• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1grammar t014parser;
2options {
3  language = JavaScript;
4}
5
6@parser::members {
7this.reportedErrors = [];
8this.events = [];
9this.emitErrorMessage = function(msg) {
10    this.reportedErrors.push(msg);
11};
12this.eventMessage = function(msg) {
13    this.events.push(msg);
14};
15}
16
17
18document:
19        ( declaration
20        | call
21        )*
22        EOF
23    ;
24
25declaration:
26        'var' t=IDENTIFIER ';'
27        {this.eventMessage(['decl', $t.getText()]);}
28    ;
29
30call:
31        t=IDENTIFIER '(' ')' ';'
32        {this.eventMessage(['call', $t.getText()]);}
33    ;
34
35IDENTIFIER: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
36WS:  (' '|'\r'|'\t'|'\n') {$channel=HIDDEN;};
37