Hyperon C
Loading...
Searching...
No Matches
hyperon.h File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  write_t
 A handle to a Rust std::fmt::Writer to be used from C code. More...
struct  atom_vec_t
 Contains a vector (list) of Atoms. More...
struct  exec_error_t
 Represents a status used to communicate between Grounded Atom execution and the MeTTa interpreter. More...
struct  bindings_set_t
 Represents a set of Bindings frames. Potentially expressing all possible matches produced by a match operarion. More...
struct  serializer_api_t
 A table of functions to receive values encoded as specific primitive types. More...
struct  gnd_api_t
 A table of callback functions to implement a Grounded Atom with behavior defined in C. More...
struct  gnd_t
 A struct header that must preface a buffer used as a backing object for a Grounded Atom. More...
struct  space_t
 A Space handle, providing access to a Space in which atoms may exist in relation to other atoms. More...
struct  bindings_t
 Represents a single Bindings frame, which is a group of mutually-compatible variable <-> atom associations, providing a scope in which variable have definde values. More...
struct  space_params_t
 Data associated with this particular space, including the space's payload and observers. More...
struct  space_api_t
 A table of functions to define the behavior of a Space implemented in C. More...
struct  space_event_t
 Represents a Space Event. More...
struct  space_observer_t
 Represents a Space Observer, registered with a Space. More...
struct  space_observer_api_t
 A table of callback functions to define the behavior of a SpaceObserver implemented in C. More...
struct  tokenizer_t
 Represents a handle to a Tokenizer, capable of recognizing meaningful Token substrings in text. More...
struct  token_api_t
 A table of callback functions to implement custom atom parsing. More...
struct  sexpr_parser_t
 Represents an S-Expression Parser state machine, to parse input text into an Atom. More...
struct  syntax_node_t
 Represents a component in a syntax tree created by parsing MeTTa code. More...
struct  step_result_t
 Contains the state for an in-flight interpreter operation. More...
struct  metta_t
 A top-level MeTTa runner. More...
struct  run_context_t
 An interface object providing access to the MeTTa run interface. More...
struct  metta_mod_ref_t
 MettaMod C API wrapper. More...
struct  module_loader_t
 A C representation of the Rust [ModuleLoader] interface. User can provide [ModuleLoader] methods implemented in C. More...
struct  env_builder_t
 Represents an environment initialization, in progress. More...
struct  module_id_t
 Identifies a loaded module inside a specific metta_t MeTTa runner. More...
struct  runner_state_t
 Represents the state of an in-flight MeTTa execution run. More...
struct  module_descriptor_t
 Identifies the properties on a specific module, including its name and version. More...
struct  fs_module_format_t
 A table of functions to load MeTTa modules from an arbitrary format. More...

Typedefs

typedef struct RustEnvBuilder RustEnvBuilder
typedef struct RustMetta RustMetta
typedef struct RustMettaModRef RustMettaModRef
typedef struct RustModuleDescriptor RustModuleDescriptor
typedef struct RustRunContext RustRunContext
typedef struct RustRunnerState RustRunnerState
typedef struct RustSyntaxNode RustSyntaxNode
typedef 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
typedef void(* c_atom_callback_t) (atom_ref_t atom, void *context)
 Function signature for a callback providing access to an atom.
typedef 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 binding.
typedef 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 Bindings Set.
typedef 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

Enumerations

enum  serial_result_t { OK , NOT_SUPPORTED }
enum  atom_type_t { SYMBOL , VARIABLE , EXPR , GROUNDED }
 Represents whether an atom is a Symbol, Variable, Expression, or Grounded atom. More...
enum  space_event_type_t { SPACE_EVENT_TYPE_ADD , SPACE_EVENT_TYPE_REMOVE , SPACE_EVENT_TYPE_REPLACE }
 Represents different types of Space Events. More...
enum  space_event_field_t { SPACE_EVENT_FIELD_ADD , SPACE_EVENT_FIELD_REMOVE , SPACE_EVENT_FIELD_REPLACE_PATTERN , SPACE_EVENT_FIELD_REPLACE_TEMPLATE }
 Accessor constants, to access the fields of a space_event_t More...
