diff options
Diffstat (limited to 'runtime/JavaScript/tests/functional/t014parser.g')
-rwxr-xr-x | runtime/JavaScript/tests/functional/t014parser.g | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/runtime/JavaScript/tests/functional/t014parser.g b/runtime/JavaScript/tests/functional/t014parser.g new file mode 100755 index 0000000..de52a0a --- /dev/null +++ b/runtime/JavaScript/tests/functional/t014parser.g @@ -0,0 +1,36 @@ +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;}; |