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

S-expression analyser, reader, writer, and display for symbols. More...

#include "x-token/sexp/symbol.h"
#include "x-eval.h"
#include "x-token.h"
#include "x-type/buffer.h"
#include "x-type/str.h"
#include "x-type/symbol.h"

Functions

x_obj_tx_sexp_symbol_analyse (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_symbol_read (x_obj_t *p_base, x_obj_t *p_args)
 

Variables

x_satom_t x_sexp_symbol_analyse_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_symbol_analyse })
 
x_satom_t x_sexp_symbol_read_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_symbol_read })
 

Detailed Description

S-expression analyser, reader, writer, and display for symbols.

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

Function Documentation

◆ x_sexp_symbol_analyse()

x_obj_t * x_sexp_symbol_analyse ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse: match any non-delimiter sequence as a symbol.

Symbols are the fallback token type. If no delimiter is found, the analyser keeps reading. When a delimiter terminates the sequence, the buffer length is scored as a negative value so that more specific types (which score positively) always win ties.

Parameters
p_baseBase (execution context).
p_argsRead-args containing the token buffer and score.
Returns
The args (keep reading), score (on delimiter), or NULL (empty).

◆ x_sexp_symbol_read()

x_obj_t * x_sexp_symbol_read ( x_obj_t p_base,
x_obj_t p_args 
)

Read a symbol from the token buffer.

Copies the buffer contents into a new string, then interns it as a symbol through x_type_symbol_make.

Parameters
p_baseBase (execution context).
p_argsRead-args containing the token buffer.
Returns
An interned symbol object.

Variable Documentation

◆ x_sexp_symbol_analyse_prim

x_satom_t x_sexp_symbol_analyse_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_symbol_analyse })

◆ x_sexp_symbol_read_prim

x_satom_t x_sexp_symbol_read_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_symbol_read })