From 3320e1496b1d099f63dea869f4a1cc19630dc3a9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 24 Nov 2014 15:51:08 -0700 Subject: Fixed an annoying parsing bug. --- src/parser.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/parser.cpp') 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() switch( t.eType ) { case Token::tEndOfInput: + while( !tsNonTerminal.isEmpty() ) + unwind(); return; case Token::tEndOfLine: - unwind(); + while( !tsNonTerminal.isEmpty() ) + unwind(); if( !tsTerminal.isEmpty() ) { Bu::println( rOut, "%1").arg( deref( tsTerminal.peek() ) ); @@ -176,6 +179,16 @@ void Parser::parse() } } +Number Parser::getVariable( const Bu::String &sName ) +{ + return hVars.get( sName ); +} + +void Parser::setVariable( const Bu::String &sName, const Number &rValue ) +{ + hVars.insert( sName, rValue ); +} + void Parser::unwind() { for(;;) @@ -200,7 +213,7 @@ void Parser::unwind() { return; } - + Token t = tsNonTerminal.peekPop(); switch( t.eType ) { @@ -312,6 +325,10 @@ void Parser::unwind() // These should never show up at all break; } + if( !tsNonTerminal.isEmpty() && + getPriority( tsNonTerminal.peek().eType ) < + getPriority( t.eType ) ) + return; } } -- cgit v1.2.3