Documentation
¶
Overview ¶
Package parser provides the parsing and execution of BF code.
Index ¶
Constants ¶
View Source
const DataMask int = math.MaxUint16
DataMask is the mask to match the size
View Source
const DataSize int = math.MaxUint16 + 1
DataSize is the size of the input data
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute[T Number](data []T, program []Instruction, reader io.ByteReader, writer *bufio.Writer) []T
Execute a compiled program
func Instructions ¶ added in v0.1.3
func Instructions(input io.ByteReader) iter.Seq[Instruction]
Instructions returns an iterator of the instructions.
func Print ¶ added in v0.1.0
func Print(program []Instruction, writer *bufio.Writer)
Print pretty prints out the parsed program.
Types ¶
type Instruction ¶
type Instruction struct {
// contains filtered or unexported fields
}
Instruction structure for intermediate program
func NewInstruction ¶
func NewInstruction(chr byte) Instruction
NewInstruction created from a sourcecode byte
func Tokenise ¶
func Tokenise(input io.ByteReader) (program []Instruction, err error)
Tokenise sourcecode into an array of operators
func (Instruction) IsZeroOp ¶ added in v0.1.0
func (inst Instruction) IsZeroOp() bool
IsZeroOp returns true for ops that have left the pointer on a zero
func (Instruction) SameOp ¶
func (inst Instruction) SameOp(instTwo Instruction) bool
SameOp compares Instructions operator but not operand
Click to show internal directories.
Click to hide internal directories.