qasm-ts 2.1.2 → 2.1.4
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/errors.d.ts +88 -0
- package/dist/errors.js +116 -228
- package/dist/lexer.d.ts +78 -0
- package/dist/lexer.js +21 -24
- package/dist/main.d.ts +87 -0
- package/dist/main.js +10 -19
- package/dist/parser.d.ts +75 -0
- package/dist/parser.js +22 -25
- package/dist/qasm2/ast.d.ts +159 -0
- package/dist/qasm2/ast.js +117 -267
- package/dist/qasm2/lexer.d.ts +135 -0
- package/dist/qasm2/lexer.js +171 -177
- package/dist/qasm2/parser.d.ts +187 -0
- package/dist/qasm2/parser.js +254 -258
- package/dist/qasm2/token.d.ts +89 -0
- package/dist/qasm2/token.js +4 -9
- package/dist/qasm3/ast.d.ts +652 -0
- package/dist/qasm3/ast.js +397 -732
- package/dist/qasm3/lexer.d.ts +156 -0
- package/dist/qasm3/lexer.js +259 -265
- package/dist/qasm3/parser.d.ts +407 -0
- package/dist/qasm3/parser.js +892 -896
- package/dist/qasm3/token.d.ts +197 -0
- package/dist/qasm3/token.js +4 -9
- package/dist/version.d.ts +41 -0
- package/dist/version.js +12 -16
- package/docs/docs-readme.md +13 -9
- package/docs/typedoc/index.html +4 -4
- package/package.json +2 -1
- package/readme.md +4 -3
- package/tsconfig.json +7 -2
package/dist/qasm3/ast.js
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.QuantumMeasurement = exports.ArrayAccess = exports.ArrayInitializer = exports.ArrayDeclaration = exports.IndexSet = exports.Cast = exports.Binary = exports.BinaryOp = exports.Arithmetic = exports.ArithmeticOp = exports.Unary = exports.UnaryOp = exports.SizeOf = exports.DurationOf = exports.DurationLiteral = exports.DurationUnit = exports.BitstringLiteral = exports.BooleanLiteral = exports.ImaginaryLiteral = exports.FloatLiteral = exports.NumericLiteral = exports.IntegerLiteral = exports.TrigFunction = exports.TrigFunctionTypes = exports.MathFunction = exports.MathFunctionTypes = exports.Tau = exports.Euler = exports.Pi = exports.SubscriptedIdentifier = exports.Identifier = exports.Range = exports.DurationType = exports.StretchType = exports.AngleType = exports.BitType = exports.UIntType = exports.IntType = exports.BoolType = exports.ComplexType = exports.FloatType = exports.Version = exports.Include = exports.CalibrationGrammarDeclaration = exports.ArrayReference = exports.ArrayReferenceModifier = exports.Parameters = exports.Expression = exports.Statement = exports.AstNode = void 0;
|
|
20
|
-
exports.ClassicalType = exports.DefaultStatement = exports.CaseStatement = exports.SwitchStatement = exports.IODeclaration = exports.IOModifier = exports.ContinueStatement = exports.BreakStatement = exports.WhileLoopStatement = exports.ForLoopStatement = exports.BranchingStatement = exports.SubroutineCall = exports.SubroutineDefinition = exports.ExternSignature = exports.BoxDefinition = exports.QuantumGateDefinition = exports.SubroutineBlock = exports.QuantumBlock = exports.ProgramBlock = exports.ReturnStatement = exports.QuantumDelay = exports.QuantumReset = exports.QuantumBarrier = exports.QuantumGateCall = exports.QuantumGateModifier = exports.QuantumGateModifierName = exports.AliasStatement = exports.HardwareQubit = exports.QuantumDeclaration = exports.AssignmentStatement = exports.ClassicalDeclaration = exports.QuantumMeasurementAssignment = void 0;
|
|
21
2
|
/** Base class representing a basic AST node. */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return AstNode;
|
|
26
|
-
}());
|
|
27
|
-
exports.AstNode = AstNode;
|
|
3
|
+
class AstNode {
|
|
4
|
+
}
|
|
28
5
|
/**
|
|
29
6
|
* Base class representing an instruction which performs an action.
|
|
30
7
|
*
|
|
@@ -38,62 +15,44 @@ exports.AstNode = AstNode;
|
|
|
38
15
|
* | aliasStatement
|
|
39
16
|
* | quantumStatement
|
|
40
17
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function Statement() {
|
|
44
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
45
|
-
}
|
|
46
|
-
return Statement;
|
|
47
|
-
}(AstNode));
|
|
48
|
-
exports.Statement = Statement;
|
|
18
|
+
class Statement extends AstNode {
|
|
19
|
+
}
|
|
49
20
|
/**
|
|
50
21
|
* Class representing a custom grammar for specifying calibrations.
|
|
51
22
|
*
|
|
52
23
|
* calibrationGrammarStatement:
|
|
53
24
|
* | DEFCALGRAMMAR StringLiteral SEMICOLON
|
|
54
25
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_this.name = name;
|
|
60
|
-
return _this;
|
|
26
|
+
class CalibrationGrammarDeclaration extends Statement {
|
|
27
|
+
constructor(name) {
|
|
28
|
+
super();
|
|
29
|
+
this.name = name;
|
|
61
30
|
}
|
|
62
|
-
|
|
63
|
-
}(Statement));
|
|
64
|
-
exports.CalibrationGrammarDeclaration = CalibrationGrammarDeclaration;
|
|
31
|
+
}
|
|
65
32
|
/**
|
|
66
33
|
* Class representing an include statement.
|
|
67
34
|
*
|
|
68
35
|
* includeStatement:
|
|
69
36
|
* INCLUDE StringLiteral SEMICOLON
|
|
70
37
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_this.filename = filename;
|
|
76
|
-
return _this;
|
|
38
|
+
class Include extends AstNode {
|
|
39
|
+
constructor(filename) {
|
|
40
|
+
super();
|
|
41
|
+
this.filename = filename;
|
|
77
42
|
}
|
|
78
|
-
|
|
79
|
-
}(AstNode));
|
|
80
|
-
exports.Include = Include;
|
|
43
|
+
}
|
|
81
44
|
/**
|
|
82
45
|
* Class representing the version statement.
|
|
83
46
|
*
|
|
84
47
|
* version
|
|
85
48
|
* : 'OPENQASM'(Integer | RealNumber) SEMICOLON
|
|
86
49
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
_this.version = version;
|
|
92
|
-
return _this;
|
|
50
|
+
class Version extends AstNode {
|
|
51
|
+
constructor(version) {
|
|
52
|
+
super();
|
|
53
|
+
this.version = version;
|
|
93
54
|
}
|
|
94
|
-
|
|
95
|
-
}(AstNode));
|
|
96
|
-
exports.Version = Version;
|
|
55
|
+
}
|
|
97
56
|
/**
|
|
98
57
|
* Base class representing a quantum instruction.
|
|
99
58
|
*
|
|
@@ -104,207 +63,114 @@ exports.Version = Version;
|
|
|
104
63
|
* | quantumReset
|
|
105
64
|
* | quantumBarrier
|
|
106
65
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
function QuantumInstruction() {
|
|
110
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
111
|
-
}
|
|
112
|
-
return QuantumInstruction;
|
|
113
|
-
}(AstNode));
|
|
66
|
+
class QuantumInstruction extends AstNode {
|
|
67
|
+
}
|
|
114
68
|
/** Base class representing a classical computing type. */
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
function ClassicalType() {
|
|
118
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
119
|
-
}
|
|
120
|
-
return ClassicalType;
|
|
121
|
-
}(AstNode));
|
|
122
|
-
exports.ClassicalType = ClassicalType;
|
|
69
|
+
class ClassicalType extends AstNode {
|
|
70
|
+
}
|
|
123
71
|
/**
|
|
124
72
|
* Class representing a classical float type.
|
|
125
73
|
*
|
|
126
74
|
* scalarType:
|
|
127
75
|
* FLOAT designator?
|
|
128
76
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
_this.width = width ? width : null;
|
|
134
|
-
return _this;
|
|
77
|
+
class FloatType extends ClassicalType {
|
|
78
|
+
constructor(width) {
|
|
79
|
+
super();
|
|
80
|
+
this.width = width ? width : null;
|
|
135
81
|
}
|
|
136
|
-
|
|
137
|
-
}(ClassicalType));
|
|
138
|
-
exports.FloatType = FloatType;
|
|
82
|
+
}
|
|
139
83
|
/**
|
|
140
84
|
* Class representing a complex number type.
|
|
141
85
|
*
|
|
142
86
|
* scalarType:
|
|
143
87
|
* COMPLEX (LBRACKET scalarType RBRACKET)?
|
|
144
88
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
_this.float = float;
|
|
150
|
-
return _this;
|
|
89
|
+
class ComplexType extends ClassicalType {
|
|
90
|
+
constructor(float) {
|
|
91
|
+
super();
|
|
92
|
+
this.float = float;
|
|
151
93
|
}
|
|
152
|
-
|
|
153
|
-
}(ClassicalType));
|
|
154
|
-
exports.ComplexType = ComplexType;
|
|
94
|
+
}
|
|
155
95
|
/** Class representing a classical boolean type. */
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
function BoolType() {
|
|
159
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
160
|
-
}
|
|
161
|
-
return BoolType;
|
|
162
|
-
}(ClassicalType));
|
|
163
|
-
exports.BoolType = BoolType;
|
|
96
|
+
class BoolType extends ClassicalType {
|
|
97
|
+
}
|
|
164
98
|
/** Class representing a classical signed integer type. */
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
_this.size = size ? size : null;
|
|
170
|
-
return _this;
|
|
99
|
+
class IntType extends ClassicalType {
|
|
100
|
+
constructor(size) {
|
|
101
|
+
super();
|
|
102
|
+
this.size = size ? size : null;
|
|
171
103
|
}
|
|
172
|
-
|
|
173
|
-
}(ClassicalType));
|
|
174
|
-
exports.IntType = IntType;
|
|
104
|
+
}
|
|
175
105
|
/** Class representing a classical unsigned integer type. */
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
_this.size = size ? size : null;
|
|
181
|
-
return _this;
|
|
106
|
+
class UIntType extends ClassicalType {
|
|
107
|
+
constructor(size) {
|
|
108
|
+
super();
|
|
109
|
+
this.size = size ? size : null;
|
|
182
110
|
}
|
|
183
|
-
|
|
184
|
-
}(ClassicalType));
|
|
185
|
-
exports.UIntType = UIntType;
|
|
111
|
+
}
|
|
186
112
|
/** Class representing a classical bit type. */
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
_this.size = size ? size : null;
|
|
192
|
-
return _this;
|
|
113
|
+
class BitType extends ClassicalType {
|
|
114
|
+
constructor(size) {
|
|
115
|
+
super();
|
|
116
|
+
this.size = size ? size : null;
|
|
193
117
|
}
|
|
194
|
-
|
|
195
|
-
}(ClassicalType));
|
|
196
|
-
exports.BitType = BitType;
|
|
118
|
+
}
|
|
197
119
|
/** Class representing an angle type. */
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
_this.size = size ? size : null;
|
|
203
|
-
return _this;
|
|
120
|
+
class AngleType extends ClassicalType {
|
|
121
|
+
constructor(size) {
|
|
122
|
+
super();
|
|
123
|
+
this.size = size ? size : null;
|
|
204
124
|
}
|
|
205
|
-
|
|
206
|
-
}(ClassicalType));
|
|
207
|
-
exports.AngleType = AngleType;
|
|
125
|
+
}
|
|
208
126
|
/** Class representing the stretch type. */
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
function StretchType() {
|
|
212
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
213
|
-
}
|
|
214
|
-
return StretchType;
|
|
215
|
-
}(ClassicalType));
|
|
216
|
-
exports.StretchType = StretchType;
|
|
127
|
+
class StretchType extends ClassicalType {
|
|
128
|
+
}
|
|
217
129
|
/** Class representing a duration type. */
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
function DurationType() {
|
|
221
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
222
|
-
}
|
|
223
|
-
return DurationType;
|
|
224
|
-
}(ClassicalType));
|
|
225
|
-
exports.DurationType = DurationType;
|
|
130
|
+
class DurationType extends ClassicalType {
|
|
131
|
+
}
|
|
226
132
|
/** Base class representing an expression. */
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
function Expression() {
|
|
230
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
231
|
-
}
|
|
232
|
-
return Expression;
|
|
233
|
-
}(AstNode));
|
|
234
|
-
exports.Expression = Expression;
|
|
133
|
+
class Expression extends AstNode {
|
|
134
|
+
}
|
|
235
135
|
/** Class representing a list of parameters. */
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
_this.args = args;
|
|
241
|
-
return _this;
|
|
136
|
+
class Parameters extends Expression {
|
|
137
|
+
constructor(args) {
|
|
138
|
+
super();
|
|
139
|
+
this.args = args;
|
|
242
140
|
}
|
|
243
|
-
|
|
244
|
-
}(Expression));
|
|
245
|
-
exports.Parameters = Parameters;
|
|
141
|
+
}
|
|
246
142
|
/** Class representing a range. */
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
return Range;
|
|
257
|
-
}(Expression));
|
|
258
|
-
exports.Range = Range;
|
|
143
|
+
class Range extends Expression {
|
|
144
|
+
constructor(start, end, step) {
|
|
145
|
+
super();
|
|
146
|
+
this.start = start ? start : null;
|
|
147
|
+
this.end = end ? end : null;
|
|
148
|
+
this.step = step ? step : null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
259
151
|
/** Class representing an expression identifier. */
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
_this.name = name;
|
|
265
|
-
return _this;
|
|
152
|
+
class Identifier extends Expression {
|
|
153
|
+
constructor(name) {
|
|
154
|
+
super();
|
|
155
|
+
this.name = name;
|
|
266
156
|
}
|
|
267
|
-
|
|
268
|
-
}(Expression));
|
|
269
|
-
exports.Identifier = Identifier;
|
|
157
|
+
}
|
|
270
158
|
/** Class representing an identifier with subscripted access. */
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
_this.subscript = subscript;
|
|
276
|
-
return _this;
|
|
159
|
+
class SubscriptedIdentifier extends Identifier {
|
|
160
|
+
constructor(name, subscript) {
|
|
161
|
+
super(name);
|
|
162
|
+
this.subscript = subscript;
|
|
277
163
|
}
|
|
278
|
-
|
|
279
|
-
}(Identifier));
|
|
280
|
-
exports.SubscriptedIdentifier = SubscriptedIdentifier;
|
|
164
|
+
}
|
|
281
165
|
/** Class representing the Pi constant. */
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
function Pi() {
|
|
285
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
286
|
-
}
|
|
287
|
-
return Pi;
|
|
288
|
-
}(Expression));
|
|
289
|
-
exports.Pi = Pi;
|
|
166
|
+
class Pi extends Expression {
|
|
167
|
+
}
|
|
290
168
|
/** Class representing the Euler constant. */
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
function Euler() {
|
|
294
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
295
|
-
}
|
|
296
|
-
return Euler;
|
|
297
|
-
}(Expression));
|
|
298
|
-
exports.Euler = Euler;
|
|
169
|
+
class Euler extends Expression {
|
|
170
|
+
}
|
|
299
171
|
/** Class representing the Tau constant. */
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
function Tau() {
|
|
303
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
304
|
-
}
|
|
305
|
-
return Tau;
|
|
306
|
-
}(Expression));
|
|
307
|
-
exports.Tau = Tau;
|
|
172
|
+
class Tau extends Expression {
|
|
173
|
+
}
|
|
308
174
|
/** Enum representing the available mathematical functions. */
|
|
309
175
|
var MathFunctionTypes;
|
|
310
176
|
(function (MathFunctionTypes) {
|
|
@@ -318,19 +184,15 @@ var MathFunctionTypes;
|
|
|
318
184
|
MathFunctionTypes["SQRT"] = "sqrt";
|
|
319
185
|
MathFunctionTypes["ROTR"] = "rotr";
|
|
320
186
|
MathFunctionTypes["ROTL"] = "rotl";
|
|
321
|
-
})(MathFunctionTypes || (
|
|
187
|
+
})(MathFunctionTypes || (MathFunctionTypes = {}));
|
|
322
188
|
/** Class representing a mathematical function. */
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
_this.operands = operands;
|
|
329
|
-
return _this;
|
|
189
|
+
class MathFunction extends Expression {
|
|
190
|
+
constructor(mathType, operands) {
|
|
191
|
+
super();
|
|
192
|
+
this.mathType = mathType;
|
|
193
|
+
this.operands = operands;
|
|
330
194
|
}
|
|
331
|
-
|
|
332
|
-
}(Expression));
|
|
333
|
-
exports.MathFunction = MathFunction;
|
|
195
|
+
}
|
|
334
196
|
/** Enum representing the available trigonometric functions. */
|
|
335
197
|
var TrigFunctionTypes;
|
|
336
198
|
(function (TrigFunctionTypes) {
|
|
@@ -340,85 +202,57 @@ var TrigFunctionTypes;
|
|
|
340
202
|
TrigFunctionTypes["COS"] = "Cos";
|
|
341
203
|
TrigFunctionTypes["SIN"] = "Sin";
|
|
342
204
|
TrigFunctionTypes["TAN"] = "Tan";
|
|
343
|
-
})(TrigFunctionTypes || (
|
|
205
|
+
})(TrigFunctionTypes || (TrigFunctionTypes = {}));
|
|
344
206
|
/** Class representing a trigonometric function. */
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
_this.operand = operand;
|
|
351
|
-
return _this;
|
|
207
|
+
class TrigFunction extends Expression {
|
|
208
|
+
constructor(trigType, operand) {
|
|
209
|
+
super();
|
|
210
|
+
this.trigType = trigType;
|
|
211
|
+
this.operand = operand;
|
|
352
212
|
}
|
|
353
|
-
|
|
354
|
-
}(Expression));
|
|
355
|
-
exports.TrigFunction = TrigFunction;
|
|
213
|
+
}
|
|
356
214
|
/** Class representing an integer literal. */
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
_this.value = value;
|
|
362
|
-
return _this;
|
|
215
|
+
class IntegerLiteral extends Expression {
|
|
216
|
+
constructor(value) {
|
|
217
|
+
super();
|
|
218
|
+
this.value = value;
|
|
363
219
|
}
|
|
364
|
-
|
|
365
|
-
}(Expression));
|
|
366
|
-
exports.IntegerLiteral = IntegerLiteral;
|
|
220
|
+
}
|
|
367
221
|
/** Class representing a scientific notation, binary, octal, or hex literal. */
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
_this.value = value;
|
|
373
|
-
return _this;
|
|
222
|
+
class NumericLiteral extends Expression {
|
|
223
|
+
constructor(value) {
|
|
224
|
+
super();
|
|
225
|
+
this.value = value;
|
|
374
226
|
}
|
|
375
|
-
|
|
376
|
-
}(Expression));
|
|
377
|
-
exports.NumericLiteral = NumericLiteral;
|
|
227
|
+
}
|
|
378
228
|
/** Class representing a float literal. */
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
_this.value = value;
|
|
384
|
-
return _this;
|
|
229
|
+
class FloatLiteral extends Expression {
|
|
230
|
+
constructor(value) {
|
|
231
|
+
super();
|
|
232
|
+
this.value = value;
|
|
385
233
|
}
|
|
386
|
-
|
|
387
|
-
}(Expression));
|
|
388
|
-
exports.FloatLiteral = FloatLiteral;
|
|
234
|
+
}
|
|
389
235
|
/** Class representing an imaginary number literal. */
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
_this.value = value;
|
|
395
|
-
return _this;
|
|
236
|
+
class ImaginaryLiteral extends Expression {
|
|
237
|
+
constructor(value) {
|
|
238
|
+
super();
|
|
239
|
+
this.value = value;
|
|
396
240
|
}
|
|
397
|
-
|
|
398
|
-
}(Expression));
|
|
399
|
-
exports.ImaginaryLiteral = ImaginaryLiteral;
|
|
241
|
+
}
|
|
400
242
|
/** Class representing a boolean literal. */
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
_this.value = value;
|
|
406
|
-
return _this;
|
|
243
|
+
class BooleanLiteral extends Expression {
|
|
244
|
+
constructor(value) {
|
|
245
|
+
super();
|
|
246
|
+
this.value = value;
|
|
407
247
|
}
|
|
408
|
-
|
|
409
|
-
}(Expression));
|
|
410
|
-
exports.BooleanLiteral = BooleanLiteral;
|
|
248
|
+
}
|
|
411
249
|
/** Class representing a bit string literal. */
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
_this.value = value;
|
|
417
|
-
return _this;
|
|
250
|
+
class BitstringLiteral extends Expression {
|
|
251
|
+
constructor(value) {
|
|
252
|
+
super();
|
|
253
|
+
this.value = value;
|
|
418
254
|
}
|
|
419
|
-
|
|
420
|
-
}(Expression));
|
|
421
|
-
exports.BitstringLiteral = BitstringLiteral;
|
|
255
|
+
}
|
|
422
256
|
/** Enum representing the supported duration units. */
|
|
423
257
|
var DurationUnit;
|
|
424
258
|
(function (DurationUnit) {
|
|
@@ -427,64 +261,48 @@ var DurationUnit;
|
|
|
427
261
|
DurationUnit["MILLISECOND"] = "ms";
|
|
428
262
|
DurationUnit["SECOND"] = "s";
|
|
429
263
|
DurationUnit["SAMPLE"] = "dt";
|
|
430
|
-
})(DurationUnit || (
|
|
264
|
+
})(DurationUnit || (DurationUnit = {}));
|
|
431
265
|
/** Class representing a duration literal. */
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
_this.unit = unit;
|
|
438
|
-
return _this;
|
|
266
|
+
class DurationLiteral extends Expression {
|
|
267
|
+
constructor(value, unit) {
|
|
268
|
+
super();
|
|
269
|
+
this.value = value;
|
|
270
|
+
this.unit = unit;
|
|
439
271
|
}
|
|
440
|
-
|
|
441
|
-
}(Expression));
|
|
442
|
-
exports.DurationLiteral = DurationLiteral;
|
|
272
|
+
}
|
|
443
273
|
/** Class representing a durationof function call. */
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
_this.scope = scope;
|
|
449
|
-
return _this;
|
|
274
|
+
class DurationOf extends Expression {
|
|
275
|
+
constructor(scope) {
|
|
276
|
+
super();
|
|
277
|
+
this.scope = scope;
|
|
450
278
|
}
|
|
451
|
-
|
|
452
|
-
}(Expression));
|
|
453
|
-
exports.DurationOf = DurationOf;
|
|
279
|
+
}
|
|
454
280
|
/** Class representing a sizeof function call. */
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
_this.dimensionIndex =
|
|
281
|
+
class SizeOf extends Expression {
|
|
282
|
+
constructor(array, dimensionIndex) {
|
|
283
|
+
super();
|
|
284
|
+
this.array = array;
|
|
285
|
+
this.dimensionIndex =
|
|
461
286
|
dimensionIndex !== undefined && dimensionIndex !== null
|
|
462
287
|
? dimensionIndex
|
|
463
288
|
: new IntegerLiteral(0);
|
|
464
|
-
return _this;
|
|
465
289
|
}
|
|
466
|
-
|
|
467
|
-
}(Expression));
|
|
468
|
-
exports.SizeOf = SizeOf;
|
|
290
|
+
}
|
|
469
291
|
/** Enum representing Unary operands. */
|
|
470
292
|
var UnaryOp;
|
|
471
293
|
(function (UnaryOp) {
|
|
472
294
|
UnaryOp["LOGIC_NOT"] = "!";
|
|
473
295
|
UnaryOp["BIT_NOT"] = "~";
|
|
474
296
|
UnaryOp["MINUS"] = "-";
|
|
475
|
-
})(UnaryOp || (
|
|
297
|
+
})(UnaryOp || (UnaryOp = {}));
|
|
476
298
|
/** Class representing a unary operator. */
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
_this.operand = operand;
|
|
483
|
-
return _this;
|
|
299
|
+
class Unary extends Expression {
|
|
300
|
+
constructor(op, operand) {
|
|
301
|
+
super();
|
|
302
|
+
this.op = op;
|
|
303
|
+
this.operand = operand;
|
|
484
304
|
}
|
|
485
|
-
|
|
486
|
-
}(Expression));
|
|
487
|
-
exports.Unary = Unary;
|
|
305
|
+
}
|
|
488
306
|
/** Enum representing arithmetic operations. */
|
|
489
307
|
var ArithmeticOp;
|
|
490
308
|
(function (ArithmeticOp) {
|
|
@@ -495,20 +313,16 @@ var ArithmeticOp;
|
|
|
495
313
|
ArithmeticOp["PLUS"] = "+";
|
|
496
314
|
ArithmeticOp["MINUS"] = "-";
|
|
497
315
|
ArithmeticOp["CONCAT"] = "++";
|
|
498
|
-
})(ArithmeticOp || (
|
|
316
|
+
})(ArithmeticOp || (ArithmeticOp = {}));
|
|
499
317
|
/** Class representing an arithmetic operator expression. */
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
return Arithmetic;
|
|
510
|
-
}(Expression));
|
|
511
|
-
exports.Arithmetic = Arithmetic;
|
|
318
|
+
class Arithmetic extends Expression {
|
|
319
|
+
constructor(op, left, right) {
|
|
320
|
+
super();
|
|
321
|
+
this.op = op;
|
|
322
|
+
this.left = left;
|
|
323
|
+
this.right = right;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
512
326
|
/** Enum representing binary operands. */
|
|
513
327
|
var BinaryOp;
|
|
514
328
|
(function (BinaryOp) {
|
|
@@ -525,119 +339,87 @@ var BinaryOp;
|
|
|
525
339
|
BinaryOp["NOT_EQUAL"] = "!=";
|
|
526
340
|
BinaryOp["SHIFT_LEFT"] = "<<";
|
|
527
341
|
BinaryOp["SHIFT_RIGHT"] = ">>";
|
|
528
|
-
})(BinaryOp || (
|
|
342
|
+
})(BinaryOp || (BinaryOp = {}));
|
|
529
343
|
/** Class representing binary operator expressions. */
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
return Binary;
|
|
540
|
-
}(Expression));
|
|
541
|
-
exports.Binary = Binary;
|
|
344
|
+
class Binary extends Expression {
|
|
345
|
+
constructor(op, left, right) {
|
|
346
|
+
super();
|
|
347
|
+
this.op = op;
|
|
348
|
+
this.left = left;
|
|
349
|
+
this.right = right;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
542
352
|
/** Class representing an cast expression. */
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
_this.operand = operand;
|
|
549
|
-
return _this;
|
|
353
|
+
class Cast extends Expression {
|
|
354
|
+
constructor(type, operand) {
|
|
355
|
+
super();
|
|
356
|
+
this.type = type;
|
|
357
|
+
this.operand = operand;
|
|
550
358
|
}
|
|
551
|
-
|
|
552
|
-
}(Expression));
|
|
553
|
-
exports.Cast = Cast;
|
|
359
|
+
}
|
|
554
360
|
/**
|
|
555
361
|
* Class representing a literal index set of values.
|
|
556
362
|
*
|
|
557
363
|
* { Expression (, Expression )* }
|
|
558
364
|
*/
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
_this.values = values;
|
|
564
|
-
return _this;
|
|
365
|
+
class IndexSet extends Expression {
|
|
366
|
+
constructor(values) {
|
|
367
|
+
super();
|
|
368
|
+
this.values = values;
|
|
565
369
|
}
|
|
566
|
-
|
|
567
|
-
}(Expression));
|
|
568
|
-
exports.IndexSet = IndexSet;
|
|
370
|
+
}
|
|
569
371
|
/** Enum representing the supported array reference modifiers. */
|
|
570
372
|
var ArrayReferenceModifier;
|
|
571
373
|
(function (ArrayReferenceModifier) {
|
|
572
374
|
ArrayReferenceModifier["READONLY"] = "readonly";
|
|
573
375
|
ArrayReferenceModifier["MUTABLE"] = "mutable";
|
|
574
|
-
})(ArrayReferenceModifier || (
|
|
376
|
+
})(ArrayReferenceModifier || (ArrayReferenceModifier = {}));
|
|
575
377
|
/** Class representing an array reference. */
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
_this.modifier = modifier;
|
|
582
|
-
return _this;
|
|
378
|
+
class ArrayReference extends Expression {
|
|
379
|
+
constructor(array, modifier) {
|
|
380
|
+
super();
|
|
381
|
+
this.array = array;
|
|
382
|
+
this.modifier = modifier;
|
|
583
383
|
}
|
|
584
|
-
|
|
585
|
-
}(Expression));
|
|
586
|
-
exports.ArrayReference = ArrayReference;
|
|
384
|
+
}
|
|
587
385
|
/** Class representing a statically sized array. */
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
_this.initializer =
|
|
386
|
+
class ArrayDeclaration extends Statement {
|
|
387
|
+
constructor(baseType, dimensions, identifier, initializer) {
|
|
388
|
+
super();
|
|
389
|
+
this.baseType = baseType;
|
|
390
|
+
this.dimensions = dimensions;
|
|
391
|
+
this.identifier = identifier;
|
|
392
|
+
this.initializer =
|
|
596
393
|
initializer !== undefined && initializer !== null ? initializer : null;
|
|
597
|
-
return _this;
|
|
598
394
|
}
|
|
599
|
-
|
|
600
|
-
}(Statement));
|
|
601
|
-
exports.ArrayDeclaration = ArrayDeclaration;
|
|
395
|
+
}
|
|
602
396
|
/** Class representing an initial value for an ArrayDeclaration. */
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
_this.values = values;
|
|
608
|
-
return _this;
|
|
397
|
+
class ArrayInitializer extends Expression {
|
|
398
|
+
constructor(values) {
|
|
399
|
+
super();
|
|
400
|
+
this.values = values;
|
|
609
401
|
}
|
|
610
|
-
|
|
611
|
-
}(Expression));
|
|
612
|
-
exports.ArrayInitializer = ArrayInitializer;
|
|
402
|
+
}
|
|
613
403
|
/** Class representing an array access */
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
_this.indices = indices !== undefined && indices !== null ? indices : null;
|
|
620
|
-
return _this;
|
|
404
|
+
class ArrayAccess extends Expression {
|
|
405
|
+
constructor(array, indices) {
|
|
406
|
+
super();
|
|
407
|
+
this.array = array;
|
|
408
|
+
this.indices = indices !== undefined && indices !== null ? indices : null;
|
|
621
409
|
}
|
|
622
|
-
|
|
623
|
-
}(Expression));
|
|
624
|
-
exports.ArrayAccess = ArrayAccess;
|
|
410
|
+
}
|
|
625
411
|
/**
|
|
626
412
|
* Class representing a quantum measurement.
|
|
627
413
|
*
|
|
628
414
|
* quantumMeasurement
|
|
629
415
|
* : `measure` identifierList
|
|
630
416
|
*/
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
_this.identifierList = identifierList;
|
|
636
|
-
return _this;
|
|
417
|
+
class QuantumMeasurement extends AstNode {
|
|
418
|
+
constructor(identifierList) {
|
|
419
|
+
super();
|
|
420
|
+
this.identifierList = identifierList;
|
|
637
421
|
}
|
|
638
|
-
|
|
639
|
-
}(AstNode));
|
|
640
|
-
exports.QuantumMeasurement = QuantumMeasurement;
|
|
422
|
+
}
|
|
641
423
|
/**
|
|
642
424
|
* Class representing a quantum measurement assignment statement.
|
|
643
425
|
*
|
|
@@ -645,45 +427,33 @@ exports.QuantumMeasurement = QuantumMeasurement;
|
|
|
645
427
|
* : quantumMeasurement ARROW indexIdentifierList
|
|
646
428
|
* | indexIdentifier EQUALS quantumMeasurement
|
|
647
429
|
*/
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
_this.quantumMeasurement = quantumMeasurement;
|
|
654
|
-
return _this;
|
|
430
|
+
class QuantumMeasurementAssignment extends Statement {
|
|
431
|
+
constructor(identifier, quantumMeasurement) {
|
|
432
|
+
super();
|
|
433
|
+
this.identifier = identifier;
|
|
434
|
+
this.quantumMeasurement = quantumMeasurement;
|
|
655
435
|
}
|
|
656
|
-
|
|
657
|
-
}(Statement));
|
|
658
|
-
exports.QuantumMeasurementAssignment = QuantumMeasurementAssignment;
|
|
436
|
+
}
|
|
659
437
|
/** Class representing the declaration of a classical type, optionally initializing it to a value. */
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
_this.identifier =
|
|
438
|
+
class ClassicalDeclaration extends Statement {
|
|
439
|
+
constructor(classicalType, identifier, initializer, isConst) {
|
|
440
|
+
super();
|
|
441
|
+
this.classicalType = classicalType;
|
|
442
|
+
this.identifier =
|
|
666
443
|
identifier !== undefined && identifier !== null ? identifier : null;
|
|
667
|
-
|
|
444
|
+
this.initializer =
|
|
668
445
|
initializer !== undefined && initializer !== null ? initializer : null;
|
|
669
|
-
|
|
670
|
-
return _this;
|
|
446
|
+
this.isConst = isConst !== undefined && isConst !== null ? isConst : false;
|
|
671
447
|
}
|
|
672
|
-
|
|
673
|
-
}(Statement));
|
|
674
|
-
exports.ClassicalDeclaration = ClassicalDeclaration;
|
|
448
|
+
}
|
|
675
449
|
/** Class representing an expression to a left value. */
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
_this.rightValue = rightValue;
|
|
682
|
-
return _this;
|
|
450
|
+
class AssignmentStatement extends Statement {
|
|
451
|
+
constructor(leftValue, rightValue) {
|
|
452
|
+
super();
|
|
453
|
+
this.leftValue = leftValue;
|
|
454
|
+
this.rightValue = rightValue;
|
|
683
455
|
}
|
|
684
|
-
|
|
685
|
-
}(Statement));
|
|
686
|
-
exports.AssignmentStatement = AssignmentStatement;
|
|
456
|
+
}
|
|
687
457
|
/**
|
|
688
458
|
* Class representing a quantum declaration.
|
|
689
459
|
*
|
|
@@ -691,44 +461,32 @@ exports.AssignmentStatement = AssignmentStatement;
|
|
|
691
461
|
* : `qreg` Identifier designator?
|
|
692
462
|
* `qubit` designator? Identifier
|
|
693
463
|
*/
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
_this.size = size ? size : null;
|
|
700
|
-
return _this;
|
|
464
|
+
class QuantumDeclaration extends AstNode {
|
|
465
|
+
constructor(identifier, size) {
|
|
466
|
+
super();
|
|
467
|
+
this.identifier = identifier;
|
|
468
|
+
this.size = size ? size : null;
|
|
701
469
|
}
|
|
702
|
-
|
|
703
|
-
}(AstNode));
|
|
704
|
-
exports.QuantumDeclaration = QuantumDeclaration;
|
|
470
|
+
}
|
|
705
471
|
/**
|
|
706
472
|
* Class representing a hardware qubit.
|
|
707
473
|
*
|
|
708
474
|
* $[NUM]
|
|
709
475
|
*/
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
_this.number = number;
|
|
715
|
-
return _this;
|
|
476
|
+
class HardwareQubit extends AstNode {
|
|
477
|
+
constructor(number) {
|
|
478
|
+
super();
|
|
479
|
+
this.number = number;
|
|
716
480
|
}
|
|
717
|
-
|
|
718
|
-
}(AstNode));
|
|
719
|
-
exports.HardwareQubit = HardwareQubit;
|
|
481
|
+
}
|
|
720
482
|
/** Class representing an alias statement. */
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
_this.value = value;
|
|
727
|
-
return _this;
|
|
483
|
+
class AliasStatement extends AstNode {
|
|
484
|
+
constructor(identifier, value) {
|
|
485
|
+
super();
|
|
486
|
+
this.identifier = identifier;
|
|
487
|
+
this.value = value;
|
|
728
488
|
}
|
|
729
|
-
|
|
730
|
-
}(AstNode));
|
|
731
|
-
exports.AliasStatement = AliasStatement;
|
|
489
|
+
}
|
|
732
490
|
/** Enum representing the available quantum gate modifiers. */
|
|
733
491
|
var QuantumGateModifierName;
|
|
734
492
|
(function (QuantumGateModifierName) {
|
|
@@ -736,88 +494,64 @@ var QuantumGateModifierName;
|
|
|
736
494
|
QuantumGateModifierName[QuantumGateModifierName["NRGCTRL"] = 1] = "NRGCTRL";
|
|
737
495
|
QuantumGateModifierName[QuantumGateModifierName["INV"] = 2] = "INV";
|
|
738
496
|
QuantumGateModifierName[QuantumGateModifierName["POW"] = 3] = "POW";
|
|
739
|
-
})(QuantumGateModifierName || (
|
|
497
|
+
})(QuantumGateModifierName || (QuantumGateModifierName = {}));
|
|
740
498
|
/** Class representing a modifier of a gate. */
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
_this.argument = argument ? argument : null;
|
|
747
|
-
return _this;
|
|
499
|
+
class QuantumGateModifier extends AstNode {
|
|
500
|
+
constructor(modifier, argument) {
|
|
501
|
+
super();
|
|
502
|
+
this.modifier = modifier;
|
|
503
|
+
this.argument = argument ? argument : null;
|
|
748
504
|
}
|
|
749
|
-
|
|
750
|
-
}(AstNode));
|
|
751
|
-
exports.QuantumGateModifier = QuantumGateModifier;
|
|
505
|
+
}
|
|
752
506
|
/**
|
|
753
507
|
* Class representing a quantum gate call.
|
|
754
508
|
*
|
|
755
509
|
* quantumGateCall
|
|
756
510
|
* : quantumGateModifier* quantumGateName ( LPAREN expressionList? RPAREN )? indexIdentifierList
|
|
757
511
|
*/
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}
|
|
768
|
-
return QuantumGateCall;
|
|
769
|
-
}(QuantumInstruction));
|
|
770
|
-
exports.QuantumGateCall = QuantumGateCall;
|
|
512
|
+
class QuantumGateCall extends QuantumInstruction {
|
|
513
|
+
constructor(quantumGateCall, qubits, parameters, modifiers) {
|
|
514
|
+
super();
|
|
515
|
+
this.quantumGateName = quantumGateCall;
|
|
516
|
+
this.qubits = qubits;
|
|
517
|
+
this.parameters = parameters ? parameters : null;
|
|
518
|
+
this.modifiers = modifiers ? modifiers : [];
|
|
519
|
+
}
|
|
520
|
+
}
|
|
771
521
|
/**
|
|
772
522
|
* Class representing a quantum barrier.
|
|
773
523
|
*
|
|
774
524
|
* quantumBarrier
|
|
775
525
|
* : `barrier` indexIdentifierList
|
|
776
526
|
*/
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
_this.qubits = qubits;
|
|
782
|
-
return _this;
|
|
527
|
+
class QuantumBarrier extends QuantumInstruction {
|
|
528
|
+
constructor(qubits) {
|
|
529
|
+
super();
|
|
530
|
+
this.qubits = qubits;
|
|
783
531
|
}
|
|
784
|
-
|
|
785
|
-
}(QuantumInstruction));
|
|
786
|
-
exports.QuantumBarrier = QuantumBarrier;
|
|
532
|
+
}
|
|
787
533
|
/** Class representing a quantum reset instruction. */
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
_this.identifier = identifier;
|
|
793
|
-
return _this;
|
|
534
|
+
class QuantumReset extends QuantumInstruction {
|
|
535
|
+
constructor(identifier) {
|
|
536
|
+
super();
|
|
537
|
+
this.identifier = identifier;
|
|
794
538
|
}
|
|
795
|
-
|
|
796
|
-
}(QuantumInstruction));
|
|
797
|
-
exports.QuantumReset = QuantumReset;
|
|
539
|
+
}
|
|
798
540
|
/** Class representing a quantum delay instruction. */
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
_this.qubits = qubits;
|
|
805
|
-
return _this;
|
|
541
|
+
class QuantumDelay extends QuantumInstruction {
|
|
542
|
+
constructor(duration, qubits) {
|
|
543
|
+
super();
|
|
544
|
+
this.duration = duration;
|
|
545
|
+
this.qubits = qubits;
|
|
806
546
|
}
|
|
807
|
-
|
|
808
|
-
}(QuantumInstruction));
|
|
809
|
-
exports.QuantumDelay = QuantumDelay;
|
|
547
|
+
}
|
|
810
548
|
/** Class representing a return statement. */
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
_this.expression = expression ? expression : null;
|
|
816
|
-
return _this;
|
|
549
|
+
class ReturnStatement extends Statement {
|
|
550
|
+
constructor(expression) {
|
|
551
|
+
super();
|
|
552
|
+
this.expression = expression ? expression : null;
|
|
817
553
|
}
|
|
818
|
-
|
|
819
|
-
}(Statement));
|
|
820
|
-
exports.ReturnStatement = ReturnStatement;
|
|
554
|
+
}
|
|
821
555
|
/**
|
|
822
556
|
* Base class representing a program block.
|
|
823
557
|
*
|
|
@@ -825,82 +559,64 @@ exports.ReturnStatement = ReturnStatement;
|
|
|
825
559
|
* : statement | controlDirective
|
|
826
560
|
* | LBRACE(statement | controlDirective) * RBRACEj
|
|
827
561
|
*/
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
_this.statements = statements;
|
|
833
|
-
return _this;
|
|
562
|
+
class ProgramBlock extends AstNode {
|
|
563
|
+
constructor(statements) {
|
|
564
|
+
super();
|
|
565
|
+
this.statements = statements;
|
|
834
566
|
}
|
|
835
|
-
|
|
836
|
-
}(AstNode));
|
|
837
|
-
exports.ProgramBlock = ProgramBlock;
|
|
567
|
+
}
|
|
838
568
|
/**
|
|
839
569
|
* Class representing a block of quantum operation statements.
|
|
840
570
|
*
|
|
841
571
|
* quantumBlock
|
|
842
572
|
* : LBRACE (quantumStatement | quantumLoop) * RBRACE
|
|
843
573
|
*/
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
return _super.call(this, statements) || this;
|
|
574
|
+
class QuantumBlock extends ProgramBlock {
|
|
575
|
+
constructor(statements) {
|
|
576
|
+
super(statements);
|
|
848
577
|
}
|
|
849
|
-
|
|
850
|
-
}(ProgramBlock));
|
|
851
|
-
exports.QuantumBlock = QuantumBlock;
|
|
578
|
+
}
|
|
852
579
|
/**
|
|
853
580
|
* Class representing a block of statements in a subroutine.
|
|
854
581
|
*
|
|
855
582
|
* subroutineBlock
|
|
856
583
|
* : LBRACE statement* returnStatement? RBRACE
|
|
857
584
|
*/
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
return _super.call(this, statements) || this;
|
|
585
|
+
class SubroutineBlock extends ProgramBlock {
|
|
586
|
+
constructor(statements) {
|
|
587
|
+
super(statements);
|
|
862
588
|
}
|
|
863
|
-
|
|
864
|
-
}(ProgramBlock));
|
|
865
|
-
exports.SubroutineBlock = SubroutineBlock;
|
|
589
|
+
}
|
|
866
590
|
/**
|
|
867
591
|
* Class representing a quantum gate definition.
|
|
868
592
|
*
|
|
869
593
|
* quantumGateDefinition
|
|
870
594
|
* : `gate` quantumGateDefinition quantumBlock
|
|
871
595
|
*/
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
return QuantumGateDefinition;
|
|
883
|
-
}(Statement));
|
|
884
|
-
exports.QuantumGateDefinition = QuantumGateDefinition;
|
|
596
|
+
class QuantumGateDefinition extends Statement {
|
|
597
|
+
constructor(name, params, qubits, body) {
|
|
598
|
+
super();
|
|
599
|
+
this.name = name;
|
|
600
|
+
this.params = params;
|
|
601
|
+
this.qubits = qubits;
|
|
602
|
+
this.body = body;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
885
605
|
/**
|
|
886
606
|
* Class representing an extern function signature.
|
|
887
607
|
*
|
|
888
608
|
* externStatement
|
|
889
609
|
* : EXTERN Identifier LPAREN externArgumentList? RPAREN returnSignature? SEMICOLON;
|
|
890
610
|
*/
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
_this.returnType =
|
|
611
|
+
class ExternSignature extends Statement {
|
|
612
|
+
constructor(name, args, returnType) {
|
|
613
|
+
super();
|
|
614
|
+
this.name = name;
|
|
615
|
+
this.args = args;
|
|
616
|
+
this.returnType =
|
|
898
617
|
returnType !== undefined && returnType !== null ? returnType : null;
|
|
899
|
-
return _this;
|
|
900
618
|
}
|
|
901
|
-
|
|
902
|
-
}(Statement));
|
|
903
|
-
exports.ExternSignature = ExternSignature;
|
|
619
|
+
}
|
|
904
620
|
/**
|
|
905
621
|
* Class representing a subroutine.
|
|
906
622
|
*
|
|
@@ -908,67 +624,51 @@ exports.ExternSignature = ExternSignature;
|
|
|
908
624
|
* : `def` Identifier LPAREN anyTypeArgumentList? RPAREN
|
|
909
625
|
* returnSignature? subroutineBlock
|
|
910
626
|
*/
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
}
|
|
921
|
-
return SubroutineDefinition;
|
|
922
|
-
}(Statement));
|
|
923
|
-
exports.SubroutineDefinition = SubroutineDefinition;
|
|
627
|
+
class SubroutineDefinition extends Statement {
|
|
628
|
+
constructor(name, subroutineBlock, args, returnType) {
|
|
629
|
+
super();
|
|
630
|
+
this.name = name;
|
|
631
|
+
this.subroutineBlock = subroutineBlock;
|
|
632
|
+
this.args = args;
|
|
633
|
+
this.returnType = returnType ? returnType : null;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
924
636
|
/**
|
|
925
637
|
* Class representing a box scoping statement.
|
|
926
638
|
*
|
|
927
639
|
* boxStatement
|
|
928
640
|
* : BOX designator? scope;
|
|
929
641
|
*/
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
_this.designator =
|
|
642
|
+
class BoxDefinition extends Statement {
|
|
643
|
+
constructor(scope, designator) {
|
|
644
|
+
super();
|
|
645
|
+
this.scope = scope;
|
|
646
|
+
this.designator =
|
|
936
647
|
designator !== undefined && designator !== null ? designator : null;
|
|
937
|
-
return _this;
|
|
938
648
|
}
|
|
939
|
-
|
|
940
|
-
}(Statement));
|
|
941
|
-
exports.BoxDefinition = BoxDefinition;
|
|
649
|
+
}
|
|
942
650
|
/** Class representing a subroutine call. */
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
_this.parameters = parameters ? parameters : null;
|
|
949
|
-
return _this;
|
|
651
|
+
class SubroutineCall extends Statement {
|
|
652
|
+
constructor(subroutineName, parameters) {
|
|
653
|
+
super();
|
|
654
|
+
this.subroutineName = subroutineName;
|
|
655
|
+
this.parameters = parameters ? parameters : null;
|
|
950
656
|
}
|
|
951
|
-
|
|
952
|
-
}(Statement));
|
|
953
|
-
exports.SubroutineCall = SubroutineCall;
|
|
657
|
+
}
|
|
954
658
|
/**
|
|
955
659
|
* Class representing a branching if statement.
|
|
956
660
|
*
|
|
957
661
|
* branchingStatement
|
|
958
662
|
* : `if` LPAREN booleanExpression RPAREN programBlock (`else` programBlock)?
|
|
959
663
|
*/
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
}
|
|
969
|
-
return BranchingStatement;
|
|
970
|
-
}(Statement));
|
|
971
|
-
exports.BranchingStatement = BranchingStatement;
|
|
664
|
+
class BranchingStatement extends Statement {
|
|
665
|
+
constructor(condition, trueBody, falseBody) {
|
|
666
|
+
super();
|
|
667
|
+
this.condition = condition;
|
|
668
|
+
this.trueBody = trueBody;
|
|
669
|
+
this.falseBody = falseBody;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
972
672
|
/**
|
|
973
673
|
* Class representing a for loop statement.
|
|
974
674
|
*
|
|
@@ -978,104 +678,69 @@ exports.BranchingStatement = BranchingStatement;
|
|
|
978
678
|
* | "{" Expression ("," Expression)* "}"
|
|
979
679
|
* | "[" Range "]"
|
|
980
680
|
*/
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
return ForLoopStatement;
|
|
992
|
-
}(Statement));
|
|
993
|
-
exports.ForLoopStatement = ForLoopStatement;
|
|
681
|
+
class ForLoopStatement extends Statement {
|
|
682
|
+
constructor(indexSet, loopVarType, parameter, body) {
|
|
683
|
+
super();
|
|
684
|
+
this.indexSet = indexSet;
|
|
685
|
+
this.loopVarType = loopVarType;
|
|
686
|
+
this.parameter = parameter;
|
|
687
|
+
this.body = body;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
994
690
|
/**
|
|
995
691
|
* Class representing a while loop statement.
|
|
996
692
|
*
|
|
997
693
|
* WhileLoop: "while" "(" Expression ")" ProgramBlock
|
|
998
694
|
*/
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
_this.body = body;
|
|
1005
|
-
return _this;
|
|
695
|
+
class WhileLoopStatement extends Statement {
|
|
696
|
+
constructor(condition, body) {
|
|
697
|
+
super();
|
|
698
|
+
this.condition = condition;
|
|
699
|
+
this.body = body;
|
|
1006
700
|
}
|
|
1007
|
-
|
|
1008
|
-
}(Statement));
|
|
1009
|
-
exports.WhileLoopStatement = WhileLoopStatement;
|
|
701
|
+
}
|
|
1010
702
|
/** Class representing a break loop statement. */
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
function BreakStatement() {
|
|
1014
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1015
|
-
}
|
|
1016
|
-
return BreakStatement;
|
|
1017
|
-
}(Statement));
|
|
1018
|
-
exports.BreakStatement = BreakStatement;
|
|
703
|
+
class BreakStatement extends Statement {
|
|
704
|
+
}
|
|
1019
705
|
/** Class representing a continue loop statement. */
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
function ContinueStatement() {
|
|
1023
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1024
|
-
}
|
|
1025
|
-
return ContinueStatement;
|
|
1026
|
-
}(Statement));
|
|
1027
|
-
exports.ContinueStatement = ContinueStatement;
|
|
706
|
+
class ContinueStatement extends Statement {
|
|
707
|
+
}
|
|
1028
708
|
/** Enum representing the available IO modifiers. */
|
|
1029
709
|
var IOModifier;
|
|
1030
710
|
(function (IOModifier) {
|
|
1031
711
|
IOModifier["INPUT"] = "input";
|
|
1032
712
|
IOModifier["OUTPUT"] = "output";
|
|
1033
|
-
})(IOModifier || (
|
|
713
|
+
})(IOModifier || (IOModifier = {}));
|
|
1034
714
|
/** Class representing a declaration of an IO variable. */
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
_this.classicalType = classicalType;
|
|
1041
|
-
return _this;
|
|
715
|
+
class IODeclaration extends Statement {
|
|
716
|
+
constructor(modifier, classicalType) {
|
|
717
|
+
super();
|
|
718
|
+
this.modifier = modifier;
|
|
719
|
+
this.classicalType = classicalType;
|
|
1042
720
|
}
|
|
1043
|
-
|
|
1044
|
-
}(Statement));
|
|
1045
|
-
exports.IODeclaration = IODeclaration;
|
|
721
|
+
}
|
|
1046
722
|
/** Class representing a switch statement. */
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
return SwitchStatement;
|
|
1057
|
-
}(Statement));
|
|
1058
|
-
exports.SwitchStatement = SwitchStatement;
|
|
723
|
+
class SwitchStatement extends Statement {
|
|
724
|
+
constructor(controlExpression, cases, defaultBlock) {
|
|
725
|
+
super();
|
|
726
|
+
this.controlExpression = controlExpression;
|
|
727
|
+
this.cases = cases;
|
|
728
|
+
this.defaultBlock = defaultBlock ? defaultBlock : null;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
1059
731
|
/** Class representing a single case in a switch statement. */
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
_this.body = body;
|
|
1066
|
-
return _this;
|
|
732
|
+
class CaseStatement extends Statement {
|
|
733
|
+
constructor(labels, body) {
|
|
734
|
+
super();
|
|
735
|
+
this.labels = labels;
|
|
736
|
+
this.body = body;
|
|
1067
737
|
}
|
|
1068
|
-
|
|
1069
|
-
}(Statement));
|
|
1070
|
-
exports.CaseStatement = CaseStatement;
|
|
738
|
+
}
|
|
1071
739
|
/** Class representing the default case in a swtich statement. */
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
_this.body = body;
|
|
1077
|
-
return _this;
|
|
740
|
+
class DefaultStatement extends Statement {
|
|
741
|
+
constructor(body) {
|
|
742
|
+
super();
|
|
743
|
+
this.body = body;
|
|
1078
744
|
}
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
exports.DefaultStatement = DefaultStatement;
|
|
745
|
+
}
|
|
746
|
+
export { AstNode, Statement, Expression, Parameters, ArrayReferenceModifier, ArrayReference, CalibrationGrammarDeclaration, Include, Version, FloatType, ComplexType, BoolType, IntType, UIntType, BitType, AngleType, StretchType, DurationType, Range, Identifier, SubscriptedIdentifier, Pi, Euler, Tau, MathFunctionTypes, MathFunction, TrigFunctionTypes, TrigFunction, IntegerLiteral, NumericLiteral, FloatLiteral, ImaginaryLiteral, BooleanLiteral, BitstringLiteral, DurationUnit, DurationLiteral, DurationOf, SizeOf, UnaryOp, Unary, ArithmeticOp, Arithmetic, BinaryOp, Binary, Cast, IndexSet, ArrayDeclaration, ArrayInitializer, ArrayAccess, QuantumMeasurement, QuantumMeasurementAssignment, ClassicalDeclaration, AssignmentStatement, QuantumDeclaration, HardwareQubit, AliasStatement, QuantumGateModifierName, QuantumGateModifier, QuantumGateCall, QuantumBarrier, QuantumReset, QuantumDelay, ReturnStatement, ProgramBlock, QuantumBlock, SubroutineBlock, QuantumGateDefinition, BoxDefinition, ExternSignature, SubroutineDefinition, SubroutineCall, BranchingStatement, ForLoopStatement, WhileLoopStatement, BreakStatement, ContinueStatement, IOModifier, IODeclaration, SwitchStatement, CaseStatement, DefaultStatement, ClassicalType, };
|