Skip to content

Commit 5594395

Browse files
committed
Add visitor for ExternPortStatement to parser.
1 parent bcfdbae commit 5594395

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

source/openpulse/openpulse/ast.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ class CalibrationBlock(QASMNode):
131131
body: List[Statement]
132132

133133

134+
@dataclass
135+
class ExternPortStatement(QASMNode):
136+
"""
137+
Node representing an extern port statement.
138+
"""
139+
140+
name: Identifier
141+
142+
134143
# Override the class from openqasm3
135144
@dataclass
136145
class CalibrationStatement(Statement):

source/openpulse/openpulse/parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
span,
4444
QASMNodeVisitor,
4545
_raise_from_context,
46+
_visit_identifier,
4647
parse as parse_qasm3,
4748
)
4849
from openqasm3.visitor import QASMVisitor
@@ -194,6 +195,9 @@ def visitCalibrationBlock(self, ctx: openpulseParser.CalibrationBlockContext):
194195
body=[self.visit(statement) for statement in ctx.openpulseStatement()]
195196
)
196197

198+
def visitExternPortStatement(self, ctx: openpulseParser.OpenpulseStatementContext):
199+
return openpulse_ast.ExternPortStatement(name=_visit_identifier(ctx.Identifier()))
200+
197201
def visitScalarType(self, ctx: openpulseParser.ScalarTypeContext):
198202
if ctx.WAVEFORM() or ctx.PORT() or ctx.FRAME():
199203
return self._visitPulseType(ctx)

0 commit comments

Comments
 (0)