|
Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
|
Per-parse-session state. More...
#include <parse_context.h>
Data Fields | |
| bool | borrowed_snapshot |
| When true, this ParseContext was created via parse_begin_borrowed() and the caller guarantees the snapshot outlives the parse session. | |
| struct GrammarContextStack * | context_stack |
| Optional grammar-mode boundary detector. | |
| void * | engine |
| Owned by parse_engine.c (opaque) | |
| LimeHostReduceFn | host_reduce |
| Letter 30: optional per-session host-reduce override. | |
| void * | host_reduce_user |
| void * | result_value |
| Letter 30: the LHS value the top-level (start-rule) reduce produced, captured when the parse accepts. | |
| ParserSnapshot * | snapshot |
| Snapshot pinned for this parse session. | |
Per-parse-session state.
Opaque parse context handle.
Pins a snapshot for the duration of a parse, ensuring grammar stability even if extensions are loaded or unloaded by other threads while parsing is in flight.
The engine field is owned by parse_engine.c (opaque to callers). It holds the parse stack and the accept/error flags. Embedding it directly in ParseContext rather than in a side-table keyed by ParseContext * is load-bearing for parse_token throughput: a side-table lookup adds a pthread_mutex_lock + linear scan to every parse_token call, which makes the runtime push parser unnecessarily slower than its compiled-in counterpart in bench/bench_flex_bison_compare. Do not move it back out without rerunning that benchmark.
See include/parse_context.h for details.
Definition at line 33 of file parse_context.h.
| bool ParseContext::borrowed_snapshot |
When true, this ParseContext was created via parse_begin_borrowed() and the caller guarantees the snapshot outlives the parse session.
parse_end will NOT call snapshot_release on the snapshot pointer (which therefore was never atomic_fetch_add'd in parse_begin_borrowed either).
The flag survives the thread-local pool: parse_context_destroy resets it to false before pooling. parse_begin_borrowed sets it to true after retrieving the pooled context.
Definition at line 60 of file parse_context.h.
| struct GrammarContextStack* ParseContext::context_stack |
Optional grammar-mode boundary detector.
When non-NULL, the parse engine consults it on every token via the context_switch.c API to spot embedded-grammar boundaries. When NULL (the common single-grammar case) the hook is a single branch on the parse-engine hot path.
Borrowed – not owned by the ParseContext. The caller owns the stack and is responsible for destroying it after the ParseContext. Attach via parse_attach_context_stack().
Definition at line 47 of file parse_context.h.
| void* ParseContext::engine |
Owned by parse_engine.c (opaque)
Definition at line 35 of file parse_context.h.
| LimeHostReduceFn ParseContext::host_reduce |
Letter 30: optional per-session host-reduce override.
When non-NULL it takes precedence over snapshot->host_reduce, letting a host bind or replace the base-reduce dispatch without mutating the (shared, possibly multi-threaded) snapshot. NULL by default – the engine then falls back to snapshot->host_reduce.
Definition at line 69 of file parse_context.h.
| void* ParseContext::host_reduce_user |
Definition at line 70 of file parse_context.h.
| void* ParseContext::result_value |
Letter 30: the LHS value the top-level (start-rule) reduce produced, captured when the parse accepts.
parse_result() returns it. NULL until accept, or when no host-reduce ran.
Definition at line 77 of file parse_context.h.
| ParserSnapshot* ParseContext::snapshot |
Snapshot pinned for this parse session.
Definition at line 34 of file parse_context.h.