1 grammar t013parser; 2 options { 3 language = JavaScript; 4 } 5 6 @parser::members { 7 this.identifiers = []; 8 this.reportedErrors = []; 9 10 this.foundIdentifier = function(name) { 11 this.identifiers.push(name); 12 }; 13 14 this.emitErrorMessage = function(msg) { 15 this.reportedErrors.push(msg); 16 }; 17 } 18 19 document: 20 t=IDENTIFIER {this.foundIdentifier($t.text)} 21 ; 22 23 IDENTIFIER: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*; 24