dlvhex  2.5.0
Term Class Reference

Stores terms. More...

#include <include/dlvhex2/Term.h>

Inheritance diagram for Term:
Collaboration diagram for Term:

Data Structures

class  PtrRef
class  Ref
class  VecRef

Public Types

typedef std::pair< Term
*, TermPtrVec * > 
Split
typedef std::pair< Term
*, TermPtrVec * > 
Split

Public Member Functions

 Term (IDKind kind, const std::string &symbol)
 Constructor.
 Term (IDKind kind, const std::vector< ID > &arguments, RegistryPtr reg)
 Constructor for nested terms.
void updateSymbolOfNestedTerm (Registry *reg)
 Recomputes the text representation of nested terms given their arguments.
bool isQuotedString () const
 Checks if the constant term is quoted.
bool isNestedTerm () const
 Checks if the term is nested.
std::string getQuotedString () const
 Returns a text representation of this term with quotes (independent of whether the term is stored with or without quotes).
std::string getUnquotedString () const
 Returns a text representation of this term without quotes (independent of whether the term is stored with or without quotes).
void analyzeTerm (RegistryPtr reg)
 Parses a nested term and splits the string representation in Term::symbol into arguments.
std::ostream & print (std::ostream &o) const
 Prints the term in form Term(symbol).
 Term (const Loc &loc)
virtual Val val (Grounder *grounder) const =0
virtual Split split ()
virtual void normalize (Lit *parent, const Ref &ref, Grounder *g, Expander *expander, bool unify)=0
virtual bool unify (Grounder *grounder, const Val &v, int binder) const =0
virtual void vars (VarSet &v) const =0
virtual void visit (PrgVisitor *visitor, bool bind)=0
virtual bool constant () const =0
virtual void print (Storage *sto, std::ostream &out) const =0
virtual Termclone () const =0
virtual ~Term ()
 Term (const Loc &loc)
virtual Val val (Grounder *grounder) const =0
virtual Split split ()
virtual void normalize (Lit *parent, const Ref &ref, Grounder *g, Expander *expander, bool unify)=0
virtual bool unify (Grounder *grounder, const Val &v, int binder) const =0
virtual void vars (VarSet &v) const =0
virtual void visit (PrgVisitor *visitor, bool bind)=0
virtual bool constant () const =0
virtual void print (Storage *sto, std::ostream &out) const =0
virtual Termclone () const =0
virtual ~Term ()

Data Fields

IDKind kind
 The kind part of the ID of this symbol.
std::string symbol
 the Textual representation of a constant, constant string (including ""), or variable.
std::vector< IDarguments
 Stores the arguments of nested terms.

Detailed Description

Stores terms.

Supported types: constants, variables and nested terms. Integers do not use this class but rather store the value directly in the address field of the ID.

Definition at line 52 of file Term.h.


Member Typedef Documentation

typedef std::pair<Term*, TermPtrVec*> Term::Split

Definition at line 26 of file term.h.

typedef std::pair<Term*, TermPtrVec*> Term::Split

Definition at line 26 of file term.h.


Constructor & Destructor Documentation

Term::Term ( IDKind  kind,
const std::string &  symbol 
) [inline]

Constructor.

Parameters:
kindIdentifies the type of the term; will be reused by Registry to construct the ID.
symbolThe term string, which can be a constant (with or without quotation marks), a variable, or a nested term (in text format).

Definition at line 78 of file Term.h.

References ID_FAIL().

DLVHEX_NAMESPACE_BEGIN Term::Term ( IDKind  kind,
const std::vector< ID > &  arguments,
RegistryPtr  reg 
)

Constructor for nested terms.

Parameters:
kindIdentifies the type of the term; will be reused by Registry to construct the ID.
argumentsElement [0] is the function symbol, the remaining elements specify its arguments.
regRegistry to use for interpreting term IDs.

Definition at line 52 of file Term.cpp.

References updateSymbolOfNestedTerm().

Term::Term ( const Loc &  loc) [inline]

Definition at line 54 of file term.h.

virtual Term::~Term ( ) [inline, virtual]

Definition at line 64 of file term.h.

Term::Term ( const Loc &  loc) [inline]

Definition at line 54 of file term.h.

virtual Term::~Term ( ) [inline, virtual]

Definition at line 64 of file term.h.


Member Function Documentation

Parses a nested term and splits the string representation in Term::symbol into arguments.

Parameters:
regRegistry to use for interpreting term IDs.

Definition at line 90 of file Term.cpp.

References analyzeTerm(), arguments, DBGLOG, ID_FAIL(), kind, ID::MAINKIND_TERM, ID::SUBKIND_TERM_CONSTANT, ID::SUBKIND_TERM_NESTED, ID::SUBKIND_TERM_VARIABLE, and symbol.

