Components needed to interact with the MaTTa language and type system.
More...
|
| 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
|
Components needed to interact with the MaTTa language and type system.
This interface includes Symbol atoms that have special meaning to the MeTTa interpreter, and it provides access to the MeTTa type system
More complete documentation on the MeTTa language, type system, and the MeTTa standard library can be found here: TODO: Where?
◆ atom_error_message()
| 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.
- Parameters
-
| [in] | atom | The error expression atom from which to extract the error message |
| [out] | buf | A buffer into which the text will be rendered |
| [in] | buf_len | The maximum allocated size of buf |
- Returns
- The length of the message string, minus the string terminator character. If return_value > buf_len + 1, then the text was not fully rendered and this function should be called again with a larger buffer.
- Warning
- The atom argument must be an error expression, otherwise this function will panic
◆ atom_is_error()
Checks if an atom is a MeTTa error expression.
- Parameters
-
- Returns
- true is the atom is a MeTTa error expression
◆ ATOM_TYPE_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.
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_BOOL()
| atom_t ATOM_TYPE_BOOL |
( |
void | | ) |
|
Creates an atom used to indicate that an atom's type is a Bool type.
- Returns
- The atom_t representing the atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_EXPRESSION()
| 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.
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_GROUNDED()
| 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.
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_GROUNDED_SPACE()
| 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.
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_NUMBER()
| atom_t ATOM_TYPE_NUMBER |
( |
void | | ) |
|
Creates an atom used to indicate that an atom's type is a Number type.
- Returns
- The atom_t representing the atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_STRING()
| atom_t ATOM_TYPE_STRING |
( |
void | | ) |
|
Creates an atom used to indicate that an atom's type is a String type.
- Returns
- The atom_t representing the atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_SYMBOL()
| 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.
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_TYPE()
| 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.
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_UNDEFINED()
| atom_t ATOM_TYPE_UNDEFINED |
( |
void | | ) |
|
Creates a Symbol atom for the special MeTTa symbol: "%Undefined%".
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_UNIT()
| atom_t ATOM_TYPE_UNIT |
( |
void | | ) |
|
Creates an atom used to indicate that an atom's type is a unit type.
- Returns
- The atom_t representing the atom
- Note
- The returned atom_t must be freed with atom_free()
◆ ATOM_TYPE_VARIABLE()
| 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.
- Returns
- The atom_t representing the Symbol atom
- Note
- The returned atom_t must be freed with atom_free()
◆ check_type()
Checks whether Atom atom has Type typ in context of space
- Parameters
-
| [in] | space | A pointer to the space_t representing the space context in which to perform the check |
| [in] | atom | A pointer to the atom_t or atom_ref_t representing the atom whose Type the function will check |
| [in] | typ | A pointer to the atom_t or atom_ref_t representing the type to check against |
- Returns
- true if the Atom's Type is a match, otherwise false
- Note
- This function can be used for a simple type check when there is no need to know type parameters
◆ EMPTY_ATOM()
Creates a Symbol atom for the special MeTTa symbol used to indicate empty results returned by function.
- Returns
- The atom_t representing the Empty atom
- Note
- The returned atom_t must be freed with atom_free()
◆ get_atom_types()
Provides all types for atom in the context of space
- Parameters
-
| [in] | space | A pointer to the space_t representing the space context in which to access the Atom's types |
| [in] | atom | A pointer to the atom_t or atom_ref_t representing the atom whose Types the function will access |
| [in] | callback | A function that will be called to provide a vector of all type atoms associated with the atom argument atom |
| [in] | context | A pointer to a caller-defined structure to facilitate communication with the callback function |
- Note
- Undefined% will be provided if atom has no type assigned. An empty vector will be provided if atom is a function call but expected types of arguments are not compatible with passed values
◆ METTA_ATOM()
Creates a Symbol atom for the special MeTTa symbol used to indicate calling MeTTa interpreter.
- Returns
- The atom_t representing the interpret atom
- Note
- The returned atom_t must be freed with atom_free()
◆ UNIT_ATOM()
Creates an atom used to return from functions which are not supposed to return results (print for example).
- Returns
- The atom_t representing the Unit atom
- Note
- The returned atom_t must be freed with atom_free()
◆ validate_atom()
Checks whether atom is correctly typed.
- Parameters
-
| [in] | space | A pointer to the space_t representing the space context in which to perform the check |
| [in] | atom | A pointer to the atom_t or atom_ref_t representing the atom whose Type the function will check |
- Returns
- true if the Atom is correctly typed, otherwise false
- Note
- This function can be used to check if function arguments have correct types