-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQASM3.json
355 lines (355 loc) · 14 KB
/
QASM3.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
{
"program": [
["OPENQASM 3.0;\n", "include \"stdgates.inc\";\n", "<registerDeclarationStatement>", "\n", "<statementsOrScopes>", "\n", "<gateCallStatement>"]
],
"<statementsOrScopes>": [["<statementOrScope>"], ["<statementOrScope>", "\n", "<statementsOrScopes>"]],
"<statementOrScope>": [["<statement>"], ["<scope>"]],
"<statement>": [["<specificStatement>"]],
"<scope>": [["{\n", "<statementsOrScopes>", "\n}"]],
"<specificStatement>": [
["<aliasDeclarationStatement>"],
["<assignmentStatement>"],
["<barrierStatement>"],
["<boxStatement>"],
["break;"],
["<classicalDeclarationStatement>"],
["continue;"],
["<delayStatement>"],
["<forStatement>"],
["<gateCallStatement>"],
["<gateStatement>"],
["<ifStatement>"],
["<measureArrowAssignmentStatement>"],
["<oldStyleDeclarationStatement>"],
["<quantumDeclarationStatement>"],
["<returnStatement>"],
["<switchStatement>"],
["<whileStatement>"]
],
"<forStatement>": [
["for int ", "<LoopVarIdentifier>", " in ", "<setExpression>", " ", "<statementOrScope>"],
["for int ", "<LoopVarIdentifier>", " in [", "<rangeExpression>", "] ", "<statementOrScope>"],
["for int ", "<LoopVarIdentifier>", " in ", "<expression>", " ", "<statementOrScope>"]
],
"<ifStatement>": [
["if (", "<Conditional>", ") ", "<statementOrScope>"],
["if (", "<Conditional>", ") ", "<statementOrScope>", " else ", "<statementOrScope>"]
],
"<returnStatement>": [
["return;"],
["return ", "<expression>", ";"],
["return ", "<measureExpression>", ";"]
],
"<whileStatement>": [["while (", "<Conditional>", ")", "<statementOrScope>"]],
"<switchStatement>": [
["switch (", "<expression>", ") {\n", "<switchCaseItems>", "}"],
["switch (", "<expression>", ") { }"]
],
"<switchCaseItems>": [
["<switchCaseItem>", "<switchCaseItems>"],
["<switchCaseItem>"]
],
"<switchCaseItem>": [
["case ", "<expressionList>", " ", "<scope>"],
["default ", "<scope>"]
],
"<barrierStatement>": [
["barrier;"],
["barrier ", "<gateOperandList>", ";"]
],
"<boxStatement>": [
["box ", "<designator>", " ", "<scope>"],
["box ", "<scope>"]
],
"<delayStatement>": [
["delay", "<designator>", " ", "<gateOperandList>", ";"],
["delay", "<designator>", ";"]
],
"<gateCallStatement>": [
["<gateModifiers>", "<gateCallInner1>"],
["<gateCallInner1>"]
],
"<gateCallInner1>": [
["<AnyGateIdentifier>", "<gateCallInnerIdentifier>"],
["gphase", "<gateCallInnerGphase>"]
],
"<gateCallInnerIdentifier>": [
["(", "<expressionList>", ") ", "<gateOperandList>", ";"],
["<designator>", " ", "<gateOperandList>", ";"],
[" ", "<gateOperandList>", ";"]
],
"<gateCallInnerGphase>": [
["() ", "<gateOperandList>", ";"],
["(", "<expressionList>", ") ", "<gateOperandList>", ";"],
["();"],
["(", "<expressionList>", ");"]
],
"<gateCallInner2>": [
["()"],
["(", "<expressionList>", ")"],
["<designator>"]
],
"<measureArrowAssignmentStatement>": [
["<measureExpression>", ";"],
["<measureExpression>", "->", "<indexedIdentifier>", ";"]
],
"<aliasDeclarationStatement>": [["let ", "<AnyIdentifier>", " = ", "<aliasExpression>", ";"]],
"<registerDeclarationStatement>": [
["<classicalDeclarationStatement>"],
["<oldStyleDeclarationStatement>"],
["<quantumDeclarationStatement>"]
],
"<classicalDeclarationStatement>": [
["<scalarType>", " ", "<RegisterIdentifier>", ";"],
["<scalarType>", " ", "<RegisterIdentifier>", " = ", "<declarationExpression>", ";"]
],
"<oldStyleDeclarationStatement>": [
["creg ", "<RegisterIdentifier>", "<designator>", ";"],
["creg ", "<RegisterIdentifier>", ";"],
["qreg ", "<RegisterIdentifier>", "<designator>", ";"],
["qreg ", "<RegisterIdentifier>", ";"]
],
"<quantumDeclarationStatement>": [["<qubitType>", " ", "<RegisterIdentifier>", ";"]],
"<gateStatement>": [
["gate ", "<AnyGateIdentifier>", "(", "<gateParamsList>", ") ", "<gateArgsList>", " ", "<scope>"],
["gate ", "<AnyGateIdentifier>", "() ", "<gateArgsList>", " ", "<scope>"],
["gate ", "<AnyGateIdentifier>", " ", "<gateArgsList>", " ", "<scope>"]
],
"<assignmentStatement>": [
["<indexedIdentifier>", " = ", "<expression>", ";"],
["<indexedIdentifier>", " = ", "<measureExpression>", ";"],
["<indexedIdentifier>", " ", "<CompoundAssignmentOperator>", " ", "<expression>", ";"],
["<indexedIdentifier>", " ", "<CompoundAssignmentOperator>", " ", "<measureExpression>", ";"]
],
"<expression>": [
["(", "<expression>", ")"],
["<expression>", "<indexOperator>"],
["~", "<expression>"],
["!", "<expression>"],
["-", "<expression>"],
["<expression>", "<BinaryOp>", "<expression>"],
["<scalarType>", "(", "<expression>", ")"],
["<AnyIdentifier>"],
["<DecimalIntegerLiteral>"],
["<FloatLiteral>"],
["<BooleanLiteral>"],
["<BitstringLiteral>"],
["<TimingLiteral>"],
["<HardwareQubit>"]
],
"<BinaryOp>": [
[" * "], [" / "], [" % "], [" + "], [" - "], [" << "], [" >> "],
["<ComparisonOp>"],
[" & "], [" | "], [" && "], [" || "]
],
"<Conditional>": [
["<expression>"],
["!", "<expression>"],
["<expression>", "<ComparisonOp>", "<expression>"]
],
"<ComparisonOp>": [
[" < "], [" > "], [" <= "], [" >= "], [" == "], [" != "]
],
"<aliasExpression>": [
["<expression>"],
["<expression>", " ++ ", "<aliasExpression>"]
],
"<declarationExpression>": [
["<arrayLiteral>"], ["<expression>"], ["<measureExpression>"]
],
"<measureExpression>": [["measure ", "<gateOperand>"]],
"<rangeExpression>": [
["<expression>", ":", "<expression>", ":", "<expression>"],
["<expression>", ":", "<expression>"],
["<expression>", ":"],
[":", "<expression>"]
],
"<setExpression>": [
["{ ", "<expressions>", ",}"],
["{ ", "<expressions>", "}"],
["{,}"],
["{}"]
],
"<expressions>": [["<expression>", ", ", "<expressions>"], ["<expression>"]],
"<arrayLiteral>": [
["{", "<expression>", "<arrayLiteralInner>", ",}"],
["{", "<expression>", "<arrayLiteralInner>", "}"],
["{", "<arrayLiteral>", "<arrayLiteralInner>", ",}"],
["{", "<arrayLiteral>", "<arrayLiteralInner>", "}"],
["{", "<expression>", ",}"],
["{", "<expression>", "}"],
["{", "<arrayLiteral>", ",}"],
["{", "<arrayLiteral>", "}"]
],
"<arrayLiteralInner>": [
[", ", "<expression>", "<arrayLiteralInner>"],
[", ", "<arrayLiteral>", "<arrayLiteralInner>"],
[", ", "<expression>"],
[", ", "<arrayLiteral>"]
],
"<indexOperator>": [
["[", "<setExpression>", "]"],
["[", "<expression>", "<indexOperatorInner>", "]"],
["[", "<setExpression>", "]"]
],
"<indexOperatorInner>": [
[", ", "<expression>", "<indexOperatorInner>"],
[", ", "<rangeExpression>", "<indexOperatorInner>"],
[", ", "<expression>"],
[", ", "<rangeExpression>"]
],
"<indexedIdentifier>": [["<RegisterIdentifier>", "<indexOperators>"], ["<RegisterIdentifier>"]],
"<indexOperators>": [["<indexOperator>", "<indexOperators>"], ["<indexOperator>"]],
"<returnSignature>": [[" -> ", "<scalarType>"]],
"<gateModifiers>": [["<gateModifier>", "<gateModifiers>"], ["<gateModifier>"]],
"<gateModifier>": [
["inv @ "],
["pow(", "<expression>", ") @ "],
["ctrl ", "(", "<expression>", ") @ "],
["negctrl ", "(", "<expression>", ") @ "]
],
"<scalarType>": [
["bit", "<designator>"],
["bit"]
],
"<qubitType>": [["qubit", "<designator>"], ["qubit"]],
"<arrayReferenceType>": [
["readonly array [", "<scalarType>", ", ", "<expressionList>", "]"],
["readonly array [", "<scalarType>", ", ", "#dim = ", "<expression>", "]"],
["mutable array [", "<scalarType>", ", ", "<expressionList>", "]"],
["mutable array [", "<scalarType>", ", ", "#dim = ", "<expression>", "]"]
],
"<designator>": [["[", "<expression>", "]"]],
"<gateOperand>": [["<indexedIdentifier>"], ["<HardwareQubit>"]],
"<expressionList>": [
["<expression>", "<exprListInner>", ","],
["<expression>", "<exprListInner>"],
["<expression>", ","],
["<expression>"]
],
"<exprListInner>": [
[", ", "<expression>", "<exprListInner>"],
[", ", "<expression>"]
],
"<identifierList>": [
["<AnyIdentifier>", "<idListInner>", ","],
["<AnyIdentifier>", "<idListInner>"],
["<AnyIdentifier>", ","],
["<AnyIdentifier>"]
],
"<idListInner>": [
[", ", "<AnyIdentifier>", "<idListInner>"],
[", ", "<AnyIdentifier>"]
],
"<gateArgsList>": [
["<GateArgIdentifier>", "<gateArgListInner>", ","],
["<GateArgIdentifier>", "<gateArgListInner>"],
["<GateArgIdentifier>", ","],
["<GateArgIdentifier>"]
],
"<gateArgListInner>": [
[", ", "<GateArgIdentifier>", "<gateArgListInner>"],
[", ", "<GateArgIdentifier>"]
],
"<gateParamsList>": [
["<GateParamIdentifier>", "<gateParamsListInner>", ","],
["<GateParamIdentifier>", "<gateParamsListInner>"],
["<GateParamIdentifier>", ","],
["<GateParamIdentifier>"]
],
"<gateParamsListInner>": [
[", ", "<GateParamIdentifier>", "<gateParamsListInner>"],
[", ", "<GateParamIdentifier>"]
],
"<gateOperandList>": [
["<gateOperand>", "<gateOpInner>"],
["<gateOperand>"]
],
"<gateOpInner>": [
[", ", "<gateOperand>", "<gateOpInner>"],
[", ", "<gateOperand>"]
],
"<BooleanLiteral>": [["true"], ["false"]],
"<CompoundAssignmentOperator>": [
["+="], ["-="], ["*="], ["/="], ["&="], ["~="], ["^="], ["<<="], [">>="]
],
"<BinaryInner>": [
["<BinDigit>", "<BinaryInner>"],
["<BinDigit>"]
],
"<BinDigit>": [["0"], ["1"]],
"<DecimalIntegerLiteral>": [
["0"], ["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"], ["11"], ["12"], ["13"], ["14"], ["15"], ["16"], ["17"], ["18"], ["19"], ["20"], ["21"], ["22"], ["23"], ["24"], ["25"], ["26"], ["27"], ["28"], ["32"], ["64"], ["128"], ["256"], ["512"], ["255"], ["32767"], ["65535"], ["100663045"], ["2139095040"], ["2147483647"]
],
"<AnyIdentifier>": [
["<AnyGateIdentifier>"],
["<RegisterIdentifier>"],
["pi"]
],
"<AnyGateIdentifier>": [
["<StdGateIdentifier>"],
["<GateParamIdentifier>"],
["<GateArgIdentifier>"],
["<NewGateIdentifier>"]
],
"<StdGateIdentifier>": [
["x"], ["y"], ["z"],
["h"], ["s"], ["sdg"], ["sx"],
["rx"], ["ry"], ["rz"],
["cx"], ["cy"], ["cz"],
["cp"], ["crx"], ["cry"], ["crz"], ["ch"],
["swap"], ["ccx"], ["cswap"], ["cu"],
["CX"], ["phase"], ["cphase"], ["id"], ["u1"], ["u2"], ["u3"]
],
"<NewGateIdentifier>": [
["g1"]
],
"<GateParamIdentifier>": [
["theta"], ["thi"], ["gamma"], ["lambda"]
],
"<GateArgIdentifier>": [
["a"], ["b"], ["c"], ["d"]
],
"<RegisterIdentifier>": [
["r1"], ["r2"]
],
"<LoopVarIdentifier>": [
["lv1"]
],
"<HardwareQubit>": [["$", "<DecimalIntegerLiteral>"]],
"<FloatLiteral>": [
["<DecimalIntegerLiteral>", ".", "<DecimalIntegerLiteral>", "<FloatLiteralExponent>"],
["0.0283940325132045"], ["0.0562610521523687"], ["0.090315771"], ["0.110276567223963"],
["0.18126868294831"], ["0.183411690555527"], ["0.23204662"], ["0.26055497"], ["0.274611561179047"],
["0.302276903187072"], ["0.304006861589844"], ["0.323124183787948"], ["0.34339104765177"],
["0.364770216832646"], ["0.386088099025332"], ["0.390289925461651"], ["0.43708748495407"],
["0.44724576"], ["0.465631192720672"], ["0.470432739067156"], ["0.488259748297606"],
["0.531560524522875"], ["0.541191586579538"], ["0.565080720693427"], ["0.583444395859387"],
["0.639992284554905"], ["0.644936496959995"], ["0.652213947544824"], ["0.658834133255635"],
["0.682154452208615"], ["0.695489997173783"], ["0.704501496809573"], ["0.720781382238064"],
["0.74535560401605"], ["0.766417482119969"], ["0.768356031305776"], ["0.768714933309941"],
["0.77792289763104"], ["0.817874127320297"], ["0.819729663880418"], ["0.877307855501848"],
["0.917540997684541"], ["0.92729522"], ["0.930988499844055"], ["0.941314187016362"], ["0.941685991932291"],
["0.952796311794947"], ["0.960824079481623"], ["0.962337066287826"], ["0.988315801149533"], ["1.0"],
["1.09267111867709"], ["1.16893331500669"], ["1.2377669"], ["1.28315816917591"], ["1.3343007"],
["1.3900562"], ["1.46213217253153"], ["1.5619683"], ["1.85578983194329"], ["1.986944517459"], ["2.2086037"],
["2.28643189871332"], ["2.28793740781859"], ["2.32308793116108"], ["2.4135628694577"], ["2.6422546"],
["2.7702916"], ["2.8078072"], ["2.8605548"], ["2.8970973"], ["2.9973442"], ["3.0"], ["3.0295952"],
["3.1378258"], ["4.43809726294417"], ["4.54167162188708"]
],
"<FloatLiteralExponent>": [
["e", "<DecimalIntegerLiteral>"],
["e+", "<DecimalIntegerLiteral>"],
["e-", "<DecimalIntegerLiteral>"]
],
"<TimeUnit>": [
["dt"], ["ns"], ["us"], ["ms"], ["s"]
],
"<TimingLiteral>": [
["<DecimalIntegerLiteral>", " ", "<TimeUnit>"],
["<FloatLiteral>", " ", "<TimeUnit>"]
],
"<BitstringLiteral>": [
["\"", "<BinaryInner>", "<BinDigit>", "\""]
]
}