Home | History | Annotate | Download | only in functional
      1 grammar t053heteroT9;
      2 options {
      3     language=JavaScript;
      4     output=AST;
      5 }
      6 @header {
      7 function V2() {
      8     var x, y, z, token, ttype;
      9     if (arguments.length===4) {
     10         ttype = arguments[0];
     11         x = arguments[1];
     12         y = arguments[2];
     13         z = arguments[3];
     14         token = new org.antlr.runtime.CommonToken(ttype, "");
     15     } else if (arguments.length===3) {
     16         ttype = arguments[0];
     17         token = arguments[1];
     18         x = arguments[2];
     19         y = 0;
     20         z = 0;
     21     } else {
     22         throw new Error("Invalid args");
     23     }
     24 
     25     V2.superclass.constructor.call(this, token);
     26     this.x = x;
     27     this.y = y;
     28     this.z = z;
     29 };
     30 
     31 org.antlr.lang.extend(V2, org.antlr.runtime.tree.CommonTree, {
     32     toString: function() {
     33         var txt = "";
     34         if (this.token) {
     35             txt += this.getText();
     36         }
     37         txt += "<V>;"+this.x.toString()+this.y.toString()+this.z.toString();
     38         return txt;
     39     }
     40 });
     41 }
     42 a : ID -> ID<V2>[42,19,30] ID<V2>[$ID,99];
     43 ID : 'a'..'z'+ ;
     44 WS : (' '|'\n') {$channel=HIDDEN;} ;
     45 
     46