Skip to content

Commit 64be2f2

Browse files
Fix some whitespace in dwarf and cleanup cli
1 parent db06cbc commit 64be2f2

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/cli.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ pub fn run() -> Result<(), Box<dyn Error>> {
2424
let parsed_input = parser::parse(input_program.as_str())?;
2525
let parse_output = parsed_input.dump();
2626

27-
match cli_options.output_file {
28-
Some(output_path) => fs::write(output_path, parse_output)?,
29-
None => println!("{}", parse_output),
27+
if let Some(output_path) = cli_options.output_file {
28+
fs::write(output_path, parse_output)?;
29+
} else {
30+
println!("{}", parse_output);
3031
};
3132

3233
Ok(())

tests/data/dwarf.red

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
;redcode
22

3-
;name Dwarf
4-
;author A. K. Dewdney
5-
;version 94.1
6-
;date April 29, 1993
3+
;name Dwarf
4+
;author A. K. Dewdney
5+
;version 94.1
6+
;date April 29, 1993
77

8-
;strategy Bombs every fourth instruction.
9-
;assert CORESIZE % 4 == 0
8+
;strategy Bombs every fourth instruction.
9+
;assert (CORESIZE % 4 == 0) && (foo > baz)
1010

11-
ORG start ; Indicates the instruction with
12-
; the label "start" should be the
13-
; first to execute.
11+
ORG start ; Indicates the instruction with
12+
; the label "start" should be the
13+
; first to execute.
1414

15-
step EQU 4 ; Replaces all occurrences of "step"
16-
; with the character "4".
15+
step EQU 4 ; Replaces all occurrences of "step"
16+
; with the character "4".
17+
18+
target DAT.F #0, #0 ; Pointer to target instruction.
19+
start ADD.AB #step, target ; Increments pointer by step.
20+
MOV.AB #0, @target ; Bombs target instruction.
21+
JMP.A start ; Same as JMP.A -2. Loops back to
22+
; the instruction labelled "start
1723

18-
target DAT.F #0, #0 ; Pointer to target instruction.
19-
start ADD.AB #step, target ; Increments pointer by step.
20-
MOV.AB #0, @target ; Bombs target instruction.
21-
JMP.A start ; Same as JMP.A -2. Loops back to
22-
; the instruction labelled "start".
2324
END

0 commit comments

Comments
 (0)