Hyperon C
Loading...
Searching...
No Matches
hyperon.h
Go to the documentation of this file.
1#ifndef HYPERON_H
2#define HYPERON_H
3
5/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
6
7
8#include <stdarg.h>
9#include <stdbool.h>
10#include <stdint.h>
11#include <stdlib.h>
12struct gnd_t;
13
33
57
77
101
150
151typedef struct RustBindings RustBindings;
152
153typedef struct RustBindingsSet RustBindingsSet;
154
155typedef struct RustEnvBuilder RustEnvBuilder;
156
157typedef struct RustMetta RustMetta;
158
163
164typedef struct RustModuleDescriptor RustModuleDescriptor;
165
166typedef struct RustOpaqueAtom RustOpaqueAtom;
167
168typedef struct RustOpaqueExecError RustOpaqueExecError;
169
170typedef struct RustOpaqueSpace RustOpaqueSpace;
171
172typedef struct RustRunContext RustRunContext;
173
174typedef struct RustRunnerState RustRunnerState;
175
176typedef struct RustSpaceCommonData RustSpaceCommonData;
177
178typedef struct RustSpaceEvent RustSpaceEvent;
179
180typedef struct RustSpaceObserver RustSpaceObserver;
181
182typedef struct RustStepResult RustStepResult;
183
184typedef struct RustSyntaxNode RustSyntaxNode;
185
186typedef struct RustTokenizer RustTokenizer;
187
194typedef struct write_t {
195 const void *_0;
196} write_t;
197
198typedef enum RustAtom_Tag {
199 None,
200 Owned,
201 Borrowed,
202} RustAtom_Tag;
203
204typedef struct RustAtom {
205 RustAtom_Tag tag;
206 union {
207 struct {
208 struct RustOpaqueAtom *owned;
209 };
210 struct {
211 const struct RustOpaqueAtom *borrowed;
212 };
213 };
214} RustAtom;
215
226typedef struct RustAtom atom_ref_t;
227
236typedef struct RustAtom atom_t;
237
246typedef struct atom_vec_t {
250 struct RustOpaqueAtom *ptr;
254 uintptr_t len;
258 uintptr_t capacity;
262 bool owned;
263} atom_vec_t;
264
273typedef enum exec_error_t_Tag {
274 NoErr,
275 Status,
276} exec_error_t_Tag;
277
278typedef struct exec_error_t {
279 exec_error_t_Tag tag;
280 union {
281 struct {
282 struct RustOpaqueExecError *status;
283 };
284 };
286
292typedef struct bindings_set_t {
296 struct RustBindingsSet *set;
298
305typedef struct serializer_api_t {
313 enum serial_result_t (*serialize_bool)(void *context, bool v);
321 enum serial_result_t (*serialize_longlong)(void *context, long long v);
329 enum serial_result_t (*serialize_double)(void *context, double v);
337 enum serial_result_t (*serialize_str)(void *context, const char *v);
339
348typedef struct gnd_api_t {
358 struct exec_error_t (*execute)(const struct gnd_t *gnd,
359 const struct atom_vec_t *args,
360 struct atom_vec_t *out);
370 struct bindings_set_t (*match_)(const struct gnd_t *gnd, const atom_ref_t *other);
379 enum serial_result_t (*serialize)(const struct gnd_t *gnd,
380 const struct serializer_api_t *api,
381 void *context);
389 bool (*eq)(const struct gnd_t *gnd, const struct gnd_t *other);
397 struct gnd_t *(*clone)(const struct gnd_t *gnd);
408 uintptr_t (*display)(const struct gnd_t *gnd, char *buf, uintptr_t buf_len);
415 void (*free)(struct gnd_t *gnd);
416} gnd_api_t;
417
426typedef struct gnd_t {
430 const struct gnd_api_t *api;
436} gnd_t;
437
448typedef struct space_t {
452 const struct RustOpaqueSpace *space;
453} space_t;
454
462typedef void (*c_atom_vec_callback_t)(const struct atom_vec_t *vec, void *context);
463
471typedef void (*c_atom_callback_t)(atom_ref_t atom, void *context);
472
478typedef struct bindings_t {
482 struct RustBindings *bindings;
483} bindings_t;
484
493typedef void (*c_var_binding_callback_t)(atom_ref_t var, atom_ref_t value, void *context);
494
502typedef void (*bindings_mut_callback_t)(struct bindings_t *bindings, void *context);
503
510typedef struct space_params_t {
514 void *payload;
518 struct RustSpaceCommonData *common;
520
528typedef struct space_api_t {
537 struct bindings_set_t (*query)(const struct space_params_t *params, const atom_ref_t *atom);
549 struct atom_vec_t (*subst)(const struct space_params_t *params,
550 const atom_ref_t *pattern,
551 const atom_ref_t *tmpl);
561 void (*add)(const struct space_params_t *params, atom_t atom);
571 bool (*remove)(const struct space_params_t *params, const atom_ref_t *atom);
583 bool (*replace)(const struct space_params_t *params, const atom_ref_t *from, atom_t to);
593 intptr_t (*atom_count)(const struct space_params_t *params);
604 void *(*new_atom_iterator_state)(const struct space_params_t *params);
616 atom_ref_t (*next_atom)(const struct space_params_t *params, void *state);
627 void (*free_atom_iterator_state)(const struct space_params_t *params, void *state);
637 void (*free_payload)(void *payload);
639
648typedef struct space_event_t {
652 struct RustSpaceEvent *event;
654
661typedef struct space_observer_t {
665 const struct RustSpaceObserver *observer;
667
675typedef struct space_observer_api_t {
682 void (*notify)(void *payload, const struct space_event_t *event);
689 void (*free_payload)(void *payload);
691
698typedef struct tokenizer_t {
702 const struct RustTokenizer *tokenizer;
704
712typedef struct token_api_t {
720 atom_t (*construct_atom)(const char *str, void *context);
727 void (*free_context)(void *context);
729
736typedef struct sexpr_parser_t {
740 void *parser;
741 char *err_string;
743
750typedef struct syntax_node_t {
754 struct RustSyntaxNode *node;
756
764typedef void (*c_syntax_node_callback_t)(const struct syntax_node_t *node, void *context);
765
781typedef struct step_result_t {
785 struct RustStepResult *result;
787
796typedef struct metta_t {
800 struct RustMetta *metta;
801 char *err_string;
802} metta_t;
803
809typedef struct run_context_t {
813 struct RustRunContext *context;
814 char *err_string;
816
822typedef struct metta_mod_ref_t {
823 const struct RustMettaModRef *module;
825
832typedef struct module_loader_t {
841 intptr_t (*load)(const void *payload, struct run_context_t *context, struct write_t err);
853 intptr_t (*load_tokens)(const void *payload,
854 struct metta_mod_ref_t target,
855 struct metta_t metta,
856 struct write_t err);
863 void (*to_string)(const void *payload, struct write_t text);
868 void (*free)(void *payload);
870
877typedef struct env_builder_t {
881 struct RustEnvBuilder *builder;
883
890typedef struct module_id_t {
894 uintptr_t id;
896
906typedef struct runner_state_t {
910 struct RustRunnerState *state;
911 char *err_string;
913
921typedef struct module_descriptor_t {
925 struct RustModuleDescriptor *descriptor;
927
936typedef struct fs_module_format_t {
952 uintptr_t (*path_for_name)(const void *payload,
953 const char *parent_dir,
954 const char *mod_name,
955 char *dst_buf,
956 uintptr_t buf_size);
967 bool (*try_path)(const void *payload,
968 const char *path,
969 const char *mod_name,
970 const struct module_loader_t **mod_loader,
971 struct module_descriptor_t *mod_descriptor);
977 void (*free)(void *payload);
979
980#ifdef __cplusplus
981extern "C" {
982#endif // __cplusplus
983
990void log_error(const char *msg);
991
998void log_warn(const char *msg);
999
1006void log_info(const char *msg);
1007
1016intptr_t write_str(struct write_t cwrite, const char *text);
1017
1029
1038
1048atom_t atom_sym(const char *name);
1049
1061 uintptr_t size);
1062
1073
1082atom_t atom_var(const char *name);
1083
1092atom_t atom_var_parse_name(const char *name);
1093
1101atom_t atom_gnd(struct gnd_t *gnd);
1102
1111
1119atom_t atom_int(int64_t n);
1120
1129
1139atom_t atom_gnd_for_space(const struct space_t *space);
1140
1148
1158
1167bool atom_eq(const atom_ref_t *a, const atom_ref_t *b);
1168
1178 const atom_ref_t *b);
1179
1188
1196bool atom_is_null(const atom_ref_t *atom);
1197
1209uintptr_t atom_to_str(const atom_ref_t *atom, char *buf, uintptr_t buf_len);
1210
1222uintptr_t atom_get_name(const atom_ref_t *atom, char *buf, uintptr_t buf_len);
1223
1234 c_atom_vec_callback_t callback,
1235 void *context);
1236
1246void atom_iterate(const atom_ref_t *atom,
1247 c_atom_callback_t callback,
1248 void *context);
1249
1262
1272struct gnd_t *atom_get_object(const atom_ref_t *atom);
1273
1282
1293
1303struct exec_error_t exec_error_runtime(const char *message);
1304
1314
1325
1335
1343
1350void throw_panic_with_message(const char *message);
1351
1360
1369struct atom_vec_t atom_vec_clone(const struct atom_vec_t *vec);
1370
1382 uintptr_t size);
1383
1390void atom_vec_free(struct atom_vec_t vec);
1391
1399uintptr_t atom_vec_len(const struct atom_vec_t *vec);
1400
1411
1420void atom_vec_push(struct atom_vec_t *vec,
1421 atom_t atom);
1422
1435 uintptr_t idx);
1436
1447 const atom_ref_t *b);
1448
1459 const struct serializer_api_t *api,
1460 void *context);
1461
1470
1478
1488
1500uintptr_t bindings_to_str(const struct bindings_t *bindings, char *buf, uintptr_t buf_len);
1501
1510bool bindings_eq(const struct bindings_t *a, const struct bindings_t *b);
1511
1521 c_var_binding_callback_t callback,
1522 void *context);
1523
1535 atom_t var,
1536 atom_t atom);
1537
1546
1557 atom_t var);
1558
1570 const struct bindings_t *other);
1571
1579void bindings_narrow_vars(struct bindings_t *bindings,
1580 const struct atom_vec_t *vars);
1581
1590
1599
1610
1620 struct bindings_t bindings);
1621
1629
1639
1648bool bindings_set_eq(const struct bindings_set_t *a, const struct bindings_set_t *b);
1649
1661uintptr_t bindings_set_to_str(const struct bindings_set_t *set, char *buf, uintptr_t buf_len);
1662
1671
1681
1692 bindings_mut_callback_t callback,
1693 void *context);
1694
1705 const atom_ref_t *a,
1706 const atom_ref_t *b);
1707
1720 const atom_ref_t *var,
1721 const atom_ref_t *value);
1722
1733 const struct bindings_set_t *other);
1734
1746struct space_t space_new(const struct space_api_t *api,
1747 void *payload);
1748
1758
1770
1779bool space_eq(const struct space_t *a,
1780 const struct space_t *b);
1781
1795
1806 atom_t atom);
1807
1817 const atom_ref_t *atom);
1818
1833 const atom_ref_t *from,
1834 atom_t to);
1835
1845struct bindings_set_t space_query(const struct space_t *space,
1846 const atom_ref_t *pattern);
1847
1860void space_subst(const struct space_t *space,
1861 const atom_ref_t *pattern,
1862 const atom_ref_t *templ,
1863 c_atom_vec_callback_t callback,
1864 void *context);
1865
1874intptr_t space_atom_count(const struct space_t *space);
1875
1886bool space_iterate(const struct space_t *space,
1887 c_atom_callback_t callback,
1888 void *context);
1889
1899
1908
1920 enum space_event_field_t field);
1921
1937 const struct space_observer_api_t *observer_api,
1938 void *observer_payload);
1939
1948
1961void *space_observer_get_payload(const struct space_observer_t *observer);
1962
1971 const struct space_event_t *event);
1972
1983
1994
2006 atom_t tmpl);
2007
2015
2024
2034
2046 const char *regex,
2047 const struct token_api_t *api,
2048 void *context);
2049
2059
2071struct sexpr_parser_t sexpr_parser_new(const char *text);
2072
2080
2094 const struct tokenizer_t *tokenizer);
2095
2107const char *sexpr_parser_err_str(const struct sexpr_parser_t *parser);
2108
2119
2127
2138
2148 c_syntax_node_callback_t callback,
2149 void *context);
2150
2159
2168
2177
2187 uintptr_t *range_start,
2188 uintptr_t *range_end);
2189
2197bool atom_is_error(const atom_ref_t *atom);
2198
2211uintptr_t atom_error_message(const atom_ref_t *atom, char *buf, uintptr_t buf_len);
2212
2221
2230
2239
2248
2257
2266
2275
2284
2293
2302
2311
2320
2330
2340
2350
2361bool check_type(const struct space_t *space,
2362 const atom_ref_t *atom,
2363 const atom_ref_t *typ);
2364
2374bool validate_atom(const struct space_t *space,
2375 const atom_ref_t *atom);
2376
2388void get_atom_types(const struct space_t *space,
2389 const atom_ref_t *atom,
2390 c_atom_vec_callback_t callback,
2391 void *context);
2392
2405 const atom_ref_t *expr);
2406
2415
2427uintptr_t step_to_str(const struct step_result_t *step, char *buf, uintptr_t buf_len);
2428
2436bool step_has_next(const struct step_result_t *step);
2437
2447 c_atom_vec_callback_t callback,
2448 void *context);
2449
2457struct metta_t metta_new(void);
2458
2472 struct space_t *space_ref,
2473 struct env_builder_t env_builder_mov);
2474
2485struct metta_t metta_new_core(struct space_t *space,
2486 struct env_builder_t env_builder);
2487
2497
2507
2520const char *metta_err_str(const struct metta_t *metta);
2521
2530bool metta_eq(const struct metta_t *a, const struct metta_t *b);
2531
2540struct space_t metta_space(struct metta_t *metta);
2541
2551
2564uintptr_t metta_working_dir(const struct metta_t *metta, char *buf, uintptr_t buf_len);
2565
2578void metta_run(struct metta_t *metta,
2579 struct sexpr_parser_t parser,
2580 c_atom_vec_callback_t callback,
2581 void *context);
2582
2594void metta_evaluate_atom(struct metta_t *metta,
2595 atom_t atom,
2596 c_atom_vec_callback_t callback,
2597 void *context);
2598
2612 const char *name_ref,
2613 struct module_loader_t *loader_mov);
2614
2629 const char *path,
2630 const char *name);
2631
2641struct space_t metta_get_module_space(const struct metta_t *metta, struct module_id_t mod_id);
2642
2650void run_context_push_parser(struct run_context_t *run_context, struct sexpr_parser_t parser);
2651
2660struct metta_t run_context_get_metta(const struct run_context_t *run_context);
2661
2671struct space_t run_context_get_space(const struct run_context_t *run_context);
2672
2682struct tokenizer_t run_context_get_tokenizer(const struct run_context_t *run_context);
2683
2693 const char *message);
2694
2707 struct sexpr_parser_t parser);
2708
2721 const struct atom_vec_t *atoms);
2722
2730
2741const char *runner_state_err_str(const struct runner_state_t *state);
2742
2751
2760
2772uintptr_t runner_state_to_str(const struct runner_state_t *state, char *buf, uintptr_t buf_len);
2773
2785 c_atom_vec_callback_t callback,
2786 void *context);
2787
2798uintptr_t environment_config_dir(char *buf, uintptr_t buf_len);
2799
2809
2820
2830
2840
2852 const char *path);
2853
2861void env_builder_set_config_dir(struct env_builder_t *builder, const char *path);
2862
2870void env_builder_create_config_dir(struct env_builder_t *builder, bool should_create);
2871
2879
2888
2898 const char *path);
2899
2908 const struct fs_module_format_t *format);
2909
2922 struct space_t *space,
2923 const char *resource_dir_path);
2924
2934struct module_id_t run_context_load_module(struct run_context_t *run_context, const char *name);
2935
2944 struct module_id_t mod_id);
2945
2946enum serial_result_t serialize_bool_rust_adapter(void *context, bool v);
2947
2948enum serial_result_t serialize_longlong_rust_adapter(void *context, long long v);
2949
2950enum serial_result_t serialize_double_rust_adapter(void *context, double v);
2951
2952enum serial_result_t serialize_str_rust_adapter(void *context, const char *v);
2953
2962
2972
2973struct module_descriptor_t module_descriptor_new_with_path_and_fmt_id(const char *name,
2974 const char *path,
2975 uint64_t fmt_id);
2976
2986
2994
3002bool module_id_is_valid(const struct module_id_t *mod_id);
3003
3004#ifdef __cplusplus
3005} // extern "C"
3006#endif // __cplusplus
3007
3008#endif /* HYPERON_H */
bool atoms_are_equivalent(const atom_ref_t *a, const atom_ref_t *b)
Checks if two atoms are alpha equivalent.
void(* c_atom_callback_t)(atom_ref_t atom, void *context)
Function signature for a callback providing access to an atom.
Definition hyperon.h:471
void atom_free(atom_t atom)
Frees an atom and all associated resources.
atom_t atom_var_parse_name(const char *name)
Create a new Variable atom parsing full formatted name of the variable.
atom_t atom_get_grounded_type(const atom_ref_t *atom)
Retrieve the grounded type of a Grounded Atom.
atom_t atom_sym(const char *name)
Create a new Symbol atom with the specified name.
enum atom_type_t atom_get_metatype(const atom_ref_t *atom)
Returns the metatype of an atom.
atom_t atom_expr_from_vec(struct atom_vec_t children)
Create a new Expression atom with the children contained in an atom_vec_t
bool atom_is_null(const atom_ref_t *atom)
Returns true if the referenced atom is invalid, otherwise returns false
void atom_iterate(const atom_ref_t *atom, c_atom_callback_t callback, void *context)
Performs a depth-first exhaustive iteration of an atom and all its children recursively.
atom_t atom_gnd_for_space(const struct space_t *space)
Creates a Grounded Atom referencing a Space.
atom_t atom_float(double f)
atom_t atom_clone(const atom_ref_t *atom)
Makes a "deep copy" of an atom. Useful to turn an atom_ref_t into an atom_t
struct space_t atom_get_space(const atom_ref_t *atom)
Access the space wrapped inside a Grounded atom.
atom_t atom_int(int64_t n)
uintptr_t atom_get_name(const atom_ref_t *atom, char *buf, uintptr_t buf_len)
Renders the name of an atom into a text buffer.
bool atom_eq(const atom_ref_t *a, const atom_ref_t *b)
Checks if two atom objects represent the same conceptual atom.
atom_type_t
Represents whether an atom is a Symbol, Variable, Expression, or Grounded atom.
Definition hyperon.h:39
atom_t atom_var(const char *name)
Create a new Variable atom with the specified name.
void atom_get_children(const atom_ref_t *atom, c_atom_vec_callback_t callback, void *context)
Provides access to all children atoms within an expression atom.
atom_t atom_bool(bool b)
atom_ref_t atom_ref_null(void)
Create an atom_ref_t that points nothing.
uintptr_t atom_to_str(const atom_ref_t *atom, char *buf, uintptr_t buf_len)
Renders a human-readable text description of an atom.
atom_t atom_gnd(struct gnd_t *gnd)
bool atom_is_cgrounded(const atom_ref_t *atom)
Check if the atom refers to CGrounded object.
struct gnd_t * atom_get_object(const atom_ref_t *atom)
Access a pointer to an object backing a Grounded Atom.
atom_t atom_expr(atom_t *children, uintptr_t size)
Create a new Expression atom with the specified children atoms.
atom_ref_t atom_ref(const atom_t *atom)
Create an atom_ref_t that points to another atom you own.
@ VARIABLE
The atom is a Variable atom.
Definition hyperon.h:47
@ EXPR
The atom is an Expression atom.
Definition hyperon.h:51
@ SYMBOL
The atom is a Symbol atom.
Definition hyperon.h:43
@ GROUNDED
The atom is a Grounded atom.
Definition hyperon.h:55
uintptr_t atom_vec_len(const struct atom_vec_t *vec)
Returns the number of elements in a vec.
atom_t atom_vec_pop(struct atom_vec_t *vec)
Removes the last element from a vec, and returns it.
void atom_vec_free(struct atom_vec_t vec)
Frees a atom_vec_t
struct atom_vec_t atom_vec_new(void)
Creates a new empty atom_vec_t
void(* c_atom_vec_callback_t)(const struct atom_vec_t *vec, void *context)
Function signature for a callback providing access to an atom_vec_t
Definition hyperon.h:462
struct atom_vec_t atom_vec_from_array(atom_t *atoms, uintptr_t size)
Creates a new atom_vec_t from a C-style array.
atom_ref_t atom_vec_get(const struct atom_vec_t *vec, uintptr_t idx)
Access an atom at a specified index in a vec.
void atom_vec_push(struct atom_vec_t *vec, atom_t atom)
Push the atom onto the end of the vec.
struct atom_vec_t atom_vec_clone(const struct atom_vec_t *vec)
Creates a new atom_vec_t by cloning an existing atom_vec_t
void env_builder_set_config_dir(struct env_builder_t *builder, const char *path)
Sets the config directory for the environment.
bool env_builder_init_common_env(struct env_builder_t builder)
Finishes initialization of the common environment.
uintptr_t environment_config_dir(char *buf, uintptr_t buf_len)
Renders the config_dir path from the common environment into a text buffer.
void env_builder_create_config_dir(struct env_builder_t *builder, bool should_create)
Sets whether the config dir should be created if it doesn't already exist.
struct env_builder_t env_builder_start(void)
Begins initialization of an environment.
struct env_builder_t env_builder_use_default(void)
Creates an env_builder_t to specify that the default common environment should be used.
void env_builder_push_include_path(struct env_builder_t *builder, const char *path)
Adds a directory to search for module imports.
void env_builder_set_is_test(struct env_builder_t *builder, bool is_test)
Configures the environment for use in unit testing.
void env_builder_set_working_dir(struct env_builder_t *builder, const char *path)
Sets the working directory for the environment.
void env_builder_push_fs_module_format(struct env_builder_t *builder, const struct fs_module_format_t *format)
Adds logic to interpret a foreign format for MeTTa modules loaded from the file system.
struct env_builder_t env_builder_use_test_env(void)
A convenience to create an env_builder_t, to specify that a unit-test environment should be used.
void env_builder_set_default_config_dir(struct env_builder_t *builder)
Sets the default config directory for the environment.
struct exec_error_t exec_error_incorrect_argument(void)
Creates a new exec_error_t representing a "Incorrect Argument" status, telling the MeTTa interpreter ...
void throw_panic_with_message(const char *message)
Used to throw panic from C Api with message to prevent panics without any info.
struct exec_error_t exec_error_no_err(void)
Creates a new exec_error_t representing a "No Error" status. This is the default interpreter status.
struct exec_error_t exec_error_runtime(const char *message)
Creates a new exec_error_t representing a runtime error that will halt the MeTTa interpreter.
void exec_error_free(struct exec_error_t error)
Frees an exec_error_t
struct exec_error_t exec_error_no_reduce(void)
Creates a new exec_error_t representing a "Don't Reduce" status, telling the MeTTa interpreter to pro...
uintptr_t runner_state_to_str(const struct runner_state_t *state, char *buf, uintptr_t buf_len)
Renders a text description of a runner_state_t into a buffer.
void metta_free(struct metta_t metta)
Frees a metta_t handle.
uintptr_t metta_working_dir(const struct metta_t *metta, char *buf, uintptr_t buf_len)
Renders the working directory of the runner's environment into a buffer.
struct metta_t metta_new(void)
Creates a new top-level MeTTa Runner, with only the Rust stdlib loaded.
void metta_evaluate_atom(struct metta_t *metta, atom_t atom, c_atom_vec_callback_t callback, void *context)
Runs the MeTTa runner to evaluate an input Atom.
const char * runner_state_err_str(const struct runner_state_t *state)
Returns the error string associated with the last runner_state_step
struct metta_t metta_clone_handle(const struct metta_t *metta)
Clones a metta_t handle.
struct metta_t metta_new_with_stdlib_loader(struct module_loader_t *stdlib_loader_mov, struct space_t *space_ref, struct env_builder_t env_builder_mov)
Creates a new top-level MeTTa Runner, with the specified stdlib module loaded.
struct step_result_t interpret_step(struct step_result_t step)
Takes a subsequent step in an in-flight interpreter operation.
struct runner_state_t runner_state_new_with_parser(const struct metta_t *metta, struct sexpr_parser_t parser)
Creates a runner_state_t, to use for step-wise execution of MeTTa text.
void run_context_raise_error(struct run_context_t *run_context, const char *message)
Sets a runtime error.
bool step_has_next(const struct step_result_t *step)
Examines a step_result_t to determine if more work is needed.
struct space_t metta_space(struct metta_t *metta)
Provides access to the Space of the runner's top-level module.
struct tokenizer_t run_context_get_tokenizer(const struct run_context_t *run_context)
Provides access to the Tokenizer of the currently running module.
uintptr_t step_to_str(const struct step_result_t *step, char *buf, uintptr_t buf_len)
Renders a text description of a step_result_t into a buffer.
struct space_t run_context_get_space(const struct run_context_t *run_context)
Provides access to the Space of the currently running module.
void run_context_push_parser(struct run_context_t *run_context, struct sexpr_parser_t parser)
Appends the parser to the Run Context's queue of input to run.
struct tokenizer_t metta_tokenizer(struct metta_t *metta)
Provides access to the Tokenizer of the runner's top-level module.
struct module_id_t metta_load_module_at_path(struct metta_t *metta, const char *path, const char *name)
Loads a module into the runner from a module resource at a file system path.
void metta_run(struct metta_t *metta, struct sexpr_parser_t parser, c_atom_vec_callback_t callback, void *context)
Runs the MeTTa runner until the input text has been fully parsed and evaluated.
struct step_result_t interpret_init(struct space_t *space, const atom_ref_t *expr)
Initializes an interpreter operation and take the initial step.
struct metta_t metta_new_core(struct space_t *space, struct env_builder_t env_builder)
Creates a new core MeTTa runner, with no loaded stdlib nor initialization.
struct module_id_t metta_load_module_direct(struct metta_t *metta_ref, const char *name_ref, struct module_loader_t *loader_mov)
Loads a module directly into the runner, from a module_loader_t.
bool runner_state_is_complete(const struct runner_state_t *state)
Returns whether or not the runner_state_t has completed all outstanding work.
struct space_t metta_get_module_space(const struct metta_t *metta, struct module_id_t mod_id)
Returns the Space for a loaded module.
void runner_state_step(struct runner_state_t *state)
Runs one step of the runner.
bool metta_eq(const struct metta_t *a, const struct metta_t *b)
Compares two metta_t handles to test whether the referenced MeTTa runner is the same.
struct runner_state_t runner_state_new_with_atoms(const struct metta_t *metta, const struct atom_vec_t *atoms)
Creates a runner_state_t, to use for step-wise execution of a list of atoms.
void step_get_result(struct step_result_t step, c_atom_vec_callback_t callback, void *context)
Consumes a step_result_t and provides the ultimate outcome of a MeTTa interpreter session.
void runner_state_free(struct runner_state_t state)
Frees a runner_state_t.
void runner_state_current_results(const struct runner_state_t *state, c_atom_vec_callback_t callback, void *context)
Accesses the current in-flight results in the runner_state_t.
struct metta_t run_context_get_metta(const struct run_context_t *run_context)
Returns a pointer to the metta_t runner that a run context is executing within.
const char * metta_err_str(const struct metta_t *metta)
Returns the error string associated with the last metta_run, metta_evaluate_atom, or metta_load_modul...
bool bindings_set_is_empty(const struct bindings_set_t *set)
Checks if a bindings_set_t contains no Bindings frames, and thus indicates no match.
void(* c_var_binding_callback_t)(atom_ref_t var, atom_ref_t value, void *context)
Function signature for a callback providing access to a variable <-> atom pair, associated with a bin...
Definition hyperon.h:493
void bindings_set_add_var_binding(struct bindings_set_t *set, const atom_ref_t *var, const atom_ref_t *value)
Adds a new variable <-> atom association to every Bindings frame in a Bindings set.
uintptr_t bindings_set_to_str(const struct bindings_set_t *set, char *buf, uintptr_t buf_len)
Renders a text description of a bindings_set_t
struct bindings_t bindings_new(void)
Creates a new bindings_t containing no variable <-> atom associations, leaving all variables free to ...
bool bindings_set_is_single(const struct bindings_set_t *set)
Checks if a bindings_set_t contains a frame with no associations, and is thus allows variables to tak...
void bindings_set_merge_into(struct bindings_set_t *_self, const struct bindings_set_t *other)
Merges the contents of one Bindings set into another Bindings set.
struct bindings_t bindings_clone(const struct bindings_t *bindings)
Makes a "deep copy" of a bindings_t
void bindings_narrow_vars(struct bindings_t *bindings, const struct atom_vec_t *vars)
Removes all variable associations from a bindings_t except those in the supplied list.
void bindings_free(struct bindings_t bindings)
Frees a bindings_t
struct bindings_set_t bindings_set_from_bindings(struct bindings_t bindings)
Creates a new bindings_set_t with the specified Bindings frame.
void bindings_traverse(const struct bindings_t *bindings, c_var_binding_callback_t callback, void *context)
Iterates each variable <-> Atom association within a bindings_t
atom_t bindings_resolve(const struct bindings_t *bindings, atom_t var)
Returns the atom bound to the supplied variable name in the bindings_t
struct bindings_set_t bindings_set_empty(void)
Creates a new bindings_set_t without any Bindings frames. Conceptually this means no valid matches ex...
bool bindings_add_var_binding(struct bindings_t *bindings, atom_t var, atom_t atom)
Adds a new variable <-> atom association within a bindings_t
struct bindings_set_t bindings_set_single(void)
Creates a new bindings_set_t with one new Bindings frame. Conceptually this means all variables are a...
uintptr_t bindings_to_str(const struct bindings_t *bindings, char *buf, uintptr_t buf_len)
Renders a text description of a bindings_t
bool bindings_is_empty(const struct bindings_t *bindings)
Checks if a bindings_t contains no associations.
void(* bindings_mut_callback_t)(struct bindings_t *bindings, void *context)
Function signature for a callback providing mutable access to individual Bindings frames within a Bin...
Definition hyperon.h:502
bool bindings_eq(const struct bindings_t *a, const struct bindings_t *b)
Checks if two bindings_t objects contain identical associations.
void bindings_set_free(struct bindings_set_t set)
Frees a bindings_set_t
void bindings_set_push(struct bindings_set_t *set, struct bindings_t bindings)
Adds a Bindings frame to an existing bindings_set_t
struct bindings_set_t bindings_set_clone(const struct bindings_set_t *set)
Makes a "deep copy" of a bindings_set_t
struct bindings_set_t atom_match_atom(const atom_ref_t *a, const atom_ref_t *b)
Matches one atom with another, establishing bindings between them.
struct bindings_set_t bindings_merge(struct bindings_t _self, const struct bindings_t *other)
Merges two bindings_t Bindings frames together into a Bindings Set.
void bindings_set_iterate(struct bindings_set_t *set, bindings_mut_callback_t callback, void *context)
Provides sequential access to each Bindings frame within a Bindings set.
bool bindings_set_eq(const struct bindings_set_t *a, const struct bindings_set_t *b)
Checks if two bindings_set_t objects contain identical associations.
void bindings_set_add_var_equality(struct bindings_set_t *set, const atom_ref_t *a, const atom_ref_t *b)
Asserts equality between two Variable atoms in a Bindings set.
atom_t ATOM_TYPE_GROUNDED(void)
Creates a Symbol atom for the special MeTTa symbol: "Grounded", used to indicate that an atom's type ...
atom_t ATOM_TYPE_TYPE(void)
Creates a Symbol atom for the special MeTTa symbol: "Type", used to indicate that an atom represents ...
bool atom_is_error(const atom_ref_t *atom)
Checks if an atom is a MeTTa error expression.
atom_t ATOM_TYPE_STRING(void)
Creates an atom used to indicate that an atom's type is a String type.
bool validate_atom(const struct space_t *space, const atom_ref_t *atom)
Checks whether atom is correctly typed.
bool check_type(const struct space_t *space, const atom_ref_t *atom, const atom_ref_t *typ)
Checks whether Atom atom has Type typ in context of space
atom_t ATOM_TYPE_UNIT(void)
Creates an atom used to indicate that an atom's type is a unit type.
atom_t ATOM_TYPE_GROUNDED_SPACE(void)
Creates a Symbol atom for the special MeTTa symbol used to indicate that an atom's type is a wrapper ...
atom_t ATOM_TYPE_ATOM(void)
Creates a Symbol atom for the special MeTTa symbol: "Atom", used to indicate that an atom's type is a...
atom_t EMPTY_ATOM(void)
Creates a Symbol atom for the special MeTTa symbol used to indicate empty results returned by functio...
void get_atom_types(const struct space_t *space, const atom_ref_t *atom, c_atom_vec_callback_t callback, void *context)
Provides all types for atom in the context of space
atom_t ATOM_TYPE_NUMBER(void)
Creates an atom used to indicate that an atom's type is a Number type.
atom_t ATOM_TYPE_UNDEFINED(void)
Creates a Symbol atom for the special MeTTa symbol: "%Undefined%".
atom_t ATOM_TYPE_BOOL(void)
Creates an atom used to indicate that an atom's type is a Bool type.
atom_t METTA_ATOM(void)
Creates a Symbol atom for the special MeTTa symbol used to indicate calling MeTTa interpreter.
atom_t ATOM_TYPE_SYMBOL(void)
Creates a Symbol atom for the special MeTTa symbol: "Symbol", used to indicate that an atom's type is...
atom_t UNIT_ATOM(void)
Creates an atom used to return from functions which are not supposed to return results (print for exa...
uintptr_t atom_error_message(const atom_ref_t *atom, char *buf, uintptr_t buf_len)
Renders the text message from an error expression atom into a buffer.
atom_t ATOM_TYPE_EXPRESSION(void)
Creates a Symbol atom for the special MeTTa symbol: "Expression", used to indicate that an atom's typ...
atom_t ATOM_TYPE_VARIABLE(void)
Creates a Symbol atom for the special MeTTa symbol: "Variable", used to indicate that an atom's type ...
void log_info(const char *msg)
Logs an informative message through the MeTTa library's logger.
void log_error(const char *msg)
Logs an error through the MeTTa library's logger. Does not halt execution.
void log_warn(const char *msg)
Logs a warning through the MeTTa library's logger.
intptr_t write_str(struct write_t cwrite, const char *text)
Write C string into a Rust writer.
bool module_id_is_valid(const struct module_id_t *mod_id)
Returns true is a module_id_t is valid, otherwise returns false
void run_context_init_self_module(struct run_context_t *run_context, struct space_t *space, const char *resource_dir_path)
Called within a module loader function to initialize the new module.
struct module_id_t run_context_load_module(struct run_context_t *run_context, const char *name)
Resolves a module name in the context of a running module, and loads that module if it's not already ...
void module_descriptor_free(struct module_descriptor_t descriptor)
Frees a module_descriptor_t.
struct module_descriptor_t module_descriptor_clone(const struct module_descriptor_t *descriptor)
Creates a new module_descriptor_t that is a clone of the argument passed.
struct module_descriptor_t module_descriptor_new(const char *name)
Creates a new module_descriptor_t with the specified name.
void run_context_import_dependency(struct run_context_t *run_context, struct module_id_t mod_id)
Imports a dependency module into the currently running module. This is "import *" behavior.
struct tokenizer_t metta_mod_ref_tokenizer(const struct metta_mod_ref_t *mod_ref)
Returns tokenizer of the MeTTa module.
enum serial_result_t atom_gnd_serialize(const atom_ref_t *atom, const struct serializer_api_t *api, void *context)
Serializes a grounded atom using the given serializer.
void space_free(struct space_t space)
Frees a space_t handle.
bool space_iterate(const struct space_t *space, c_atom_callback_t callback, void *context)
Iterates all top-level Atoms in a Space, if that is possible.
struct bindings_set_t space_query(const struct space_t *space, const atom_ref_t *pattern)
Queries a Space for atoms matching a pattern.
struct space_t space_clone_handle(const struct space_t *space)
Creates a new space_t handle that refers to the same underlying space as another space_t
struct space_t space_new(const struct space_api_t *api, void *payload)
Creates a new Space, backed by an implementation in C.
bool space_remove(struct space_t *space, const atom_ref_t *atom)
Removes a specific atom from the Space.
struct space_t space_new_grounding_space(void)
Creates a new Space, backed by a GroundSpace.
bool space_eq(const struct space_t *a, const struct space_t *b)
Checks if two space_t handles refer to the same underlying Space.
void space_subst(const struct space_t *space, const atom_ref_t *pattern, const atom_ref_t *templ, c_atom_vec_callback_t callback, void *context)
Substitutes all Atoms matching a pattern with Atoms constructed from a template.
void * space_get_payload(struct space_t *space)
Access the payload object belonging to a space implemented in C.
intptr_t space_atom_count(const struct space_t *space)
Returns the number of top-level atoms in a Space, if it can be readily determined.
bool space_replace(struct space_t *space, const atom_ref_t *from, atom_t to)
Replaces an Atom in the Space with another Atom.
void space_add(struct space_t *space, atom_t atom)
Adds an atom to the Space.
void space_event_free(struct space_event_t event)
Frees a space_event_t
struct space_event_t space_event_new_replace(atom_t pattern, atom_t tmpl)
Creates a new space_event_t representing a Replace event.
void space_params_notify_all_observers(const struct space_params_t *params, const struct space_event_t *event)
Notifies all associated observers of an event.
struct space_event_t space_event_new_remove(atom_t atom)
Creates a new space_event_t representing a Remove event.
struct space_event_t space_event_new_add(atom_t atom)
Creates a new space_event_t representing an Add event.
space_event_type_t
Represents different types of Space Events.
Definition hyperon.h:63
atom_ref_t space_event_get_field_atom(const struct space_event_t *event, enum space_event_field_t field)
Accesses the atom associated with a field of a space_event_t
enum space_event_type_t space_event_get_type(const struct space_event_t *event)
Gets the type of a Space Event.
space_event_field_t
Accessor constants, to access the fields of a space_event_t
Definition hyperon.h:83
void space_observer_free(struct space_observer_t observer)
Frees a space_observer_t
struct space_observer_t space_register_observer(struct space_t *space, const struct space_observer_api_t *observer_api, void *observer_payload)
Registers a new observer, to monitor activity within the Space.
void * space_observer_get_payload(const struct space_observer_t *observer)
Returns a pointer to the payload associated with the space_observer_t.
@ SPACE_EVENT_TYPE_REPLACE
The event is a Replace event.
Definition hyperon.h:75
@ SPACE_EVENT_TYPE_REMOVE
The event is a Remove event.
Definition hyperon.h:71
@ SPACE_EVENT_TYPE_ADD
The event is an Add event.
Definition hyperon.h:67
@ SPACE_EVENT_FIELD_ADD
Access the atom field of an Add event.
Definition hyperon.h:87
@ SPACE_EVENT_FIELD_REPLACE_TEMPLATE
Access the template field of a Replace event.
Definition hyperon.h:99
@ SPACE_EVENT_FIELD_REMOVE
Access the atom field of a Remove event.
Definition hyperon.h:91
@ SPACE_EVENT_FIELD_REPLACE_PATTERN
Access the pattern field of a Replace event.
Definition hyperon.h:95
void syntax_node_iterate(const struct syntax_node_t *node, c_syntax_node_callback_t callback, void *context)
Performs a depth-first iteration of all child syntax nodes within a syntax tree.
void sexpr_parser_free(struct sexpr_parser_t parser)
Frees an S-Expression Parser.
struct syntax_node_t syntax_node_clone(const struct syntax_node_t *node)
Creates a deep copy of a syntax_node_t
bool syntax_node_is_leaf(const struct syntax_node_t *node)
Returns true if a syntax node is a leaf (has no children) and false otherwise.
const char * sexpr_parser_err_str(const struct sexpr_parser_t *parser)
Returns the error string associated with the last sexpr_parser_parse call.
struct tokenizer_t tokenizer_clone(const struct tokenizer_t *tokenizer)
Performs a "deep copy" of a Tokenizer.
enum syntax_node_type_t syntax_node_type(const struct syntax_node_t *node)
Returns the type of a syntax_node_t
struct syntax_node_t sexpr_parser_parse_to_syntax_tree(struct sexpr_parser_t *parser)
Parses the text associated with an sexpr_parser_t, and creates a syntax tree.
void syntax_node_src_range(const struct syntax_node_t *node, uintptr_t *range_start, uintptr_t *range_end)
Returns the beginning and end positions in the parsed source of the text represented by the syntax no...
syntax_node_type_t
The type of language construct respresented by a syntax_node_t.
Definition hyperon.h:107
atom_t sexpr_parser_parse(struct sexpr_parser_t *parser, const struct tokenizer_t *tokenizer)
Parses the text associated with an sexpr_parser_t, and creates the corresponding Atom.
void syntax_node_free(struct syntax_node_t node)
Frees a syntax_node_t.
bool syntax_node_is_null(const struct syntax_node_t *node)
Returns true if a syntax node represents the end of the stream.
void(* c_syntax_node_callback_t)(const struct syntax_node_t *node, void *context)
Function signature for a callback providing access to a syntax_node_t
Definition hyperon.h:764
void tokenizer_free(struct tokenizer_t tokenizer)
Frees a Tokenizer handle.
struct tokenizer_t tokenizer_new(void)
Creates a new Tokenizer, without any registered Tokens.
struct sexpr_parser_t sexpr_parser_new(const char *text)
Creates a new S-Expression Parser.
void tokenizer_register_token(struct tokenizer_t *tokenizer, const char *regex, const struct token_api_t *api, void *context)
Registers a new custom Token in a Tokenizer.
@ ERROR_GROUP
A Group of nodes that cannot be combined into a coherent atom due to a parse error,...
Definition hyperon.h:148
@ WORD_TOKEN
Word Token. Any other whitespace-delimited token that isn't a VARIABLE_TOKEN or STRING_TOKEN.
Definition hyperon.h:123
@ VARIABLE_TOKEN
A variable. A symbol immediately preceded by a '$' sigil.
Definition hyperon.h:115
@ LEFTOVER_TEXT
Leftover Text that remains unparsed after a parse error has occurred.
Definition hyperon.h:139
@ STRING_TOKEN
A String Literal. All text between non-escaped '"' (double quote) characters.
Definition hyperon.h:119
@ CLOSE_PAREN
Close Parenthesis. A non-escaped ')' character indicating the end of an expression.
Definition hyperon.h:131
@ EXPRESSION_GROUP
A Group of nodes between an OPEN_PAREN and a matching CLOSE_PAREN
Definition hyperon.h:143
@ COMMENT
A Comment, beginning with a ';' character.
Definition hyperon.h:111
@ WHITESPACE
Whitespace. One or more whitespace chars.
Definition hyperon.h:135
@ OPEN_PAREN
Open Parenthesis. A non-escaped '(' character indicating the beginning of an expression.
Definition hyperon.h:127
serial_result_t
Definition hyperon.h:21
@ OK
Successful serialization.
Definition hyperon.h:26
@ NOT_SUPPORTED
Serialization of the value is not supported by serializer.
Definition hyperon.h:31
struct RustMettaModRef RustMettaModRef
Definition hyperon.h:162
Refers to an Atom owned by another object.
Represents an Atom of any type.
Contains a vector (list) of Atoms.
Definition hyperon.h:246
struct RustOpaqueAtom * ptr
Definition hyperon.h:250
uintptr_t capacity
Definition hyperon.h:258
bool owned
Definition hyperon.h:262
uintptr_t len
Definition hyperon.h:254
Represents a set of Bindings frames. Potentially expressing all possible matches produced by a match ...
Definition hyperon.h:292
struct RustBindingsSet * set
Definition hyperon.h:296
Represents a single Bindings frame, which is a group of mutually-compatible variable <-> atom associa...
Definition hyperon.h:478
struct RustBindings * bindings
Definition hyperon.h:482
Represents an environment initialization, in progress.
Definition hyperon.h:877
struct RustEnvBuilder * builder
Definition hyperon.h:881
Represents a status used to communicate between Grounded Atom execution and the MeTTa interpreter.
Definition hyperon.h:278
A table of functions to load MeTTa modules from an arbitrary format.
Definition hyperon.h:936
bool(* try_path)(const void *payload, const char *path, const char *mod_name, const struct module_loader_t **mod_loader, struct module_descriptor_t *mod_descriptor)
Tests a path in the file system to determine if a valid module resides at the path.
Definition hyperon.h:967
uintptr_t(* path_for_name)(const void *payload, const char *parent_dir, const char *mod_name, char *dst_buf, uintptr_t buf_size)
Constructs a path for a module with a given name that resides in a parent directory.
Definition hyperon.h:952
void(* free)(void *payload)
Frees a user-defined structure that may have been allocated in try_path.
Definition hyperon.h:977
A table of callback functions to implement a Grounded Atom with behavior defined in C.
Definition hyperon.h:348
bool(* eq)(const struct gnd_t *gnd, const struct gnd_t *other)
Tests whether two atoms instantiated from the same interface are equal.
Definition hyperon.h:389
struct exec_error_t(* execute)(const struct gnd_t *gnd, const struct atom_vec_t *args, struct atom_vec_t *out)
An optional function to implement executable atom behavior.
Definition hyperon.h:358
struct bindings_set_t(* match_)(const struct gnd_t *gnd, const atom_ref_t *other)
An optional function to match the atom with another atom.
Definition hyperon.h:370
uintptr_t(* display)(const struct gnd_t *gnd, char *buf, uintptr_t buf_len)
Renders a human-readable text description of the Grounded Atom into a buffer.
Definition hyperon.h:408
enum serial_result_t(* serialize)(const struct gnd_t *gnd, const struct serializer_api_t *api, void *context)
An optional function to encode the atom in terms of primitive types.
Definition hyperon.h:379
void(* free)(struct gnd_t *gnd)
Frees the backing object belonging to a Grounded Atom, and all associated resources.
Definition hyperon.h:415
A struct header that must preface a buffer used as a backing object for a Grounded Atom.
Definition hyperon.h:426
const struct gnd_api_t * api
A pointer to the table of functions that implement the Grounded Atom's behavior.
Definition hyperon.h:430
atom_t typ
An atom representing the grounded type of the Grounded Atom.
Definition hyperon.h:435
MettaMod C API wrapper.
Definition hyperon.h:822
A top-level MeTTa runner.
Definition hyperon.h:796
struct RustMetta * metta
Definition hyperon.h:800
Identifies the properties on a specific module, including its name and version.
Definition hyperon.h:921
struct RustModuleDescriptor * descriptor
Definition hyperon.h:925
Identifies a loaded module inside a specific metta_t MeTTa runner.
Definition hyperon.h:890
uintptr_t id
Definition hyperon.h:894
A C representation of the Rust [ModuleLoader] interface. User can provide [ModuleLoader] methods impl...
Definition hyperon.h:832
intptr_t(* load)(const void *payload, struct run_context_t *context, struct write_t err)
A function to load the module my making MeTTa API calls.
Definition hyperon.h:841
void(* free)(void *payload)
Frees module loader and all associated memory.
Definition hyperon.h:868
intptr_t(* load_tokens)(const void *payload, struct metta_mod_ref_t target, struct metta_t metta, struct write_t err)
Loads module's tokens into target module. This method is used for both initial token loading and expo...
Definition hyperon.h:853
void(* to_string)(const void *payload, struct write_t text)
Prints module loader content as a string, used for implementing [std::fmt::Debug].
Definition hyperon.h:863
An interface object providing access to the MeTTa run interface.
Definition hyperon.h:809
struct RustRunContext * context
Definition hyperon.h:813
Represents the state of an in-flight MeTTa execution run.
Definition hyperon.h:906
struct RustRunnerState * state
Definition hyperon.h:910
The result of a serialize operation reported by serializer.
A table of functions to receive values encoded as specific primitive types.
Definition hyperon.h:305
enum serial_result_t(* serialize_str)(void *context, const char *v)
Serialize C char[] value.
Definition hyperon.h:337
enum serial_result_t(* serialize_bool)(void *context, bool v)
Serialize C bool value.
Definition hyperon.h:313
enum serial_result_t(* serialize_longlong)(void *context, long long v)
Serialize C long long value.
Definition hyperon.h:321
enum serial_result_t(* serialize_double)(void *context, double v)
Serialize C double value.
Definition hyperon.h:329
Represents an S-Expression Parser state machine, to parse input text into an Atom.
Definition hyperon.h:736
void * parser
Definition hyperon.h:740
A table of functions to define the behavior of a Space implemented in C.
Definition hyperon.h:528
void(* free_payload)(void *payload)
Frees the payload buffer passed when the space was created.
Definition hyperon.h:637
bool(* replace)(const struct space_params_t *params, const atom_ref_t *from, atom_t to)
Replaces one atom in the space with another.
Definition hyperon.h:583
atom_ref_t(* next_atom)(const struct space_params_t *params, void *state)
Advances to the next top-level atom in the iteration sequence of the Space.
Definition hyperon.h:616
struct atom_vec_t(* subst)(const struct space_params_t *params, const atom_ref_t *pattern, const atom_ref_t *tmpl)
Substitutes atoms matched by a query with atoms in a form derived from a template.
Definition hyperon.h:549
intptr_t(* atom_count)(const struct space_params_t *params)
Returns the number of atoms contained within the space.
Definition hyperon.h:593
void(* add)(const struct space_params_t *params, atom_t atom)
Adds an atom to the space.
Definition hyperon.h:561
bool(* remove)(const struct space_params_t *params, const atom_ref_t *atom)
Removes an atom from the space.
Definition hyperon.h:571
struct bindings_set_t(* query)(const struct space_params_t *params, const atom_ref_t *atom)
Performs a query against atoms in a space.
Definition hyperon.h:537
void(* free_atom_iterator_state)(const struct space_params_t *params, void *state)
Frees the iterator state allocated by new_atom_iterator_state
Definition hyperon.h:627
Represents a Space Event.
Definition hyperon.h:648
struct RustSpaceEvent * event
Definition hyperon.h:652
A table of callback functions to define the behavior of a SpaceObserver implemented in C.
Definition hyperon.h:675
void(* free_payload)(void *payload)
Responsible for freeing the payload passed to space_register_observer
Definition hyperon.h:689
void(* notify)(void *payload, const struct space_event_t *event)
Called to pass an event to the observer.
Definition hyperon.h:682
Represents a Space Observer, registered with a Space.
Definition hyperon.h:661
const struct RustSpaceObserver * observer
Definition hyperon.h:665
Data associated with this particular space, including the space's payload and observers.
Definition hyperon.h:510
struct RustSpaceCommonData * common
Opaque Data maintained by Hyperon.
Definition hyperon.h:518
void * payload
A pointer to the payload passed when the Space was created.
Definition hyperon.h:514
A Space handle, providing access to a Space in which atoms may exist in relation to other atoms.
Definition hyperon.h:448
const struct RustOpaqueSpace * space
Definition hyperon.h:452
Contains the state for an in-flight interpreter operation.
Definition hyperon.h:781
struct RustStepResult * result
Definition hyperon.h:785
Represents a component in a syntax tree created by parsing MeTTa code.
Definition hyperon.h:750
struct RustSyntaxNode * node
Definition hyperon.h:754
A table of callback functions to implement custom atom parsing.
Definition hyperon.h:712
void(* free_context)(void *context)
Frees the context, passed to tokenizer_register_token(), along with all other associated resources.
Definition hyperon.h:727
atom_t(* construct_atom)(const char *str, void *context)
Creates a new Atom based the provided text.
Definition hyperon.h:720
Represents a handle to a Tokenizer, capable of recognizing meaningful Token substrings in text.
Definition hyperon.h:698
const struct RustTokenizer * tokenizer
Definition hyperon.h:702
A handle to a Rust std::fmt::Writer to be used from C code.
Definition hyperon.h:194