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

Build a runtime ParserSnapshot from generated parser tables. More...

#include "snapshot.h"

Go to the source code of this file.

Data Structures

struct  LimeParserTables
 Bundle of pointers + sizes the generator emits for a parser. More...
 

Macros

#define LIME_TABLES_ABI_VERSION   1
 
#define LIME_TABLES_MAGIC   0x4C494D45U /* 'L','I','M','E' */
 

Functions

ParserSnapshotsnapshot_build_from_tables (const LimeParserTables *tables)
 Build a fresh ParserSnapshot from a LimeParserTables bundle.
 

Detailed Description

Build a runtime ParserSnapshot from generated parser tables.

A Lime-generated parser contains everything needed to drive an LALR(1) parse: action tables, rule metadata, and the constants that partition the action range into shifts / reduces / errors. The generator emits these as static arrays inside the parser .c file.

This header provides the bridge that lets a generated parser hand those tables to the runtime so the runtime push parser (parse_begin / parse_token / parse_end) and the JIT can drive them.

Two ways to use this:

  1. Call lime_snapshot_create("foo.y", &err) which subprocesses lime -n foo.y to produce a *_snapshot.c file, compiles it, dlopens it, and calls the registration entry point below. Used for true runtime grammar loading.
  2. The generated parser's *_snapshot.c file calls snapshot_build_from_tables() at static init / on-demand to hand its tables to a snapshot the application acquires. Used for "static parser, runtime API" applications.

The snapshot returned takes a shared reference to the static tables – it does not free them – so the same generated parser can be used by many concurrent ParseContext instances. When extensions mutate the snapshot via apply_modification, the snapshot's tables are first deep-copied; the originals stay untouched.

Definition in file snapshot_build.h.

Macro Definition Documentation

◆ LIME_TABLES_ABI_VERSION

#define LIME_TABLES_ABI_VERSION   1

Definition at line 139 of file snapshot_build.h.

◆ LIME_TABLES_MAGIC

#define LIME_TABLES_MAGIC   0x4C494D45U /* 'L','I','M','E' */

Definition at line 138 of file snapshot_build.h.

Function Documentation

◆ snapshot_build_from_tables()

ParserSnapshot * snapshot_build_from_tables ( const LimeParserTables tables)

Build a fresh ParserSnapshot from a LimeParserTables bundle.

The snapshot deep-copies the action tables and rule metadata so that subsequent extension modifications do not touch the static generator-emitted arrays. Returns a snapshot with refcount 1, or NULL on allocation failure.

Parameters
tablesCompile-time table bundle from a generated parser.
Returns
New snapshot, or NULL on allocation failure.