diff options
Diffstat (limited to 'src/lexer.cpp')
-rw-r--r-- | src/lexer.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
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 @@ | |||
6 | 6 | ||
7 | Lexer::Lexer( Bu::Stream &rIn ) : | 7 | Lexer::Lexer( Bu::Stream &rIn ) : |
8 | rIn( rIn ), | 8 | rIn( rIn ), |
9 | iBufPos( 0 ), | 9 | iBufPos( -1 ), |
10 | iScale( 0 ), | 10 | iScale( 0 ), |
11 | iRadix( 10 ), | 11 | iRadix( 10 ), |
12 | numRangeTop('9'), | 12 | numRangeTop('9'), |
@@ -55,28 +55,12 @@ void Lexer::fillToken() | |||
55 | default: | 55 | default: |
56 | throw Bu::ExceptionBase("Invalid mode."); | 56 | throw Bu::ExceptionBase("Invalid mode."); |
57 | } | 57 | } |
58 | /* | ||
59 | Bu::sio << "read[" | ||
60 | << ((iLookAheadUsed+iLookAheadStart)%iLookAheadSize) | ||
61 | << "]: " | ||
62 | << aLookAhead[(iLookAheadUsed+iLookAheadStart)%iLookAheadSize].eType; | ||
63 | if( aLookAhead[(iLookAheadUsed+iLookAheadStart)%iLookAheadSize].eType == Token::tNumber ) | ||
64 | Bu::sio << "(" | ||
65 | << aLookAhead[(iLookAheadUsed+iLookAheadStart)%iLookAheadSize].nVal->toString() << ")"; | ||
66 | Bu::sio << Bu::sio.nl; | ||
67 | */ | ||
68 | } | 58 | } |
69 | 59 | ||
70 | Token Lexer::nextTokenNormal() | 60 | Token Lexer::nextTokenNormal() |
71 | { | 61 | { |
72 | for(;;) | 62 | for(;;) |
73 | { | 63 | { |
74 | if( iBufPos >= sBuf.getSize() ) | ||
75 | { | ||
76 | iBufPos = -1; | ||
77 | return Token( Token::tEndOfLine ); | ||
78 | } | ||
79 | |||
80 | if( iBufPos < 0 ) | 64 | if( iBufPos < 0 ) |
81 | { | 65 | { |
82 | if( rIn.isEos() ) | 66 | if( rIn.isEos() ) |
@@ -90,8 +74,12 @@ Token Lexer::nextTokenNormal() | |||
90 | } | 74 | } |
91 | iBufPos = 0; | 75 | iBufPos = 0; |
92 | } | 76 | } |
77 | if( iBufPos >= sBuf.getSize() ) | ||
78 | { | ||
79 | iBufPos = -1; | ||
80 | return Token( Token::tEndOfLine ); | ||
81 | } | ||
93 | 82 | ||
94 | //Bu::println("Testing char '%1' at %2").arg( sBuf[iBufPos] ).arg( iBufPos ); | ||
95 | switch( sBuf[iBufPos] ) | 83 | switch( sBuf[iBufPos] ) |
96 | { | 84 | { |
97 | case ' ': | 85 | case ' ': |