aboutsummaryrefslogtreecommitdiff
path: root/antlr-3.4/runtime/JavaScript/tests/functional/t053heteroT9.g
diff options
context:
space:
mode:
Diffstat (limited to 'antlr-3.4/runtime/JavaScript/tests/functional/t053heteroT9.g')
-rwxr-xr-xantlr-3.4/runtime/JavaScript/tests/functional/t053heteroT9.g45
1 files changed, 45 insertions, 0 deletions
diff --git a/antlr-3.4/runtime/JavaScript/tests/functional/t053heteroT9.g b/antlr-3.4/runtime/JavaScript/tests/functional/t053heteroT9.g
new file mode 100755
index 0000000..39ce3d4
--- /dev/null
+++ b/antlr-3.4/runtime/JavaScript/tests/functional/t053heteroT9.g
@@ -0,0 +1,45 @@
+grammar t053heteroT9;
+options {
+ language=JavaScript;
+ output=AST;
+}
+@header {
+function V2() {
+ var x, y, z, token, ttype;
+ if (arguments.length===4) {
+ ttype = arguments[0];
+ x = arguments[1];
+ y = arguments[2];
+ z = arguments[3];
+ token = new org.antlr.runtime.CommonToken(ttype, "");
+ } else if (arguments.length===3) {
+ ttype = arguments[0];
+ token = arguments[1];
+ x = arguments[2];
+ y = 0;
+ z = 0;
+ } else {
+ throw new Error("Invalid args");
+ }
+
+ V2.superclass.constructor.call(this, token);
+ this.x = x;
+ this.y = y;
+ this.z = z;
+};
+
+org.antlr.lang.extend(V2, org.antlr.runtime.tree.CommonTree, {
+ toString: function() {
+ var txt = "";
+ if (this.token) {
+ txt += this.getText();
+ }
+ txt += "<V>;"+this.x.toString()+this.y.toString()+this.z.toString();
+ return txt;
+ }
+});
+}
+a : ID -> ID<V2>[42,19,30] ID<V2>[$ID,99];
+ID : 'a'..'z'+ ;
+WS : (' '|'\n') {$channel=HIDDEN;} ;
+