You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
674 B

grammar t014parser;
options {
language = JavaScript;
}
@parser::members {
this.reportedErrors = [];
this.events = [];
this.emitErrorMessage = function(msg) {
this.reportedErrors.push(msg);
};
this.eventMessage = function(msg) {
this.events.push(msg);
};
}
document:
( declaration
| call
)*
EOF
;
declaration:
'var' t=IDENTIFIER ';'
{this.eventMessage(['decl', $t.getText()]);}
;
call:
t=IDENTIFIER '(' ')' ';'
{this.eventMessage(['call', $t.getText()]);}
;
IDENTIFIER: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
WS: (' '|'\r'|'\t'|'\n') {$channel=HIDDEN;};