diff options
-rw-r--r-- | src/astbranch.cpp | 2 | ||||
-rw-r--r-- | src/astnode.cpp | 1 | ||||
-rw-r--r-- | src/astnode.h | 1 | ||||
-rw-r--r-- | src/functiondisplay.cpp | 2 | ||||
-rw-r--r-- | src/gamestate.cpp | 4 | ||||
-rw-r--r-- | src/parser.y | 5 | ||||
-rw-r--r-- | test.stage | 11 |
7 files changed, 21 insertions, 5 deletions
diff --git a/src/astbranch.cpp b/src/astbranch.cpp index a422a62..e506d9c 100644 --- a/src/astbranch.cpp +++ b/src/astbranch.cpp | |||
@@ -31,7 +31,7 @@ Bu::Formatter &operator<<( Bu::Formatter &f, const AstBranch &b ) | |||
31 | { | 31 | { |
32 | f << "(Branch " << b.getType() << ": "; | 32 | f << "(Branch " << b.getType() << ": "; |
33 | f.incIndent(); | 33 | f.incIndent(); |
34 | for( typename AstBranch::NodeList::const_iterator i = b.lNodes.begin(); | 34 | for( AstBranch::NodeList::const_iterator i = b.lNodes.begin(); |
35 | i; i++ ) | 35 | i; i++ ) |
36 | { | 36 | { |
37 | f << f.nl << *(*i); | 37 | f << f.nl << *(*i); |
diff --git a/src/astnode.cpp b/src/astnode.cpp index 7191292..d7295b3 100644 --- a/src/astnode.cpp +++ b/src/astnode.cpp | |||
@@ -39,6 +39,7 @@ Bu::Formatter &operator<<( Bu::Formatter &f, AstNode::Type t ) | |||
39 | case AstNode::tMultiplyStore: return f << "tMultiplyStore"; | 39 | case AstNode::tMultiplyStore: return f << "tMultiplyStore"; |
40 | case AstNode::tNegate: return f << "tNegate"; | 40 | case AstNode::tNegate: return f << "tNegate"; |
41 | case AstNode::tIn: return f << "tIn"; | 41 | case AstNode::tIn: return f << "tIn"; |
42 | case AstNode::tGoto: return f << "tGoto"; | ||
42 | 43 | ||
43 | case AstNode::tLeafLiteral: return f << "!tLeafLiteral!"; | 44 | case AstNode::tLeafLiteral: return f << "!tLeafLiteral!"; |
44 | case AstNode::tVarName: return f << "tVarName"; | 45 | case AstNode::tVarName: return f << "tVarName"; |
diff --git a/src/astnode.h b/src/astnode.h index 28e5336..c0a8eea 100644 --- a/src/astnode.h +++ b/src/astnode.h | |||
@@ -29,6 +29,7 @@ public: | |||
29 | tMultiplyStore = 0x01000011, | 29 | tMultiplyStore = 0x01000011, |
30 | tNegate = 0x01000012, | 30 | tNegate = 0x01000012, |
31 | tIn = 0x01000013, | 31 | tIn = 0x01000013, |
32 | tGoto = 0x01000014, | ||
32 | 33 | ||
33 | tLeafLiteral = 0x02000000, | 34 | tLeafLiteral = 0x02000000, |
34 | tVarName = 0x02000001, | 35 | tVarName = 0x02000001, |
diff --git a/src/functiondisplay.cpp b/src/functiondisplay.cpp index 16b1175..332a2c9 100644 --- a/src/functiondisplay.cpp +++ b/src/functiondisplay.cpp | |||
@@ -15,7 +15,7 @@ FunctionDisplay::~FunctionDisplay() | |||
15 | 15 | ||
16 | Variable FunctionDisplay::call( class GameState &gState ) | 16 | Variable FunctionDisplay::call( class GameState &gState ) |
17 | { | 17 | { |
18 | Variable v = gState.pop(); | 18 | Variable v = gState.popDeref(); |
19 | sio << "Display: " << v << sio.nl; | 19 | sio << "Display: " << v << sio.nl; |
20 | } | 20 | } |
21 | 21 | ||
diff --git a/src/gamestate.cpp b/src/gamestate.cpp index cd6414c..4cab5c1 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp | |||
@@ -5,6 +5,9 @@ | |||
5 | #include "astleaf.h" | 5 | #include "astleaf.h" |
6 | #include "astleafliteral.h" | 6 | #include "astleafliteral.h" |
7 | 7 | ||
8 | #include <bu/sio.h> | ||
9 | using namespace Bu; | ||
10 | |||
8 | GameState::GameState( Game *pGame ) : | 11 | GameState::GameState( Game *pGame ) : |
9 | pGame( pGame ) | 12 | pGame( pGame ) |
10 | { | 13 | { |
@@ -115,6 +118,7 @@ void GameState::parse( const AstBranch::NodeList &lCode ) | |||
115 | { | 118 | { |
116 | for( AstBranch::NodeList::const_iterator i = lCode.begin(); i; i++ ) | 119 | for( AstBranch::NodeList::const_iterator i = lCode.begin(); i; i++ ) |
117 | { | 120 | { |
121 | sio << "Stack: " << lStack << sio.nl; | ||
118 | switch( (*i)->getType() ) | 122 | switch( (*i)->getType() ) |
119 | { | 123 | { |
120 | // tLeaf | 124 | // tLeaf |
diff --git a/src/parser.y b/src/parser.y index 8f538a5..ffb6da2 100644 --- a/src/parser.y +++ b/src/parser.y | |||
@@ -12,7 +12,8 @@ typedef void *yyscan_t; | |||
12 | 12 | ||
13 | 13 | ||
14 | %locations | 14 | %locations |
15 | %define api.pure | 15 | %pure-parser |
16 | /* %define api.pure */ | ||
16 | %debug | 17 | %debug |
17 | %error-verbose | 18 | %error-verbose |
18 | 19 | ||
@@ -149,7 +150,7 @@ cmpltExprList: | |||
149 | ; | 150 | ; |
150 | 151 | ||
151 | cmpltExpr: expr ';' | 152 | cmpltExpr: expr ';' |
152 | | tokGoto '(' expr ')' ';' | 153 | | tokGoto '(' expr ')' ';' { bld.addNode( AstNode::tGoto ); } |
153 | | ifbase | 154 | | ifbase |
154 | | tokFor tokEach forIterator tokIn expr tokDo '{' cmpltExprList '}' | 155 | | tokFor tokEach forIterator tokIn expr tokDo '{' cmpltExprList '}' |
155 | | tokWhile { | 156 | | tokWhile { |
@@ -18,11 +18,20 @@ situation <<start>> | |||
18 | setup | 18 | setup |
19 | { | 19 | { |
20 | name = "Bob"; | 20 | name = "Bob"; |
21 | display("Hello " + name + ''' and then some'''); | 21 | display("This is the setup phase for start, " + name); |
22 | display("???"); | ||
22 | } | 23 | } |
23 | 24 | ||
24 | enter | 25 | enter |
25 | { | 26 | { |
27 | display('''This is the enter part of the start situation'''); | ||
26 | } | 28 | } |
27 | } | 29 | } |
28 | 30 | ||
31 | situation <<stuff>> | ||
32 | { | ||
33 | enter | ||
34 | { | ||
35 | display('''Entered stuff'''); | ||
36 | } | ||
37 | } | ||