Marsyas
0.6.0-alpha
|
ExNode is the base class for an expression tree node. More...
#include <ExNode.h>
Inherits ExRefCount.
Inherited by ExFun, ExNode_ADD, ExNode_AND, ExNode_AsgnVar, ExNode_BoolNeg, ExNode_BoolToString, ExNode_Conditional, ExNode_DIV, ExNode_EQ, ExNode_GE, ExNode_GetCtrlBool, ExNode_GetCtrlNatural, ExNode_GetCtrlReal, ExNode_GetCtrlString, ExNode_GetElem, ExNode_GT, ExNode_IterFor, ExNode_IterIter, ExNode_IterMap, ExNode_IterRFor, ExNode_LE, ExNode_Link, ExNode_LT, ExNode_MathNeg_Natural, ExNode_MathNeg_Real, ExNode_MOD, ExNode_MUL, ExNode_NaturalToReal, ExNode_NaturalToString, ExNode_NE, ExNode_OR, ExNode_Range, ExNode_ReadVar, ExNode_RealToNatural, ExNode_RealToString, ExNode_SetCtrlBool, ExNode_SetCtrlNatural, ExNode_SetCtrlReal, ExNode_SetCtrlString, ExNode_SetElem, ExNode_StringFor, ExNode_StringIter, ExNode_StringMap, ExNode_StringRFor, and ExNode_SUB.
Public Member Functions | |
virtual ExVal | calc () |
virtual ExNode * | copy () |
virtual ExVal | eval () |
ExNode () | |
ExNode (int k, std::string t) | |
ExNode (int k, std::string t, ExVal v) | |
ExNode (ExVal v) | |
ExNode (const ExNode &v) | |
std::string | getElemType () const |
std::string | getEvalType () const |
int | getKind () const |
ExVal | getSeqElem (int idx) |
ExVal | getSeqRange (int lidx, int ridx) |
std::string | getType () const |
ExVal | getValue () |
void | init () |
virtual bool | is_const () |
bool | is_list () const |
bool | is_seq () const |
virtual std::string | oot () |
void | setKind (const int k) |
void | setSeqElem (int idx, ExVal v) |
void | setType (const std::string t) |
void | setValue (mrs_natural x) |
void | setValue (std::string x) |
void | setValue (mrs_real x) |
void | setValue (mrs_bool x) |
virtual std::string | toString () |
mrs_natural | valToNatural () |
virtual | ~ExNode () |
Data Fields | |
ExNode * | next |
std::string | val_str |
ExVal | value |
ExNode is the base class for an expression tree node.
ExNode represents an expression tree node. Additional nodes may be added later, but may also need to be added to the parser.
There should only ever exist a single parent of any node, that is, a node may only be referenced by one object.
To add library functions add a line like this to ExParser.h::preload() :- library->addRecord("Real|R.cos(mrs_real)|cos(mrs_natural)",new ExRecord(T_FUN,new ExNode_RealCos("mrs_real","Real.cos(mrs_real)"),true));
then define the function as an ExNode class, you must support the calc and copy functions. In the constructor make sure you set is_pure to true if the function can be reduced to a const value given const parameters, or false otherwise.
class ExNode_NatDbl : public ExNode_Fun { ExNode* child; public: ExNode_NatDbl(std::string typ, std::string sig, ExNode* x) : ExNode_Fun(typ,sig,true) { child=x; } virtual ExVal calc() { return false; } ExNode* copy() { return new ExNode_NatDbl(type,signature); } };
ExNode | ( | ) |
Definition at line 128 of file ExNode.cpp.
ExNode | ( | int | k, |
std::string | t | ||
) |
Definition at line 133 of file ExNode.cpp.
Definition at line 140 of file ExNode.cpp.
Definition at line 148 of file ExNode.cpp.
Definition at line 157 of file ExNode.cpp.
~ExNode | ( | ) | [virtual] |
Definition at line 199 of file ExNode.cpp.
Reimplemented in ExFun_ListLen, ExFun_TimerUpdBool, ExFun_TimerUpdString, ExFun_TimerUpdNatural, ExFun_TimerUpdReal, ExFun_TimerIntrvlSize, ExFun_TimerGetTime, ExFun_TimerGetType, ExFun_TimerGetName, ExFun_TimerGetPrefix, ExFun_StreamOutNVal, ExFun_StreamOutNBool, ExFun_StreamOutNNatural, ExFun_StreamOutNReal, ExFun_StreamOutNString, ExFun_StreamOutBool, ExFun_StreamOutNatural, ExFun_StreamOutReal, ExFun_StreamOutString, ExFun_StrSub, ExFun_StrLen, ExFun_RealRand, ExFun_RealLog2, ExFun_RealAbs, ExFun_RealLog10, ExFun_RealLog, ExFun_RealTan, ExFun_RealSinH, ExFun_RealCosH, ExFun_RealATan, ExFun_RealASin, ExFun_RealACos, ExFun_RealSin, ExFun_RealSqrt, ExFun_RealCos, ExFun_NaturalAbs, ExFun_NaturalSRand, ExFun_NaturalRandRange2, ExFun_NaturalRandRange1, ExFun_NaturalRand, ExFun_NaturalMax, ExFun_NaturalMin, ExNode_ReadVar, ExNode_AsgnVar, ExNode_Link, ExNode_SetCtrlBool, ExNode_SetCtrlNatural, ExNode_SetCtrlString, ExNode_SetCtrlReal, ExNode_GetCtrlBool, ExNode_GetCtrlNatural, ExNode_GetCtrlString, ExNode_GetCtrlReal, ExNode_GetElem, ExNode_Range, ExNode_SetElem, ExNode_StringRFor, ExNode_StringFor, ExNode_StringIter, ExNode_StringMap, ExNode_IterRFor, ExNode_IterFor, ExNode_IterIter, ExNode_IterMap, ExNode_Conditional, ExNode_AND, ExNode_OR, ExNode_LE, ExNode_LT, ExNode_GE, ExNode_GT, ExNode_NE, ExNode_EQ, ExNode_MOD, ExNode_DIV, ExNode_MUL, ExNode_SUB, ExNode_ADD, ExNode_BoolToString, ExNode_NaturalToString, ExNode_RealToString, ExNode_RealToNatural, ExNode_NaturalToReal, ExNode_BoolNeg, ExNode_MathNeg_Natural, and ExNode_MathNeg_Real.
Reimplemented in ExFun_ListLen, ExFun_TimerUpdBool, ExFun_TimerUpdString, ExFun_TimerUpdNatural, ExFun_TimerUpdReal, ExFun_TimerIntrvlSize, ExFun_TimerGetTime, ExFun_TimerGetType, ExFun_TimerGetName, ExFun_TimerGetPrefix, ExFun_StreamOutNVal, ExFun_StreamOutNBool, ExFun_StreamOutNNatural, ExFun_StreamOutNReal, ExFun_StreamOutNString, ExFun_StreamOutBool, ExFun_StreamOutNatural, ExFun_StreamOutReal, ExFun_StreamOutString, ExFun_StrSub, ExFun_StrLen, ExFun_RealRand, ExFun_RealLog2, ExFun_RealAbs, ExFun_RealLog10, ExFun_RealLog, ExFun_RealTan, ExFun_RealSinH, ExFun_RealCosH, ExFun_RealATan, ExFun_RealASin, ExFun_RealACos, ExFun_RealSin, ExFun_RealSqrt, ExFun_RealCos, ExFun_NaturalAbs, ExFun_NaturalSRand, ExFun_NaturalRandRange2, ExFun_NaturalRandRange1, ExFun_NaturalRand, ExFun_NaturalMax, ExFun_NaturalMin, and ExFun.
Definition at line 205 of file ExNode.cpp.
Definition at line 259 of file ExNode.cpp.
std::string getElemType | ( | ) | const |
Definition at line 232 of file ExNode.cpp.
std::string getEvalType | ( | ) | const |
Definition at line 218 of file ExNode.cpp.
ExVal getSeqElem | ( | int | idx | ) |
Definition at line 273 of file ExNode.cpp.
ExVal getSeqRange | ( | int | lidx, |
int | ridx | ||
) |
Definition at line 267 of file ExNode.cpp.
std::string getType | ( | void | ) | const |
Definition at line 211 of file ExNode.cpp.
void init | ( | ) |
Definition at line 168 of file ExNode.cpp.
bool is_const | ( | ) | [virtual] |
Reimplemented in ExFun.
Definition at line 175 of file ExNode.cpp.
bool is_list | ( | ) | const |
Definition at line 181 of file ExNode.cpp.
bool is_seq | ( | ) | const |
Definition at line 194 of file ExNode.cpp.
std::string oot | ( | ) | [virtual] |
Definition at line 253 of file ExNode.cpp.
void setKind | ( | const int | k | ) |
Definition at line 239 of file ExNode.cpp.
void setSeqElem | ( | int | idx, |
ExVal | v | ||
) |
Definition at line 279 of file ExNode.cpp.
void setType | ( | const std::string | t | ) |
Definition at line 226 of file ExNode.cpp.
void setValue | ( | mrs_natural | x | ) | [inline] |
std::string toString | ( | ) | [virtual] |
Definition at line 245 of file ExNode.cpp.
mrs_natural valToNatural | ( | ) | [inline] |