enum  syntax_node_type_t {
  COMMENT , VARIABLE_TOKEN , STRING_TOKEN , WORD_TOKEN ,
  OPEN_PAREN , CLOSE_PAREN , WHITESPACE , LEFTOVER_TEXT ,
  EXPRESSION_GROUP , ERROR_GROUP
}
 The type of language construct respresented by a syntax_node_t. More...

Functions

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.
void log_info (const char *msg)
 Logs an informative message through the MeTTa library's logger.
intptr_t write_str (struct write_t cwrite, const char *text)
 Write C string into a Rust writer.
atom_ref_t atom_ref (const atom_t *atom)
 Create an atom_ref_t that points to another atom you own.
atom_ref_t atom_ref_null (void)
 Create an atom_ref_t that points nothing.
atom_t atom_sym (const char *name)
 Create a new Symbol atom with the specified name.
atom_t atom_expr (atom_t *children, uintptr_t size)
 Create a new Expression atom with the specified children atoms.
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
atom_t atom_var (const char *name)
 Create a new Variable atom with the specified name.
atom_t atom_var_parse_name (const char *name)
 Create a new Variable atom parsing full formatted name of the variable.
atom_t atom_gnd (struct gnd_t *gnd)
atom_t atom_bool (bool b)
atom_t atom_int (int64_t n)
atom_t atom_float (double f)
atom_t atom_gnd_for_space (const struct space_t *space)
 Creates a Grounded Atom referencing a Space.
void atom_free (atom_t atom)
 Frees an atom and all associated resources.
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
bool atom_eq (const atom_ref_t *a, const atom_ref_t *b)
 Checks if two atom objects represent the same conceptual atom.
bool atoms_are_equivalent (const atom_ref_t *a, const atom_ref_t *b)
 Checks if two atoms are alpha equivalent.
enum atom_type_t atom_get_metatype (const atom_ref_t *atom)
 Returns the metatype of an atom.
bool atom_is_null (const atom_ref_t *atom)
 Returns true if the referenced atom is invalid, otherwise returns false
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.
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.
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.
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_get_grounded_type (const atom_ref_t *atom)
 Retrieve the grounded type of a Grounded Atom.
struct gnd_tatom_get_object (const atom_ref_t *atom)
 Access a pointer to an object backing a Grounded Atom.
bool atom_is_cgrounded (const atom_ref_t *atom)
 Check if the atom refers to CGrounded object.
struct space_t atom_get_space (const atom_ref_t *atom)
 Access the space wrapped inside a Grounded atom.
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.
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 process the atoms as they are.
struct exec_error_t exec_error_incorrect_argument (void)
 Creates a new exec_error_t representing a "Incorrect Argument" status, telling the MeTTa interpreter that argument was not recognized by the function implementation.
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.
void exec_error_free (struct exec_error_t error)
 Frees an exec_error_t
void throw_panic_with_message (const char *message)
 Used to throw panic from C Api with message to prevent panics without any info.
struct atom_vec_t atom_vec_new (void)
 Creates a new empty atom_vec_t
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
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.
void atom_vec_free (struct atom_vec_t vec)
 Frees a atom_vec_t
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_push (struct atom_vec_t *vec, atom_t atom)
 Push the atom onto the end of the vec.
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.
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.
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.
struct bindings_t bindings_new (void)
 Creates a new bindings_t containing no variable <-> atom associations, leaving all variables free to match any atom.
void bindings_free (struct bindings_t bindings)
 Frees a bindings_t
struct bindings_t bindings_clone (const struct bindings_t *bindings)
 Makes a "deep copy" of a bindings_t
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_eq (const struct bindings_t *a, const struct bindings_t *b)
 Checks if two bindings_t objects contain identical associations.
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
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
bool bindings_is_empty (const struct bindings_t *bindings)
 Checks if a bindings_t contains no associations.
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_merge (struct bindings_t _self, const struct bindings_t *other)
 Merges two bindings_t Bindings frames together into a Bindings Set.
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.
struct bindings_set_t bindings_set_empty (void)
 Creates a new bindings_set_t without any Bindings frames. Conceptually this means no valid matches exist.
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 able to take on any value.
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_set_push (struct bindings_set_t *set, struct bindings_t bindings)
 Adds a Bindings frame to an existing bindings_set_t
