summaryrefslogtreecommitdiff
path: root/src/lexer.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2016-12-01 09:31:45 -0700
committerMike Buland <eichlan@xagasoft.com>2016-12-01 09:31:45 -0700
commit3015ea4677201060777435cf76815e898d221f8c (patch)
tree8415fcef57ed5456ec03b2ea115ebd3789fd8c10 /src/lexer.cpp
parent5b8df4e1ab3faffe5c010222ff3f8ce3a4ff810c (diff)
downloadclic-3015ea4677201060777435cf76815e898d221f8c.tar.gz
clic-3015ea4677201060777435cf76815e898d221f8c.tar.bz2
clic-3015ea4677201060777435cf76815e898d221f8c.tar.xz
clic-3015ea4677201060777435cf76815e898d221f8c.zip
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.
Diffstat (limited to 'src/lexer.cpp')
-rw-r--r--src/lexer.cpp24
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
7Lexer::Lexer( Bu::Stream &rIn ) : 7Lexer::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
70Token Lexer::nextTokenNormal() 60Token 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 ' ':