Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
Loading...
Searching...
No Matches
Parse Context API

Manage parse sessions pinned to a snapshot. More...

Functions

ParseContextparse_begin (ParserSnapshot *snap)
 Begin a parse session pinned to a snapshot.
 
void parse_end (ParseContext *ctx)
 End the parse session.
 
ParserSnapshotparse_get_snapshot (ParseContext *ctx)
 Return the snapshot pinned by this context.
 
int parse_token (ParseContext *ctx, int token_code, void *token_value, int location)
 Feed a token to the parser.
 

Detailed Description

Manage parse sessions pinned to a snapshot.

Function Documentation

◆ parse_begin()

ParseContext * parse_begin ( ParserSnapshot snap)

#include <include/parser.h>

Begin a parse session pinned to a snapshot.

Acquires a reference to snap.

Parameters
snapSnapshot to pin.
Returns
New parse context, or NULL on failure.
See also
parse_end()

◆ parse_end()

void parse_end ( ParseContext ctx)

#include <include/parser.h>

End the parse session.

Releases the snapshot reference and frees all internal state.

Parameters
ctxParse context to end. Passing NULL is safe.

◆ parse_get_snapshot()

ParserSnapshot * parse_get_snapshot ( ParseContext ctx)

#include <include/parser.h>

Return the snapshot pinned by this context.

Parameters
ctxActive parse context.
Returns
The pinned ParserSnapshot.

◆ parse_token()

int parse_token ( ParseContext ctx,
int  token_code,
void *  token_value,
int  location 
)

#include <include/parser.h>

Feed a token to the parser.

Parameters
ctxActive parse context.
token_codeToken code (0 for end-of-input).
token_valueSemantic value associated with the token (may be NULL).
locationByte offset of the token in the original source, or LIME_LOC_UNKNOWN if the grammar does not declare locations or the caller does not track positions. Currently stored but not yet propagated into reduce actions (that plumbing lands with the push-parser full implementation); callers should pass real locations anyway so they are ready for it.
Return values
0Success.
non-zeroParse error.