dlvhex
2.5.0
|
Stores terms. More...
#include <include/dlvhex2/Term.h>
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 Term * | clone () 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 Term * | clone () 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< ID > | arguments |
Stores the arguments of nested terms. |
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.
typedef std::pair<Term*, TermPtrVec*> Term::Split |
typedef std::pair<Term*, TermPtrVec*> Term::Split |
Term::Term | ( | IDKind | kind, |
const std::string & | symbol | ||
) | [inline] |
DLVHEX_NAMESPACE_BEGIN Term::Term | ( | IDKind | kind, |
const std::vector< ID > & | arguments, | ||
RegistryPtr | reg | ||
) |
Constructor for nested terms.
kind | Identifies the type of the term; will be reused by Registry to construct the ID. |
arguments | Element [0] is the function symbol, the remaining elements specify its arguments. |
reg | Registry to use for interpreting term IDs. |
Definition at line 52 of file Term.cpp.
References updateSymbolOfNestedTerm().
Term::Term | ( | const Loc & | loc | ) | [inline] |
virtual Term::~Term | ( | ) | [inline, virtual] |
Term::Term | ( | const Loc & | loc | ) | [inline] |
virtual Term::~Term | ( | ) | [inline, virtual] |
void Term::analyzeTerm | ( | RegistryPtr | reg | ) |
Parses a nested term and splits the string representation in Term::symbol into arguments.
reg | Registry 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] |
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).
Definition at line 129 of file Term.h.
Referenced by FunctionInterprete::retrieve().
bool Term::isNestedTerm | ( | ) | const [inline] |
Checks if the term is nested.
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] |
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] |
virtual Split Term::split | ( | ) | [inline, virtual] |
virtual Split Term::split | ( | ) | [inline, virtual] |
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] |
void Term::updateSymbolOfNestedTerm | ( | Registry * | reg | ) |
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.
reg | Registry 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] |
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 kind part of the ID of this symbol.
Definition at line 56 of file Term.h.
Referenced by analyzeTerm(), BOOST_AUTO_TEST_CASE(), Registry::getAuxiliaryConstantSymbol(), Registry::storeConstantTerm(), Registry::storeTerm(), Registry::storeVariableTerm(), and updateSymbolOfNestedTerm().
std::string Term::symbol |
the Textual representation of a constant, constant string (including ""), or variable.
Definition at line 62 of file Term.h.
Referenced by analyzeTerm(), BOOST_AUTO_TEST_CASE(), Registry::getAuxiliaryConstantSymbol(), Registry::getAuxiliaryVariableSymbol(), sem< HexGrammarSemantics::termFromFunctionTerm >::operator()(), sem< HexGrammarSemantics::termFromRange >::operator()(), RawPrinter::print(), Registry::replaceVariablesInTerm(), TestConcatAtom::retrieve(), FunctionComposeAtom::retrieve(), AbovePluginAtom::retrieve(), SenseNotArmed1PluginAtom::retrieve(), Registry::storeConstOrVarTerm(), Registry::storeTerm(), and updateSymbolOfNestedTerm().