qasm-ts 2.1.1 → 2.1.3

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