void bindings_set_free (struct bindings_set_t set)
 Frees a 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
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.
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
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.
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 take on any value.
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.
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.
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.
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 space_t space_new (const struct space_api_t *api, void *payload)
 Creates a new Space, backed by an implementation in C.
void space_free (struct space_t space)
 Frees a space_t handle.
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
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_get_payload (struct space_t *space)
 Access the payload object belonging to a space implemented in C.
void space_add (struct space_t *space, atom_t atom)
 Adds an atom to the Space.
bool space_remove (struct space_t *space, const atom_ref_t *atom)
 Removes a specific atom from the Space.
bool space_replace (struct space_t *space, const atom_ref_t *from, atom_t to)
 Replaces an Atom in the Space with another Atom.
struct bindings_set_t space_query (const struct space_t *space, const atom_ref_t *pattern)
 Queries a Space for atoms matching a pattern.
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.
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_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 space_t space_new_grounding_space (void)
 Creates a new Space, backed by a GroundSpace.
enum space_event_type_t space_event_get_type (const struct space_event_t *event)
 Gets the type of a Space Event.
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
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_free (struct space_observer_t observer)
 Frees a space_observer_t
void * space_observer_get_payload (const struct space_observer_t *observer)
 Returns a pointer to the payload associated with the space_observer_t.
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_add (atom_t atom)
 Creates a new space_event_t representing an Add 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_replace (atom_t pattern, atom_t tmpl)
 Creates a new space_event_t representing a Replace event.
void space_event_free (struct space_event_t event)
 Frees a space_event_t
struct tokenizer_t tokenizer_new (void)
 Creates a new Tokenizer, without any registered Tokens.
void tokenizer_free (struct tokenizer_t tokenizer)
 Frees a Tokenizer handle.
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.
struct tokenizer_t tokenizer_clone (const struct tokenizer_t *tokenizer)
 Performs a "deep copy" of a Tokenizer.
struct sexpr_parser_t sexpr_parser_new (const char *text)
 Creates a new S-Expression Parser.
void sexpr_parser_free (struct sexpr_parser_t parser)
 Frees an S-Expression Parser.
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.
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 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_free (struct syntax_node_t node)
 Frees a syntax_node_t.
struct syntax_node_t syntax_node_clone (const struct syntax_node_t *node)
 Creates a deep copy of a syntax_node_t
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.
enum syntax_node_type_t syntax_node_type (const struct syntax_node_t *node)
 Returns the type of 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.
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.
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 node.
bool atom_is_error (const atom_ref_t *atom)
 Checks if an atom is a MeTTa error expression.
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_UNDEFINED (void)
 Creates a Symbol atom for the special MeTTa symbol: "%Undefined%".
atom_t ATOM_TYPE_TYPE (void)
 Creates a Symbol atom for the special MeTTa symbol: "Type", used to indicate that an atom represents the type of another atom.
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 generic atom.
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 a symbol atom.
atom_t ATOM_TYPE_VARIABLE (void)
 Creates a Symbol atom for the special MeTTa symbol: "Variable", used to indicate that an atom's type is a variable atom.
atom_t ATOM_TYPE_EXPRESSION (void)
 Creates a Symbol atom for the special MeTTa symbol: "Expression", used to indicate that an atom's type is an expression atom.
atom_t ATOM_TYPE_GROUNDED (void)
 Creates a Symbol atom for the special MeTTa symbol: "Grounded", used to indicate that an atom's type is a grounded atom.
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 around a 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_NUMBER (void)
 Creates an atom used to indicate that an atom's type is a Number type.
atom_t ATOM_TYPE_BOOL (void)
 Creates an atom used to indicate that an atom's type is a Bool type.
