Documentation ¶
Index ¶
- Variables
- type Command
- func NewDecrementPointer[T state.StateType]() Command[T]
- func NewDecrementPointerValue[T state.StateType]() Command[T]
- func NewEndLoop[T state.StateType]() Command[T]
- func NewIncrementPointer[T state.StateType]() Command[T]
- func NewIncrementPointerValue[T state.StateType]() Command[T]
- func NewReadByte[T state.StateType](reader io.Reader, promptWriter, errWriter io.Writer) Command[T]
- func NewStartLoop[T state.StateType]() Command[T]
- func NewWriteByte[T state.StateType](writer io.Writer, errWriter io.Writer) Command[T]
- type CommandFn
- type Controller
- type Symbol
Constants ¶
This section is empty.
Variables ¶
var ErrNotLoopScope = errors.New("top scope is not a loop scope")
Return from endLoop if last opened scope is not a loop scope
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command[T state.StateType] interface { HandleCommand(passive bool, vm Controller[T]) error }
Define Command interface. HandleCommand would be called each time the command need to be run by the interpreter.
func NewDecrementPointer ¶
Move the pointer to the left
func NewDecrementPointerValue ¶
Decrement the pointer value by one
func NewEndLoop ¶
If pointer value is not 0 return to the last openLoop, else move to next command
func NewIncrementPointer ¶
Move the pointer to the right
func NewIncrementPointerValue ¶
Increment the pointer value by one
func NewReadByte ¶
func NewReadByte[T state.StateType]( reader io.Reader, promptWriter, errWriter io.Writer, ) Command[T]
Read a single byte a numeric value from reader. If promptWriter is not nil, it will use to show the prompt message if user input have any error, it will be write to errWriter
func NewStartLoop ¶
If pointer value is 0 skip till next endLoop, else move to next command
type CommandFn ¶
type CommandFn[T state.StateType] func(bool, Controller[T]) error
convert a function to a Command and will call the provided function on HandleCommand
func (CommandFn[T]) HandleCommand ¶
func (fn CommandFn[T]) HandleCommand(passive bool, wm Controller[T]) error