From e9ca0738a4b18032151af42baca1f88629408d52 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 29 Dec 2011 23:43:25 -0700 Subject: While loops work perfectly :) --- src/gamestate.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/gamestate.cpp b/src/gamestate.cpp index 3f09c3f..902d0a9 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -366,7 +366,30 @@ void GameState::parse( const AstBranch::NodeList &lCode ) break; case AstNode::tForEach: + + break; + case AstNode::tWhile: + { + AstBranch::NodeList lWhile = + dynamic_cast(*i)->getNodeList(); + AstBranch::NodeList::const_iterator iTest = lWhile.begin(); + AstBranch::NodeList::const_iterator iDo = iTest+1; + + for(;;) + { + parse( dynamic_cast(*iTest)-> + getNodeList() ); + Variable v = popDeref(); + if( v.getType() != Variable::tBool ) + throw Bu::ExceptionBase("conditional did not evaluate to boolean."); + if( !v.getBool() ) + break; + + parse( dynamic_cast(*iDo)-> + getNodeList() ); + } + } break; } -- cgit v1.2.3