Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
Loading...
Searching...
No Matches
LimeParserPlugin Struct Reference

The plugin interface struct – the contract between the manager and a parser implementation. More...

#include <parser_manager.h>

Data Fields

void * _reserved [8]
 Reserved for ABI-compatible future additions.
 
ParserSnapshot *(* create_snapshot )(const char *grammar_file, char **error)
 Create a snapshot from a grammar file path.
 
ParserSnapshot *(* deserialize_snapshot )(const uint8_t *buf, size_t len, char **error)
 Deserialize a snapshot from a byte buffer.
 
void(* destroy )(void)
 Teardown callback.
 
uint16_t(* get_abi_major )(void)
 Return the ABI major version this plugin was compiled against.
 
uint16_t(* get_abi_minor )(void)
 Return the ABI minor version this plugin was compiled against.
 
uint32_t(* get_capabilities )(void)
 Return a bitmask of LimePluginCaps describing this plugin.
 
const char *(* get_name )(void)
 Return the plugin's human-readable name.
 
LimePluginVersion(* get_version )(void)
 Return the plugin's semantic version.
 
bool(* init )(void *user_data)
 One-time initialization.
 
bool(* serialize_snapshot )(const ParserSnapshot *snap, uint8_t **buf_out, size_t *len_out)
 Serialize a snapshot to a byte buffer.
 
bool(* validate_snapshot )(const ParserSnapshot *snap, char **error)
 Validate that a snapshot is internally consistent.
 

Detailed Description

The plugin interface struct – the contract between the manager and a parser implementation.

Every plugin, whether loaded from a shared library or linked statically, must provide one of these.

Required callbacks
Optional callbacks (set to NULL if not supported)
Lifetime
The LimeParserPlugin struct must remain valid from the time it is registered until destroy() is called. For dynamically loaded plugins, the shared library must stay loaded for that duration.
Thread Safety
All callbacks except init() and destroy() may be called concurrently from multiple threads. Implementations that need internal synchronization must provide it themselves.

Definition at line 192 of file parser_manager.h.

Field Documentation

◆ _reserved

void* LimeParserPlugin::_reserved[8]

Reserved for ABI-compatible future additions.

Definition at line 327 of file parser_manager.h.

◆ create_snapshot

ParserSnapshot *(* LimeParserPlugin::create_snapshot) (const char *grammar_file, char **error)

Create a snapshot from a grammar file path.

Parameters
grammar_filePath to the grammar file.
[out]errorOn failure, set to a malloc'd error message the caller must free. Set to NULL on success.
Returns
New ParserSnapshot with refcount == 1 on success, or NULL on failure.
Note
Required if LIME_CAP_SNAPSHOT is set in capabilities.

Definition at line 277 of file parser_manager.h.

◆ deserialize_snapshot

ParserSnapshot *(* LimeParserPlugin::deserialize_snapshot) (const uint8_t *buf, size_t len, char **error)

Deserialize a snapshot from a byte buffer.

Parameters
bufBuffer previously produced by serialize_snapshot().
lenLength of the buffer in bytes.
[out]errorOn failure, set to a malloc'd error message.
Returns
New ParserSnapshot with refcount == 1 on success, or NULL on failure.

Definition at line 319 of file parser_manager.h.

◆ destroy

void(* LimeParserPlugin::destroy) (void)

Teardown callback.

Called when the plugin is unloaded from the manager. Must release all resources owned by the plugin. After this call the plugin struct and any pointers it returned are invalid.

Note
The manager guarantees that no other callbacks are in flight when destroy() is called.

Definition at line 260 of file parser_manager.h.

◆ get_abi_major

uint16_t(* LimeParserPlugin::get_abi_major) (void)

Return the ABI major version this plugin was compiled against.

The manager rejects plugins whose ABI major version does not match LIME_PLUGIN_ABI_VERSION_MAJOR.

Returns
ABI major version number.

Definition at line 217 of file parser_manager.h.

◆ get_abi_minor

uint16_t(* LimeParserPlugin::get_abi_minor) (void)

Return the ABI minor version this plugin was compiled against.

Returns
ABI minor version number.

Definition at line 223 of file parser_manager.h.

◆ get_capabilities

uint32_t(* LimeParserPlugin::get_capabilities) (void)

Return a bitmask of LimePluginCaps describing this plugin.

Returns
Bitwise OR of zero or more LimePluginCaps values.

Definition at line 229 of file parser_manager.h.

◆ get_name

const char *(* LimeParserPlugin::get_name) (void)

Return the plugin's human-readable name.

Returns
NUL-terminated name string. Must remain valid for the lifetime of the plugin.

Definition at line 202 of file parser_manager.h.

◆ get_version

LimePluginVersion(* LimeParserPlugin::get_version) (void)

Return the plugin's semantic version.

Returns
A LimePluginVersion struct.

Definition at line 208 of file parser_manager.h.

◆ init

bool(* LimeParserPlugin::init) (void *user_data)

One-time initialization.

Called after the plugin is loaded but before any other callbacks. Receives the user_data pointer passed to parser_manager_load() or parser_manager_register().

Parameters
user_dataOpaque pointer from the load/register call.
Return values
trueInitialization succeeded.
falseInitialization failed; plugin is not registered.
Note
Optional: set to NULL if no initialization is needed.

Definition at line 248 of file parser_manager.h.

◆ serialize_snapshot

bool(* LimeParserPlugin::serialize_snapshot) (const ParserSnapshot *snap, uint8_t **buf_out, size_t *len_out)

Serialize a snapshot to a byte buffer.

Parameters
snapSnapshot to serialize.
[out]buf_outOn success, points to a malloc'd buffer the caller must free.
[out]len_outOn success, receives the buffer length in bytes.
Return values
trueSerialization succeeded.
falseSerialization failed.

Definition at line 306 of file parser_manager.h.

◆ validate_snapshot

bool(* LimeParserPlugin::validate_snapshot) (const ParserSnapshot *snap, char **error)

Validate that a snapshot is internally consistent.

Parameters
snapSnapshot to validate.
[out]errorOn failure, set to a malloc'd diagnostic message.
Return values
trueSnapshot is well-formed.
falseSnapshot is invalid.
Note
Optional: set to NULL to skip validation.

Definition at line 290 of file parser_manager.h.


The documentation for this struct was generated from the following file: