From 9f7cbe624a91008a4cbe47c7b369c5e3f96a4eff Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 28 Nov 2014 13:45:37 -0700 Subject: Division fixes, better config, more tests. Other minor fixes and options such as --version being added. --- src/parser.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 72f7bb3..bd49c38 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1,3 +1,4 @@ +#include "config.h" #include "parser.h" #include "lexer.h" #include "number.h" @@ -6,7 +7,6 @@ #include #include -//#define DEBUG Parser::Parser( Lexer &lex, Bu::Stream &rOut ) : lex( lex ), @@ -140,16 +140,17 @@ void Parser::parse() getPriority( tsNonTerminal.peek().eType ) < getPriority( t.eType ) ) { -#ifdef DEBUG - Bu::println("Pushing non-terminal: %1").arg( t.eType ); -#endif + DBS( PARSE, + Bu::println("Pushing non-terminal: %1").arg( t.eType ) + ); tsNonTerminal.push( t ); } else { -#ifdef DEBUG - Bu::println("Unwinding stack before pushing: %1").arg( t.eType ); -#endif + DBS( PARSE, + Bu::println("Unwinding stack before pushing: %1") + .arg( t.eType ) + ); unwind(); tsNonTerminal.push( t ); } @@ -172,7 +173,7 @@ void Parser::unwind() { for(;;) { -#ifdef DEBUG + DBS_START( PARSE ); for( TokenStack::iterator i = tsTerminal.begin(); i; i++ ) { if( (*i).eType == Token::tNumber ) @@ -184,7 +185,8 @@ void Parser::unwind() for( TokenStack::iterator i = tsNonTerminal.begin(); i; i++ ) Bu::print(" <%1>").arg( (*i).eType ); Bu::println(""); -#endif + DBS_END(); + if( tsNonTerminal.isEmpty() ) return; -- cgit v1.2.3