-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_program.py
43 lines (37 loc) · 889 Bytes
/
test_program.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
42
43
import d_lexer1
import d_parser
import d_ast1
import d_inte_gene
import d_gene
mypro=' for i = 1 : 3 i = i + 1 '
tokens=d_lexer1.d_lex(mypro)
root=d_ast1.tree('headers')
headers=d_parser.d_par(tokens)
for header in headers:
#print(type(header),header.data)
if header.id==1:
root.add(header)
#print(header)
#print(root.getchildren())
cod=d_inte_gene.in_gene(headers)
ins=d_gene.d_gene(cod)
print('************************************')
print('user program:')
print()
print(mypro)
print('************************************')
print('token stream :')
print()
for token in tokens:
print(token)
print('***********************************************')
print('intermediate code :')
print()
for co in cod:
print(co)
print()
print('***********************************************')
print('instructions:')
print()
for inn in ins:
print(inn)