diff --git a/src/OpenQASM/QEDAListener2.py b/src/OpenQASM/QEDAListener2.py index 20542a7..365ff02 100644 --- a/src/OpenQASM/QEDAListener2.py +++ b/src/OpenQASM/QEDAListener2.py @@ -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): @@ -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): diff --git a/src/OpenQASM/__pycache__/QEDAListener2.cpython-36.pyc b/src/OpenQASM/__pycache__/QEDAListener2.cpython-36.pyc index 884b8cd..9886f12 100644 Binary files a/src/OpenQASM/__pycache__/QEDAListener2.cpython-36.pyc and b/src/OpenQASM/__pycache__/QEDAListener2.cpython-36.pyc differ diff --git a/src/OpenQASM/__pycache__/qasm3Listener.cpython-36.pyc b/src/OpenQASM/__pycache__/qasm3Listener.cpython-36.pyc index 36b920e..714a68a 100644 Binary files a/src/OpenQASM/__pycache__/qasm3Listener.cpython-36.pyc and b/src/OpenQASM/__pycache__/qasm3Listener.cpython-36.pyc differ diff --git a/src/OpenQASM/qasm3Listener.py b/src/OpenQASM/qasm3Listener.py index 6ccb387..cafa40d 100644 --- a/src/OpenQASM/qasm3Listener.py +++ b/src/OpenQASM/qasm3Listener.py @@ -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