-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
23 lines (22 loc) · 783 Bytes
/
main.py
File metadata and controls
23 lines (22 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
from tokenizer import tokenize
from combinator import S, S1, S2, E
get_str = lambda x: " ".join(map(lambda y: y.value, x))
for arg in sys.argv[1:]:
with open(arg) as f:
tokens = tokenize(f.read())
print "Testing:\n {0}".format(get_str(tokens))
consumed, remaining = S(tokens)
if remaining:
if consumed is not None:
print get_str(tokens)
print "Error at"
print "{0} -> {1}\n".format(get_str(consumed),
get_str(remaining))
else:
print "Rejected"
print get_str(tokens)
else:
print "Accepted"
print get_str(consumed)
print generate_code(consumed)