Clingo C API
C API for clingo providing high level functions to control grounding and solving.
Classes | Typedefs | Enumerations | Functions
Abstract Syntax Trees

Detailed Description

Functions and data structures to work with program ASTs.

Warning
There might still be changes to this part of the API and there is not much documentation yet. In its current form the interface is rather large but has the advantage that the structure of a logic program is (hopefully) self-explanatory. The API could also be much reduced by, for example, just providing one node type as done in clingo's python API. Feedback would be very welcome!

For an example, see ast.c.

Classes

struct  clingo_ast_term
 
struct  clingo_ast_unary_operation
 
struct  clingo_ast_binary_operation
 
struct  clingo_ast_interval
 
struct  clingo_ast_function
 
struct  clingo_ast_pool
 
struct  clingo_ast_csp_product_term
 
struct  clingo_ast_csp_sum_term
 
struct  clingo_ast_csp_guard
 
struct  clingo_ast_csp_literal
 
struct  clingo_ast_id
 
struct  clingo_ast_comparison
 
struct  clingo_ast_literal
 
struct  clingo_ast_aggregate_guard
 
struct  clingo_ast_conditional_literal
 
struct  clingo_ast_aggregate
 
struct  clingo_ast_body_aggregate_element
 
struct  clingo_ast_body_aggregate
 
struct  clingo_ast_head_aggregate_element
 
struct  clingo_ast_head_aggregate
 
struct  clingo_ast_disjunction
 
struct  clingo_ast_disjoint_element
 
struct  clingo_ast_disjoint
 
struct  clingo_ast_theory_term
 
struct  clingo_ast_theory_term_array
 
struct  clingo_ast_theory_function
 
struct  clingo_ast_theory_unparsed_term_element
 
struct  clingo_ast_theory_unparsed_term
 
struct  clingo_ast_theory_atom_element
 
struct  clingo_ast_theory_guard
 
struct  clingo_ast_theory_atom
 
struct  clingo_ast_head_literal
 
struct  clingo_ast_body_literal
 
struct  clingo_ast_theory_operator_definition
 
struct  clingo_ast_theory_term_definition
 
struct  clingo_ast_theory_guard_definition
 
struct  clingo_ast_theory_atom_definition
 
struct  clingo_ast_theory_definition
 
struct  clingo_ast_rule
 
struct  clingo_ast_definition
 
struct  clingo_ast_show_signature
 
struct  clingo_ast_show_term
 
struct  clingo_ast_minimize
 
struct  clingo_ast_script
 
struct  clingo_ast_program
 
struct  clingo_ast_external
 
struct  clingo_ast_edge
 
struct  clingo_ast_heuristic
 
struct  clingo_ast_project
 
struct  clingo_ast_statement
 

Typedefs

typedef int clingo_ast_comparison_operator_t
 
typedef int clingo_ast_sign_t
 
typedef int clingo_ast_term_type_t
 
typedef struct clingo_ast_unary_operation clingo_ast_unary_operation_t
 
typedef struct clingo_ast_binary_operation clingo_ast_binary_operation_t
 
typedef struct clingo_ast_interval clingo_ast_interval_t
 
typedef struct clingo_ast_function clingo_ast_function_t
 
typedef struct clingo_ast_pool clingo_ast_pool_t
 
typedef struct clingo_ast_term clingo_ast_term_t
 
typedef int clingo_ast_unary_operator_t
 
typedef int clingo_ast_binary_operator_t
 
typedef struct clingo_ast_csp_product_term clingo_ast_csp_product_term_t
 
typedef struct clingo_ast_csp_sum_term clingo_ast_csp_sum_term_t
 
typedef struct clingo_ast_csp_guard clingo_ast_csp_guard_t
 
typedef struct clingo_ast_csp_literal clingo_ast_csp_literal_t
 
typedef struct clingo_ast_id clingo_ast_id_t
 
typedef struct clingo_ast_comparison clingo_ast_comparison_t
 
typedef int clingo_ast_literal_type_t
 
typedef struct clingo_ast_literal clingo_ast_literal_t
 
typedef int clingo_ast_aggregate_function_t
 
typedef struct clingo_ast_aggregate_guard clingo_ast_aggregate_guard_t
 
typedef struct clingo_ast_conditional_literal clingo_ast_conditional_literal_t
 
typedef struct clingo_ast_aggregate clingo_ast_aggregate_t
 
typedef struct clingo_ast_body_aggregate_element clingo_ast_body_aggregate_element_t
 
typedef struct clingo_ast_body_aggregate clingo_ast_body_aggregate_t
 
typedef struct clingo_ast_head_aggregate_element clingo_ast_head_aggregate_element_t
 
typedef struct clingo_ast_head_aggregate clingo_ast_head_aggregate_t
 
typedef struct clingo_ast_disjunction clingo_ast_disjunction_t
 
typedef struct clingo_ast_disjoint_element clingo_ast_disjoint_element_t
 
typedef struct clingo_ast_disjoint clingo_ast_disjoint_t
 
typedef int clingo_ast_theory_term_type_t
 
typedef struct clingo_ast_theory_function clingo_ast_theory_function_t
 
typedef struct clingo_ast_theory_term_array clingo_ast_theory_term_array_t
 
typedef struct clingo_ast_theory_unparsed_term clingo_ast_theory_unparsed_term_t
 
typedef struct clingo_ast_theory_term clingo_ast_theory_term_t
 
typedef struct clingo_ast_theory_unparsed_term_element clingo_ast_theory_unparsed_term_element_t
 
typedef struct clingo_ast_theory_atom_element clingo_ast_theory_atom_element_t
 
typedef struct clingo_ast_theory_guard clingo_ast_theory_guard_t
 
typedef struct clingo_ast_theory_atom clingo_ast_theory_atom_t
 
typedef int clingo_ast_head_literal_type_t
 
typedef struct clingo_ast_head_literal clingo_ast_head_literal_t
 
typedef int clingo_ast_body_literal_type_t
 
typedef struct clingo_ast_body_literal clingo_ast_body_literal_t
 
typedef int clingo_ast_theory_operator_type_t
 
typedef struct clingo_ast_theory_operator_definition clingo_ast_theory_operator_definition_t
 
typedef struct clingo_ast_theory_term_definition clingo_ast_theory_term_definition_t
 
typedef struct clingo_ast_theory_guard_definition clingo_ast_theory_guard_definition_t
 
typedef int clingo_ast_theory_atom_definition_type_t
 
typedef struct clingo_ast_theory_atom_definition clingo_ast_theory_atom_definition_t
 
typedef struct clingo_ast_theory_definition clingo_ast_theory_definition_t
 
typedef struct clingo_ast_rule clingo_ast_rule_t
 
typedef struct clingo_ast_definition clingo_ast_definition_t
 
typedef struct clingo_ast_show_signature clingo_ast_show_signature_t
 
typedef struct clingo_ast_show_term clingo_ast_show_term_t
 
typedef struct clingo_ast_minimize clingo_ast_minimize_t
 
typedef int clingo_ast_script_type_t
 
typedef struct clingo_ast_script clingo_ast_script_t
 
typedef struct clingo_ast_program clingo_ast_program_t
 
typedef struct clingo_ast_external clingo_ast_external_t
 
typedef struct clingo_ast_edge clingo_ast_edge_t
 
typedef struct clingo_ast_heuristic clingo_ast_heuristic_t
 
typedef struct clingo_ast_project clingo_ast_project_t
 
typedef int clingo_ast_statement_type_t
 
typedef struct clingo_ast_statement clingo_ast_statement_t
 
typedef bool(* clingo_ast_callback_t) (clingo_ast_statement_t const *, void *)
 

Enumerations

enum  clingo_ast_comparison_operator {
  clingo_ast_comparison_operator_greater_than = 0, clingo_ast_comparison_operator_less_than = 1, clingo_ast_comparison_operator_less_equal = 2, clingo_ast_comparison_operator_greater_equal = 3,
  clingo_ast_comparison_operator_not_equal = 4, clingo_ast_comparison_operator_equal = 5
}
 
enum  clingo_ast_sign { clingo_ast_sign_none = 0, clingo_ast_sign_negation = 1, clingo_ast_sign_double_negation = 2 }
 
enum  clingo_ast_term_type {
  clingo_ast_term_type_symbol = 0, clingo_ast_term_type_variable = 1, clingo_ast_term_type_unary_operation = 2, clingo_ast_term_type_binary_operation = 3,
  clingo_ast_term_type_interval = 4, clingo_ast_term_type_function = 5, clingo_ast_term_type_external_function = 6, clingo_ast_term_type_pool = 7
}
 
enum  clingo_ast_unary_operator { clingo_ast_unary_operator_minus = 0, clingo_ast_unary_operator_negation = 1, clingo_ast_unary_operator_absolute = 2 }
 
enum  clingo_ast_binary_operator {
  clingo_ast_binary_operator_xor = 0, clingo_ast_binary_operator_or = 1, clingo_ast_binary_operator_and = 2, clingo_ast_binary_operator_plus = 3,
  clingo_ast_binary_operator_minus = 4, clingo_ast_binary_operator_multiplication = 5, clingo_ast_binary_operator_division = 6, clingo_ast_binary_operator_modulo = 7
}
 
enum  clingo_ast_literal_type { clingo_ast_literal_type_boolean = 0, clingo_ast_literal_type_symbolic = 1, clingo_ast_literal_type_comparison = 2, clingo_ast_literal_type_csp = 3 }
 
enum  clingo_ast_aggregate_function {
  clingo_ast_aggregate_function_count = 0, clingo_ast_aggregate_function_sum = 1, clingo_ast_aggregate_function_sump = 2, clingo_ast_aggregate_function_min = 3,
  clingo_ast_aggregate_function_max = 4
}
 
enum  clingo_ast_theory_term_type {
  clingo_ast_theory_term_type_symbol = 0, clingo_ast_theory_term_type_variable = 1, clingo_ast_theory_term_type_tuple = 2, clingo_ast_theory_term_type_list = 3,
  clingo_ast_theory_term_type_set = 4, clingo_ast_theory_term_type_function = 5, clingo_ast_theory_term_type_unparsed_term = 6
}
 
enum  clingo_ast_head_literal_type {
  clingo_ast_head_literal_type_literal = 0, clingo_ast_head_literal_type_disjunction = 1, clingo_ast_head_literal_type_aggregate = 2, clingo_ast_head_literal_type_head_aggregate = 3,
  clingo_ast_head_literal_type_theory_atom = 4
}
 
enum  clingo_ast_body_literal_type {
  clingo_ast_body_literal_type_literal = 0, clingo_ast_body_literal_type_conditional = 1, clingo_ast_body_literal_type_aggregate = 2, clingo_ast_body_literal_type_body_aggregate = 3,
  clingo_ast_body_literal_type_theory_atom = 4, clingo_ast_body_literal_type_disjoint = 5
}
 
enum  clingo_ast_theory_operator_type { clingo_ast_theory_operator_type_unary = 0, clingo_ast_theory_operator_type_binary_left = 1, clingo_ast_theory_operator_type_binary_right = 2 }
 
enum  clingo_ast_theory_atom_definition_type { clingo_ast_theory_atom_definition_type_head = 0, clingo_ast_theory_atom_definition_type_body = 1, clingo_ast_theory_atom_definition_type_any = 2, clingo_ast_theory_atom_definition_type_directive = 3 }
 
enum  clingo_ast_script_type { clingo_ast_script_type_lua = 0, clingo_ast_script_type_python = 1 }
 
enum  clingo_ast_statement_type {
  clingo_ast_statement_type_rule = 0, clingo_ast_statement_type_const = 1, clingo_ast_statement_type_show_signature = 2, clingo_ast_statement_type_show_term = 3,
  clingo_ast_statement_type_minimize = 4, clingo_ast_statement_type_script = 5, clingo_ast_statement_type_program = 6, clingo_ast_statement_type_external = 7,
  clingo_ast_statement_type_edge = 8, clingo_ast_statement_type_heuristic = 9, clingo_ast_statement_type_project_atom = 10, clingo_ast_statement_type_project_atom_signature = 11,
  clingo_ast_statement_type_theory_definition = 12
}
 

Functions

CLINGO_VISIBILITY_DEFAULT bool clingo_parse_program (char const *program, clingo_ast_callback_t callback, void *callback_data, clingo_logger_t logger, void *logger_data, unsigned message_limit)
 Parse the given program and return an abstract syntax tree for each statement via a callback. More...
 

Function Documentation

◆ clingo_parse_program()

CLINGO_VISIBILITY_DEFAULT bool clingo_parse_program ( char const *  program,
clingo_ast_callback_t  callback,
void *  callback_data,
clingo_logger_t  logger,
void *  logger_data,
unsigned  message_limit 
)

Parse the given program and return an abstract syntax tree for each statement via a callback.

Parameters
[in]programthe program in gringo syntax
[in]callbackthe callback reporting statements
[in]callback_datauser data for the callback
[in]loggercallback to report messages during parsing
[in]logger_datauser data for the logger
[in]message_limitthe maximum number of times the logger is called
Returns
whether the call was successful; might set one of the following error codes:
Examples:
ast.c.