diff options
author | Mike Buland <mike@xagasoft.com> | 2014-11-24 15:51:08 -0700 |
---|---|---|
committer | Mike Buland <mike@xagasoft.com> | 2014-11-24 15:51:08 -0700 |
commit | 3320e1496b1d099f63dea869f4a1cc19630dc3a9 (patch) | |
tree | c56f8262951481376122650e9bc1c49358e304f1 /src/parser.cpp | |
parent | f2f92156531b49da71067336ef0724f411226644 (diff) | |
download | clic-3320e1496b1d099f63dea869f4a1cc19630dc3a9.tar.gz clic-3320e1496b1d099f63dea869f4a1cc19630dc3a9.tar.bz2 clic-3320e1496b1d099f63dea869f4a1cc19630dc3a9.tar.xz clic-3320e1496b1d099f63dea869f4a1cc19630dc3a9.zip |
Fixed an annoying parsing bug.0.10
Diffstat (limited to '')
-rw-r--r-- | src/parser.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 8675a7c..f97078a 100644 --- a/src/parser.cpp +++ b/src/parser.cpp | |||
@@ -25,10 +25,13 @@ void Parser::parse() | |||
25 | switch( t.eType ) | 25 | switch( t.eType ) |
26 | { | 26 | { |
27 | case Token::tEndOfInput: | 27 | case Token::tEndOfInput: |
28 | while( !tsNonTerminal.isEmpty() ) | ||
29 | unwind(); | ||
28 | return; | 30 | return; |
29 | 31 | ||
30 | case Token::tEndOfLine: | 32 | case Token::tEndOfLine: |
31 | unwind(); | 33 | while( !tsNonTerminal.isEmpty() ) |
34 | unwind(); | ||
32 | if( !tsTerminal.isEmpty() ) | 35 | if( !tsTerminal.isEmpty() ) |
33 | { | 36 | { |
34 | Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); | 37 | Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); |
@@ -176,6 +179,16 @@ void Parser::parse() | |||
176 | } | 179 | } |
177 | } | 180 | } |
178 | 181 | ||
182 | Number Parser::getVariable( const Bu::String &sName ) | ||
183 | { | ||
184 | return hVars.get( sName ); | ||
185 | } | ||
186 | |||
187 | void Parser::setVariable( const Bu::String &sName, const Number &rValue ) | ||
188 | { | ||
189 | hVars.insert( sName, rValue ); | ||
190 | } | ||
191 | |||
179 | void Parser::unwind() | 192 | void Parser::unwind() |
180 | { | 193 | { |
181 | for(;;) | 194 | for(;;) |
@@ -200,7 +213,7 @@ void Parser::unwind() | |||
200 | { | 213 | { |
201 | return; | 214 | return; |
202 | } | 215 | } |
203 | 216 | ||
204 | Token t = tsNonTerminal.peekPop(); | 217 | Token t = tsNonTerminal.peekPop(); |
205 | switch( t.eType ) | 218 | switch( t.eType ) |
206 | { | 219 | { |
@@ -312,6 +325,10 @@ void Parser::unwind() | |||
312 | // These should never show up at all | 325 | // These should never show up at all |
313 | break; | 326 | break; |
314 | } | 327 | } |
328 | if( !tsNonTerminal.isEmpty() && | ||
329 | getPriority( tsNonTerminal.peek().eType ) < | ||
330 | getPriority( t.eType ) ) | ||
331 | return; | ||
315 | } | 332 | } |
316 | } | 333 | } |
317 | 334 | ||