souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions | Protected Attributes
souffle::ast::Atom Class Reference

An atom class. More...

#include <Atom.h>

Inheritance diagram for souffle::ast::Atom:
Inheritance graph
Collaboration diagram for souffle::ast::Atom:
Collaboration graph

Public Member Functions

void addArgument (Own< Argument > arg)
 Add argument to the atom. More...
 
void apply (const NodeMapper &map) override
 Apply the mapper to all child nodes. More...
 
 Atom (QualifiedName name={}, VecOwn< Argument > args={}, SrcLocation loc={})
 
Atomclone () const override
 Create a clone (i.e. More...
 
std::vector< Argument * > getArguments () const
 Return arguments. More...
 
size_t getArity () const
 Return arity of the atom. More...
 
std::vector< const Node * > getChildNodes () const override
 Obtain a list of all embedded AST child nodes. More...
 
const QualifiedNamegetQualifiedName () const
 Return qualified name. More...
 
void setQualifiedName (QualifiedName n)
 Set qualified name. More...
 
- Public Member Functions inherited from souffle::ast::Literal
 Node (SrcLocation loc={})
 
- Public Member Functions inherited from souffle::ast::Node
std::string extloc () const
 Return source location of the syntactic element. More...
 
const SrcLocationgetSrcLoc () const
 Return source location of the Node. More...
 
 Node (SrcLocation loc={})
 
bool operator!= (const Node &other) const
 Inequality check for two AST nodes. More...
 
bool operator== (const Node &other) const
 Equivalence check for two AST nodes. More...
 
void setSrcLoc (SrcLocation l)
 Set source location for the Node. More...
 
virtual ~Node ()=default
 

Protected Member Functions

bool equal (const Node &node) const override
 Abstract equality check for two AST nodes. More...
 
void print (std::ostream &os) const override
 Output to a given output stream. More...
 

Protected Attributes

VecOwn< Argumentarguments
 Arguments of atom. More...
 
QualifiedName name
 Name of atom. More...
 

Detailed Description

An atom class.

An atom representing the use of a relation either in the head or in the body of a clause, e.g., parent(x,y), !parent(x,y), ...

Definition at line 51 of file Atom.h.

Constructor & Destructor Documentation

◆ Atom()

souffle::ast::Atom::Atom ( QualifiedName  name = {},
VecOwn< Argument args = {},
SrcLocation  loc = {} 
)
inline

Definition at line 53 of file Atom.h.

56  {

Member Function Documentation

◆ addArgument()

void souffle::ast::Atom::addArgument ( Own< Argument arg)
inline

Add argument to the atom.

Definition at line 72 of file Atom.h.

75  {

◆ apply()

void souffle::ast::Atom::apply ( const NodeMapper )
inlineoverridevirtual

Apply the mapper to all child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 85 of file Atom.h.

85  {
86  std::vector<const Node*> res;
87  for (auto& cur : arguments) {
88  res.push_back(cur.get());
89  }

References arguments.

◆ clone()

Atom* souffle::ast::Atom::clone ( ) const
inlineoverridevirtual

Create a clone (i.e.

deep copy) of this node

Implements souffle::ast::Literal.

Definition at line 81 of file Atom.h.

◆ equal()

bool souffle::ast::Atom::equal ( const Node ) const
inlineoverrideprotectedvirtual

Abstract equality check for two AST nodes.

Reimplemented from souffle::ast::Node.

Definition at line 104 of file Atom.h.

◆ getArguments()

std::vector<Argument*> souffle::ast::Atom::getArguments ( ) const
inline

◆ getArity()

size_t souffle::ast::Atom::getArity ( ) const
inline

Return arity of the atom.

Definition at line 62 of file Atom.h.

66  {

◆ getChildNodes()

std::vector<const Node*> souffle::ast::Atom::getChildNodes ( ) const
inlineoverridevirtual

Obtain a list of all embedded AST child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 91 of file Atom.h.

93  :
94  void print(std::ostream& os) const override {
95  os << getQualifiedName() << "(" << join(arguments) << ")";
96  }
97 

◆ getQualifiedName()

const QualifiedName& souffle::ast::Atom::getQualifiedName ( ) const
inline

◆ print()

void souffle::ast::Atom::print ( std::ostream &  os) const
inlineoverrideprotectedvirtual

Output to a given output stream.

Implements souffle::ast::Node.

Definition at line 100 of file Atom.h.

◆ setQualifiedName()

void souffle::ast::Atom::setQualifiedName ( QualifiedName  n)
inline

Set qualified name.

Definition at line 67 of file Atom.h.

Field Documentation

◆ arguments

VecOwn<Argument> souffle::ast::Atom::arguments
protected

Arguments of atom.

Definition at line 113 of file Atom.h.

Referenced by apply().

◆ name

QualifiedName souffle::ast::Atom::name
protected

Name of atom.

Definition at line 110 of file Atom.h.


The documentation for this class was generated from the following file:
souffle::ast::Atom::print
void print(std::ostream &os) const override
Output to a given output stream.
Definition: Atom.h:100
souffle::ast::Atom::getQualifiedName
const QualifiedName & getQualifiedName() const
Return qualified name.
Definition: Atom.h:57
souffle::ast::Atom::arguments
VecOwn< Argument > arguments
Arguments of atom.
Definition: Atom.h:113
souffle::join
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
Definition: StreamUtil.h:175