atom_t ATOM_TYPE_STRING (void)
 Creates an atom used to indicate that an atom's type is a String type.
atom_t EMPTY_ATOM (void)
 Creates a Symbol atom for the special MeTTa symbol used to indicate empty results returned by function.
atom_t UNIT_ATOM (void)
 Creates an atom used to return from functions which are not supposed to return results (print for example).
atom_t METTA_ATOM (void)
 Creates a Symbol atom for the special MeTTa symbol used to indicate calling MeTTa interpreter.
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
bool validate_atom (const struct space_t *space, const atom_ref_t *atom)
 Checks whether atom is correctly typed.
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
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 step_result_t interpret_step (struct step_result_t step)
 Takes a subsequent step in an in-flight interpreter operation.
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.
bool step_has_next (const struct step_result_t *step)
 Examines a step_result_t to determine if more work is needed.
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.
struct metta_t metta_new (void)
 Creates a new top-level MeTTa Runner, with only the Rust stdlib loaded.
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 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 metta_t metta_clone_handle (const struct metta_t *metta)
 Clones a metta_t handle.
void metta_free (struct metta_t metta)
 Frees a metta_t handle.
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_module call.
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 space_t metta_space (struct metta_t *metta)
 Provides access to the Space of the runner's top-level module.
struct tokenizer_t metta_tokenizer (struct metta_t *metta)
 Provides access to the Tokenizer of the runner's top-level module.
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.
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.
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.
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.
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.
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 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 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.
struct space_t run_context_get_space (const struct run_context_t *run_context)
 Provides access to the Space of the currently running 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.
void run_context_raise_error (struct run_context_t *run_context, const char *message)
 Sets a runtime error.
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.
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 runner_state_free (struct runner_state_t state)
 Frees a runner_state_t.
const char * runner_state_err_str (const struct runner_state_t *state)
 Returns the error string associated with the last runner_state_step
void runner_state_step (struct runner_state_t *state)
 Runs one step of the runner.
bool runner_state_is_complete (const struct runner_state_t *state)
 Returns whether or not the runner_state_t has completed all outstanding work.
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 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.
uintptr_t environment_config_dir (char *buf, uintptr_t buf_len)
 Renders the config_dir path from the common environment into a text buffer.
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.
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.
bool env_builder_init_common_env (struct env_builder_t builder)
 Finishes initialization of the common environment.
void env_builder_set_working_dir (struct env_builder_t *builder, const char *path)
 Sets the working directory for the environment.
void env_builder_set_config_dir (struct env_builder_t *builder, const char *path)
 Sets the config directory for the environment.
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.
void env_builder_set_default_config_dir (struct env_builder_t *builder)
 Sets the default config directory for the environment.
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_push_include_path (struct env_builder_t *builder, const char *path)
 Adds a directory to search for module imports.
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.
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 loaded.
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.
enum serial_result_t serialize_bool_rust_adapter (void *context, bool v)
enum serial_result_t serialize_longlong_rust_adapter (void *context, long long v)
enum serial_result_t serialize_double_rust_adapter (void *context, double v)
enum serial_result_t serialize_str_rust_adapter (void *context, const char *v)
struct tokenizer_t metta_mod_ref_tokenizer (const struct metta_mod_ref_t *mod_ref)
 Returns tokenizer of the MeTTa module.
struct module_descriptor_t module_descriptor_new (const char *name)
 Creates a new module_descriptor_t with the specified name.
struct module_descriptor_t module_descriptor_new_with_path_and_fmt_id (const char *name, const char *path, uint64_t fmt_id)
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.
void module_descriptor_free (struct module_descriptor_t descriptor)
 Frees a module_descriptor_t.
bool module_id_is_valid (const struct module_id_t *mod_id)
 Returns true is a module_id_t is valid, otherwise returns false

Typedef Documentation

◆ RustMettaModRef

This structure is required to remove notice of MettaMod from C header file

Enumeration Type Documentation

◆ serial_result_t

enum serial_result_t
Enumerator
OK 

Successful serialization.

NOT_SUPPORTED 

Serialization of the value is not supported by serializer.