1
0
Fork 0

parser can be recalled from the ctx context

This commit is contained in:
Kevin Matz 2018-10-21 15:52:14 -04:00
parent f1624604c2
commit c19da112bf
2 changed files with 3 additions and 4 deletions

View File

@ -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

View File

@ -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)