Skip to content

Commit

Permalink
Removed blank line on printing opDupVal.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmorgan committed Jun 12, 2024
1 parent 256ebc1 commit 5e84d89
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/bfg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Options:

var (
// Version is the main version number that is being run at the moment.
Version = "0.1.0"
Version = "0.1.1"

// VersionPrerelease is A pre-release marker for the Version. If this is ""
// (empty string) then it means that it is a final release. Otherwise, this
Expand Down
3 changes: 2 additions & 1 deletion parser/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func Print(program []Instruction, writer *bufio.Writer) {
endLoop := NewInstruction(']')
lastInst := NewInstruction('!')
for _, inst := range program {
if inst.operator == opMulVal {
if inst.operator == opMulVal ||
inst.operator == opDupVal {
lastInst = inst
continue
}
Expand Down
2 changes: 1 addition & 1 deletion parser/print_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestPrint(t *testing.T) {
outputBuf := bufio.NewWriter(&buf)
Print(program, outputBuf)
got := buf.String()
want := " \n >>>>>\n [-]\n +++++\n [->>+<<]\n [\n\t ,\n\t [->>++<<]\n\t \n\t [->+>+<<]\n ]\n >>\n"
want := " \n >>>>>\n [-]\n +++++\n [->>+<<]\n [\n\t ,\n\t [->>++<<]\n\t [->+>+<<]\n ]\n >>\n"

if !reflect.DeepEqual(got, want) {
t.Errorf("got %v want %v", got, want)
Expand Down
10 changes: 3 additions & 7 deletions sample/ascii.bf
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env bf
8x12=96
++++++++
[>++++++++++++<-]
[>+>+<<-]>>
[>++++++++++++<-]< 8x12=96
[>++++<-]>8x4=32
start at 32
++++++++++
++++++++++
++++++++++
++
count down 96 and print up from space
>[-<.+>]
Expand Down

0 comments on commit 5e84d89

Please sign in to comment.