parser can be recalled from the ctx context
This commit is contained in:
parent
f1624604c2
commit
c19da112bf
|
@ -54,8 +54,7 @@ def beautify_lisp_string(in_string):
|
|||
|
||||
|
||||
class OscCommentMacroListener(CommentMacroListener):
|
||||
def __init__(self, parser, servers):
|
||||
self.parser = parser
|
||||
def __init__(self, servers):
|
||||
self.osc = HogDevice(servers)
|
||||
|
||||
def exitDevice(self, ctx: CommentMacroParser.DeviceContext):
|
||||
|
@ -71,7 +70,7 @@ class OscCommentMacroListener(CommentMacroListener):
|
|||
|
||||
def exitMacro(self, ctx: CommentMacroParser.MacroContext):
|
||||
# print the lisp tree of this macro
|
||||
lisp_tree_str = ctx.toStringTree(recog=self.parser)
|
||||
lisp_tree_str = ctx.toStringTree(recog=ctx.parser)
|
||||
logger.info(beautify_lisp_string(lisp_tree_str))
|
||||
|
||||
# execute macro from name
|
||||
|
|
|
@ -53,7 +53,7 @@ def comment(text):
|
|||
stream = antlr4.CommonTokenStream(lexer)
|
||||
parser = CommentMacroParser(stream)
|
||||
tree = parser.prog()
|
||||
oscMacro = OscCommentMacroListener(parser, hog4)
|
||||
oscMacro = OscCommentMacroListener(hog4)
|
||||
walker = antlr4.ParseTreeWalker()
|
||||
walker.walk(oscMacro, tree)
|
||||
|
||||
|
|
Loading…
Reference in New Issue