x-engine-c v0.2.13
The C engine for x-lang
Loading...
Searching...
No Matches
char.h File Reference

S-expression analyser and reader for character literals. More...

#include "x-obj.h"

Go to the source code of this file.

Macros

#define X_SEXP_CHAR_PRE_STR   "#\\"
 

Functions

x_obj_tx_sexp_char_analyse1 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_char_analyse2 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_char_analyse3 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_char_read (x_obj_t *p_base, x_obj_t *p_args)
 

Variables

Analyser state primitives (spair – composable state machines).
x_spair_t x_sexp_char_analyse1_prim
 
x_spair_t x_sexp_char_analyse2_prim
 
x_spair_t x_sexp_char_analyse3_prim
 
Read primitives (satom – type-internal).
x_satom_t x_sexp_char_read_prim
 

Detailed Description

S-expression analyser and reader for character literals.

Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Macro Definition Documentation

◆ X_SEXP_CHAR_PRE_STR

#define X_SEXP_CHAR_PRE_STR   "#\\"

Character literal prefix.

Function Documentation

◆ x_sexp_char_analyse1()

x_obj_t * x_sexp_char_analyse1 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 1: match first char of #\ prefix.

Analyse state 1: match first character of the #\ prefix.

Parameters
p_baseBase (execution context).
p_argsPair of (self, read-args).
Returns
Next analyser state, or NULL on mismatch.

◆ x_sexp_char_analyse2()

x_obj_t * x_sexp_char_analyse2 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 2: match second char of #\ prefix.

Analyse state 2: match second character of the #\ prefix.

Parameters
p_baseBase (execution context).
p_argsPair of (self, read-args).
Returns
Next analyser state, or NULL on mismatch.

◆ x_sexp_char_analyse3()

x_obj_t * x_sexp_char_analyse3 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 3: classify single character vs. named character start.

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_baseBase (execution context).
p_argsPair of (self, read-args).
Returns
Score object on match, next state for named chars, or NULL.

◆ x_sexp_char_read()

x_obj_t * x_sexp_char_read ( x_obj_t p_base,
x_obj_t p_args 
)

Read a character literal from the token buffer.

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_baseBase (execution context).
p_argsRead-args containing the token buffer.
Returns
A newly created character object, or NULL on error.
Note
Signals an error for unknown character names.

Variable Documentation

◆ x_sexp_char_analyse1_prim

x_spair_t x_sexp_char_analyse1_prim
extern

◆ x_sexp_char_analyse2_prim

x_spair_t x_sexp_char_analyse2_prim

◆ x_sexp_char_analyse3_prim

x_spair_t x_sexp_char_analyse3_prim

◆ x_sexp_char_read_prim

x_satom_t x_sexp_char_read_prim
extern