maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
mlisps.h
Go to the documentation of this file.
1
2#ifndef MLISPS_H
3#define MLISPS_H
4
13#ifndef MLISP_TRACE_LVL
14# define MLISP_TRACE_LVL 0
15#endif /* !MLISP_TRACE_LVL */
16
17#ifndef MLISP_TRACE_SIGIL
18# define MLISP_TRACE_SIGIL "TRACE"
19#endif /* !MLISP_TRACE_SIGIL */
20
21#ifndef MLISP_AST_IDX_CHILDREN_MAX
22# define MLISP_AST_IDX_CHILDREN_MAX 10
23#endif /* !MLISP_AST_IDX_CHILDREN_MAX */
24
29#define MLISP_EXEC_FLAG_DEF_TERM 0x02
30
36typedef ssize_t mlisp_lambda_t;
37
38typedef mlisp_lambda_t mlisp_args_t;
39typedef mlisp_lambda_t mlisp_arge_t;
40typedef mlisp_lambda_t mlisp_if_t;
41typedef mlisp_lambda_t mlisp_begin_t;
42
43typedef uint8_t mlisp_bool_t;
44
50#define MLISP_NUM_TYPE_TABLE( f ) \
51 f( 1, int16_t, integer, INT, "%d" ) \
52 f( 2, float, floating, FLOAT, "%f" ) \
53 f( 3, mlisp_bool_t, boolean, BOOLEAN, "%u" )
54
60#define MLISP_TYPE_TABLE( f ) \
61 MLISP_NUM_TYPE_TABLE( f ) \
62 f( 4, mdata_strpool_idx_t, strpool_idx, STR, SSIZE_T_FMT ) \
63 f( 5, mlisp_env_cb_t, cb, CB, "%p" ) \
64 f( 6, mlisp_lambda_t, lambda, LAMBDA, SSIZE_T_FMT ) \
65 f( 7, mlisp_args_t, args_start, ARGS_S, SSIZE_T_FMT ) \
66 f( 8, mlisp_arge_t, args_end, ARGS_E, SSIZE_T_FMT ) \
67 f(10, mlisp_begin_t, begin, BEGIN, SSIZE_T_FMT )
68
69 /* mlisp_types */
70
71struct MLISP_PARSER;
72struct MLISP_EXEC_STATE;
73
74typedef MERROR_RETVAL (*mlisp_env_cb_t)(
75 struct MLISP_PARSER* parser, struct MLISP_EXEC_STATE* exec, size_t n_idx,
76 size_t args_c, void* cb_data, uint8_t flags );
77
78#define _MLISP_TYPE_TABLE_FIELDS( idx, ctype, name, const_name, fmt ) \
79 ctype name;
80
81union MLISP_VAL {
82 MLISP_TYPE_TABLE( _MLISP_TYPE_TABLE_FIELDS )
83};
84
86 uint8_t flags;
87 uint8_t type;
88 mdata_strpool_idx_t name_strpool_idx;
89 union MLISP_VAL value;
90 void* cb_data;
91};
92
94 uint8_t type;
95 union MLISP_VAL value;
96};
97
99 uint8_t flags;
100 mdata_strpool_idx_t token_idx;
101 size_t token_sz;
102 ssize_t ast_idx_parent;
103 ssize_t env_idx_op;
104 ssize_t ast_idx_children[MLISP_AST_IDX_CHILDREN_MAX];
107};
108
110 uint8_t flags;
112 struct MDATA_VECTOR per_node_visit_ct;
113 struct MDATA_VECTOR per_node_child_idx;
115 struct MDATA_VECTOR stack;
122 struct MDATA_VECTOR env;
127 struct MDATA_VECTOR lambda_trace;
128 void* cb_attachment;
129#ifdef MLISP_DEBUG_TRACE
130 size_t trace[MLISP_DEBUG_TRACE];
131 size_t trace_depth;
132#endif /* MLISP_DEBUG_TRACE */
133};
134
136 struct MPARSER base;
137 struct MDATA_STRPOOL strpool;
138 struct MDATA_VECTOR ast;
139 ssize_t ast_node_iter;
140};
141
142 /* mlisp */
143
144#endif /* !MLISPS_H */
145
int MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition merror.h:19
#define MLISP_TYPE_TABLE(f)
Table of other types.
Definition mlisps.h:60
Definition mlisps.h:98
size_t ast_idx_children_sz
Number of children in MLISP_AST_NODE::ast_idx_children.
Definition mlisps.h:106
Definition mlisps.h:85
Definition mlisps.h:109
struct MDATA_VECTOR lambda_trace
Path through any lambdas the execution has entered during this heartbeat cycle. Used to detect tail c...
Definition mlisps.h:127
struct MDATA_VECTOR per_node_visit_ct
The number of times each node has been visited ever.
Definition mlisps.h:112
struct MDATA_VECTOR stack
A stack of data values resulting from evaluating statements.
Definition mlisps.h:115
struct MDATA_VECTOR env
Environment in which statements are defined.
Definition mlisps.h:122
Definition mlisps.h:135
Definition mlisps.h:93
Definition mlisps.h:81