|
Hyperon C
|
Interface for working with atom matching and variable-to-atom binding. More...
Classes | |
| struct | bindings_set_t |
| Represents a set of Bindings frames. Potentially expressing all possible matches produced by a match operarion. 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... | |
Typedefs | |
| 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. | |
Functions | |
| 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_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. | |
Interface for working with atom matching and variable-to-atom 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.
| [in] | bindings | A pointer to the bindings_t. It is ok to call functions that modify the bindings_t within the callback |
| [in] | context | The context state pointer initially passed to the upstream function initiating the callback |
| 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.
| [in] | var | A reference to the Variable atom. This atom should not be modified or freed by the callback |
| [in] | value | A reference to the other atom associated with the variable. This atom should not be modified or freed by the callback |
| [in] | context | The context state pointer initially passed to the upstream function initiating the callback |
| 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.
| [in] | a | A pointer to an atom_t or an atom_ref_t to match |
| [in] | b | A pointer to another atom_t or an atom_ref_t to match against |
| 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
| [in] | bindings | A pointer to the bindings_t to add the association to |
| [in] | var | The Variable atom (L-value) for the variable <-> atom association |
| [in] | atom | The other atom (R-value) for the variable <-> atom association |
| struct bindings_t bindings_clone | ( | const struct bindings_t * | bindings | ) |
Makes a "deep copy" of a bindings_t
| [in] | bindings | A pointer to the bindings_t to clone |
| bool bindings_eq | ( | const struct bindings_t * | a, |
| const struct bindings_t * | b ) |
Checks if two bindings_t objects contain identical associations.
| [in] | a | A pointer to a bindings_t representing the first Bindings frame |
| [in] | b | A pointer to a bindings_t representing the second Bindings frame |
| void bindings_free | ( | struct bindings_t | bindings | ) |
Frees a bindings_t
| [in] | bindings | The bindings_t to free |
| bool bindings_is_empty | ( | const struct bindings_t * | bindings | ) |
Checks if a bindings_t contains no associations.
| [in] | bindings | A pointer to the bindings_t to inspect |
| 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.
| [in] | _self | The first bindings_t to merge. Ownership of this argument is taken by this function |
| [in] | other | A pointer to the second bindings_t to merge. This argument is not modified |
| 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.
| [in] | bindings | A pointer to the bindings_t to modify |
| [in] | vars | A pointer to a vec of Variable atoms, to specify which variables should remain in the Bindings |
| struct bindings_t bindings_new | ( | void | ) |
Creates a new bindings_t containing no variable <-> atom associations, leaving all variables free to match any atom.
| 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
| [in] | bindings | A pointer to the bindings_t to inspect |
| [in] | var | The Variable atom (L-value) for the variable <-> atom association |
| 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.
| [in] | set | A pointer to the bindings_set_t to modify |
| [in] | var | A pointer to the Variable atom |
| [in] | value | A pointer to the other atom to associate the variable with |
| 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.
| [in] | set | A pointer to the bindings_set_t to modify |
| [in] | a | A pointer to the first Variable atom for the variable <-> variable association |
| [in] | b | A pointer to the second Variable atom for the variable <-> variable association |
| struct bindings_set_t bindings_set_clone | ( | const struct bindings_set_t * | set | ) |
Makes a "deep copy" of a bindings_set_t
| [in] | set | A pointer to the bindings_set_t to use as the source for the clone |
| 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.
| 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.
| [in] | a | A pointer to a bindings_set_t representing the first Bindings Set |
| [in] | b | A pointer to a bindings_set_t representing the second Bindings Set |
| void bindings_set_free | ( | struct bindings_set_t | set | ) |
Frees a bindings_set_t
| [in] | set | The bindings_set_t to free |
| struct bindings_set_t bindings_set_from_bindings | ( | struct bindings_t | bindings | ) |
Creates a new bindings_set_t with the specified Bindings frame.
| [in] | bindings | The bindings_t to incorporate into the new Bindings Set. Ownership of this argument is taken by this function |
| 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.
| [in] | set | A pointer to the bindings_set_t to inspect |
| 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.
| [in] | set | A pointer to the bindings_set_t to inspect |
| 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.
| [in] | set | A pointer to the bindings_set_t to iterate |
| [in] | callback | A function that will be called to provide access to each Bindings frame |
| [in] | context | A pointer to a caller-defined structure to facilitate communication with the callback function |
| 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.
| [in] | _self | A pointer to the bindings_set_t to modify |
| [in] | other | A pointer to another 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
| [in] | set | The bindings_set_t to add bindings into |
| [in] | bindings | The bindings_t to incorporate into set. Ownership of this argument is taken by this function |
| 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.
| 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
| [in] | set | A pointer to the bindings_set_t to render |
| [out] | buf | A buffer into which the text will be rendered |
| [in] | buf_len | The maximum allocated size of buf |
| uintptr_t bindings_to_str | ( | const struct bindings_t * | bindings, |
| char * | buf, | ||
| uintptr_t | buf_len ) |
Renders a text description of a bindings_t
| [in] | bindings | A pointer to the bindings_t to render |
| [out] | buf | A buffer into which the text will be rendered |
| [in] | buf_len | The maximum allocated size of buf |
| 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
| [in] | bindings | A pointer to the bindings_t to iterate |
| [in] | callback | A function that will be called for each variable <-> atom pair within the Bindings frame |
| [in] | context | A pointer to a caller-defined structure to facilitate communication with the callback function |