Skip to content

Commit

Permalink
修好了5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tao1122334 committed Jan 12, 2024
1 parent b4b8f66 commit b16073e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion phase4/splc.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def translate(tac: str) -> "list[str]":
if re.fullmatch(f'{id} := .+', tac): # x := ...
x, _ = tac.split(' := ')
active_vars.add(x)

if re.fullmatch(f'{id} := {num}', tac): # x := #k
x, k = tac.split(' := #')
command.append(f'li {reg(x)}, {k}')
Expand Down
5 changes: 4 additions & 1 deletion phase4/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
subprocess.run(f'../bin/splc {id}.ir', shell=True)
for test in tests.read().split('\n\n'):
input, expect_out = test.split('\n----------\n')
actual_out = (subprocess.run(f'echo {input} | spim -file {id}.s', shell=True, capture_output=True, text=True).stdout
input=input.replace(' ','\\n')
if '\\n' in input:
input=input+'\\n'
actual_out = (subprocess.run(f'echo "{input}" | spim -file {id}.s', shell=True, capture_output=True, text=True).stdout
.replace(spim_header, '') # remove SPIM's header
.replace(input_prompt,'') # remove input prompt
.strip())
Expand Down

0 comments on commit b16073e

Please sign in to comment.