mirror of https://github.com/t1meshift/js.git
Print parsed string tree
parent
812f5107c3
commit
8b88405fc5
|
@ -44,13 +44,19 @@ def main():
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
input_stream = InputStream('"use strict";var a;\na=2+a;')
|
input_stream = InputStream("var a;\n{a=2+a;}")
|
||||||
lexer = JSL(input_stream)
|
lexer = JSL(input_stream)
|
||||||
stream = CommonTokenStream(lexer)
|
stream = CommonTokenStream(lexer)
|
||||||
|
|
||||||
|
stream.fill()
|
||||||
|
for token in stream.tokens:
|
||||||
|
print("Token: {}".format(str(token)))
|
||||||
|
|
||||||
parser = JSP(stream)
|
parser = JSP(stream)
|
||||||
print("Created parsers")
|
print("Created parsers")
|
||||||
tree = parser.program()
|
tree = parser.program()
|
||||||
ParseTreeWalker.DEFAULT.walk(WriteTreeListener(), tree)
|
print(tree.toStringTree(parser.ruleNames))
|
||||||
|
# ParseTreeWalker.DEFAULT.walk(WriteTreeListener(), tree)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue