qasm-ts 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ast.js +267 -0
- package/dist/errors.js +148 -0
- package/dist/example.js +22 -0
- package/dist/lexer.js +300 -0
- package/dist/main.js +26 -0
- package/dist/parser.js +489 -0
- package/dist/token.js +89 -0
- package/package.json +36 -0
- package/readme.md +122 -0
- package/src/ast.ts +192 -0
- package/src/errors.ts +102 -0
- package/src/lexer.ts +319 -0
- package/src/main.ts +27 -0
- package/src/parser.ts +531 -0
- package/src/token.ts +92 -0
- package/tsconfig.json +14 -0
package/dist/ast.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.Variable = exports.Real = exports.NNInteger = exports.Pi = exports.Sqrt = exports.Ln = exports.Exp = exports.Tan = exports.Cos = exports.Sin = exports.Power = exports.Times = exports.Minus = exports.Plus = exports.Divide = exports.Id = exports.If = exports.Gate = exports.ApplyGate = exports.Measure = exports.Barrier = exports.CReg = exports.QReg = exports.AstNode = void 0;
|
|
19
|
+
/** Base class representing a basic AST node. */
|
|
20
|
+
var AstNode = /** @class */ (function () {
|
|
21
|
+
function AstNode() {
|
|
22
|
+
}
|
|
23
|
+
return AstNode;
|
|
24
|
+
}());
|
|
25
|
+
exports.AstNode = AstNode;
|
|
26
|
+
/** Class representing a qubit register. */
|
|
27
|
+
var QReg = /** @class */ (function (_super) {
|
|
28
|
+
__extends(QReg, _super);
|
|
29
|
+
function QReg(id, size) {
|
|
30
|
+
var _this = _super.call(this) || this;
|
|
31
|
+
_this.id = id;
|
|
32
|
+
_this.size = size;
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
return QReg;
|
|
36
|
+
}(AstNode));
|
|
37
|
+
exports.QReg = QReg;
|
|
38
|
+
/** Class representing a classical register. */
|
|
39
|
+
var CReg = /** @class */ (function (_super) {
|
|
40
|
+
__extends(CReg, _super);
|
|
41
|
+
function CReg(id, size) {
|
|
42
|
+
var _this = _super.call(this) || this;
|
|
43
|
+
_this.id = id;
|
|
44
|
+
_this.size = size;
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
return CReg;
|
|
48
|
+
}(AstNode));
|
|
49
|
+
exports.CReg = CReg;
|
|
50
|
+
/** Class representing an identifier. */
|
|
51
|
+
var Id = /** @class */ (function (_super) {
|
|
52
|
+
__extends(Id, _super);
|
|
53
|
+
function Id(id) {
|
|
54
|
+
var _this = _super.call(this) || this;
|
|
55
|
+
_this.id = id;
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
return Id;
|
|
59
|
+
}(AstNode));
|
|
60
|
+
exports.Id = Id;
|
|
61
|
+
/** Class representing a barrier. */
|
|
62
|
+
var Barrier = /** @class */ (function (_super) {
|
|
63
|
+
__extends(Barrier, _super);
|
|
64
|
+
function Barrier(register, index) {
|
|
65
|
+
var _this = _super.call(this) || this;
|
|
66
|
+
_this.index = index || null;
|
|
67
|
+
_this.register = register;
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
return Barrier;
|
|
71
|
+
}(AstNode));
|
|
72
|
+
exports.Barrier = Barrier;
|
|
73
|
+
/** Class representing a variable. */
|
|
74
|
+
var Variable = /** @class */ (function (_super) {
|
|
75
|
+
__extends(Variable, _super);
|
|
76
|
+
function Variable(value) {
|
|
77
|
+
var _this = _super.call(this) || this;
|
|
78
|
+
_this.value = value || null;
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
return Variable;
|
|
82
|
+
}(AstNode));
|
|
83
|
+
exports.Variable = Variable;
|
|
84
|
+
/** Class representing a measurement. */
|
|
85
|
+
var Measure = /** @class */ (function (_super) {
|
|
86
|
+
__extends(Measure, _super);
|
|
87
|
+
function Measure(src_register, dest_register, src_index, dest_index) {
|
|
88
|
+
var _this = _super.call(this) || this;
|
|
89
|
+
_this.src_index = src_index != undefined ? src_index : null;
|
|
90
|
+
_this.src_register = src_register;
|
|
91
|
+
_this.dest_index = dest_index != undefined ? dest_index : null;
|
|
92
|
+
_this.dest_register = dest_register;
|
|
93
|
+
return _this;
|
|
94
|
+
}
|
|
95
|
+
return Measure;
|
|
96
|
+
}(AstNode));
|
|
97
|
+
exports.Measure = Measure;
|
|
98
|
+
/** Class representing a gate application. */
|
|
99
|
+
var ApplyGate = /** @class */ (function (_super) {
|
|
100
|
+
__extends(ApplyGate, _super);
|
|
101
|
+
function ApplyGate(name, qubits, params) {
|
|
102
|
+
var _this = _super.call(this) || this;
|
|
103
|
+
_this.name = name;
|
|
104
|
+
_this.qubits = qubits;
|
|
105
|
+
_this.params = params;
|
|
106
|
+
return _this;
|
|
107
|
+
}
|
|
108
|
+
return ApplyGate;
|
|
109
|
+
}(AstNode));
|
|
110
|
+
exports.ApplyGate = ApplyGate;
|
|
111
|
+
/** Class representing a gate. */
|
|
112
|
+
var Gate = /** @class */ (function (_super) {
|
|
113
|
+
__extends(Gate, _super);
|
|
114
|
+
function Gate(name, registers, params, nodes) {
|
|
115
|
+
var _this = _super.call(this) || this;
|
|
116
|
+
_this.name = name;
|
|
117
|
+
_this.registers = registers;
|
|
118
|
+
_this.params = params;
|
|
119
|
+
_this.nodes = nodes;
|
|
120
|
+
return _this;
|
|
121
|
+
}
|
|
122
|
+
return Gate;
|
|
123
|
+
}(AstNode));
|
|
124
|
+
exports.Gate = Gate;
|
|
125
|
+
/** Class representing conditional. */
|
|
126
|
+
var If = /** @class */ (function (_super) {
|
|
127
|
+
__extends(If, _super);
|
|
128
|
+
function If(register, param, gate) {
|
|
129
|
+
var _this = _super.call(this) || this;
|
|
130
|
+
_this.register = register;
|
|
131
|
+
_this.param = param;
|
|
132
|
+
_this.gate = gate;
|
|
133
|
+
return _this;
|
|
134
|
+
}
|
|
135
|
+
return If;
|
|
136
|
+
}(AstNode));
|
|
137
|
+
exports.If = If;
|
|
138
|
+
/** Class representing minus. */
|
|
139
|
+
var Minus = /** @class */ (function (_super) {
|
|
140
|
+
__extends(Minus, _super);
|
|
141
|
+
function Minus() {
|
|
142
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
143
|
+
}
|
|
144
|
+
return Minus;
|
|
145
|
+
}(AstNode));
|
|
146
|
+
exports.Minus = Minus;
|
|
147
|
+
/** Class representing plus. */
|
|
148
|
+
var Plus = /** @class */ (function (_super) {
|
|
149
|
+
__extends(Plus, _super);
|
|
150
|
+
function Plus() {
|
|
151
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
152
|
+
}
|
|
153
|
+
return Plus;
|
|
154
|
+
}(AstNode));
|
|
155
|
+
exports.Plus = Plus;
|
|
156
|
+
/** Class representing times. */
|
|
157
|
+
var Times = /** @class */ (function (_super) {
|
|
158
|
+
__extends(Times, _super);
|
|
159
|
+
function Times() {
|
|
160
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
161
|
+
}
|
|
162
|
+
return Times;
|
|
163
|
+
}(AstNode));
|
|
164
|
+
exports.Times = Times;
|
|
165
|
+
/** Class representing power. */
|
|
166
|
+
var Power = /** @class */ (function (_super) {
|
|
167
|
+
__extends(Power, _super);
|
|
168
|
+
function Power() {
|
|
169
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
170
|
+
}
|
|
171
|
+
return Power;
|
|
172
|
+
}(AstNode));
|
|
173
|
+
exports.Power = Power;
|
|
174
|
+
/** Class representing division. */
|
|
175
|
+
var Divide = /** @class */ (function (_super) {
|
|
176
|
+
__extends(Divide, _super);
|
|
177
|
+
function Divide() {
|
|
178
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
179
|
+
}
|
|
180
|
+
return Divide;
|
|
181
|
+
}(AstNode));
|
|
182
|
+
exports.Divide = Divide;
|
|
183
|
+
/** Class representing pi. */
|
|
184
|
+
var Pi = /** @class */ (function (_super) {
|
|
185
|
+
__extends(Pi, _super);
|
|
186
|
+
function Pi() {
|
|
187
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
188
|
+
}
|
|
189
|
+
return Pi;
|
|
190
|
+
}(AstNode));
|
|
191
|
+
exports.Pi = Pi;
|
|
192
|
+
/** Class representing the square root. */
|
|
193
|
+
var Sqrt = /** @class */ (function (_super) {
|
|
194
|
+
__extends(Sqrt, _super);
|
|
195
|
+
function Sqrt() {
|
|
196
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
197
|
+
}
|
|
198
|
+
return Sqrt;
|
|
199
|
+
}(AstNode));
|
|
200
|
+
exports.Sqrt = Sqrt;
|
|
201
|
+
/** Class representing natural logarithm. */
|
|
202
|
+
var Ln = /** @class */ (function (_super) {
|
|
203
|
+
__extends(Ln, _super);
|
|
204
|
+
function Ln() {
|
|
205
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
206
|
+
}
|
|
207
|
+
return Ln;
|
|
208
|
+
}(AstNode));
|
|
209
|
+
exports.Ln = Ln;
|
|
210
|
+
/** Class representing exponentiation. */
|
|
211
|
+
var Exp = /** @class */ (function (_super) {
|
|
212
|
+
__extends(Exp, _super);
|
|
213
|
+
function Exp() {
|
|
214
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
215
|
+
}
|
|
216
|
+
return Exp;
|
|
217
|
+
}(AstNode));
|
|
218
|
+
exports.Exp = Exp;
|
|
219
|
+
/** Class representing tagnent. */
|
|
220
|
+
var Tan = /** @class */ (function (_super) {
|
|
221
|
+
__extends(Tan, _super);
|
|
222
|
+
function Tan() {
|
|
223
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
224
|
+
}
|
|
225
|
+
return Tan;
|
|
226
|
+
}(AstNode));
|
|
227
|
+
exports.Tan = Tan;
|
|
228
|
+
/** Class representing cosine. */
|
|
229
|
+
var Cos = /** @class */ (function (_super) {
|
|
230
|
+
__extends(Cos, _super);
|
|
231
|
+
function Cos() {
|
|
232
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
233
|
+
}
|
|
234
|
+
return Cos;
|
|
235
|
+
}(AstNode));
|
|
236
|
+
exports.Cos = Cos;
|
|
237
|
+
/** Class representing sine. */
|
|
238
|
+
var Sin = /** @class */ (function (_super) {
|
|
239
|
+
__extends(Sin, _super);
|
|
240
|
+
function Sin() {
|
|
241
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
242
|
+
}
|
|
243
|
+
return Sin;
|
|
244
|
+
}(AstNode));
|
|
245
|
+
exports.Sin = Sin;
|
|
246
|
+
/** Class representing an integer. */
|
|
247
|
+
var NNInteger = /** @class */ (function (_super) {
|
|
248
|
+
__extends(NNInteger, _super);
|
|
249
|
+
function NNInteger(value) {
|
|
250
|
+
var _this = _super.call(this) || this;
|
|
251
|
+
_this.value = value;
|
|
252
|
+
return _this;
|
|
253
|
+
}
|
|
254
|
+
return NNInteger;
|
|
255
|
+
}(AstNode));
|
|
256
|
+
exports.NNInteger = NNInteger;
|
|
257
|
+
/** Class representing a real. */
|
|
258
|
+
var Real = /** @class */ (function (_super) {
|
|
259
|
+
__extends(Real, _super);
|
|
260
|
+
function Real(value) {
|
|
261
|
+
var _this = _super.call(this) || this;
|
|
262
|
+
_this.value = value;
|
|
263
|
+
return _this;
|
|
264
|
+
}
|
|
265
|
+
return Real;
|
|
266
|
+
}(AstNode));
|
|
267
|
+
exports.Real = Real;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.MissingSemicolonError = exports.BadParameterError = exports.BadEqualsError = exports.BadGateError = exports.BadMeasurementError = exports.BadBarrierError = exports.BadConditionalError = exports.BadQregError = exports.BadCregError = exports.BadArgumentError = void 0;
|
|
19
|
+
/** Class representing a bad argument exception. */
|
|
20
|
+
var BadArgumentError = /** @class */ (function (_super) {
|
|
21
|
+
__extends(BadArgumentError, _super);
|
|
22
|
+
function BadArgumentError(message) {
|
|
23
|
+
var _newTarget = this.constructor;
|
|
24
|
+
var _this = _super.call(this, message) || this;
|
|
25
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
26
|
+
_this.name = BadArgumentError.name;
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
return BadArgumentError;
|
|
30
|
+
}(Error));
|
|
31
|
+
exports.BadArgumentError = BadArgumentError;
|
|
32
|
+
/** Class representing a bad quantum register exception. */
|
|
33
|
+
var BadQregError = /** @class */ (function (_super) {
|
|
34
|
+
__extends(BadQregError, _super);
|
|
35
|
+
function BadQregError(message) {
|
|
36
|
+
var _newTarget = this.constructor;
|
|
37
|
+
var _this = _super.call(this, message) || this;
|
|
38
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
39
|
+
_this.name = BadQregError.name;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
return BadQregError;
|
|
43
|
+
}(Error));
|
|
44
|
+
exports.BadQregError = BadQregError;
|
|
45
|
+
/** Class representing a bad equality exception. */
|
|
46
|
+
var BadEqualsError = /** @class */ (function (_super) {
|
|
47
|
+
__extends(BadEqualsError, _super);
|
|
48
|
+
function BadEqualsError(message) {
|
|
49
|
+
var _newTarget = this.constructor;
|
|
50
|
+
var _this = _super.call(this, message) || this;
|
|
51
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
52
|
+
_this.name = BadEqualsError.name;
|
|
53
|
+
return _this;
|
|
54
|
+
}
|
|
55
|
+
return BadEqualsError;
|
|
56
|
+
}(Error));
|
|
57
|
+
exports.BadEqualsError = BadEqualsError;
|
|
58
|
+
/** Class representing a bad classical register exception. */
|
|
59
|
+
var BadCregError = /** @class */ (function (_super) {
|
|
60
|
+
__extends(BadCregError, _super);
|
|
61
|
+
function BadCregError(message) {
|
|
62
|
+
var _newTarget = this.constructor;
|
|
63
|
+
var _this = _super.call(this, message) || this;
|
|
64
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
65
|
+
_this.name = BadCregError.name;
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
return BadCregError;
|
|
69
|
+
}(Error));
|
|
70
|
+
exports.BadCregError = BadCregError;
|
|
71
|
+
/** Class representing a bad conditional exception. */
|
|
72
|
+
var BadConditionalError = /** @class */ (function (_super) {
|
|
73
|
+
__extends(BadConditionalError, _super);
|
|
74
|
+
function BadConditionalError(message) {
|
|
75
|
+
var _newTarget = this.constructor;
|
|
76
|
+
var _this = _super.call(this, message) || this;
|
|
77
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
78
|
+
_this.name = BadConditionalError.name;
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
return BadConditionalError;
|
|
82
|
+
}(Error));
|
|
83
|
+
exports.BadConditionalError = BadConditionalError;
|
|
84
|
+
/** Class representing a bad barrier exception. */
|
|
85
|
+
var BadBarrierError = /** @class */ (function (_super) {
|
|
86
|
+
__extends(BadBarrierError, _super);
|
|
87
|
+
function BadBarrierError(message) {
|
|
88
|
+
var _newTarget = this.constructor;
|
|
89
|
+
var _this = _super.call(this, message) || this;
|
|
90
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
91
|
+
_this.name = BadBarrierError.name;
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
return BadBarrierError;
|
|
95
|
+
}(Error));
|
|
96
|
+
exports.BadBarrierError = BadBarrierError;
|
|
97
|
+
/** Class representing a bad measurement exception. */
|
|
98
|
+
var BadMeasurementError = /** @class */ (function (_super) {
|
|
99
|
+
__extends(BadMeasurementError, _super);
|
|
100
|
+
function BadMeasurementError(message) {
|
|
101
|
+
var _newTarget = this.constructor;
|
|
102
|
+
var _this = _super.call(this, message) || this;
|
|
103
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
104
|
+
_this.name = BadMeasurementError.name;
|
|
105
|
+
return _this;
|
|
106
|
+
}
|
|
107
|
+
return BadMeasurementError;
|
|
108
|
+
}(Error));
|
|
109
|
+
exports.BadMeasurementError = BadMeasurementError;
|
|
110
|
+
/** Class representing a bad gate exception. */
|
|
111
|
+
var BadGateError = /** @class */ (function (_super) {
|
|
112
|
+
__extends(BadGateError, _super);
|
|
113
|
+
function BadGateError(message) {
|
|
114
|
+
var _newTarget = this.constructor;
|
|
115
|
+
var _this = _super.call(this, message) || this;
|
|
116
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
117
|
+
_this.name = BadGateError.name;
|
|
118
|
+
return _this;
|
|
119
|
+
}
|
|
120
|
+
return BadGateError;
|
|
121
|
+
}(Error));
|
|
122
|
+
exports.BadGateError = BadGateError;
|
|
123
|
+
/** Class representing a bad parameter exception. */
|
|
124
|
+
var BadParameterError = /** @class */ (function (_super) {
|
|
125
|
+
__extends(BadParameterError, _super);
|
|
126
|
+
function BadParameterError(message) {
|
|
127
|
+
var _newTarget = this.constructor;
|
|
128
|
+
var _this = _super.call(this, message) || this;
|
|
129
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
130
|
+
_this.name = BadParameterError.name;
|
|
131
|
+
return _this;
|
|
132
|
+
}
|
|
133
|
+
return BadParameterError;
|
|
134
|
+
}(Error));
|
|
135
|
+
exports.BadParameterError = BadParameterError;
|
|
136
|
+
/** Class representing a missing semicolon exception. */
|
|
137
|
+
var MissingSemicolonError = /** @class */ (function (_super) {
|
|
138
|
+
__extends(MissingSemicolonError, _super);
|
|
139
|
+
function MissingSemicolonError(message) {
|
|
140
|
+
var _newTarget = this.constructor;
|
|
141
|
+
var _this = _super.call(this, message) || this;
|
|
142
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
143
|
+
_this.name = MissingSemicolonError.name;
|
|
144
|
+
return _this;
|
|
145
|
+
}
|
|
146
|
+
return MissingSemicolonError;
|
|
147
|
+
}(Error));
|
|
148
|
+
exports.MissingSemicolonError = MissingSemicolonError;
|
package/dist/example.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
var lexer_1 = require("./lexer");
|
|
4
|
+
var parser_1 = require("./parser");
|
|
5
|
+
var fs = require("fs");
|
|
6
|
+
var qmasm = fs.readFileSync('spec/qmasm/comparator.qmasm', 'utf8');
|
|
7
|
+
console.log(qmasm);
|
|
8
|
+
var lexer = new lexer_1["default"](qmasm, 0);
|
|
9
|
+
var tokens = lexer.lex();
|
|
10
|
+
console.log(tokens);
|
|
11
|
+
var parser = new parser_1["default"](tokens, false, 'spec/qmasm/');
|
|
12
|
+
var ast = parser.parse();
|
|
13
|
+
for (var i = 0; i < ast.length; i++) {
|
|
14
|
+
console.log(ast[i]);
|
|
15
|
+
if (ast[i]['val'] && ast[i]['val']['elements']) {
|
|
16
|
+
for (var j = 0; j < ast[i]['val']['elements'].length; j++) {
|
|
17
|
+
console.log(ast[i]['val']['elements'][j]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
console.log(JSON.stringify(ast[i]));
|
|
21
|
+
console.log('\n');
|
|
22
|
+
}
|