maug
Quick and dirty C mini-augmentation library.
Modules | Files | Data Structures | Macros | Typedefs | Functions
MLISP Interpreter
Collaboration diagram for MLISP Interpreter:

Modules

 MLISP Commands
 
 MLISP Execution Stack
 
 MLISP Types
 
 MLISP Abstract Syntax Tree Parser
 

Files

file  mlispe.h
 MLISP Interpreter Functions and Macros.
 
file  mlisps.h
 MLISP Interpreter/Parser Structs.
 
file  mlispp.h
 MLISP Parser Functions and Macros.
 

Data Structures

union  MLISP_VAL
 
struct  MLISP_ENV_NODE
 
struct  MLISP_STACK_NODE
 
struct  MLISP_AST_NODE
 
struct  MLISP_EXEC_STATE
 Current execution state to associate with a MLISP_PARSER. More...
 
struct  MLISP_PARSER
 

Macros

#define MLISP_TOKEN_SZ_MAX   4096
 
#define MLISP_EXEC_TRACE_LVL   0
 
#define MLISP_STACK_TRACE_LVL   0
 
#define MLISP_ENV_FLAG_BUILTIN   0x02
 
#define MLISP_ENV_FLAG_CMP_GT   0x10
 Flag for _mlisp_env_cb_cmp() specifying TRUE if A > B.
 
#define MLISP_ENV_FLAG_CMP_LT   0x20
 Flag for _mlisp_env_cb_cmp() specifying TRUE if A < B.
 
#define MLISP_ENV_FLAG_CMP_EQ   0x40
 Flag for _mlisp_env_cb_cmp() specifying TRUE if A == B.
 
#define MLISP_ENV_FLAG_ARI_ADD   0x10
 Flag for _mlisp_env_cb_arithmetic() specifying to add A + B.
 
#define MLISP_ENV_FLAG_ARI_MUL   0x20
 Flag for _mlisp_env_cb_arithmetic() specifying to multiply A * B.
 
#define MLISP_ENV_FLAG_ARI_DIV   0x40
 
#define MLISP_ENV_FLAG_ARI_MOD   0x80
 
#define MLISP_ENV_FLAG_ANO_OR   0x10
 
#define MLISP_ENV_FLAG_ANO_AND   0x20
 
#define MLISP_ENV_FLAG_DEFINE_GLOBAL   0x10
 Flag for _mlisp_env_cb_define() specifying global env.
 
#define MLISP_AUTOLOCK_EXEC_ENV   0x01
 
#define MLISP_AUTOLOCK_CHILD_IDX   0x02
 
#define MLISP_AUTOLOCK_VISIT_CT   0x04
 
#define MLISP_AUTOLOCK_PARSER_AST   0x08
 
#define MLISP_AUTOLOCK_GLOBAL_ENV   0x10
 
#define _MLISP_TYPE_TABLE_PUSH_PROTO(idx, ctype, name, const_name, fmt)
 
#define MLISP_TRACE_LVL   0
 
#define MLISP_EXEC_ENV_FRAME_CT_MAX   10
 
#define MLISP_TRACE_SIGIL   "TRACE"
 
#define MLISP_AST_IDX_CHILDREN_MAX   10
 
#define MLISP_EXEC_FLAG_INITIALIZED   0x08
 
#define _MLISP_TYPE_TABLE_FIELDS(idx, ctype, name, const_name, fmt)    ctype name;
 
#define MLISP_PARSE_TRACE_LVL   0
 
#define MLISP_AST_FLAG_LAMBDA   0x02
 
#define MLISP_AST_FLAG_IF   0x04
 
#define MLISP_AST_FLAG_DEFINE   0x08
 
#define MLISP_AST_FLAG_BEGIN   0x20
 
#define MLISP_PARSER_PSTATE_TABLE(f)
 

Typedefs

typedef MERROR_RETVAL(* mlisp_env_cb_t) (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec, size_t n_idx, size_t args_c, uint8_t *cb_data, uint8_t flags)
 A callback to attach to an mlisp command with mlisp_env_set() with MLISP_TYPE_CB. More...
 

Functions

MERROR_RETVAL mlisp_env_dump (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec, uint8_t global)
 Dump the environment from the given parser/exec combination. More...
 
struct MLISP_ENV_NODEmlisp_env_get (struct MLISP_EXEC_STATE *exec, const char *key)
 
