From 04f56c12e82ea5228b2b65e68c46ed7f4563182b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 23 Apr 2013 11:47:01 -0600 Subject: Variables work. --- src/lexer.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/lexer.cpp') diff --git a/src/lexer.cpp b/src/lexer.cpp index 3ebb0cf..46686c8 100644 --- a/src/lexer.cpp +++ b/src/lexer.cpp @@ -63,6 +63,26 @@ Token Lexer::nextToken() } break; + case '$': + { + Bu::String *sTmp = new Bu::String(); + for( iBufPos++; iBufPos < sBuf.getSize() && + sBuf[iBufPos] != ' ' && sBuf[iBufPos] != '\t' && + sBuf[iBufPos] != '+' && sBuf[iBufPos] != '-' && + sBuf[iBufPos] != '*' && sBuf[iBufPos] != '/' && + sBuf[iBufPos] != '(' && sBuf[iBufPos] != ')'; + iBufPos++ ) + { + sTmp->append( sBuf[iBufPos] ); + } + return Token( Token::tVariable, sTmp ); + } + break; + + case '=': + iBufPos++; + return Token( Token::tEquals ); + case '+': iBufPos++; return Token( Token::tPlus ); @@ -115,26 +135,6 @@ Token Lexer::nextToken() delete sTmp; return Token( Token::tNumber, n ); } - else if( (sBuf[iBufPos]>=(ascRangeTop+1) && sBuf[iBufPos]<='z') || - (sBuf[iBufPos]>='A' && sBuf[iBufPos]<='Z') || - sBuf[iBufPos] == '_' ) - { - for( ; iBufPos < sBuf.getSize(); iBufPos++ ) - { - if( (sBuf[iBufPos]>='a' && sBuf[iBufPos]<='z') || - (sBuf[iBufPos]>='A' && sBuf[iBufPos]<='Z') || - (sBuf[iBufPos]>='0' && sBuf[iBufPos]<='9') || - sBuf[iBufPos] == '_' ) - { - sTmp->append( sBuf[iBufPos] ); - } - else - { - break; - } - } - return Token( Token::tString, sTmp ); - } else { sBuf.clear(); -- cgit v1.2.3