Clingo
|
Functions and data structures to work with program ASTs. More...
Classes | |
class | Clingo::AST::Node |
Node capturing expressions in logic programs. More... | |
class | Clingo::AST::RewriteContext |
A context object for rewriting. More... | |
class | Clingo::AST::Program |
A program to add statements to. More... | |
Typedefs | |
using | Clingo::AST::Visitor = std::function< void(Node const &)> |
Function to visit ast nodes. | |
using | Clingo::AST::Transformer = std::function< std::optional< Node >(Node const &)> |
Function to transform ast nodes. | |
Enumerations | |
enum class | Clingo::AST::Attribute : clingo_ast_attribute_t { anonymous = clingo_ast_attribute_anonymous , arguments = clingo_ast_attribute_arguments , arity = clingo_ast_attribute_arity , atom = clingo_ast_attribute_atom , atoms = clingo_ast_attribute_atoms , atom_type = clingo_ast_attribute_atom_type , body = clingo_ast_attribute_body , comment_type = clingo_ast_attribute_comment_type , condition = clingo_ast_attribute_condition , precedence = clingo_ast_attribute_precedence , elements = clingo_ast_attribute_elements , external = clingo_ast_attribute_external , external_type = clingo_ast_attribute_external_type , function = clingo_ast_attribute_function , guard = clingo_ast_attribute_guard , head = clingo_ast_attribute_head , include_type = clingo_ast_attribute_include_type , left = clingo_ast_attribute_left , literal = clingo_ast_attribute_literal , location = clingo_ast_attribute_location , modifier = clingo_ast_attribute_modifier , name = clingo_ast_attribute_name , operators = clingo_ast_attribute_operators , operator_type = clingo_ast_attribute_operator_type , optimize_type = clingo_ast_attribute_optimize_type , pool = clingo_ast_attribute_pool , priority = clingo_ast_attribute_priority , relation = clingo_ast_attribute_relation , right = clingo_ast_attribute_right , script_type = clingo_ast_attribute_script_type , sign = clingo_ast_attribute_sign , symbol = clingo_ast_attribute_symbol , term = clingo_ast_attribute_term , terms = clingo_ast_attribute_terms , theory_operator = clingo_ast_attribute_theory_operator , tuple = clingo_ast_attribute_tuple , tuple_type = clingo_ast_attribute_tuple_type , u = clingo_ast_attribute_u , v = clingo_ast_attribute_v , value = clingo_ast_attribute_value , weight = clingo_ast_attribute_weight } |
Enumeration of available ast attributes. | |
enum class | Clingo::AST::NodeType : clingo_ast_type_t { projection = clingo_ast_type_projection , term_variable = clingo_ast_type_term_variable , term_symbolic = clingo_ast_type_term_symbolic , term_absolute = clingo_ast_type_term_absolute , term_unary_operation = clingo_ast_type_term_unary_operation , term_binary_operation = clingo_ast_type_term_binary_operation , term_tuple = clingo_ast_type_term_tuple , term_function = clingo_ast_type_term_function , argument_tuple = clingo_ast_type_argument_tuple , unparsed_element = clingo_ast_type_unparsed_element , theory_term_variable = clingo_ast_type_theory_term_variable , theory_term_symbolic = clingo_ast_type_theory_term_symbolic , theory_term_tuple = clingo_ast_type_theory_term_tuple , theory_term_function = clingo_ast_type_theory_term_function , theory_term_unparsed = clingo_ast_type_theory_term_unparsed , left_guard = clingo_ast_type_left_guard , right_guard = clingo_ast_type_right_guard , literal_boolean = clingo_ast_type_literal_boolean , literal_comparison = clingo_ast_type_literal_comparison , literal_symbolic = clingo_ast_type_literal_symbolic , set_aggregate_element = clingo_ast_type_set_aggregate_element , theory_atom_element = clingo_ast_type_theory_atom_element , theory_right_guard = clingo_ast_type_theory_right_guard , body_simple_literal = clingo_ast_type_body_simple_literal , body_aggregate_element = clingo_ast_type_body_aggregate_element , body_aggregate = clingo_ast_type_body_aggregate , body_set_aggregate = clingo_ast_type_body_set_aggregate , body_theory_atom = clingo_ast_type_body_theory_atom , body_conditional_literal = clingo_ast_type_body_conditional_literal , head_simple_literal = clingo_ast_type_head_simple_literal , head_aggregate_element = clingo_ast_type_head_aggregate_element , head_aggregate = clingo_ast_type_head_aggregate , head_set_aggregate = clingo_ast_type_head_set_aggregate , head_theory_atom = clingo_ast_type_head_theory_atom , head_conditional_literal = clingo_ast_type_head_conditional_literal , head_disjunction = clingo_ast_type_head_disjunction , theory_operator_definition = clingo_ast_type_theory_operator_definition , theory_term_definition = clingo_ast_type_theory_term_definition , theory_guard_definition = clingo_ast_type_theory_guard_definition , theory_atom_definition = clingo_ast_type_theory_atom_definition , optimize_tuple = clingo_ast_type_optimize_tuple , optimize_element = clingo_ast_type_optimize_element , edge = clingo_ast_type_edge , program_part = clingo_ast_type_program_part , statement_rule = clingo_ast_type_statement_rule , statement_theory = clingo_ast_type_statement_theory , statement_optimize = clingo_ast_type_statement_optimize , statement_weak_constraint = clingo_ast_type_statement_weak_constraint , statement_show = clingo_ast_type_statement_show , statement_show_nothing = clingo_ast_type_statement_show_nothing , statement_show_signature = clingo_ast_type_statement_show_signature , statement_project = clingo_ast_type_statement_project , statement_project_signature = clingo_ast_type_statement_project_signature , statement_defined = clingo_ast_type_statement_defined , statement_external = clingo_ast_type_statement_external , statement_edge = clingo_ast_type_statement_edge , statement_heuristic = clingo_ast_type_statement_heuristic , statement_script = clingo_ast_type_statement_script , statement_program = clingo_ast_type_statement_program , statement_include = clingo_ast_type_statement_include , statement_const = clingo_ast_type_statement_const , statement_parts = clingo_ast_type_statement_parts , statement_comment = clingo_ast_type_statement_comment } |
Enumeration of available ast node types. More... | |
enum class | Clingo::AST::ParseType : clingo_ast_parse_type_t { ParseType::term = clingo_ast_parse_type_term , ParseType::theory_term = clingo_ast_parse_type_theory_term , ParseType::literal = clingo_ast_parse_type_literal , ParseType::body_literal = clingo_ast_parse_type_body_literal , ParseType::head_literal = clingo_ast_parse_type_head_literal , ParseType::statement = clingo_ast_parse_type_statement } |
Enumeration of expression types that can be parsed. More... | |
enum class | Clingo::AST::ProjectionMode : clingo_projection_mode_t { ProjectionMode::disabled = clingo_projection_mode_disabled , ProjectionMode::anonymous = clingo_projection_mode_anonymous , ProjectionMode::pure = clingo_projection_mode_pure } |
The available projection modes. More... | |
Functions | |
void | Clingo::AST::visit (Visitor const &fun, Node const &node) |
Visit the given node with the visitor. | |
void | Clingo::AST::visit (Visitor const &fun, std::optional< Node > const &node) |
Visit the given node with the visitor if engaged. | |
void | Clingo::AST::visit (Visitor const &fun, std::span< Node const > nodes) |
Visit the nodes in the given span with the visitor. | |
auto | Clingo::AST::transform (Transformer const &fun, Node const &node) -> std::optional< Node > |
Transform the given node with the transformer. | |
auto | Clingo::AST::transform (Transformer const &fun, std::optional< Node > const &node) -> std::optional< std::optional< Node > > |
Transform the given node with the transformer if engaged. | |
auto | Clingo::AST::transform (Transformer const &fun, std::vector< Node > nodes) -> std::optional< std::vector< Node > > |
Transform the nodes in the given span with the transformer. | |
auto | Clingo::AST::rewrite (RewriteContext &ctx, Node const &stm) -> std::vector< Node > |
Rewrite a statement with the given rewrite context. | |
auto | Clingo::AST::parse (Library const &lib, std::string_view string, ParseType type=ParseType::statement) -> Node |
Parse an expression of the given type. | |
template<class Callback > | |
void | Clingo::AST::parse (Library const &lib, std::string_view program, Callback &&callback, Clingo::Control const *control=nullptr) |
Parse the program in the given string. | |
template<class Callback > | |
void | Clingo::AST::parse (Library const &lib, std::span< std::string_view const > files, Callback &&callback, Clingo::Control const *control=nullptr) |
Parse the program in the given files. | |
template<class Callback > | |
void | Clingo::AST::parse (Library const &lib, std::initializer_list< std::string_view > files, Callback &&callback, Clingo::Control const *control=nullptr) |
Parse the program in the given files. | |
Functions and data structures to work with program ASTs.
using Clingo::AST::Transformer = typedef std::function<std::optional<Node>(Node const &)> |
Function to transform ast nodes.
The function can either return an updated node or return std::nullopt to keep it as is.
|
strong |
Enumeration of available ast node types.
Each note type is associated with a set of attributes.
|
strong |
|
strong |
|
inline |
Parse the program in the given files.
lib | the library to store symbols in |
files | the files to parse |
callback | callback to report nodes |
control | optional control object to handle aspif |
|
inline |
Parse the program in the given files.
lib | the library to store symbols in |
files | the files to parse |
callback | callback to report nodes |
control | optional control object to handle aspif |
|
inline |
Parse the program in the given string.
lib | the library to store symbols in |
program | the string to parse |
callback | callback to report nodes |
control | optional control object to handle aspif |
|
inline |
Parse an expression of the given type.
lib | the library to store symbols in |
string | the string to parse |
type | the node type to parse |
|
inline |
Rewrite a statement with the given rewrite context.
Removes pools, simplifies arithmetics, parses theory atoms, etc.
ctx | the rewrite context |
stm | the statement to rewrite |
|
inline |
Transform the given node with the transformer.
This function simply calls fun(node)
.
fun | the visitor |
node | the node to transform |
|
inline |
Transform the given node with the transformer if engaged.
fun | the visitor |
node | the node to transform |
|
inline |
Transform the nodes in the given span with the transformer.
fun | the visitor |
nodes | the node to visit |
Visit the given node with the visitor.
This function simply calls fun(node)
.
fun | the visitor |
node | the node to visit |
Visit the given node with the visitor if engaged.
fun | the visitor |
node | the node to visit |