-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.py
25 lines (22 loc) · 1.06 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from antlr4 import *
from funxLexer import funxLexer
from funxParser import funxParser
from visitor import Visitor, VisitorError
# Welcome message
print(" ________ ___ ___ ________ ___ ___ \n|\\ _____\\\\ \\|\\ \\|\\ ___ \\ |\\ \\ / /|\n\\ \\ \\__/\\ \\ \\\\\\ \\ \\ \\\\ \\ \\ \\ \\ \\/ / /\n \\ \\ __\\\\ \\ \\\\\\ \\ \\ \\\\ \\ \\ \\ \\ / / \n \\ \\ \\_| \\ \\ \\\\\\ \\ \\ \\\\ \\ \\ / \\/ \n \\ \\__\\ \\ \\_______\\ \\__\\\\ \\__\\/ /\\ \\ \n \\|__| \\|_______|\\|__| \\|__/__/ /\\ __\\ \n |__|/ \\|__|")
print("By Gonzalo Cordova\n")
print("Start coding:\n")
visitor = Visitor()
while True:
input_stream = InputStream(input('? '))
lexer = funxLexer(input_stream)
token_stream = CommonTokenStream(lexer)
parser = funxParser(token_stream)
tree = parser.root()
# print(tree.toStringTree(recog=parser))
ret = visitor.visit(tree)
if ret is not None:
if isinstance(ret, VisitorError):
print(ret.msg)
else:
print(ret)