|
x-engine-c v0.2.13
The C engine for x-lang
|
Tokenizer: analysis, reading, writing, and display of expressions. More...
#include "x-eval.h"#include "x-heap.h"#include "x-obj.h"#include "x-token.h"#include "x-type.h"#include "x-type/buffer.h"#include "x-type/char.h"#include "x-type/int.h"#include "x-type/iter.h"#include "x-type/prim.h"#include "x-type/str.h"#include "x-type/list.h"#include "x-token/sexp/atom.h"#include "x-token/sexp/pair.h"Macros | |
| #define | prim_arg_prim x_0((x_obj_t *)prim_args) |
Functions | |
| x_obj_t * | x_token_delimit (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_token_analyse (x_obj_t *p_base, x_obj_t *p_args, x_int_t *p_variant) |
| x_obj_t * | x_token_read (x_obj_t *p_base, x_obj_t *p_args) |
Variables | |
| x_satom_t | x_type_list_iter_prim |
| x_satom_t | x_token_eof_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .v = (void *)x_token_eof_prim }) |
Tokenizer: analysis, reading, writing, and display of expressions.
Determine which type best matches the next token in the buffer.
Iterates all registered types, calling each type's analyse hook character by character. Tracks the winning type by score (number of buffer characters consumed). Uses first-char hint strings on x-lang closures to skip non-matching types early. The >= comparison means later types (C built-ins) win ties against earlier (custom) types.
After finding the winner, advances the buffer read pointer by the winning score.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (buffer . base) pair |
| p_variant | x_int_t* – Out: the variant the winning handler declared through the variant cell (0 when none) |
Check whether any type's delimiter matches at the current buffer position.
Iterates all registered types (except the given type itself) and calls each type's delimit hook. Returns the buffer if a delimiter matched, NULL otherwise.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Read-args whose first element is the buffer |
Read the next token from the buffer and return its parsed object.
Calls x_token_analyse to identify the token type, counts newlines in the consumed region for line tracking, then invokes the winning type's read hook. Types with no read hook (e.g. whitespace) are discarded and the loop retries. Stamps source line numbers on created objects when meta tracking is enabled.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (buffer . base) pair |
()) or every reader declined; x_token_eof_prim at clean end of input (zero consumption). | x_satom_t x_token_eof_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .v = (void *)x_token_eof_prim }) |
Clean-EOF sentinel (see x-token.h). The value word is its own address so eq?'s value-word compare cannot conflate it with a small integer; identity tests use the ADDRESS (C ==, x-lang (obj same?)).
|
extern |