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

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

#include "x-obj.h"

Go to the source code of this file.

Macros

#define X_SEXP_COMMENT_PRE_STR   ";"
 
#define X_SEXP_COMMENT_PRE_STR_LEN   1
 
#define X_SEXP_COMMENT_POST_STR   "\n"
 
#define X_SEXP_COMMENT_POST_STR_LEN   1
 
#define X_SEXP_COMMENT_CHARS_STR   X_SEXP_COMMENT_PRE_STR
 

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

Analyser / delimiter primitives (satom).
x_satom_t x_sexp_comment_analyse1_prim
 
x_satom_t x_sexp_comment_analyse2_prim
 
x_satom_t x_sexp_comment_delimit_prim
 

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)

Macro Definition Documentation

◆ X_SEXP_COMMENT_CHARS_STR

#define X_SEXP_COMMENT_CHARS_STR   X_SEXP_COMMENT_PRE_STR

Characters that delimit other tokens.

◆ X_SEXP_COMMENT_POST_STR

#define X_SEXP_COMMENT_POST_STR   "\n"

Comment end delimiter.

◆ X_SEXP_COMMENT_POST_STR_LEN

#define X_SEXP_COMMENT_POST_STR_LEN   1

Length of comment end delimiter.

◆ X_SEXP_COMMENT_PRE_STR

#define X_SEXP_COMMENT_PRE_STR   ";"

Comment start delimiter.

◆ X_SEXP_COMMENT_PRE_STR_LEN

#define X_SEXP_COMMENT_PRE_STR_LEN   1

Length of comment start delimiter.

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.

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.

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: back up read pointer on comment-start char.

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
extern

◆ x_sexp_comment_analyse2_prim

x_satom_t x_sexp_comment_analyse2_prim

◆ x_sexp_comment_delimit_prim

x_satom_t x_sexp_comment_delimit_prim