Documentation
¶
Index ¶
- Constants
- func NewByteEngine(generator_res_type int, pipeline []string, add_default_events bool, ...) *engine.ByteEngine
- func NewStringEngine(generator_res_type int, pipeline []string, add_default_events bool, ...) *engine.StringEngine
- type EngineBuilder
- func (b *EngineBuilder) Build() (*EngineUniversal, error)
- func (b *EngineBuilder) WithByteParser(parser byteParser) *EngineBuilder
- func (b *EngineBuilder) WithColors() *EngineBuilder
- func (b *EngineBuilder) WithContext(context context.Context) *EngineBuilder
- func (b *EngineBuilder) WithDefaultEvents(add bool) *EngineBuilder
- func (b *EngineBuilder) WithEndianess(endianess int) *EngineBuilder
- func (b *EngineBuilder) WithLogger(logger *core.Logger) *EngineBuilder
- func (b *EngineBuilder) WithPipeline(pipeline []string) *EngineBuilder
- func (b *EngineBuilder) WithPluginManager(plugins ...*plugin.Plugin) *EngineBuilder
- func (b *EngineBuilder) WithScope(scope core.ScopeType) *EngineBuilder
- func (b *EngineBuilder) WithStringParser(parser stringParser) *EngineBuilder
- type EngineUniversal
- func (e *EngineUniversal) GetUEP() *core.UniversalEngineParams
- func (e *EngineUniversal) NewCommandByte(opcode int, ...) error
- func (e *EngineUniversal) NewCommandString(cmdSwitch string, ...) error
- func (e *EngineUniversal) ProcessBytes(input []byte) error
- func (e *EngineUniversal) ProcessBytesWithCtx(input []byte, ctx context.Context) error
- func (e *EngineUniversal) ProcessString(input string) error
- func (e *EngineUniversal) ProcessStringWithCtx(input string, ctx context.Context) error
Constants ¶
const ( ByteEngineType = iota StringEngineType )
const (
EuPtrPluginsScope = "EuPtr"
)
const (
PluginManagerEuScope = "LC-PM"
)
const Version = "1.1.2"
Variables ¶
This section is empty.
Functions ¶
func NewByteEngine ¶
func NewByteEngine( generator_res_type int, pipeline []string, add_default_events bool, parser byteParser, endianess int, colorEnable bool, context context.Context, ) *engine.ByteEngine
NewByteEngine creates a byte-oriented engine for binary formats or bytecode.
The endianess parameter (e.g., bytecode.LittleEndian) is stored in scope.
It registers default events when add_default_events is true.
The parser must implement paraing.ParserInterface.
func NewStringEngine ¶
func NewStringEngine( generator_res_type int, pipeline []string, add_default_events bool, parser stringParser, colorEnable bool, context context.Context, ) *engine.StringEngine
NewStringEngine creates a ready-to-use string-based engine. Parameters:
generator_res_type – core.StringResType (usually) for text generation.
pipeline – ordered list of generation points (e.g., []string{"pre","main"}).
add_default_events – if true, registers standard parsing and call events.
parser – an implementation parser.ParserInterface.
Returns a StringEngine with empty command map and initialized UEP.
Types ¶
type EngineBuilder ¶
type EngineBuilder struct {
// contains filtered or unexported fields
}
EngineBuilder is a fluent builder for constructing universal engines. It allows to configure pipeline stages, event handling, logging, custom parsers, scope variables, and byte order before calling Build(). Use NewEngineBuilder to create a builder instance.
func NewEngineBuilder ¶
func NewEngineBuilder(engineType int) *EngineBuilder
NewEngineBuilder creates a new EngineBuilder for the given engine type. engineType must be either ByteEngineType or StringEngineType. Defaults: pipeline = []string{"main"}, default events enabled, endianess = bytecode.LittleEndian, empty scope. Example:
builder := lc.NewEngineBuilder(lc.StringEngineType).
WithPipeline([]string{"pre","main"}).
WithStringParser(myParser)
func (*EngineBuilder) Build ¶
func (b *EngineBuilder) Build() (*EngineUniversal, error)
Build constructs and returns an EngineUniversal or an error if required components are missing (e.g., a string parser for a StringEngine). The returned engineUniversal can process strings or bytes depending on its type and provides methods to register commands.
func (*EngineBuilder) WithByteParser ¶
func (b *EngineBuilder) WithByteParser(parser byteParser) *EngineBuilder
func (*EngineBuilder) WithColors ¶
func (b *EngineBuilder) WithColors() *EngineBuilder
func (*EngineBuilder) WithContext ¶
func (b *EngineBuilder) WithContext(context context.Context) *EngineBuilder
func (*EngineBuilder) WithDefaultEvents ¶
func (b *EngineBuilder) WithDefaultEvents(add bool) *EngineBuilder
func (*EngineBuilder) WithEndianess ¶
func (b *EngineBuilder) WithEndianess(endianess int) *EngineBuilder
func (*EngineBuilder) WithLogger ¶
func (b *EngineBuilder) WithLogger(logger *core.Logger) *EngineBuilder
func (*EngineBuilder) WithPipeline ¶
func (b *EngineBuilder) WithPipeline(pipeline []string) *EngineBuilder
func (*EngineBuilder) WithPluginManager ¶ added in v1.1.2
func (b *EngineBuilder) WithPluginManager(plugins ...*plugin.Plugin) *EngineBuilder
func (*EngineBuilder) WithScope ¶
func (b *EngineBuilder) WithScope(scope core.ScopeType) *EngineBuilder
func (*EngineBuilder) WithStringParser ¶
func (b *EngineBuilder) WithStringParser(parser stringParser) *EngineBuilder
type EngineUniversal ¶
type EngineUniversal struct {
Plugins *lcplugin.PluginManager
Type int
StringEngine *engine.StringEngine
ByteEngine *engine.ByteEngine
Context context.Context
// contains filtered or unexported fields
}
func (*EngineUniversal) GetUEP ¶
func (e *EngineUniversal) GetUEP() *core.UniversalEngineParams
func (*EngineUniversal) NewCommandByte ¶
func (e *EngineUniversal) NewCommandByte( opcode int, handler core.CommandType[engine.ByteEngine, byteParsing.ParsedBytes], name string, autoByecodeIdxShift bool, ) error
NewCommandByte registers a bytecode command identified by an opcode. If opcode == -1, the engine automatically assigns the next available opcode. handler receives (*ByteEngine, ParsedBytes).
func (*EngineUniversal) NewCommandString ¶
func (e *EngineUniversal) NewCommandString( cmdSwitch string, handler core.CommandType[engine.StringEngine, stringParsing.ParsedNode], doc string, ) error
NewCommandString registers a text-based command in a StringEngine. cmdSwitch is the command name (e.g., "print"). handler must have signature func([]interface{}) error where arguments are (*StringEngine, ParsedNode). doc is an optional documentation string.
func (*EngineUniversal) ProcessBytes ¶
func (e *EngineUniversal) ProcessBytes(input []byte) error
ProcessBytes feeds a byte slice into the engine (ByteEngineType only). The input is passed via scope under key "input_[]byte", then parsed and processed.
func (*EngineUniversal) ProcessBytesWithCtx ¶
func (e *EngineUniversal) ProcessBytesWithCtx(input []byte, ctx context.Context) error
func (*EngineUniversal) ProcessString ¶
func (e *EngineUniversal) ProcessString(input string) error
ProcessString feeds a string input into the engine. It works only for engines of type StringEngineType; otherwise returns an error. Internally triggers the parse and call events, executing registered handlers.
func (*EngineUniversal) ProcessStringWithCtx ¶
func (e *EngineUniversal) ProcessStringWithCtx(input string, ctx context.Context) error