Skip to content

Commit

Permalink
modified: OpenQASM/qasm3Listener.py
Browse files Browse the repository at this point in the history
Added support for includes
  • Loading branch information
NoahGWood committed Oct 3, 2021
1 parent 3285a10 commit 06367e5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/OpenQASM/QEDAListener2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ def __init__(self, file=None):
self.file = os.getcwd()
else:
self.file = os.getcwd() + '/' + ''.join([x+'/' for x in file.split('/')[:-1]])
self.QCODE = []
self.GATES = []
self.HEADER = None
self.GLOBALS = []
self.LOCALS = []
self.file = "/" + self.file.strip("/")
self.currentModifier = None
self.modExpression = None

def enterProgram(self, ctx: qasm3Parser.ProgramContext):
self.HEADER=self.enterHeader(ctx.header())
self.GLOBALS=[] # Global Statements
self.LOCALS=[] # Localized Statements
i=0
while True:
if(ctx.statement(i) != None):
Expand Down Expand Up @@ -86,7 +85,10 @@ def enterVersion(self, ctx:qasm3Parser.VersionContext):

# Enter a parse tree produced by qasm3Parser#header.
def enterInclude(self, ctx: qasm3Parser.IncludeContext):
return super().enterInclude(ctx)
listener = self.INCLUDE(ctx.StringLiteral())
self.GLOBALS += listener.GLOBALS
self.LOCALS += listener.LOCALS
# return super().enterInclude(ctx)

# Enter a parse tree produced by qasm3Parser#ioIdentifier.
def enterIoIdentifier(self, ctx:qasm3Parser.IoIdentifierContext):
Expand Down
Binary file modified src/OpenQASM/__pycache__/QEDAListener2.cpython-36.pyc
Binary file not shown.
Binary file modified src/OpenQASM/__pycache__/qasm3Listener.cpython-36.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion src/OpenQASM/qasm3Listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def enterProgram(self, ctx:qasm3Parser.ProgramContext):

# Exit a parse tree produced by qasm3Parser#program.
def exitProgram(self, ctx:qasm3Parser.ProgramContext):
return self.QCODE
pass


Expand Down

0 comments on commit 06367e5

Please sign in to comment.