S-expression analyser, reader, and writer for character literals.
More...
|
| x_spair_t | x_sexp_char_analyse1_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_char_analyse1 }, { NULL }) |
| |
| x_spair_t | x_sexp_char_analyse2_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_char_analyse2 }, { NULL }) |
| |
| x_spair_t | x_sexp_char_analyse3_prim = x_obj_set(NULL, X_OBJ_FLAG_NONE, { .fn = x_sexp_char_analyse3 }, { NULL }) |
| |
| x_satom_t | x_sexp_char_read_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_char_read }) |
| |
| static x_spair_t | x_sexp_char_analyse4_prim |
| |
| static x_spair_t | x_sexp_char_analyse_utf8_prim |
| |
S-expression analyser, reader, and writer for character literals.
- Author
- Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
- Copyright
- 2023 Jon Ruttan @license MIT No Attribution (MIT-0)
◆ x_next_state
| #define x_next_state |
( |
|
self, |
|
|
|
dflt |
|
) |
| |
Value:
int x_obj_isnil(x_obj_t *p_base, x_obj_t *p_obj)
Definition x-obj.c:54
#define x_callable_state(X)
Definition prim.h:40
Read next-state from callable state slot, with default fallback.
◆ is_lower()
◆ x_sexp_char_analyse1()
Analyse state 1: match first character of the #\ prefix.
- Parameters
-
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
- Returns
- Next analyser state, or NULL on mismatch.
◆ x_sexp_char_analyse2()
Analyse state 2: match second character of the #\ prefix.
- Parameters
-
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
- Returns
- Next analyser state, or NULL on mismatch.
◆ x_sexp_char_analyse3()
Analyse state 3: classify character after prefix.
A lowercase letter transitions to the named-character state (analyse4). Any other character scores immediately as a single-char literal.
- Parameters
-
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
- Returns
- Score object on match, next state for named chars, or NULL.
◆ x_sexp_char_analyse4()
Analyse state 4 (static): named-character continuation.
Keeps consuming lowercase letters. On a non-letter delimiter the read pointer is backed up and the accumulated length is scored.
- Parameters
-
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
- Returns
- Self to keep reading, or score on delimiter.
◆ x_sexp_char_analyse_utf8()
Analyse UTF-8 continuation: consume 10xxxxxx bytes.
Reached after a multi-byte lead byte. Keeps consuming continuation bytes (0x80-0xBF). On the first non-continuation byte the read pointer is backed up and the accumulated length is scored.
- Parameters
-
| p_base | Base (execution context). |
| p_args | Pair of (self, read-args). |
- Returns
- Self to keep reading, or score at the end of the sequence.
◆ x_sexp_char_read()
Read a character literal from the token buffer.
Handles single-character literals (#\c, length 3) and named characters (e.g. #\newline) by looking up the name in the character type's data alist.
- Parameters
-
| p_base | Base (execution context). |
| p_args | Read-args containing the token buffer. |
- Returns
- A newly created character object, or NULL on error.
- Note
- Signals an error for unknown character names.
◆ x_sexp_char_analyse1_prim
◆ x_sexp_char_analyse2_prim
◆ x_sexp_char_analyse3_prim
◆ x_sexp_char_analyse4_prim
Initial value:=
@ X_OBJ_FLAG_NONE
Definition x-obj.h:129
#define x_obj_set(T, F,...)
Definition x-obj.h:342
static x_obj_t * x_sexp_char_analyse4(x_obj_t *p_base, x_obj_t *p_args)
Definition char.c:130
◆ x_sexp_char_analyse_utf8_prim
Initial value:=
static x_obj_t * x_sexp_char_analyse_utf8(x_obj_t *p_base, x_obj_t *p_args)
Definition char.c:158
◆ x_sexp_char_read_prim