-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpycc
executable file
·80 lines (67 loc) · 1.54 KB
/
pycc
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! python
import json
import os
import sys
from typing import Dict
from dotenv import load_dotenv
from easygraphics import Color, easy_run, init_graph, close_graph
from src.execute_tokens import execute_tokens
from src.generate_tokens import generate_tokens
from src.parse_file import get_ast
load_dotenv()
debug = os.getenv("DEBUG") == "TRUE"
if len(sys.argv) != 2:
print(f"Usage: pycc <filename>")
exit(1)
file_name = sys.argv[1]
if debug:
print(f"Opening file: {file_name}")
ast = get_ast(file_name)
if debug:
print(f"File parsed...")
tree_file_name = "tree.json"
with open(tree_file_name, 'w', encoding='utf-8') as f:
print(f"Saved to {tree_file_name}")
json.dump(ast, f, indent=2)
variables: Dict[str, any] = {
# VGA Modes
"VGALO": 0,
"VGAMED": 1,
"VGAHI": 2,
"VGAMAX": 3,
"VGA640": 4,
"VGA800": 5,
"VGA1024": 6,
# VGA Drivers
"VGA": 9,
"DETECT": 0,
"USER": 0,
# Colors
"BLACK": 0,
"BLUE": 1,
"GREEN": 2,
"CYAN": 3,
"RED": 4,
"MAGENTA": 5,
"BROWN": 6,
"LIGHTGRAY": 7,
"DARKGRAY": 8,
"LIGHTBLUE": 9,
"LIGHTGREEN": 10,
"LIGHTCYAN": 11,
"LIGHTRED": 12,
"LIGHTMAGENTA": 13,
"YELLOW": 14,
"WHITE": 15,
"__text_color__": Color.WHITE # Always set as integer
}
tokens = generate_tokens(ast)
# print([token.__str__() for token in tokens])
# print(variables)
def main():
init_graph(1200, 900)
execute_tokens(tokens, variables)
close_graph()
if debug:
print(variables)
easy_run(main)