#include <Grammar.hpp>
Inheritance diagram for Grammar:
Public Member Functions | |
std::string | getGrammarID () const |
virtual Result * | execute (Context &context)=0 |
virtual std::string | toString (Context &context)=0 |
void | setExpression (std::vector< Grammar * > *pvpgramExpression, int iRule) |
int | getExpression (std::vector< Grammar * > *&pvpgramExpression) const |
int | getNumArguments () const |
Grammar * | getArgument (int iArgument) const |
void | deleteExpression () |
int | getDepth () const |
void | setDepth (int iDepth) |
virtual Grammar * | clone ()=0 |
Protected Member Functions | |
void | clone (Grammar *pgramClone) |
void Grammar::clone | ( | Grammar * | pgramClone | ) | [protected] |
Performs common operations for cloning symbols. Specifically this method copies the children nodes and the depth.
[in,out] | pgramClone | The clone node being produced |
virtual Grammar* Grammar::clone | ( | ) | [pure virtual] |
void Grammar::deleteExpression | ( | ) |
Removes this nodes children and their subtrees, freeing the corresponding memory.
Executes the symbol. In the case of non-functions this method calls the appropriate child arguments, coordinating resulting values. In functions this method performs the necessary computation.
[in,out] | context | The context or key-value pairs to be passed to the functions |
Implemented in FAdd, FArgument, FConst, FDiv, FMul, FSub, GExpr, GOp, GStart, and GTerm.
Grammar * Grammar::getArgument | ( | int | iArgument | ) | const |
Returns a pointer to a particular child of this node.
[in] | iArgument | The child to be returned |
int Grammar::getDepth | ( | ) | const |
Returns the depth of this particular node in the symbol tree.
int Grammar::getExpression | ( | std::vector< Grammar * > *& | pvpgramExpression | ) | const |
Returns the children of this node.
[out] | pvpgramExpression | A vector of symbols which follow from this symbol, NULL if there is none. |
string Grammar::getGrammarID | ( | ) | const |
Returns a string reprsenting the particular grammar symbol the object represents.
int Grammar::getNumArguments | ( | ) | const |
Returns the number of children this node has.
void Grammar::setDepth | ( | int | iDepth | ) |
Sets the depth of this node in the symbol tree.
[in] | iDepth | The depth |
void Grammar::setExpression | ( | std::vector< Grammar * > * | pvpgramExpression, | |
int | iRule | |||
) |
Sets the child nodes of this grammar. These nodes are typically created by GrammarRules to match the given grammar.
[in] | pvpgramExpression | A vector of symbols which follow from this symbol |
[in] | iRule | The corresponding rule number from GrammarRules. May be useful if different rules must be put together differently, for example if a symbol may either be followed by a function and two terminals or by a single terminal then the object must know which it currently must handle. |
virtual std::string Grammar::toString | ( | Context & | context | ) | [pure virtual] |
Determines how this symbol and its children are represented when a string is used to represent the program.
[in] | context | Unused currently, a reimplementation may use the context to determine actual/formal parameter pairs or to print out global variables |