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

S-expression analyser and delimiter for line comments. More...

#include "x-token/sexp/comment.h"
#include "x-eval.h"
#include "x-token.h"
#include "x-type/buffer.h"
#include "x-type/char.h"

Functions

x_obj_tx_sexp_comment_analyse1 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_comment_analyse2 (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_sexp_comment_delimit (x_obj_t *p_base, x_obj_t *p_args)
 

Variables

x_satom_t x_sexp_comment_analyse1_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_comment_analyse1 })
 
x_satom_t x_sexp_comment_analyse2_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_comment_analyse2 })
 
x_satom_t x_sexp_comment_delimit_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_comment_delimit })
 

Detailed Description

S-expression analyser and delimiter for line comments.

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

Function Documentation

◆ x_sexp_comment_analyse1()

x_obj_t * x_sexp_comment_analyse1 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 1: detect the comment start delimiter.

Compares the buffer contents against X_SEXP_COMMENT_PRE_STR.

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

◆ x_sexp_comment_analyse2()

x_obj_t * x_sexp_comment_analyse2 ( x_obj_t p_base,
x_obj_t p_args 
)

Analyse state 2: consume characters until end-of-line.

Continues reading until X_SEXP_COMMENT_POST_STR is found, then scores the full comment length.

Parameters
p_baseBase (execution context).
p_argsRead-args containing the token buffer and score.
Returns
Score on end-of-line match, or self to keep reading.

◆ x_sexp_comment_delimit()

x_obj_t * x_sexp_comment_delimit ( x_obj_t p_base,
x_obj_t p_args 
)

Delimiter callback for comment characters.

If the last character in the buffer is a comment-start character, backs up the read pointer so the comment is not consumed by the current token, and returns the buffer to signal delimiting.

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

Variable Documentation

◆ x_sexp_comment_analyse1_prim

x_satom_t x_sexp_comment_analyse1_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_comment_analyse1 })

◆ x_sexp_comment_analyse2_prim

x_satom_t x_sexp_comment_analyse2_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_comment_analyse2 })

◆ x_sexp_comment_delimit_prim

x_satom_t x_sexp_comment_delimit_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .fn = x_sexp_comment_delimit })