-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInterpreter.py
More file actions
50 lines (44 loc) · 1.48 KB
/
Copy pathInterpreter.py
File metadata and controls
50 lines (44 loc) · 1.48 KB
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
__author__ = 'Ties'
import Statement as S
import sys
# sys.setrecursionlimit(5000)
if False:
with open (raw_input(), "r") as file:
data=file.read().replace('\n','').replace('\t','').replace(chr(184),'').replace(chr(248),chr(195))
print "DATA =" + data
else:
data = raw_input().replace('\n','').replace('\t','').replace(chr(184),'').replace(chr(248),chr(195))
input = []
with open ("input.txt", "r") as file:
input=file.read().replace('\n','')
print "Input: " + input
input = "In"
input = list(input)
state = S.Statement(data)
print "State: " + str(state.statement)
# state = S.Statement("20[1-$][$.]#")
# state = S.Statement("10$[1-$$.7>[a;!]?]a:a;!")
# state = S.Statement("[3 5+]a:5a;-")
# state = S.Statement("[3-]a:3 5+[[$-1][$.]#]z:%{ dit is een comment }99 9[1-$][\$@$@$@$@\/*=[1-$$[%\ 1-$@]?0=[\$.\]?]?]#")
# state = S.Statement("1$[$][$@+$.]#")
stack = []
output = []
variables = {}
# state.execute(stack, variables)
# try:
state.execute(stack, variables, input, output)
# except Exception as exc:
# print "EXCEPTION: " + str(exc)
# exit()
print "\nExecute succesfull:"
print " Stack: " + str(stack)
print " Variables: " + str(variables)
print " Syntax: " + state.printtree()
print " Output: " + str(output)
with open ("header.tex", "r") as file:
header=file.read()
busstree = header + state.printbuss() + "\DP\n\\end{document}"
# print " LaTeX: \n" + busstree
# print " Counter: " + str(counter)
with open ("busstree.tex", "w") as file:
file.write(busstree)