Clingo
|
Node capturing expressions in logic programs. More...
#include <ast.hh>
Public Member Functions | |
Node (clingo_ast_t *ast, bool copy=false) | |
Construct a node form its C representation. | |
template<NodeType Type, class Updater > | |
auto | update (Library const &lib, Updater const &fun) const -> Node |
Visit a node of the given type. | |
void | accept (Visitor const &fun) const |
Visit the direct children of the node with the given visitor. | |
auto | accept (Library const &lib, Transformer const &fun) const -> std::optional< Node > |
Transform the direct children of the node with the given transformer. | |
auto | type () const -> NodeType |
Get the type of the node. | |
auto | number (Attribute attribute) const -> int |
Get the numeric value of the given attribute. | |
auto | symbol (Attribute attribute) const -> Symbol |
Get the symbolic value of the given attribute. | |
auto | symbols (Attribute attribute) const -> SymbolVector |
Get the symbolic values of the given attribute. | |
auto | location (Attribute attribute) const -> Location |
Get the location value of the given attribute. | |
auto | string (Attribute attribute) const -> std::string_view |
Get the string value of the given attribute. | |
auto | strings (Attribute attribute) const -> std::vector< std::string_view > |
Get the string values of the given attribute. | |
auto | node (Attribute attribute) const -> Node |
Get the node value of the given attribute. | |
auto | optional_node (Attribute attribute) const -> std::optional< Node > |
Get the optional node value of the given attribute. | |
auto | nodes (Attribute attribute) const -> std::vector< Node > |
Get the node values of the given attribute. | |
auto | to_string () const -> std::string |
Get a string representation of the node. | |
auto | hash () const noexcept -> size_t |
Get a hash for the node. | |
Static Public Member Functions | |
template<NodeType Type, class... Args> | |
static auto | create (Library const &lib, Args const &...args) -> Node |
Construct a node of the given type. | |
Friends | |
auto | c_cast (Node const &x) -> clingo_ast_t * |
Cast the node to its underlying C representation. | |
auto | operator== (Node const &a, Node const &b) noexcept -> bool |
Equality compare two nodes. | |
auto | operator<=> (Node const &a, Node const &b) noexcept -> std::strong_ordering |
Compare two nodes. | |
Node capturing expressions in logic programs.
Nodes are immutable objects supporting record updates.
Refer to lib/c-api/src/ast_yaml.cc
for node types and their arguments.
|
inlineexplicit |
Construct a node form its C representation.
If copy is true copies the given node or otherwise takes ownership. Copying itself is cheap and just involves updating reference counts.
For internal sue.
ast | the C ast |
copy | whether to copy |
|
inline |
Transform the direct children of the node with the given transformer.
lib | the library object to store symbols |
fun | the transformer |
|
inline |
Visit the direct children of the node with the given visitor.
Note that the visitor is in charge of recursively visiting further nodes.
fun | the visitor |
|
inlinestatic |
Construct a node of the given type.
Type | the type of the node |
lib | the library object to store symbols |
args | the attributes that make up the nodes |
|
inlinenoexcept |
Get a hash for the node.
The hash is designed for usage in hash tables. There is also an associated specialization for std::hash.
Get the location value of the given attribute.
attribute | the attribute |
Get the node value of the given attribute.
attribute | the attribute |
Get the node values of the given attribute.
attribute | the attribute |
|
inline |
Get the numeric value of the given attribute.
attribute | the attribute |
Get the optional node value of the given attribute.
attribute | the attribute |
|
inline |
Get the string value of the given attribute.
attribute | the attribute |
|
inline |
Get the string values of the given attribute.
attribute | the attribute |
Get the symbolic value of the given attribute.
attribute | the attribute |
|
inline |
Get the symbolic values of the given attribute.
attribute | the attribute |
|
inline |
Get a string representation of the node.
The string representation is intended to be parsable.
|
inline |
Get the type of the node.
|
inline |
Visit a node of the given type.
The given type must correspond to the actual type of the node. The given updater must be templated for the attributes of the node that are to be changed. If the return type of this function is not void, it will be used to update the respective attribute.
Type | the type of the node |
lib | the library object to store symbols |
fun | the templated updater |
Compare two nodes.
a | the first node |
b | the second node |
Equality compare two nodes.
a | the first node |
b | the second node |