#include <exprint.h>
Collaboration diagram for Ars::ExprIntParser:

Public Member Functions | |
| ExprIntParser (void) | |
| ~ExprIntParser (void) | |
| TreeNode * | Eval (const string &aBuffer) |
| int | Apply (TreeNode *tn) |
Private Member Functions | |
| void | Init (void) |
| void | WalkTree (TreeNode *tn, Context &ctx) |
Private Attributes | |
| map< icstring, double > | variables |
| Interpret * | itp |
|
|
Definition at line 78 of file inc/ars/exprint.h.
|
|
|
Definition at line 84 of file inc/ars/exprint.h. References itp.
|
|
|
Definition at line 103 of file inc/ars/exprint.h. References Ars::ExprIntParser::Context::val, variables, and WalkTree(). Referenced by Ars::Thing::Init().
00104 {
00105 Context ctx( variables );
00106 WalkTree( tn , ctx );
00107 return (int)ctx.val;
00108 }
|
|
|
Definition at line 91 of file inc/ars/exprint.h. References itp, and Interpret::Run(). Referenced by Ars::Thing::Init().
|
|
|
Definition at line 112 of file inc/ars/exprint.h. References Cfg::GetCfg(), Cfg::Handler::GetCfgInt(), icstring, and variables. Referenced by ExprIntParser().
00113 {
00114 Cfg::Handler &h = Cfg::GetCfg();
00115 variables.insert( make_pair( icstring( "scrw" ) , h.GetCfgInt( "SetupScreen" , "screenw" ) ) );
00116 variables.insert( make_pair( icstring( "scrh" ) , h.GetCfgInt( "SetupScreen" , "screenh" ) ) );
00117 }
|
|
||||||||||||
|
< Value < Identifier: check if already existing if not create it Definition at line 119 of file inc/ars/exprint.h. References TreeNode::child, TreeNode::constant, icstring, TreeNode::next, TreeNode::symbolId, Ars::ExprIntParser::Context::val, and Ars::ExprIntParser::Context::variables. Referenced by Apply().
00120 {
00121 if( tn )
00122 {
00123 Context lctx( ctx );
00124 if( tn->child != 0 )
00125 WalkTree( tn->child , lctx );
00126
00127 Context rctx( ctx );
00128 if( tn->next != 0 )
00129 WalkTree( tn->next , rctx );
00130
00131 if( tn->symbolId == 9 )
00132 ctx.val = atof( tn->constant.c_str() );
00133 else if( tn->symbolId == 5 )
00134 {
00135 map<icstring,double>::iterator pos = ctx.variables.find( icstring( tn->constant.c_str() ) );
00136 if( pos != ctx.variables.end() )
00137 ctx.val = pos->second;
00138 }
00139 else
00140 {
00141 ctx = lctx;
00142
00143 switch( tn->constant.c_str()[0] )
00144 {
00145 case '+' : ctx += rctx; break;
00146 case '-' : ctx -= rctx; break;
00147 case '*' : ctx *= rctx; break;
00148 case '/' : ctx /= rctx; break;
00149 case '|' : ctx |= rctx; break;
00150 default:
00151 if( lctx.val != 0 )
00152 ctx = lctx;
00153 if( rctx.val != 0 )
00154 if( ctx.val == 0 )
00155 ctx = rctx;
00156 else
00157 printf( "ERROR\n" );
00158 break;
00159 }
00160 }
00161 }
00162 }
|
|
|
Definition at line 75 of file inc/ars/exprint.h. Referenced by Eval(), ExprIntParser(), and ~ExprIntParser(). |
|
|
Definition at line 24 of file inc/ars/exprint.h. |
1.3.3