Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
Loading...
Searching...
No Matches
parser.h
Go to the documentation of this file.
1
35#ifndef PARSER_H
36#define PARSER_H
37
38#include <stdbool.h>
39#include <stddef.h>
40#include <stdint.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
51const char *lime_parser_version(void);
52
53/* --- Snapshot API -------------------------------------------------- */
54
65typedef struct ParserSnapshot ParserSnapshot;
66
79
89
104
123int lime_snapshot_token_code(const ParserSnapshot *snap, const char *name);
124
136ParserSnapshot *lime_snapshot_create(const char *grammar_file, char **error);
137
152ParserSnapshot *lime_compile_grammar_text(const char *grammar_text, size_t len, char **error);
153
/* end snapshot_api */
155
156/* --- Parse Context API ----------------------------------------------- */
157
168typedef struct ParseContext ParseContext;
169
181
200int parse_token(ParseContext *ctx, int token_code, void *token_value, int location);
201
210
218
/* end parse_ctx_api */
220
221/* --- JIT Compilation API ----------------------------------------- */
222
235
244
/* end jit_api */
246
247/* --- Extension API ------------------------------------------------ */
248
265
272
/* end ext_init */
274
275#ifdef __cplusplus
276}
277#endif
278
279#endif /* PARSER_H */
void lime_extension_registry_destroy(void)
Destroy the global extension registry.
bool lime_extension_registry_init(void)
Initialize the global extension registry.
bool lime_jit_available(void)
Check whether JIT compilation support is available at runtime.
int lime_jit_compile(ParserSnapshot *snap)
Compile and attach JIT code to a snapshot's action tables.
int parse_token(ParseContext *ctx, int token_code, void *token_value, int location)
Feed a token to the parser.
ParseContext * parse_begin(ParserSnapshot *snap)
Begin a parse session pinned to a snapshot.
void parse_end(ParseContext *ctx)
End the parse session.
ParserSnapshot * parse_get_snapshot(ParseContext *ctx)
Return the snapshot pinned by this context.
ParserSnapshot * lime_compile_grammar_text(const char *grammar_text, size_t len, char **error)
Build a base snapshot from in-memory grammar text.
int lime_snapshot_token_code(const ParserSnapshot *snap, const char *name)
Map a token name to its external code in a snapshot.
uint16_t lime_snapshot_first_token(const ParserSnapshot *snap)
The first_token offset baked into a snapshot.
ParserSnapshot * lime_snapshot_create(const char *grammar_file, char **error)
Create a base snapshot by parsing a grammar file.
ParserSnapshot * lime_snapshot_acquire(ParserSnapshot *snap)
Acquire a reference to a snapshot.
void lime_snapshot_release(ParserSnapshot *snap)
Release a snapshot reference.
const char * lime_parser_version(void)
Return the Lime parser library version string.
Per-parse-session state.
Opaque snapshot handle.
Definition snapshot.h:177