Referenced by analyzeTerm().

virtual Term* Term::clone ( ) const [pure virtual]

Referenced by boost::new_clone().

virtual Term* Term::clone ( ) const [pure virtual]
virtual bool Term::constant ( ) const [pure virtual]
virtual bool Term::constant ( ) const [pure virtual]
std::string Term::getQuotedString ( ) const [inline]

Returns a text representation of this term with quotes (independent of whether the term is stored with or without quotes).

Returns:
Text representation of the term.

Definition at line 121 of file Term.h.

std::string Term::getUnquotedString ( ) const [inline]

Returns a text representation of this term without quotes (independent of whether the term is stored with or without quotes).

Returns:
Text representation of the term.

Definition at line 129 of file Term.h.

Referenced by FunctionInterprete::retrieve().

bool Term::isNestedTerm ( ) const [inline]

Checks if the term is nested.

Returns:
True if it is nested and false otherwise.

Definition at line 113 of file Term.h.

References ID_FAIL().

Referenced by FunctionDecomposeAtom::retrieve(), IsFunctionTermAtom::retrieve(), GetArityAtom::retrieve(), and FunctionDecomposeGeneralAtom::retrieve().

bool Term::isQuotedString ( ) const [inline]

Checks if the constant term is quoted.

Returns:
True if it is quoted and false otherwise.

Definition at line 103 of file Term.h.

virtual void Term::normalize ( Lit *  parent,
const Ref ref,
Grounder *  g,
Expander *  expander,
bool  unify 
) [pure virtual]
virtual void Term::normalize ( Lit *  parent,
const Ref ref,
Grounder *  g,
Expander *  expander,
bool  unify 
) [pure virtual]
virtual void Term::print ( Storage *  sto,
std::ostream &  out 
) const [pure virtual]
virtual void Term::print ( Storage *  sto,
std::ostream &  out 
) const [pure virtual]
std::ostream& Term::print ( std::ostream &  o) const [inline]

Prints the term in form Term(symbol).

Parameters:
oStream to print.
Returns:
o.

Definition at line 148 of file Term.h.

virtual Split Term::split ( ) [inline, virtual]

Definition at line 56 of file term.h.

virtual Split Term::split ( ) [inline, virtual]

Definition at line 56 of file term.h.

virtual bool Term::unify ( Grounder *  grounder,
const Val &  v,
int  binder 
) const [pure virtual]
virtual bool Term::unify ( Grounder *  grounder,
const Val &  v,
int  binder 
) const [pure virtual]

Recomputes the text representation of nested terms given their arguments.

Sets Term::symbol to the text representation generated from the arguments of the nested term.

Parameters:
regRegistry to use for interpreting term IDs.

Definition at line 61 of file Term.cpp.

References arguments, TermTable::getByID(), kind, ID::PROPERTY_MASK, ID::PROPERTY_TERM_RANGE, symbol, and Registry::terms.

Referenced by Registry::replaceVariablesInTerm(), FunctionInterprete::retrieve(), and Term().

virtual Val Term::val ( Grounder *  grounder) const [pure virtual]
virtual Val Term::val ( Grounder *  grounder) const [pure virtual]
virtual void Term::vars ( VarSet &  v) const [pure virtual]
virtual void Term::vars ( VarSet &  v) const [pure virtual]
virtual void Term::visit ( PrgVisitor *  visitor,
bool  bind 
) [pure virtual]
virtual void Term::visit ( PrgVisitor *  visitor,
bool  bind 
) [pure virtual]

Field Documentation

std::vector<ID> Term::arguments

Stores the arguments of nested terms.

Nested terms are function terms consisting of a function symbol and its arguments. For primitive terms (constant, constant string, variable), the only element is ID_FAIL. For nested terms, arguments[0] is the function symbol (primitive term) and arguments[n] for n>=1 are the arguments (which might be nested themselves). Moreover ,for nested terms, symbol contains a string representation of the whole term.

Definition at line 71 of file Term.h.

Referenced by analyzeTerm(), FunctionRewriter::composeTerm(), FunctionInterprete::containsPlaceholder(), FunctionRewriter::decomposeTerm(), Registry::getOutVariablesInID(), Registry::getVariablesInID(), Registry::replaceVariablesInTerm(), FunctionDecomposeAtom::retrieve(), GetArityAtom::retrieve(), FunctionDecomposeGeneralAtom::retrieve(), FunctionInterprete::retrieve(), OrdinaryAtom::unifiesWith(), and updateSymbolOfNestedTerm().


The documentation for this class was generated from the following files: