Clingo
|
Working with (evaluated) ground terms and related functions. More...
Typedefs | |
typedef int | clingo_symbol_type_t |
Corresponding type to clingo_symbol_type. | |
typedef uint64_t | clingo_symbol_t |
Type to represent a symbol. | |
typedef bool(* | clingo_symbol_callback_t) (clingo_symbol_t const *symbols, size_t symbols_size, void *data) |
Callback function to inject symbols. | |
Enumerations | |
enum | clingo_symbol_type_e { clingo_symbol_type_number = 0 , clingo_symbol_type_supremum = 1 , clingo_symbol_type_infimum = 2 , clingo_symbol_type_string = 3 , clingo_symbol_type_tuple = 4 , clingo_symbol_type_function = 5 } |
Enumeration of available symbol types. More... | |
Symbol Construction Functions | |
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t | clingo_symbol_create_infimum (void) |
Construct a symbol representing #inf . | |
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t | clingo_symbol_create_supremum (void) |
Construct a symbol representing #sup. | |
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t | clingo_symbol_create_number (int32_t number) |
Construct a symbol representing a number. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_create_number_str (clingo_lib_t *lib, char const *number, size_t size, clingo_symbol_t *symbol) |
Construct a symbol representing a number. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_create_string (clingo_lib_t *lib, char const *string, size_t size, clingo_symbol_t *symbol) |
Construct a symbol representing a string. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_create_id (clingo_lib_t *lib, char const *name, size_t size, bool is_positive, clingo_symbol_t *symbol) |
Construct a symbol representing an id. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_create_tuple (clingo_lib_t *lib, clingo_symbol_t const *arguments, size_t arguments_size, clingo_symbol_t *symbol) |
Construct a symbol representing a tuple. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_create_function (clingo_lib_t *lib, char const *name, size_t name_size, clingo_symbol_t const *arguments, size_t arguments_size, bool is_positive, clingo_symbol_t *symbol) |
Construct a symbol representing a function. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_parse_term (clingo_lib_t *lib, char const *string, size_t size, clingo_symbol_t *symbol) |
Parse a term in string form. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_symbol_acquire (clingo_symbol_t symbol) |
Acquire ownership of the given symbol. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_symbol_release (clingo_symbol_t symbol) |
Release ownership of the given symbol. | |
Symbol Inspection Functions | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_number (clingo_symbol_t symbol, int32_t *number) |
Get the number of a symbol. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_name (clingo_symbol_t symbol, clingo_string_t *name) |
Get the name of a symbol. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_string (clingo_symbol_t symbol, clingo_string_t *string) |
Get the string of a symbol. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_is_positive (clingo_symbol_t symbol, bool *is_positive) |
Check whether a function or number is positive. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_arguments (clingo_symbol_t symbol, clingo_symbol_t const **arguments, size_t *arguments_size) |
Get the arguments of a symbol. | |
CLINGO_VISIBILITY_DEFAULT clingo_symbol_type_t | clingo_symbol_type (clingo_symbol_t symbol) |
Get the type of a symbol. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_to_string (clingo_symbol_t symbol, clingo_string_builder_t *builder) |
Get the string representation of a symbol. | |
Symbol Comparison Functions | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbol_equal (clingo_symbol_t a, clingo_symbol_t b) |
Check if two symbols are equal. | |
CLINGO_VISIBILITY_DEFAULT int | clingo_symbol_compare (clingo_symbol_t a, clingo_symbol_t b) |
Check if a symbol is less than another symbol. | |
CLINGO_VISIBILITY_DEFAULT size_t | clingo_symbol_hash (clingo_symbol_t symbol) |
Calculate a hash code of a symbol. | |
Working with (evaluated) ground terms and related functions.
For an example, see symbol.c.
typedef bool(* clingo_symbol_callback_t) (clingo_symbol_t const *symbols, size_t symbols_size, void *data) |
Callback function to inject symbols.
symbols | array of symbols |
symbols_size | size of the symbol array |
data | user data of the callback |
typedef uint64_t clingo_symbol_t |
Type to represent a symbol.
This includes numbers, strings, tuples, functions (including constants when arguments are empty), #inf
and #sup
.
enum clingo_symbol_type_e |
Enumeration of available symbol types.
CLINGO_VISIBILITY_DEFAULT bool clingo_parse_term | ( | clingo_lib_t * | lib, |
char const * | string, | ||
size_t | size, | ||
clingo_symbol_t * | symbol | ||
) |
Parse a term in string form.
The result of this function is a symbol. The input term can contain unevaluated functions, which are evaluated during parsing.
[in] | lib | library object storing the symbol |
[in] | string | the string to parse |
[in] | size | the size of the string |
[out] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT void clingo_symbol_acquire | ( | clingo_symbol_t | symbol | ) |
Acquire ownership of the given symbol.
Symbols not having any owners, are freed during garbage collection.
[in] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_arguments | ( | clingo_symbol_t | symbol, |
clingo_symbol_t const ** | arguments, | ||
size_t * | arguments_size | ||
) |
Get the arguments of a symbol.
[in] | symbol | the target symbol |
[out] | arguments | the resulting arguments |
[out] | arguments_size | the number of arguments |
CLINGO_VISIBILITY_DEFAULT int clingo_symbol_compare | ( | clingo_symbol_t | a, |
clingo_symbol_t | b | ||
) |
Check if a symbol is less than another symbol.
Symbols are first compared by type. If the types are equal, the values are compared (where strings are compared using strcmp). Functions are first compared by signature and then lexicographically by arguments.
[in] | a | first symbol |
[in] | b | second symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_function | ( | clingo_lib_t * | lib, |
char const * | name, | ||
size_t | name_size, | ||
clingo_symbol_t const * | arguments, | ||
size_t | arguments_size, | ||
bool | is_positive, | ||
clingo_symbol_t * | symbol | ||
) |
Construct a symbol representing a function.
[in] | lib | library object storing the symbol |
[in] | name | the name of the function |
[in] | name_size | the size of the name |
[in] | arguments | the arguments of the function |
[in] | arguments_size | the number of arguments |
[in] | is_positive | whether the symbol is_positive |
[out] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_id | ( | clingo_lib_t * | lib, |
char const * | name, | ||
size_t | size, | ||
bool | is_positive, | ||
clingo_symbol_t * | symbol | ||
) |
Construct a symbol representing an id.
[in] | lib | library object storing the symbol |
[in] | name | the name |
[in] | size | the size of the string |
[in] | is_positive | whether the symbol is positive |
[out] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_infimum | ( | void | ) |
Construct a symbol representing #inf
.
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_number | ( | int32_t | number | ) |
Construct a symbol representing a number.
[in] | number | the number |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_number_str | ( | clingo_lib_t * | lib, |
char const * | number, | ||
size_t | size, | ||
clingo_symbol_t * | symbol | ||
) |
Construct a symbol representing a number.
[in] | lib | library object storing the symbol |
[in] | number | the number in form of a string |
[in] | size | the size of the string |
[out] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_string | ( | clingo_lib_t * | lib, |
char const * | string, | ||
size_t | size, | ||
clingo_symbol_t * | symbol | ||
) |
Construct a symbol representing a string.
[in] | lib | library object storing the symbol |
[in] | string | the string |
[in] | size | the size of the string |
[out] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_supremum | ( | void | ) |
Construct a symbol representing #sup.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_tuple | ( | clingo_lib_t * | lib, |
clingo_symbol_t const * | arguments, | ||
size_t | arguments_size, | ||
clingo_symbol_t * | symbol | ||
) |
Construct a symbol representing a tuple.
[in] | lib | library object storing the symbol |
[in] | arguments | the arguments of the function |
[in] | arguments_size | the number of arguments |
[out] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_equal | ( | clingo_symbol_t | a, |
clingo_symbol_t | b | ||
) |
Check if two symbols are equal.
[in] | a | first symbol |
[in] | b | second symbol |
CLINGO_VISIBILITY_DEFAULT size_t clingo_symbol_hash | ( | clingo_symbol_t | symbol | ) |
Calculate a hash code of a symbol.
[in] | symbol | the target symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_is_positive | ( | clingo_symbol_t | symbol, |
bool * | is_positive | ||
) |
Check whether a function or number is positive.
[in] | symbol | the target symbol |
[out] | is_positive | the result |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_name | ( | clingo_symbol_t | symbol, |
clingo_string_t * | name | ||
) |
Get the name of a symbol.
[in] | symbol | the target symbol |
[out] | name | the resulting name |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_number | ( | clingo_symbol_t | symbol, |
int32_t * | number | ||
) |
Get the number of a symbol.
[in] | symbol | the target symbol |
[out] | number | the resulting number |
CLINGO_VISIBILITY_DEFAULT void clingo_symbol_release | ( | clingo_symbol_t | symbol | ) |
Release ownership of the given symbol.
Symbols not having any owners, are freed during garbage collection.
[in] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_string | ( | clingo_symbol_t | symbol, |
clingo_string_t * | string | ||
) |
Get the string of a symbol.
[in] | symbol | the target symbol |
[out] | string | the resulting string |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_to_string | ( | clingo_symbol_t | symbol, |
clingo_string_builder_t * | builder | ||
) |
CLINGO_VISIBILITY_DEFAULT clingo_symbol_type_t clingo_symbol_type | ( | clingo_symbol_t | symbol | ) |
Get the type of a symbol.
[in] | symbol | the target symbol |