Documentation
¶
Overview ¶
Package asm parses and compiles vise assembly code to bytecode.
Index ¶
- func Parse(s string, w io.Writer) (int, error)
- type Arg
- type Asm
- type BatchCode
- type Batcher
- type FlagParser
- func (pp *FlagParser) GetAsString(key string) (string, error)
- func (pp *FlagParser) GetDescription(idx uint32) (string, error)
- func (pp *FlagParser) GetFlag(key string) (uint32, error)
- func (pp *FlagParser) Last() uint32
- func (pp *FlagParser) Load(fp string) (int, error)
- func (pp *FlagParser) WithDebug() *FlagParser
- type Instruction
- type MenuProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Arg ¶
type Arg struct { Sym *string `(@Sym Whitespace?)?` Size *uint32 `(@Size Whitespace?)?` Flag *uint8 `(@Size Whitespace?)?` Selector *string `(@Sym Whitespace?)?` Desc *string `(@Sym Whitespace?)?` }
Arg holds all parsed argument elements of a single line of assembly code.
TODO: Conceal from outside use
type Asm ¶
type Asm struct {
Instructions []*Instruction `@@*`
}
Asm assembles bytecode from the vise assembly mini-language.
TODO: Conceal from outside use
type BatchCode ¶
type BatchCode uint16
BatchCode defines quasi-opcodes that expand to mulitple individual vm instructions.
type Batcher ¶
type Batcher struct {
// contains filtered or unexported fields
}
Batcher handles assembly commands that generates multiple instructions, such as menu navigation commands.
func NewBatcher ¶
func NewBatcher(mp MenuProcessor) Batcher
NewBatcher creates a new Batcher objcet.
func (*Batcher) Exit ¶
Exit is a synonym for MenuExit
func (*Batcher) MenuAdd ¶
MenuAdd adds a new menu instruction to the batcher.
type FlagParser ¶
type FlagParser struct {
// contains filtered or unexported fields
}
FlagParser is used to resolve flag strings to corresponding flag index integer values.
func (*FlagParser) GetAsString ¶
func (pp *FlagParser) GetAsString(key string) (string, error)
GetFlag returns the flag index value for a given flag string as a numeric string.
If flag string has not been registered, an error is returned.
func (*FlagParser) GetDescription ¶
func (pp *FlagParser) GetDescription(idx uint32) (string, error)
GetDescription returns a flag description for a given flag index, if available.
If no description has been provided, an error is returned.
func (*FlagParser) GetFlag ¶
func (pp *FlagParser) GetFlag(key string) (uint32, error)
GetFlag returns the flag index integer value for a given flag string
If flag string has not been registered, an error is returned.
func (*FlagParser) Last ¶
func (pp *FlagParser) Last() uint32
Last returns the highest registered flag index value
func (*FlagParser) Load ¶
func (pp *FlagParser) Load(fp string) (int, error)
Load parses a Comma Seperated Value file under the given filepath to provide mappings between flag strings and flag indices.
The expected format is:
Field 1: The literal string "flag" Field 2: Flag string Field 3: Flag index Field 4: Flag description (optional)
func (*FlagParser) WithDebug ¶
func (pp *FlagParser) WithDebug() *FlagParser
type Instruction ¶
type Instruction struct { OpCode string `@Ident` OpArg Arg `(Whitespace @@)?` Comment string `Comment? EOL` }
Instruction represents one full line of assembly code.
TODO: Conceal from outside use
func (Instruction) String ¶
func (i Instruction) String() string
String implements the String interface.
type MenuProcessor ¶
type MenuProcessor struct {
// contains filtered or unexported fields
}
MenuProcessor handles code lines with BatchCode quasi-opcodes that control menu generation.
It creates vm instructions for display of menu and handling of input on either size of a vm.HALT instruction.
func NewMenuProcessor ¶
func NewMenuProcessor() MenuProcessor
NewMenuProcessor creates a new MenuProcessor object.
func (*MenuProcessor) Add ¶
Add a menu batch instruction to be processed.
Instructions will be rendered in the order in which they have been added.
func (*MenuProcessor) ToLines ¶
func (mp *MenuProcessor) ToLines() []byte
ToLines returns the generated bytecode from the added menu batch instructions.