#include <exprint.h>
Public Member Functions | |
| ExprParser (void) | |
| TreeNode * | Eval (const string &aBuffer) |
| SumRandom * | Apply (TreeNode *tn) |
Private Member Functions | |
| void | WalkTree (TreeNode *tn, Context &ctx) |
|
|
Definition at line 83 of file ars/exprint.h.
00084 {
00085 }
|
|
|
Definition at line 95 of file ars/exprint.h. References WalkTree().
|
|
|
Definition at line 87 of file ars/exprint.h. References Interpret::Run().
|
|
||||||||||||
|
< Value < Identifier: check if already existing if not create it Definition at line 104 of file ars/exprint.h. References TreeNode::child, TreeNode::constant, TreeNode::next, TreeNode::symbolId, Ars::ExprParser::Context::val, and Ars::ExprParser::Context::variables. Referenced by Apply().
00105 {
00106 if( tn )
00107 {
00108 Context lctx( ctx );
00109 if( tn->child != 0 )
00110 WalkTree( tn->child , lctx );
00111
00112 Context rctx( ctx );
00113 if( tn->next != 0 )
00114 WalkTree( tn->next , rctx );
00115
00116 if( tn->symbolId == 9 )
00117 ctx.val = atof( tn->constant.c_str() );
00118 else if( tn->symbolId == 5 )
00119 {
00120 map<string,double>::iterator pos = ctx.variables.find( tn->constant );
00121 if( pos != ctx.variables.end() )
00122 ctx.val = pos->second;
00123 }
00124 else
00125 {
00126 ctx = lctx;
00127
00128 switch( tn->constant.c_str()[0] )
00129 {
00130 case '+' : ctx += rctx; break;
00131 case '-' : ctx -= rctx; break;
00132 case '*' : ctx *= rctx; break;
00133 case '/' : ctx /= rctx; break;
00134 case '|' : ctx |= rctx; break;
00135 default:
00136 if( lctx.val != 0 )
00137 ctx = lctx;
00138 if( rctx.val != 0 )
00139 if( ctx.val == 0 )
00140 ctx = rctx;
00141 else
00142 printf( "ERROR\n" );
00143 break;
00144 }
00145 }
00146 }
00147 }
|
1.3.3