~jacksonchen666/brainfuck_interpreter

86cc3d2752e995d6624f4ad35c756dff75c738d3 — Jackson Chen 1 year, 1 month ago 74aee1c
handle errors from Step function
1 files changed, 12 insertions(+), 2 deletions(-)

M cmd/test/main.go
M cmd/test/main.go => cmd/test/main.go +12 -2
@@ 1,7 1,9 @@
package main

import (
	"errors"
	"flag"

	"git.sr.ht/~jacksonchen666/brainfuck_interpreter"
)



@@ 15,7 17,15 @@ func main() {

	programState := brainfuck_interpreter.InitProgramState(&instructions)

	for range instructions {
		programState.Step()
	loop: for {
		err := programState.Step()
		if err != nil {
			switch {
			case errors.Is(err, brainfuck_interpreter.EOF):
				break loop
			default:
				panic(err)
			}
		}
	}
}