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):
|
class OscCommentMacroListener(CommentMacroListener):
|
||||||
def __init__(self, parser, servers):
|
def __init__(self, servers):
|
||||||
self.parser = parser
|
|
||||||
self.osc = HogDevice(servers)
|
self.osc = HogDevice(servers)
|
||||||
|
|
||||||
def exitDevice(self, ctx: CommentMacroParser.DeviceContext):
|
def exitDevice(self, ctx: CommentMacroParser.DeviceContext):
|
||||||
|
@ -71,7 +70,7 @@ class OscCommentMacroListener(CommentMacroListener):
|
||||||
|
|
||||||
def exitMacro(self, ctx: CommentMacroParser.MacroContext):
|
def exitMacro(self, ctx: CommentMacroParser.MacroContext):
|
||||||
# print the lisp tree of this macro
|
# 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))
|
logger.info(beautify_lisp_string(lisp_tree_str))
|
||||||
|
|
||||||
# execute macro from name
|
# execute macro from name
|
||||||
|
|
|
@ -53,7 +53,7 @@ def comment(text):
|
||||||
stream = antlr4.CommonTokenStream(lexer)
|
stream = antlr4.CommonTokenStream(lexer)
|
||||||
parser = CommentMacroParser(stream)
|
parser = CommentMacroParser(stream)
|
||||||
tree = parser.prog()
|
tree = parser.prog()
|
||||||
oscMacro = OscCommentMacroListener(parser, hog4)
|
oscMacro = OscCommentMacroListener(hog4)
|
||||||
walker = antlr4.ParseTreeWalker()
|
walker = antlr4.ParseTreeWalker()
|
||||||
walker.walk(oscMacro, tree)
|
walker.walk(oscMacro, tree)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue