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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182 | 1
1
1
1
1
1191
1191
1
34
14476
14476
14476
14476
14476
1185
14476
1
998
998
1
1226
1226
1
158
158
1
1
4041
4041
1
2701
2701
1
1
127
127
127
1
131
131
131
1
1
1
96
96
96
96
96
96
96
96
1
1
1
1
19
19
19
19
1
19
19
19
19
1
19
19
1
6
6
1
8
8
1
9
9
9
9
1
2
2
1
41
41
41
41
1
48
48
48
48
1
15
15
15
15
1
44
44
44
44
1
2
2
2
2
1
2152
2152
2152
1
4
4
4
1
1365
1365
1365
1365
1
1
1
9
9
9
1
4
4
4
4
4
1
41
41
41
41
1
| (function() {
exports.forceNoLoc = false;
exports.defineNodes = function(builder) {
var def, defaultIni, funIni;
defaultIni = function(loc) {
this.loc = loc;
return this;
};
def = function(name, ini) {
return builder[name[0].toLowerCase() + name.slice(1)] = function(a, b, c, d, e, f, g, h) {
var obj;
obj = {};
obj.type = name;
ini.call(obj, a, b, c, d, e, f, g, h);
if (exports.forceNoLoc === true) {
delete obj.loc;
}
return obj;
};
};
def('Program', function(elements, loc) {
this.body = elements;
return this.loc = loc;
});
def('ExpressionStatement', function(expression, loc) {
this.expression = expression;
return this.loc = loc;
});
def('BlockStatement', function(body, loc) {
this.body = body;
return this.loc = loc;
});
def('EmptyStatement', defaultIni);
def('Identifier', function(name, loc) {
this.name = name;
return this.loc = loc;
});
def('Literal', function(value, loc, raw) {
this.value = value;
return this.loc = loc;
});
def('ThisExpression', defaultIni);
def('VariableDeclaration', function(kind, declarations, loc) {
this.declarations = declarations;
this.kind = kind;
return this.loc = loc;
});
def('VariableDeclarator', function(id, init, loc) {
this.id = id;
this.init = init;
return this.loc = loc;
});
def('ArrayExpression', function(elements, loc) {
this.elements = elements;
return this.loc = loc;
});
def('ObjectExpression', function(properties, loc) {
this.properties = properties;
return this.loc = loc;
});
funIni = function(ident, params, rest, body, isGen, isExp, loc) {
this.id = ident;
this.params = params;
this.defaults = [];
this.rest = rest;
this.body = body;
this.loc = loc;
this.generator = isGen;
return this.expression = isExp;
};
def('FunctionDeclaration', funIni);
def('FunctionExpression', funIni);
def('ReturnStatement', function(argument, loc) {
this.argument = argument;
return this.loc = loc;
});
def('TryStatement', function(block, handlers, finalizer, loc) {
this.block = block;
this.handlers = handlers || [];
this.finalizer = finalizer;
return this.loc = loc;
});
def('CatchClause', function(param, guard, body, loc) {
this.param = param;
this.guard = guard;
this.body = body;
return this.loc = loc;
});
def('ThrowStatement', function(argument, loc) {
this.argument = argument;
return this.loc = loc;
});
def('BreakStatement', function(label, loc) {
this.label = label;
return this.loc = loc;
});
def('ContinueStatement', function(label, loc) {
this.label = label;
return this.loc = loc;
});
def('ConditionalExpression', function(test, consequent, alternate, loc) {
this.test = test;
this.consequent = consequent;
this.alternate = alternate;
return this.loc = loc;
});
def('SequenceExpression', function(expressions, loc) {
this.expressions = expressions;
return this.loc = loc;
});
def('BinaryExpression', function(op, left, right, loc) {
this.operator = op;
this.left = left;
this.right = right;
return this.loc = loc;
});
def('AssignmentExpression', function(op, left, right, loc) {
this.operator = op;
this.left = left;
this.right = right;
return this.loc = loc;
});
def('LogicalExpression', function(op, left, right, loc) {
this.operator = op;
this.left = left;
this.right = right;
return this.loc = loc;
});
def('UnaryExpression', function(operator, argument, prefix, loc) {
this.operator = operator;
this.argument = argument;
this.prefix = prefix;
return this.loc = loc;
});
def('UpdateExpression', function(operator, argument, prefix, loc) {
this.operator = operator;
this.argument = argument;
this.prefix = prefix;
return this.loc = loc;
});
def('CallExpression', function(callee, args, loc) {
this.callee = callee;
this["arguments"] = args;
return this.loc = loc;
});
def('NewExpression', function(callee, args, loc) {
this.callee = callee;
this["arguments"] = args;
return this.loc = loc;
});
def('MemberExpression', function(object, property, computed, loc) {
this.object = object;
this.property = property;
this.computed = computed;
return this.loc = loc;
});
def('DebuggerStatement', defaultIni);
def('Empty', defaultIni);
def('WhileStatement', function(test, body, loc) {
this.test = test;
this.body = body;
return this.loc = loc;
});
def('ForStatement', function(init, test, update, body, loc) {
this.init = init;
this.test = test;
this.update = update;
this.body = body;
return this.loc = loc;
});
def('IfStatement', function(test, consequent, alternate, loc) {
this.test = test;
this.consequent = consequent;
this.alternate = alternate;
return this.loc = loc;
});
return def;
};
}).call(this);
|