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

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

#include "x-obj.h"

Go to the source code of this file.

Functions

x_obj_tx_sexp_int_analyse_digits (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_int_analyse_xdigits (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_int_analyse_base (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_int_analyse_prefix (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_int_analyse_sign (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_int_read (x_obj_t *p_base, x_obj_t *p_args)
 

Variables

Analyser state primitives (spair – composable state machines).
x_spair_t x_sexp_int_analyse_sign_prim
 
x_spair_t x_sexp_int_analyse_prefix_prim
 
x_spair_t x_sexp_int_analyse_base_prim
 
x_spair_t x_sexp_int_analyse_digits_prim
 
x_spair_t x_sexp_int_analyse_xdigits_prim
 
Read primitives (satom – type-internal).
x_satom_t x_sexp_int_read_prim
 

Detailed Description

S-expression analyser and reader for integer literals.

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

Function Documentation

◆ x_sexp_int_analyse_base()

x_obj_t * x_sexp_int_analyse_base ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse: detect 0x hex prefix or fall through to decimal digits.

Analyse: detect 0x/0X hex prefix or fall through to decimal.

If the current character is x or X, transitions to the xdigits state. Otherwise delegates to the digits analyser.

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

◆ x_sexp_int_analyse_digits()

x_obj_t * x_sexp_int_analyse_digits ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse: consume decimal digits and score.

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).

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

◆ x_sexp_int_analyse_prefix()

x_obj_t * x_sexp_int_analyse_prefix ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse: handle leading 0 (possible hex prefix) or first digit.

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.

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

◆ x_sexp_int_analyse_sign()

x_obj_t * x_sexp_int_analyse_sign ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse: handle optional leading +/- sign.

Analyse: handle optional leading + or - sign.

If a sign character is found, transitions to the prefix state. Otherwise delegates directly to the prefix analyser.

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

◆ x_sexp_int_analyse_xdigits()

x_obj_t * x_sexp_int_analyse_xdigits ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse: consume hexadecimal digits and score.

Analyse: consume hexadecimal digits and score.

Identical logic to analyse_digits but accepts 0-9, a-f, A-F.

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

◆ x_sexp_int_read()

x_obj_t * x_sexp_int_read ( x_obj_t p_base,
x_obj_t p_args 
)

Read an integer literal from the token buffer.

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).

Parameters
p_baseBase (execution context).
p_argsRead-args whose first element is the token buffer.
Returns
A newly created integer object, or NULL on empty buffer.

Variable Documentation

◆ x_sexp_int_analyse_base_prim

x_spair_t x_sexp_int_analyse_base_prim

◆ x_sexp_int_analyse_digits_prim

x_spair_t x_sexp_int_analyse_digits_prim

◆ x_sexp_int_analyse_prefix_prim

x_spair_t x_sexp_int_analyse_prefix_prim

◆ x_sexp_int_analyse_sign_prim

x_spair_t x_sexp_int_analyse_sign_prim
extern

◆ x_sexp_int_analyse_xdigits_prim

x_spair_t x_sexp_int_analyse_xdigits_prim

◆ x_sexp_int_read_prim

x_satom_t x_sexp_int_read_prim
extern