MERROR_RETVAL mlisp_env_unset (struct MLISP_EXEC_STATE *exec, const char *token, size_t token_sz, uint8_t global)
 
MERROR_RETVAL mlisp_env_set (struct MLISP_EXEC_STATE *exec, const char *token, size_t token_sz, uint8_t env_type, const void *data, uint8_t global, uint8_t flags)
 
ssize_t mlisp_count_builtins (struct MLISP_EXEC_STATE *exec)
 
MERROR_RETVAL mlisp_check_state (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec)
 
MERROR_RETVAL mlisp_step (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec)
 Iterate the current exec_state() starting from the next MLISP_AST_NODE to be executed according to the tree of MLISP_EXEC_STATE::per_node_child_idx values.
 
MERROR_RETVAL mlisp_step_lambda (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec, const char *lambda)
 Iterate the current exec_state() starting from the lambda named. More...
 
MERROR_RETVAL mlisp_exec_add_env_builtins (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec)
 
MERROR_RETVAL mlisp_exec_init (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec, uint8_t flags)
 
MERROR_RETVAL mlisp_exec_set_global_env (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec, struct MDATA_TABLE *global_env)
 Set the given exec state to use the given vector as a global variable environment. This can be long-lived and shared with other exec states.
 
void mlisp_exec_free (struct MLISP_EXEC_STATE *exec)
 
MERROR_RETVAL mlisp_deserialize_prepare_EXEC_STATE (struct MLISP_EXEC_STATE *exec, size_t i)
 
MERROR_RETVAL mlisp_parse_c (struct MLISP_PARSER *parser, char c)
 
MERROR_RETVAL mlisp_parse_file (struct MLISP_PARSER *parser, const retroflat_asset_path ai_path)
 
MERROR_RETVAL mlisp_parser_init (struct MLISP_PARSER *parser)
 
void mlisp_parser_free (struct MLISP_PARSER *parser)
 

Detailed Description

Macro Definition Documentation

◆ _MLISP_TYPE_TABLE_PUSH_PROTO

#define _MLISP_TYPE_TABLE_PUSH_PROTO (   idx,
  ctype,
  name,
  const_name,
  fmt 
)
Value:
MERROR_RETVAL _mlisp_stack_push_ ## ctype( \
struct MLISP_EXEC_STATE* exec, ctype i );
uint16_t MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition: merror.h:19
Current execution state to associate with a MLISP_PARSER.
Definition: mlisps.h:136

◆ MLISP_PARSER_PSTATE_TABLE

#define MLISP_PARSER_PSTATE_TABLE (   f)
Value:
f( MLISP_PSTATE_NONE, 0 ) \
f( MLISP_PSTATE_SYMBOL_OP, 1 ) \
f( MLISP_PSTATE_SYMBOL, 2 ) \
f( MLISP_PSTATE_STRING, 3 ) \
f( MLISP_PSTATE_LAMBDA_ARGS, 4 ) \
f( MLISP_PSTATE_COMMENT, 5 )

Typedef Documentation

◆ mlisp_env_cb_t

typedef MERROR_RETVAL(* mlisp_env_cb_t) (struct MLISP_PARSER *parser, struct MLISP_EXEC_STATE *exec, size_t n_idx, size_t args_c, uint8_t *cb_data, uint8_t flags)

A callback to attach to an mlisp command with mlisp_env_set() with MLISP_TYPE_CB.

Parameters
args_cThe number of top-level arguments provided to this callback when it was called.

Function Documentation

◆ mlisp_env_dump()

MERROR_RETVAL mlisp_env_dump ( struct MLISP_PARSER parser,
struct MLISP_EXEC_STATE exec,
uint8_t  global 
)

Dump the environment from the given parser/exec combination.

Warning
This is only available if MLISP_DUMP_ENABLED is defined at compile time!

◆ mlisp_step_lambda()

MERROR_RETVAL mlisp_step_lambda ( struct MLISP_PARSER parser,
struct MLISP_EXEC_STATE exec,
const char *  lambda 
)

Iterate the current exec_state() starting from the lambda named.

This should be called repeatedly in place of mlisp_step() until MERROR_PREEMPT is no longer returned so that the lambda is able to complete its execution.

Warning
The script should be run normally with mlisp_step() until it returns MERROR_EXEC, so that lambdas defined by the script are present in the env to be stepped from!