49#ifndef MICROLISP_MICROLISP_H
50#define MICROLISP_MICROLISP_H
53#include "microlisp/version.h"
174 void *(*alloc)(
size_t size,
void *
user);
184#define MICROLISP_DEFAULT_MAX_READ_DEPTH 256
187#define MICROLISP_DEFAULT_MAX_EVAL_DEPTH 1024
190#define MICROLISP_DEFAULT_MAX_PRINT_DEPTH 1024
193#define MICROLISP_DEFAULT_MAX_EQUAL_DEPTH 1024
327 FILE *in_file, FILE *out_file,
#define MICROLISP_API
Definition export.h:26
#define MICROLISP_NODISCARD
Definition export.h:36
MICROLISP_API const char * microlisp_status_string(microlisp_status status)
Human-readable name of a status code.
Definition status.c:13
MICROLISP_API MICROLISP_NODISCARD microlisp_status microlisp_state_create(const microlisp_options *opts, microlisp_state **out_state)
Create a fresh interpreter state with the built-in primitive bindings loaded in the top-level environ...
Definition state.c:112
MICROLISP_API MICROLISP_NODISCARD microlisp_status microlisp_eval(microlisp_state *state, const char *source, size_t source_len, char **out_bytes, size_t *out_len)
Evaluate a source buffer of Scheme code as a sequence of top-level forms.
Definition state.c:225
MICROLISP_API const char * microlisp_state_error(const microlisp_state *state)
Retrieve a human-readable description of the most recent error on state.
Definition state.c:65
MICROLISP_API MICROLISP_NODISCARD microlisp_status microlisp_repl(microlisp_state *state, FILE *in_file, FILE *out_file, const char *prompt)
Run an interactive Read-Eval-Print Loop reading from in_file and writing prompts and results to out_f...
Definition state.c:328
MICROLISP_API void microlisp_buffer_free(microlisp_state *state, char *bytes)
Free a buffer previously returned by microlisp_eval via out_bytes .
Definition state.c:310
microlisp_status
Error and status codes returned by every fallible API entry point.
Definition microlisp.h:71
@ MICROLISP_ERR_UNBOUND
Evaluator looked up a symbol that has no binding in any frame of the active environment.
Definition microlisp.h:95
@ MICROLISP_OK
Success.
Definition microlisp.h:73
@ MICROLISP_ERR_ARITY
Procedure called with the wrong number of arguments.
Definition microlisp.h:102
@ MICROLISP_ERR_TYPE
Evaluator received a value of the wrong type – e.g.
Definition microlisp.h:99
@ MICROLISP_ERR_SYNTAX
Malformed special form – e.g.
Definition microlisp.h:121
@ MICROLISP_ERR_IO
An output stream reported a write error during display , write , or newline , or while writing the re...
Definition microlisp.h:117
@ MICROLISP_ERR_READ_TRUNCATED
Reader reached end-of-input mid-form (e.g.
Definition microlisp.h:87
@ MICROLISP_ERR_DIV_ZERO
Division by zero in / , quotient , remainder , or modulo .
Definition microlisp.h:106
@ MICROLISP_ERR_READ_DEPTH
Reader nesting depth exceeded the configured limit (DoS guard against pathologically deep inputs).
Definition microlisp.h:91
@ MICROLISP_ERR_PRINT_DEPTH
Printer recursion depth exceeded the configured limit.
Definition microlisp.h:136
@ MICROLISP_ERR_NOMEM
Allocator (or platform malloc) returned NULL.
Definition microlisp.h:79
@ MICROLISP_ERR_OVERFLOW
Integer operation would overflow the int64_t range.
Definition microlisp.h:109
@ MICROLISP_ERR_EQUAL_DEPTH
Structural-equality (eqv?, equal?) recursion depth exceeded the configured limit.
Definition microlisp.h:144
@ MICROLISP_ERR_READ_SYNTAX
Reader encountered a syntax error – bad token, unmatched paren, malformed string escape,...
Definition microlisp.h:83
@ MICROLISP_ERR_INVALID_ARG
A required argument was NULL or otherwise structurally invalid.
Definition microlisp.h:76
@ MICROLISP_ERR_EVAL_DEPTH
Evaluator recursion depth exceeded the configured limit.
Definition microlisp.h:127
@ MICROLISP_ERR_USER
A Scheme program invoked the error built-in.
Definition microlisp.h:113
MICROLISP_API const char * microlisp_version(void)
Library version (e.g.
Definition version.c:8
MICROLISP_API void microlisp_state_error_position(const microlisp_state *state, size_t *out_line, size_t *out_column)
Source position of the most recent error, as line and column (both 1-based).
Definition state.c:72
MICROLISP_API void microlisp_state_destroy(microlisp_state *state)
Destroy a state, releasing its GC heap and all interned symbols.
Definition state.c:189
Caller-supplied allocator.
Definition microlisp.h:163
void * user
Opaque user data passed verbatim to alloc and free.
Definition microlisp.h:180
void(* free)(void *ptr, void *user)
Free a pointer previously returned by alloc.
Definition microlisp.h:178
Options controlling a state.
Definition microlisp.h:199
size_t max_equal_depth
Maximum structural-equality walk depth.
Definition microlisp.h:229
size_t max_read_depth
Maximum reader nesting depth.
Definition microlisp.h:206
size_t max_eval_depth
Maximum evaluator recursion depth.
Definition microlisp.h:214
size_t max_print_depth
Maximum printer pair-walk depth.
Definition microlisp.h:222
size_t gc_initial_threshold
Hard ceiling on heap objects between GC collections.
Definition microlisp.h:236
const microlisp_allocator * allocator
Allocator.
Definition microlisp.h:201
Definition microlisp_internal.h:267