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

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

#include "x-obj.h"

Go to the source code of this file.

Macros

#define X_SEXP_STR_PRE_STR   "\""
 
#define X_SEXP_STR_PRE_STR_LEN   1
 
#define X_SEXP_STR_POST_STR   X_SEXP_STR_PRE_STR
 
#define X_SEXP_STR_POST_STR_LEN   X_SEXP_STR_PRE_STR_LEN
 
#define X_SEXP_STR_CHARS_STR   X_SEXP_STR_PRE_STR
 

Functions

x_obj_tx_sexp_str_analyse1 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_str_analyse2 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_str_analyse3 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_str_read (x_obj_t *p_base, x_obj_t *p_args)
 

Variables

Analyser state primitives (spair – composable state machines).
x_spair_t x_sexp_str_analyse1_prim
 
x_spair_t x_sexp_str_analyse2_prim
 
x_spair_t x_sexp_str_analyse3_prim
 
Read primitives (satom – type-internal).
x_satom_t x_sexp_str_read_prim
 

Detailed Description

S-expression analyser and reader for string literals.

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

Macro Definition Documentation

◆ X_SEXP_STR_CHARS_STR

#define X_SEXP_STR_CHARS_STR   X_SEXP_STR_PRE_STR

Characters that delimit other tokens.

◆ X_SEXP_STR_POST_STR

#define X_SEXP_STR_POST_STR   X_SEXP_STR_PRE_STR

String close delimiter.

◆ X_SEXP_STR_POST_STR_LEN

#define X_SEXP_STR_POST_STR_LEN   X_SEXP_STR_PRE_STR_LEN

Length of string close delimiter.

◆ X_SEXP_STR_PRE_STR

#define X_SEXP_STR_PRE_STR   "\""

String open delimiter.

◆ X_SEXP_STR_PRE_STR_LEN

#define X_SEXP_STR_PRE_STR_LEN   1

Length of string open delimiter.

Function Documentation

◆ x_sexp_str_analyse1()

x_obj_t * x_sexp_str_analyse1 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 1: match the opening quote.

Analyse state 1: match the opening double-quote.

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

◆ x_sexp_str_analyse2()

x_obj_t * x_sexp_str_analyse2 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 2: consume body characters, detect escape or close.

Analyse state 2: consume string body characters.

Detects backslash (transitions to escape state) and closing quote (scores the full token length). All other characters loop.

Parameters
p_baseBase (execution context).
p_argsPair of (self, read-args).
Returns
Self, score, or next state.

◆ x_sexp_str_analyse3()

x_obj_t * x_sexp_str_analyse3 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 3: escape state – consume one character after backslash.

Analyse state 3: escape state.

Unconditionally consumes one character after a backslash and returns to the normal body-reading state (analyse2).

Parameters
p_baseBase (execution context).
p_argsPair of (self, read-args).
Returns
The analyse2 state primitive.

◆ x_sexp_str_read()

x_obj_t * x_sexp_str_read ( x_obj_t p_base,
x_obj_t p_args 
)

Read a string literal from the token buffer (with unescape).

Read a string literal from the token buffer.

Strips the surrounding quotes and processes escape sequences in-place. Supported escapes: \", \\, \n, \t, \r, \0, and \xHH (two hex digits). Unknown escapes are preserved literally.

Parameters
p_baseBase (execution context).
p_argsRead-args containing the token buffer.
Returns
A newly created owned-string object.

Variable Documentation

◆ x_sexp_str_analyse1_prim

x_spair_t x_sexp_str_analyse1_prim
extern

◆ x_sexp_str_analyse2_prim

x_spair_t x_sexp_str_analyse2_prim

◆ x_sexp_str_analyse3_prim

x_spair_t x_sexp_str_analyse3_prim

◆ x_sexp_str_read_prim

x_satom_t x_sexp_str_read_prim
extern