engine

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ByteEngineScopeEndianess   = "ENDIANESS int"
	ByteEngineScopeBytecodeIdx = "BYTECODE_IDX *int"
	ByteEngineScopeInput       = "INPUT []byte"
)
View Source
const (
	StringEngineScopeInput  = "INPUT string"
	StringEngineScopeParsed = "PARSED []ParsedNode"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteEngine

type ByteEngine struct {
	Commands               map[int]core.CommandMeta[ByteEngine, byteParsing.ParsedBytes]
	Parser                 parsing.ParserInterface[[]byte, byteParsing.ParsedBytes]
	AutoBytecodeIndexShift map[int]bool
	UEP                    *core.UniversalEngineParams
	// contains filtered or unexported fields
}

ByteEngine handles binary inputs. Commands are indexed by integer opcodes. It uses a byte parser to decode raw bytes into ParsedBytes structures. The Process method triggers ByteParseEvent and ByteCallEvent in order.

func (*ByteEngine) AddToBytecodeIdx

func (e *ByteEngine) AddToBytecodeIdx(n int)

func (*ByteEngine) GetBytecodeIdx

func (e *ByteEngine) GetBytecodeIdx() (*int, error)

func (*ByteEngine) NewCommand

func (e *ByteEngine) NewCommand(
	cmd_switch int, handler core.CommandType[ByteEngine, byteParsing.ParsedBytes],
	name string, autoBytecodeIndexShift bool)

Your handler MUST shift bytecode index if autoBytecodeIndexShift false!

Usually it's like a:

AddToBytecodeIdx(1) // next instruction

Or:

SetBytecodeIdx(10) // jump
AddToBytecodeIdx(-1) // prev instruction

func (*ByteEngine) Process

func (e *ByteEngine) Process(input []byte) error

Process transforms a byte slice by parsing it and invoking the registered bytecode handlers. The parsed result is stored in scope["parsed_[]ParsedBytes"].

func (*ByteEngine) SetBytecodeIdx

func (e *ByteEngine) SetBytecodeIdx(n int)

type StringEngine

type StringEngine struct {
	Commands map[string]core.CommandMeta[StringEngine, stringParsing.ParsedNode]
	Parser   parsing.ParserInterface[string, stringParsing.ParsedNode]
	UEP      *core.UniversalEngineParams
	// contains filtered or unexported fields
}

StringEngine is the core for text‑based languages. It holds command definitions, a parser, and universal engine parameters (UEP) that include generator, events, scope, and logger. The Process method drives compilation.

func (*StringEngine) NewCommand

func (e *StringEngine) NewCommand(cmd_switch string,
	handler core.CommandType[StringEngine, stringParsing.ParsedNode], doc string)

func (*StringEngine) Process

func (e *StringEngine) Process(input string) error

Process executes the compilation pipeline for a string input. It stores the input in scope["input_string"], then calls the StringParseEvent (to parse into []ParsedNode) and StringCallEvent (to dispatch commands). Any error stops execution.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL