-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
41 lines (33 loc) · 976 Bytes
/
__main__.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pseudotoken as tokenizer
import pseudoyacc as parser
file = open("Main.mayudo", encoding="utf8")
data = file.readlines()
for line in range(len(data)):
data[line] = data[line].removesuffix("\n")
print("\nTokens:\n==========")
for line_number, line in enumerate(data):
print(f"Line {line_number + 1}:")
tokenList = list(tokenizer.tokenize(line))
for token in tokenList:
print(token)
print("")
print("")
parse = ([], [])
for line in data:
parse = parser.parse(line)
print("Transpiled python code:")
print("=========================")
print("--[BEGIN PYTHON CODE]--")
for line in parse[0]:
print(line)
print("--[END PYTHON CODE]--\n\n")
def stack_trace():
print("Stack Trace:")
print("==============")
for trace in parse[1]:
if trace in ["p_root[None]", "p_error(Blank line)"]:
print("----LINE----")
else:
print(trace)
# Uncomment below line to print out trace
stack_trace()