-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
34 lines (26 loc) · 1.34 KB
/
run.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
# coding=utf-8
import pprint
from scanner import get_token # scanner
from Pascal_Helper_Files.pascal_reader import PascalFile
from parse import Parser # parser
from emulator import Emulator # emulator
if __name__ == '__main__':
pretty_printer = pprint.PrettyPrinter()
# UNCOMMENT the below statements one at a time
# tokens = get_token(PascalFile(input_file_location='array_example.pas', output_location=''))
# tokens = get_token(PascalFile(input_file_location='assignment_example.pas', output_location=''))
# tokens = get_token(PascalFile(input_file_location='for_example.pas', output_location=''))
# tokens = get_token(PascalFile(input_file_location='if_example.pas', output_location=''))
tokens = get_token(PascalFile(input_file_location='while_example.pas', output_location=''))
# UNCOMMENT THE LINE BELOW TO TEST THE SCANNER --> YOU WILL SEE THE TOKENS
# pretty_printer.pprint(tokens)
print '----------------------------------'
# UNCOMMENT THE LINE BELOW TO TEST THE PARSER
# parser = Parser(token_list=tokens, verbose=True)
parser = Parser(token_list=tokens)
byte_array = parser.parse()
# This prints the byte array, uncomment to see the bytearray
# pretty_printer.pprint(byte_array)
print '----------------------------------'
emulator = Emulator(byte_array)
emulator.start()