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

Extension Registry – manages grammar extensions with rich metadata. More...

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  ExtensionOrder
 Result of dependency resolution: a sorted array of extension names in load order (dependencies before dependents). More...
 
struct  GrammarExtensionMetadata
 Metadata describing a grammar extension participant in the execution pipeline. More...
 
struct  OracleContext
 Context passed to an oracle callback when the system needs a disambiguation decision. More...
 

Typedefs

typedef struct ExtensionRegistry ExtensionRegistry
 Opaque extension registry handle.
 
typedef bool(* ExtensionVisitorFn) (const GrammarExtensionMetadata *meta, void *user_data)
 Visitor callback for extension iteration.
 
typedef int(* OracleCallback) (const OracleContext *ctx)
 Oracle callback type.
 

Enumerations

enum  DisambiguationStrategy {
  DISAMBIG_PRIORITY = 0 , DISAMBIG_FORK_RESOLVE , DISAMBIG_ORACLE , DISAMBIG_CONTEXT ,
  DISAMBIG_NONE
}
 How an extension prefers to resolve ambiguities introduced by its grammar modifications. More...
 
enum  ExecutionPolicy { EXEC_SEQUENTIAL = 0 , EXEC_PARALLEL , EXEC_PIPELINE , EXEC_LAZY }
 Controls how an extension's modifications are applied relative to other extensions. More...
 

Functions

void extension_order_destroy (ExtensionOrder *order)
 Free an ExtensionOrder and all owned strings.
 
bool extension_registry_check_dependencies (ExtensionRegistry *reg, char **error_out)
 Validate all dependency and conflict declarations.
 
uint32_t extension_registry_count (const ExtensionRegistry *reg)
 Return the number of registered extensions.
 
ExtensionRegistryextension_registry_create (void)
 Create an empty extension registry.
 
void extension_registry_destroy (ExtensionRegistry *reg)
 Destroy the registry and free all owned memory.
 
const GrammarExtensionMetadataextension_registry_find (ExtensionRegistry *reg, const char *name)
 Look up an extension by name.
 
void extension_registry_foreach (const ExtensionRegistry *reg, ExtensionVisitorFn visitor, void *user_data)
 Iterate over all registered extensions.
 
bool extension_registry_get_order (ExtensionRegistry *reg, ExtensionOrder *order_out, char **error_out)
 Produce a topological ordering of all registered extensions.
 
bool extension_registry_register (ExtensionRegistry *reg, const GrammarExtensionMetadata *metadata)
 Register an extension with its metadata.
 
bool extension_registry_unregister (ExtensionRegistry *reg, const char *name)
 Unregister an extension by name.
 

Detailed Description

Extension Registry – manages grammar extensions with rich metadata.

The extension registry manages grammar extensions with metadata including disambiguation strategies, execution policies, dependency tracking, and conflict declarations. It builds on the existing extension system (src/extension.h) by adding:

  • Per-extension disambiguation strategy and priority
  • Execution policy (sequential, parallel, pipeline, etc.)
  • Oracle callbacks for runtime conflict resolution
  • Declarative dependency and conflict relationships
  • Topological ordering with cycle detection
  • Hash-table-backed O(1) lookups by name
Usage Example
.name = "jsonb",
.version = "1.0.0",
.strategy = DISAMBIG_PRIORITY,
.priority = 100,
.policy = EXEC_SEQUENTIAL,
};
char *error = NULL;
@ DISAMBIG_PRIORITY
Resolve by numeric priority (higher wins)
@ EXEC_SEQUENTIAL
Apply modifications one at a time.
bool extension_registry_register(ExtensionRegistry *reg, const GrammarExtensionMetadata *metadata)
Register an extension with its metadata.
bool extension_registry_check_dependencies(ExtensionRegistry *reg, char **error_out)
Validate all dependency and conflict declarations.
void extension_registry_destroy(ExtensionRegistry *reg)
Destroy the registry and free all owned memory.
ExtensionRegistry * extension_registry_create(void)
Create an empty extension registry.
struct ExtensionRegistry ExtensionRegistry
Opaque extension registry handle.
Metadata describing a grammar extension participant in the execution pipeline.
const char * name
Extension name (borrowed pointer)
See also
disambiguation.h for conflict resolution strategies.
execution_policy.h for execution policy details.

Definition in file extension_registry.h.