151typedef struct RustBindings RustBindings;
153typedef struct RustBindingsSet RustBindingsSet;
155typedef struct RustEnvBuilder RustEnvBuilder;
157typedef struct RustMetta RustMetta;
164typedef struct RustModuleDescriptor RustModuleDescriptor;
166typedef struct RustOpaqueAtom RustOpaqueAtom;
168typedef struct RustOpaqueExecError RustOpaqueExecError;
170typedef struct RustOpaqueSpace RustOpaqueSpace;
172typedef struct RustRunContext RustRunContext;
174typedef struct RustRunnerState RustRunnerState;
176typedef struct RustSpaceCommonData RustSpaceCommonData;
178typedef struct RustSpaceEvent RustSpaceEvent;
180typedef struct RustSpaceObserver RustSpaceObserver;
182typedef struct RustStepResult RustStepResult;
184typedef struct RustSyntaxNode RustSyntaxNode;
186typedef struct RustTokenizer RustTokenizer;
198typedef enum RustAtom_Tag {
204typedef struct RustAtom {
208 struct RustOpaqueAtom *owned;
211 const struct RustOpaqueAtom *borrowed;
236typedef struct RustAtom
atom_t;
250 struct RustOpaqueAtom *
ptr;
273typedef enum exec_error_t_Tag {
279 exec_error_t_Tag tag;
282 struct RustOpaqueExecError *status;
296 struct RustBindingsSet *
set;
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);
452 const struct RustOpaqueSpace *
space;
953 const char *parent_dir,
954 const char *mod_name,
969 const char *mod_name,
1938 void *observer_payload);
2187 uintptr_t *range_start,
2188 uintptr_t *range_end);
2612 const char *name_ref,
2693 const char *message);
2923 const char *resource_dir_path);
2946enum serial_result_t serialize_bool_rust_adapter(
void *context,
bool v);
2948enum serial_result_t serialize_longlong_rust_adapter(
void *context,
long long v);
2950enum serial_result_t serialize_double_rust_adapter(
void *context,
double v);
2952enum serial_result_t serialize_str_rust_adapter(
void *context,
const char *v);
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_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 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