From 3015ea4677201060777435cf76815e898d221f8c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 1 Dec 2016 09:31:45 -0700 Subject: The parser works. There's still more to do, however. It doesn't do math anymore, it produces a script that can then be executed. Now we have to capture that script and execute it. --- src/lexer.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src/lexer.cpp') diff --git a/src/lexer.cpp b/src/lexer.cpp index 538e088..87d603a 100644 --- a/src/lexer.cpp +++ b/src/lexer.cpp @@ -6,7 +6,7 @@ Lexer::Lexer( Bu::Stream &rIn ) : rIn( rIn ), - iBufPos( 0 ), + iBufPos( -1 ), iScale( 0 ), iRadix( 10 ), numRangeTop('9'), @@ -55,28 +55,12 @@ void Lexer::fillToken() default: throw Bu::ExceptionBase("Invalid mode."); } -/* - Bu::sio << "read[" - << ((iLookAheadUsed+iLookAheadStart)%iLookAheadSize) - << "]: " - << aLookAhead[(iLookAheadUsed+iLookAheadStart)%iLookAheadSize].eType; - if( aLookAhead[(iLookAheadUsed+iLookAheadStart)%iLookAheadSize].eType == Token::tNumber ) - Bu::sio << "(" - << aLookAhead[(iLookAheadUsed+iLookAheadStart)%iLookAheadSize].nVal->toString() << ")"; - Bu::sio << Bu::sio.nl; -*/ } Token Lexer::nextTokenNormal() { for(;;) { - if( iBufPos >= sBuf.getSize() ) - { - iBufPos = -1; - return Token( Token::tEndOfLine ); - } - if( iBufPos < 0 ) { if( rIn.isEos() ) @@ -90,8 +74,12 @@ Token Lexer::nextTokenNormal() } iBufPos = 0; } + if( iBufPos >= sBuf.getSize() ) + { + iBufPos = -1; + return Token( Token::tEndOfLine ); + } - //Bu::println("Testing char '%1' at %2").arg( sBuf[iBufPos] ).arg( iBufPos ); switch( sBuf[iBufPos] ) { case ' ': -- cgit v1.2.3