|
x-engine-c v0.2.13
The C engine for x-lang
|
S-expression analyser, reader, and writer for integer literals. More...
#include <ctype.h>#include "x-token/sexp/int.h"#include "x-token.h"#include "x-type/char.h"#include "x-type/buffer.h"#include "x-type/int.h"#include "x-type/prim.h"Macros | |
| #define | x_next_state(self, dflt) |
Functions | |
| x_obj_t * | x_sexp_int_analyse_digits (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_sexp_int_analyse_xdigits (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_sexp_int_analyse_base (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_sexp_int_analyse_prefix (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_sexp_int_analyse_sign (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_sexp_int_read (x_obj_t *p_base, x_obj_t *p_args) |
Variables | |
| x_spair_t | x_sexp_int_analyse_sign_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_sign }, { NULL }) |
| x_spair_t | x_sexp_int_analyse_prefix_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_prefix }, { NULL }) |
| x_spair_t | x_sexp_int_analyse_base_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_base }, { NULL }) |
| x_spair_t | x_sexp_int_analyse_digits_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_digits }, { NULL }) |
| x_spair_t | x_sexp_int_analyse_xdigits_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_xdigits }, { NULL }) |
| x_satom_t | x_sexp_int_read_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_read }) |
S-expression analyser, reader, and writer for integer literals.
| #define x_next_state | ( | self, | |
| dflt | |||
| ) |
Read next-state from callable state slot, with default fallback.
Analyse: detect 0x/ prefix or fall through to decimal.0X hex
If the current character is x or X, transitions to the xdigits state. Otherwise delegates to the digits analyser.
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
Analyse: consume decimal digits and score.
Returns self while digits are being read. On a non-digit, backs up the read pointer and scores the buffer length (or returns NULL if no digits were consumed).
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
Analyse: handle leading 0 (possible hex prefix) or first digit.
A leading 0 transitions to the base state; other digits delegate to the digits analyser; non-digits cause rejection.
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
Analyse: handle optional leading + or - sign.
If a sign character is found, transitions to the prefix state. Otherwise delegates directly to the prefix analyser.
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
Analyse: consume hexadecimal digits and score.
Identical logic to analyse_digits but accepts 0-9, a-f, A-F.
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
Read an integer literal from the token buffer.
Parses the buffer contents with x_lib_strtoint using base 0 (auto-detecting decimal, octal, or hexadecimal).
| p_base | Base (execution context). |
| p_args | Read-args whose first element is the token buffer. |
| x_spair_t x_sexp_int_analyse_base_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_base }, { NULL }) |
| x_spair_t x_sexp_int_analyse_digits_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_digits }, { NULL }) |
| x_spair_t x_sexp_int_analyse_prefix_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_prefix }, { NULL }) |
| x_spair_t x_sexp_int_analyse_sign_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_sign }, { NULL }) |
| x_spair_t x_sexp_int_analyse_xdigits_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_analyse_xdigits }, { NULL }) |
| x_satom_t x_sexp_int_read_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_int_read }) |