forked from openqasm/openpulse-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenpulseParser.g4
More file actions
67 lines (60 loc) · 1.73 KB
/
openpulseParser.g4
File metadata and controls
67 lines (60 loc) · 1.73 KB
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
/***** ANTLRv4 grammar for OpenPulse. *****/
// This grammar is OpenPulse extension for QOpenQASM3.0
// We introduce several new types for OpenPulse.
// We override several nodes in qasm3 to consume the new types.
// The OpenPulse grammar can be used inside cal or defcal blocks.
parser grammar openpulseParser;
import qasm3Parser;
options {
tokenVocab = openpulseLexer;
}
calibrationBlock: openpulseStatement*;
openpulseStatement:
// Statements can be used in the cal or defcal body
pragma
| annotation* (
aliasDeclarationStatement
| assignmentStatement
| barrierStatement
| boxStatement
| breakStatement
| classicalDeclarationStatement
| constDeclarationStatement
| continueStatement
| defStatement
| delayStatement
| endStatement
| expressionStatement
| externStatement
| externFrameStatement
| externPortStatement
| forStatement
| gateCallStatement
| ifStatement
| includeStatement
| ioDeclarationStatement
| quantumDeclarationStatement
| resetStatement
| returnStatement
| switchStatement
| whileStatement
)
;
/** In the following we extend existing OpenQASM nodes. Need to refresh whenever OpenQASM is updated. **/
// We extend the scalarType with WAVEFORM, PORT and FRAME
scalarType:
BIT designator?
| INT designator?
| UINT designator?
| FLOAT designator?
| ANGLE designator?
| BOOL
| DURATION
| STRETCH
| COMPLEX (LBRACKET scalarType RBRACKET)?
| WAVEFORM
| PORT
| FRAME
;
externFrameStatement: EXTERN FRAME Identifier SEMICOLON;
externPortStatement: EXTERN PORT Identifier SEMICOLON;