summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2013-11-13 09:10:28 -0700
committerMike Buland <mike@xagasoft.com>2013-11-13 09:10:28 -0700
commit8bebb14861ce8e11ee518a72f9b27201f0a9455d (patch)
tree3b8346f01b1a43bb108f567b590d1d6de0683f4f
parent2ddaaf2cc2b7e06125c84961e37367c629f01ff2 (diff)
downloadclic-8bebb14861ce8e11ee518a72f9b27201f0a9455d.tar.gz
clic-8bebb14861ce8e11ee518a72f9b27201f0a9455d.tar.bz2
clic-8bebb14861ce8e11ee518a72f9b27201f0a9455d.tar.xz
clic-8bebb14861ce8e11ee518a72f9b27201f0a9455d.zip
Corrected silly bug in variable assignment.
-rw-r--r--src/lexer.cpp2
-rw-r--r--src/parser.cpp14
2 files changed, 11 insertions, 5 deletions
diff --git a/src/lexer.cpp b/src/lexer.cpp
index 97ceb1b..7704343 100644
--- a/src/lexer.cpp
+++ b/src/lexer.cpp
@@ -86,7 +86,7 @@ Token Lexer::nextTokenNormal()
86 sBuf[iBufPos] != ' ' && sBuf[iBufPos] != '\t' && 86 sBuf[iBufPos] != ' ' && sBuf[iBufPos] != '\t' &&
87 sBuf[iBufPos] != '+' && sBuf[iBufPos] != '-' && 87 sBuf[iBufPos] != '+' && sBuf[iBufPos] != '-' &&
88 sBuf[iBufPos] != '*' && sBuf[iBufPos] != '/' && 88 sBuf[iBufPos] != '*' && sBuf[iBufPos] != '/' &&
89 sBuf[iBufPos] != '%' && 89 sBuf[iBufPos] != '%' && sBuf[iBufPos] != '=' &&
90 sBuf[iBufPos] != '(' && sBuf[iBufPos] != ')'; 90 sBuf[iBufPos] != '(' && sBuf[iBufPos] != ')';
91 iBufPos++ ) 91 iBufPos++ )
92 { 92 {
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