summaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index eb90637..de86b95 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -5,6 +5,8 @@
5#include <bu/sio.h> 5#include <bu/sio.h>
6#include <stdlib.h> 6#include <stdlib.h>
7 7
8#define DEBUG
9
8Parser::Parser( Lexer &lex, Bu::Stream &rOut ) : 10Parser::Parser( Lexer &lex, Bu::Stream &rOut ) :
9 lex( lex ), 11 lex( lex ),
10 rOut( rOut ) 12 rOut( rOut )
@@ -156,12 +158,16 @@ void Parser::parse()
156 getPriority( tsNonTerminal.peek().eType ) <= 158 getPriority( tsNonTerminal.peek().eType ) <=
157 getPriority( t.eType ) ) 159 getPriority( t.eType ) )
158 { 160 {
159// Bu::println("Pushing non-terminal: %1").arg( t.eType ); 161#ifdef DEBUG
162 Bu::println("Pushing non-terminal: %1").arg( t.eType );
163#endif
160 tsNonTerminal.push( t ); 164 tsNonTerminal.push( t );
161 } 165 }
162 else 166 else
163 { 167 {
164// Bu::println("Unwinding stack before pushing: %1").arg( t.eType ); 168#ifdef DEBUG
169 Bu::println("Unwinding stack before pushing: %1").arg( t.eType );
170#endif
165 unwind(); 171 unwind();
166 tsNonTerminal.push( t ); 172 tsNonTerminal.push( t );
167 } 173 }
@@ -174,7 +180,7 @@ void Parser::unwind()
174{ 180{
175 for(;;) 181 for(;;)
176 { 182 {
177/* 183#ifdef DEBUG
178 for( TokenStack::iterator i = tsTerminal.begin(); i; i++ ) 184 for( TokenStack::iterator i = tsTerminal.begin(); i; i++ )
179 { 185 {
180 if( (*i).eType == Token::tNumber ) 186 if( (*i).eType == Token::tNumber )
@@ -186,7 +192,7 @@ void Parser::unwind()
186 for( TokenStack::iterator i = tsNonTerminal.begin(); i; i++ ) 192 for( TokenStack::iterator i = tsNonTerminal.begin(); i; i++ )
187 Bu::print(" <%1>").arg( (*i).eType ); 193 Bu::print(" <%1>").arg( (*i).eType );
188 Bu::println(""); 194 Bu::println("");
189*/ 195#endif
190 if( tsNonTerminal.isEmpty() ) 196 if( tsNonTerminal.isEmpty() )
191 return; 197 return;
192 198