forked from JessicaDouthit00/C-Compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSAST_SME.py
More file actions
59 lines (51 loc) · 1.49 KB
/
SAST_SME.py
File metadata and controls
59 lines (51 loc) · 1.49 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
51
52
53
54
55
56
57
58
59
"""
Author: Ariana Meatchem, Jessica Douthit, Deanna M. Wilborne
Created: 2025-04-08
Purpose: Test SAST and SME
Course: 25SP.CSC486 - Compiler Design & Interpretation
History:
2025-04-08, DMW, created
"""
from SAST import SAST
from SME import SME
def main() -> None:
# Team members: Yin Kyay, Diliara, Ariana
#
# Test 1: writeln with a static string
writeln_str_test = SAST("writeln", value={
'value': 'Hello, \"Yin Kyay\"', 'type': 'str'
})
sme1 = SME(writeln_str_test)
sme1.emit_mips32()
print("Test 1: writeln string")
print(sme1.asm_text)
print("-" * 40)
# Test 2: writeln with a static integer
writeln_int_test = SAST("writeln", value={
'value': 1234, 'type': 'int'
})
sme2 = SME(writeln_int_test)
sme2.emit_mips32()
print("Test 2: writeln int")
print(sme2.asm_text)
print("-" * 40)
# Test 3: write with a static string
write_str_test = SAST("write", value={
'value': 'No newline', 'type': 'str'
})
sme3 = SME(write_str_test)
sme3.emit_mips32()
print("Test 3: write string")
print(sme3.asm_text)
print("-" * 40)
# Test 4: write with a static integer
write_int_test = SAST("write", value={
'value': 42, 'type': 'int'
})
sme4 = SME(write_int_test)
sme4.emit_mips32()
print("Test 4: write int")
print(sme4.asm_text)
print("-" * 40)
if __name__ == "__main__":
main()