summaryrefslogtreecommitdiff
path: root/src/lexer.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2016-11-30 14:52:39 -0700
committerMike Buland <eichlan@xagasoft.com>2016-11-30 14:52:39 -0700
commit2297488eae424197dce4ed6b1dc50ae67c093074 (patch)
treec28956f193f9ee8bdde083f780984736d48a5e41 /src/lexer.cpp
parent0321e6e39b8cf24718cf853c28f0f35443753264 (diff)
downloadclic-2297488eae424197dce4ed6b1dc50ae67c093074.tar.gz
clic-2297488eae424197dce4ed6b1dc50ae67c093074.tar.bz2
clic-2297488eae424197dce4ed6b1dc50ae67c093074.tar.xz
clic-2297488eae424197dce4ed6b1dc50ae67c093074.zip
I managed to confuse myself pretty well.
I'm doing some reading up on LR(n) parsers, I just sort of started without thinking about it this time, not a great approach. I feel like it can't hurt to have an update on how this works anyway. I think the idea was solid, but I was trying to do too much at once. One question is what my goal should be for this. I could just solve the equation as we go, or I could generate code that will let us solve the equation. The later is obviously attractive in that it will let us run an expression more than once, and maybe even define functions. I like that.
Diffstat (limited to 'src/lexer.cpp')
-rw-r--r--src/lexer.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lexer.cpp b/src/lexer.cpp
index fbcaafb..55d155d 100644
--- a/src/lexer.cpp
+++ b/src/lexer.cpp
@@ -26,15 +26,15 @@ Lexer::~Lexer()
26 26
27void Lexer::nextToken() 27void Lexer::nextToken()
28{ 28{
29 if( iLookAheadSize <= 1 ) 29 if( iLookAheadUsed <= 1 )
30 { 30 {
31 iLookAheadSize = 0; 31 iLookAheadUsed = 0;
32 iLookAheadStart = 0; 32 iLookAheadStart = 0;
33 } 33 }
34 else 34 else
35 { 35 {
36 iLookAheadStart = (iLookAheadStart+1)%iLookAheadSize; 36 iLookAheadStart = (iLookAheadStart+1)%iLookAheadSize;
37 iLookAheadSize--; 37 iLookAheadUsed--;
38 } 38 }
39} 39}
40 40
@@ -55,11 +55,16 @@ void Lexer::fillToken()
55 default: 55 default:
56 throw Bu::ExceptionBase("Invalid mode."); 56 throw Bu::ExceptionBase("Invalid mode.");
57 } 57 }
58 58/*
59 Bu::sio << "read[" 59 Bu::sio << "read["
60 << ((iLookAheadUsed+iLookAheadStart)%iLookAheadSize) 60 << ((iLookAheadUsed+iLookAheadStart)%iLookAheadSize)
61 << "]: " 61 << "]: "
62 << aLookAhead[(iLookAheadUsed+iLookAheadStart)%iLookAheadSize].eType; 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*/
63} 68}
64 69
65Token Lexer::nextTokenNormal() 70Token Lexer::nextTokenNormal()