summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-12-29 23:43:25 -0700
committerMike Buland <eichlan@xagasoft.com>2011-12-29 23:43:25 -0700
commite9ca0738a4b18032151af42baca1f88629408d52 (patch)
treebf264d9a029589a61c057acb00f15d4b675e3b90
parentca31bda6b8dd27d59c053a4f391164496577f479 (diff)
downloadstage-e9ca0738a4b18032151af42baca1f88629408d52.tar.gz
stage-e9ca0738a4b18032151af42baca1f88629408d52.tar.bz2
stage-e9ca0738a4b18032151af42baca1f88629408d52.tar.xz
stage-e9ca0738a4b18032151af42baca1f88629408d52.zip
While loops work perfectly :)
-rw-r--r--src/gamestate.cpp23
-rw-r--r--test.stage6
2 files changed, 29 insertions, 0 deletions
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 )
366 break; 366 break;
367 367
368 case AstNode::tForEach: 368 case AstNode::tForEach:
369
370 break;
371
369 case AstNode::tWhile: 372 case AstNode::tWhile:
373 {
374 AstBranch::NodeList lWhile =
375 dynamic_cast<const AstBranch *>(*i)->getNodeList();
376 AstBranch::NodeList::const_iterator iTest = lWhile.begin();
377 AstBranch::NodeList::const_iterator iDo = iTest+1;
378
379 for(;;)
380 {
381 parse( dynamic_cast<const AstBranch *>(*iTest)->
382 getNodeList() );
383 Variable v = popDeref();
384 if( v.getType() != Variable::tBool )
385 throw Bu::ExceptionBase("conditional did not evaluate to boolean.");
386 if( !v.getBool() )
387 break;
388
389 parse( dynamic_cast<const AstBranch *>(*iDo)->
390 getNodeList() );
391 }
392 }
370 break; 393 break;
371 } 394 }
372 395
diff --git a/test.stage b/test.stage
index c19dac9..3fa32c0 100644
--- a/test.stage
+++ b/test.stage
@@ -57,5 +57,11 @@ situation <<stuff>>
57 enter 57 enter
58 { 58 {
59 display('''Entered stuff''' + player.name); 59 display('''Entered stuff''' + player.name);
60 count = 0;
61 while count < 5 do
62 {
63 display('thing to count!');
64 count += 1;
65 }
60 } 66 }
61} 67}