Finalize the new approach to reading chars in the reader

This commit is contained in:
Sameer Rahmani 2021-09-12 17:03:08 +01:00
parent 70df6f4368
commit b285172597
3 changed files with 2 additions and 10 deletions

View File

@ -1,10 +1,9 @@
(def main
(fn () 3))
(fn () 4))
(def main1 (fn (v y n) 3))
ht
3d
(- 3 4 (sh - r e 3bea -32) ((((())))))

View File

@ -69,7 +69,6 @@ private:
Location currentLocation;
bool readEOL = false;
bool startedReading = false;
/// Returns a clone of the current location
Location getCurrentLocation();

View File

@ -56,7 +56,7 @@ Reader::Reader(SereneContext &ctx, llvm::StringRef buffer, llvm::StringRef ns,
: ctx(ctx), ns(ns), filename(filename), buf(buffer),
currentLocation(Location(ns, filename)) {
READER_LOG("Setting the first char of the buffer");
currentChar = buf.begin();
currentChar = buf.begin() - 1;
currentPos = 1;
currentLocation.line = 1;
currentLocation.col = 1;
@ -94,8 +94,6 @@ void Reader::advanceByOne() {
<< currentLocation.toString());
};
void Reader::advance(bool skipWhitespace) {
startedReading = true;
if (skipWhitespace) {
for (;;) {
auto next = currentChar + 1;
@ -112,10 +110,6 @@ void Reader::advance(bool skipWhitespace) {
};
const char *Reader::nextChar(bool skipWhitespace, unsigned count) {
if (!startedReading) {
return currentChar;
}
if (!skipWhitespace) {
READER_LOG("Next char: " << *(currentChar + count));
return currentChar + count;