From 7e0edb6c2db17c87415fbd041ef7add9dfb467e5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 13 Dec 2016 12:46:09 -0700 Subject: Corrected negation and single value parse bugs. Discovered arithmetic bug in the Number class, -4 + 5 is coming back as -1, not 1. It's getting the sign wrong somehow. I'll have to hunt that down. --- src/scriptengine.cpp | 70 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 31 deletions(-) (limited to 'src/scriptengine.cpp') diff --git a/src/scriptengine.cpp b/src/scriptengine.cpp index b65db70..e4c5c2e 100644 --- a/src/scriptengine.cpp +++ b/src/scriptengine.cpp @@ -39,6 +39,12 @@ void ScriptEngine::exec( Expression *pExpr ) for( Expression::iterator i = pExpr->begin(); i; i++ ) { +// Bu::sio << (*i).eType << " - " << sNums << Bu::sio.nl; + if( ((*i).eType&Token::mMetaCmd) ) + { + command( i ); + continue; + } switch( (*i).eType ) { case Token::tNumber: @@ -96,10 +102,6 @@ void ScriptEngine::exec( Expression *pExpr ) case Token::tNegate: sNums.push( -sNums.peekPop() ); break; - - case Token::tCommand: - command( i ); - return; } } @@ -109,35 +111,39 @@ void ScriptEngine::exec( Expression *pExpr ) void ScriptEngine::command( Expression::iterator &i ) { - Bu::String sCmd = *(*i).sVal; - if( sCmd == "exit" || sCmd == "quit" ) + switch( (*i).eType ) { - bRunning = false; - return; - } - else if( sCmd == "scale" ) - { - if( !(++i) ) - { - if( sigError.isSet() ) - sigError("You must provide a positive integer."); + case Token::tCmdExit: + bRunning = false; return; - } - int32_t iScale = strtol( (*i).sVal->getStr(), 0, 10 ); - if( iScale < 0 ) - { - if( sigError.isSet() ) - sigError("You must provide a positive integer."); - return; - } - if( sigMessage.isSet() ) - sigMessage(Bu::String("Changed scale to: %1").arg( iScale )); - for( VarHash::iterator i = hVarState.begin(); i; i++ ) - (*i).setScale( iScale ); - } - else if( sCmd == "radix" ) - { - } + + case Token::tCmdScale: + { + if( !(++i) ) + { + if( sigError.isSet() ) + sigError("You must provide a positive integer."); + return; + } + int32_t iScale = strtol( (*i).sVal->getStr(), 0, 10 ); + if( iScale < 0 ) + { + if( sigError.isSet() ) + sigError("You must provide a positive integer."); + return; + } + if( sigMessage.isSet() ) + sigMessage(Bu::String("Changed scale to: %1").arg( iScale )); + for( VarHash::iterator i = hVarState.begin(); i; i++ ) + (*i).setScale( iScale ); + } + break; + + case Token::tCmdRadix: + break; + + case Token::tCmdExtended: + /* else if( sCmd == "vars" ) { } @@ -146,6 +152,8 @@ void ScriptEngine::command( Expression::iterator &i ) } else { + }*/ + break; } } -- cgit v1.2.3