diff options
Diffstat (limited to '')
-rw-r--r-- | src/parser.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 72f7bb3..bd49c38 100644 --- a/src/parser.cpp +++ b/src/parser.cpp | |||
@@ -1,3 +1,4 @@ | |||
1 | #include "config.h" | ||
1 | #include "parser.h" | 2 | #include "parser.h" |
2 | #include "lexer.h" | 3 | #include "lexer.h" |
3 | #include "number.h" | 4 | #include "number.h" |
@@ -6,7 +7,6 @@ | |||
6 | #include <bu/sio.h> | 7 | #include <bu/sio.h> |
7 | #include <stdlib.h> | 8 | #include <stdlib.h> |
8 | 9 | ||
9 | //#define DEBUG | ||
10 | 10 | ||
11 | Parser::Parser( Lexer &lex, Bu::Stream &rOut ) : | 11 | Parser::Parser( Lexer &lex, Bu::Stream &rOut ) : |
12 | lex( lex ), | 12 | lex( lex ), |
@@ -140,16 +140,17 @@ void Parser::parse() | |||
140 | getPriority( tsNonTerminal.peek().eType ) < | 140 | getPriority( tsNonTerminal.peek().eType ) < |
141 | getPriority( t.eType ) ) | 141 | getPriority( t.eType ) ) |
142 | { | 142 | { |
143 | #ifdef DEBUG | 143 | DBS( PARSE, |
144 | Bu::println("Pushing non-terminal: %1").arg( t.eType ); | 144 | Bu::println("Pushing non-terminal: %1").arg( t.eType ) |
145 | #endif | 145 | ); |
146 | tsNonTerminal.push( t ); | 146 | tsNonTerminal.push( t ); |
147 | } | 147 | } |
148 | else | 148 | else |
149 | { | 149 | { |
150 | #ifdef DEBUG | 150 | DBS( PARSE, |
151 | Bu::println("Unwinding stack before pushing: %1").arg( t.eType ); | 151 | Bu::println("Unwinding stack before pushing: %1") |
152 | #endif | 152 | .arg( t.eType ) |
153 | ); | ||
153 | unwind(); | 154 | unwind(); |
154 | tsNonTerminal.push( t ); | 155 | tsNonTerminal.push( t ); |
155 | } | 156 | } |
@@ -172,7 +173,7 @@ void Parser::unwind() | |||
172 | { | 173 | { |
173 | for(;;) | 174 | for(;;) |
174 | { | 175 | { |
175 | #ifdef DEBUG | 176 | DBS_START( PARSE ); |
176 | for( TokenStack::iterator i = tsTerminal.begin(); i; i++ ) | 177 | for( TokenStack::iterator i = tsTerminal.begin(); i; i++ ) |
177 | { | 178 | { |
178 | if( (*i).eType == Token::tNumber ) | 179 | if( (*i).eType == Token::tNumber ) |
@@ -184,7 +185,8 @@ void Parser::unwind() | |||
184 | for( TokenStack::iterator i = tsNonTerminal.begin(); i; i++ ) | 185 | for( TokenStack::iterator i = tsNonTerminal.begin(); i; i++ ) |
185 | Bu::print(" <%1>").arg( (*i).eType ); | 186 | Bu::print(" <%1>").arg( (*i).eType ); |
186 | Bu::println(""); | 187 | Bu::println(""); |
187 | #endif | 188 | DBS_END(); |
189 | |||
188 | if( tsNonTerminal.isEmpty() ) | 190 | if( tsNonTerminal.isEmpty() ) |
189 | return; | 191 | return; |
190 | 192 | ||