edelib
2.1.0
|
Macros | |
#define | edelib_scheme_init_raw scheme_init_new |
#define | edelib_scheme_deinit scheme_deinit |
#define | edelib_scheme_load_file scheme_load_file |
#define | edelib_scheme_load_named_file scheme_load_named_file |
#define | edelib_scheme_load_string scheme_load_string |
#define | edelib_scheme_eval scheme_eval |
#define | edelib_scheme_apply0 scheme_apply0 |
#define | edelib_scheme_set_external_data scheme_set_external_data |
#define | edelib_scheme_get_external_data(sc) (sc)->ext_data |
#define | edelib_scheme_define scheme_define |
#define | edelib_scheme_call scheme_call |
#define | edelib_scheme_set_input_port_file scheme_set_input_port_file |
#define | edelib_scheme_set_output_port_file scheme_set_output_port_file |
#define | edelib_scheme_set_input_port_string scheme_set_input_port_string |
#define | edelib_scheme_set_output_port_string scheme_set_output_port_string |
#define | edelib_scheme_gensym(sc) (sc)->vptr->gensym(sc) |
#define | edelib_scheme_cons(sc, a, b) _cons((sc), a, b, 0) |
#define | edelib_scheme_immutable_cons(sc, a, b) _cons((sc), a, b, 1) |
#define | edelib_scheme_reserve_cells(sc, n) (sc)->vptr->reserve_cells(sc, n) |
#define | edelib_scheme_mk_int(sc, num) (sc)->vptr->mk_integer(sc, num) |
#define | edelib_scheme_mk_double(sc, num) (sc)->vptr->mk_real(sc, num) |
#define | edelib_scheme_mk_symbol(sc, sym) (sc)->vptr->mk_symbol(sc, sym) |
#define | edelib_scheme_mk_string(sc, str) (sc)->vptr->mk_string(sc, str) |
#define | edelib_scheme_mk_string_counted(sc, str) (sc)->vptr->mk_counted_string(sc, str) |
#define | EDELIB_SCHEME_DEFINE(sc, func_ptr, func_name) |
#define | EDELIB_SCHEME_DEFINE2(sc, func_ptr, func_name, doc) |
#define | EDELIB_SCHEME_IS_NIL(sc, var) ((var) == sc->NIL) |
Typedefs | |
typedef scheme | edelib_scheme_t |
typedef pointer | edelib_scheme_pointer_t |
Functions | |
scheme * | edelib_scheme_init (void) |
This code provides Scheme interpreter and implements most of R5RS specification. The backend is based on tinyscheme.
If you are not familiar with Scheme, you can find numerous tutorials online about this language. Here are two, quite suitable for begginers:
To initialize interpreter you start with edelib_scheme_init or edelib_scheme_init_raw, which will return interpreter object. As interpreter does not use any global state, you can safely run multiple interpreter instances in different threads.
#define edelib_scheme_apply0 scheme_apply0 |
Call a scheme function without arguments.
#define edelib_scheme_call scheme_call |
Calls scheme function.
#define edelib_scheme_cons | ( | sc, | |
a, | |||
b | |||
) | _cons((sc), a, b, 0) |
Construct a new list by prepending a element in b list. Element can be any scheme object.
#define edelib_scheme_define scheme_define |
Defines a new function. You shoud use EDELIB_SCHEME_DEFINE or EDELIB_SCHEME_DEFINE2 instead.
#define EDELIB_SCHEME_DEFINE | ( | sc, | |
func_ptr, | |||
func_name | |||
) |
Define new scheme function.
#define EDELIB_SCHEME_DEFINE2 | ( | sc, | |
func_ptr, | |||
func_name, | |||
doc | |||
) |
Define new scheme function with documentation.
#define edelib_scheme_deinit scheme_deinit |
Deinitialize and clear scheme interpeter object.
#define edelib_scheme_eval scheme_eval |
Call a scheme function with arguments.
#define edelib_scheme_gensym | ( | sc | ) | (sc)->vptr->gensym(sc) |
Generate unique symbol on every invocation. This is mostly useful inside macros.
#define edelib_scheme_get_external_data | ( | sc | ) | (sc)->ext_data |
Get data set with edelib_scheme_set_external_data.
#define edelib_scheme_immutable_cons | ( | sc, | |
a, | |||
b | |||
) | _cons((sc), a, b, 1) |
Same as edelib_scheme_cons, except immutable list is created.
#define edelib_scheme_init_raw scheme_init_new |
Initialize scheme interpeter, but will not load any code. Useful for explicitly loading desired bootstrap code.
#define EDELIB_SCHEME_IS_NIL | ( | sc, | |
var | |||
) | ((var) == sc->NIL) |
Macro for checking if given variable nil (NULL in scheme parlance).
#define edelib_scheme_load_file scheme_load_file |
Load scheme source from file.
#define edelib_scheme_load_named_file scheme_load_named_file |
Load scheme source from file, but provide filename for error report.
#define edelib_scheme_load_string scheme_load_string |
Load scheme source from string.
#define edelib_scheme_mk_double | ( | sc, | |
num | |||
) | (sc)->vptr->mk_real(sc, num) |
Convert double to scheme number.
#define edelib_scheme_mk_int | ( | sc, | |
num | |||
) | (sc)->vptr->mk_integer(sc, num) |
Convert integer to scheme number.
#define edelib_scheme_mk_string | ( | sc, | |
str | |||
) | (sc)->vptr->mk_string(sc, str) |
Convert C string to scheme string.
#define edelib_scheme_mk_string_counted | ( | sc, | |
str | |||
) | (sc)->vptr->mk_counted_string(sc, str) |
Convert C string to counted scheme string.
#define edelib_scheme_mk_symbol | ( | sc, | |
sym | |||
) | (sc)->vptr->mk_symbol(sc, sym) |
Make scheme symbol.
#define edelib_scheme_reserve_cells | ( | sc, | |
n | |||
) | (sc)->vptr->reserve_cells(sc, n) |
Reserve given number of cells.
#define edelib_scheme_set_external_data scheme_set_external_data |
Set additional data (pointer) accessible from scheme function. You can get data with edelib_scheme_get_external_data
#define edelib_scheme_set_input_port_file scheme_set_input_port_file |
Set FILE object as input port.
#define edelib_scheme_set_input_port_string scheme_set_input_port_string |
Set character array as input port. You should give pointer to the first element and pointer to the last.
#define edelib_scheme_set_output_port_file scheme_set_output_port_file |
Set FILE object as output port.
#define edelib_scheme_set_output_port_string scheme_set_output_port_string |
Set character array as output port. You should give pointer to the first element and pointer to the last.
typedef pointer edelib_scheme_pointer_t |
Alias for internal pointer object.
typedef scheme edelib_scheme_t |
Alias for internal scheme object.
scheme* edelib_scheme_init | ( | void | ) |
Initialize scheme interpreter and returns scheme object. By default, it will try to search bootstrap files in builtin path (depends on –prefix when configure script was run). This can be overridden by setting EDELIB_SCHEME_INIT environment variable with explicitly given bootstrap files and their absolute path. The paths should be separated with : (just as PATH), e.g. path/init.ss:path/init-2.ss:/path/other.ss.