#include <expr.h>
Collaboration diagram for ExprParser:

Public Member Functions | |
| ExprParser (void) | |
| virtual | ~ExprParser (void) |
| TreeNode * | Eval (const string &aBuffer) |
| SumRandom * | Apply (TreeNode *tn) |
Static Public Attributes | |
| vector< Uniform * > | toDelinExprParser |
Private Member Functions | |
| void | WalkTree (TreeNode *tn, Context &ctx) |
Private Attributes | |
| map< string, Random * > | variables |
| Interpret * | itp |
|
|
Definition at line 113 of file expr.h. References itp.
00113 : itp( 0 ) 00114 { 00115 } |
|
|
Definition at line 117 of file expr.h. References itp.
|
|
|
Definition at line 135 of file expr.h. References ExprParser::Context::rdm, variables, and WalkTree(). Referenced by Parameters::CreateGalaxy(), Parameters::SetupPlanetInfo(), and Parameters::SetupStarInfo().
|
|
|
Definition at line 125 of file expr.h. References itp, and Interpret::Run(). Referenced by Parameters::CreateGalaxy(), Parameters::SetupPlanetInfo(), and Parameters::SetupStarInfo().
|
|
||||||||||||
|
< Value < Identifier: check if already existing if not create it Definition at line 150 of file expr.h. References TreeNode::child, TreeNode::constant, TreeNode::next, ExprParser::Context::rdm, TreeNode::symbolId, toDelinExprParser, ExprParser::Context::val, and ExprParser::Context::variables. Referenced by Apply().
00151 {
00152 if( tn )
00153 {
00154 Context lctx( ctx );
00155 if( tn->child != 0 )
00156 WalkTree( tn->child , lctx );
00157
00158 Context rctx( ctx );
00159 if( tn->next != 0 )
00160 WalkTree( tn->next , rctx );
00161
00162 if( tn->symbolId == 9 )
00163 ctx.val = atof( tn->constant.c_str() );
00164 else if( tn->symbolId == 5 )
00165 {
00166 map<string,Random *>::iterator pos = ctx.variables.find( tn->constant );
00167 if( pos == ctx.variables.end() )
00168 {
00169 ctx.variables.insert( make_pair( tn->constant , ctx.rdm = new Uniform ) );
00170 toDelinExprParser.push_back( dynamic_cast<Uniform *>( ctx.rdm ) );
00171 }
00172 else
00173 ctx.rdm = pos->second;
00174 }
00175 else
00176 {
00177 ctx = lctx;
00178
00179 switch( tn->constant.c_str()[0] )
00180 {
00181 case '+' : ctx += rctx; break;
00182 case '-' : ctx -= rctx; break;
00183 case '*' : ctx *= rctx; break;
00184 case '/' : ctx /= rctx; break;
00185 case '|' : ctx |= rctx; break;
00186 default:
00187 if( lctx.rdm != 0 )
00188 ctx = lctx;
00189 if( rctx.rdm != 0 )
00190 if( ctx.rdm == 0 )
00191 ctx = rctx;
00192 else
00193 printf( "ERROR\n" );
00194 break;
00195 }
00196 }
00197 }
00198 }
|
|
|
Definition at line 109 of file expr.h. Referenced by Eval(), ExprParser(), and ~ExprParser(). |
|
|
Definition at line 63 of file expr.cpp. Referenced by WalkTree(), and MainGame::~MainGame(). |
|
|
Definition at line 22 of file expr.h. Referenced by Apply(). |
1.3.3