aboutsummaryrefslogtreecommitdiff
path: root/runtime/JavaScript/tests/functional/t053heteroT9.g
blob: 39ce3d41e2920bf00c104348eb8c019864cdba5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;} ;