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

S-expression analyser and delimiter for whitespace tokens. More...

#include "x-obj.h"

Go to the source code of this file.

Macros

#define X_SEXP_WHITESPACE_SPACE_STR   " "
 
#define X_SEXP_WHITESPACE_NEWLINE_STR   "\n"
 
#define X_SEXP_WHITESPACE_TAB_STR   "\t"
 
#define X_SEXP_WHITESPACE_CHARS_STR   "\t\n\v\f\r "
 

Functions

x_obj_tx_sexp_whitespace_analyse1 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_whitespace_analyse2 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_whitespace_delimit (x_obj_t *p_base, x_obj_t *p_args)
 

Variables

Analyser / delimiter primitives (satom).
x_satom_t x_sexp_whitespace_analyse1_prim
 
x_satom_t x_sexp_whitespace_analyse2_prim
 
x_satom_t x_sexp_whitespace_delimit_prim
 

Detailed Description

S-expression analyser and delimiter for whitespace tokens.

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

Macro Definition Documentation

◆ X_SEXP_WHITESPACE_CHARS_STR

#define X_SEXP_WHITESPACE_CHARS_STR   "\t\n\v\f\r "

All recognised whitespace characters.

◆ X_SEXP_WHITESPACE_NEWLINE_STR

#define X_SEXP_WHITESPACE_NEWLINE_STR   "\n"

Newline character string.

◆ X_SEXP_WHITESPACE_SPACE_STR

#define X_SEXP_WHITESPACE_SPACE_STR   " "

Space character string.

◆ X_SEXP_WHITESPACE_TAB_STR

#define X_SEXP_WHITESPACE_TAB_STR   "\t"

Tab character string.

Function Documentation

◆ x_sexp_whitespace_analyse1()

x_obj_t * x_sexp_whitespace_analyse1 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 1: detect a whitespace character.

Analyse state 1: detect a whitespace character.

Checks the last character in the buffer against X_SEXP_WHITESPACE_CHARS_STR.

Parameters
p_baseBase (execution context).
p_argsRead-args containing the token buffer.
Returns
The analyse2 primitive on match, or NULL.

◆ x_sexp_whitespace_analyse2()

x_obj_t * x_sexp_whitespace_analyse2 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 2: consume additional whitespace, score on non-whitespace.

Analyse state 2: consume additional whitespace and score.

Re-invokes analyse1 to check for more whitespace. When a non-whitespace character is found, scores bufferlen-1 (the -1 accounts for the extra non-whitespace character that was read to terminate the run).

Parameters
p_baseBase (execution context).
p_argsRead-args containing the token buffer and score.
Returns
Self to keep reading, or score on non-whitespace.

◆ x_sexp_whitespace_delimit()

x_obj_t * x_sexp_whitespace_delimit ( x_obj_t p_base,
x_obj_t p_args 
)

Delimiter callback: back up read pointer on whitespace characters.

Delimiter callback for whitespace characters.

If the current character is whitespace, backs up the read pointer so the whitespace is not consumed by the current token.

Parameters
p_baseBase (execution context).
p_argsRead-args containing the token buffer.
Returns
The buffer on whitespace match, or NULL.

Variable Documentation

◆ x_sexp_whitespace_analyse1_prim

x_satom_t x_sexp_whitespace_analyse1_prim
extern

◆ x_sexp_whitespace_analyse2_prim

x_satom_t x_sexp_whitespace_analyse2_prim

◆ x_sexp_whitespace_delimit_prim

x_satom_t x_sexp_whitespace_delimit_prim