summaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp21
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
182Number Parser::getVariable( const Bu::String &sName )
183{
184 return hVars.get( sName );
185}
186
187void Parser::setVariable( const Bu::String &sName, const Number &rValue )
188{
189 hVars.insert( sName, rValue );
190}
191
179void Parser::unwind() 192void 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