Skip to content

Commit

Permalink
process "\n" when finishing up lexer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksherlock committed Feb 3, 2016
1 parent 0c96252 commit 09ed342
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions mpw-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void init(Environment &env) {
int read_file(phase1 &p, const std::string &file) {
const mapped_file mf(file, mapped_file::readonly);

p.process(mf.begin(), mf.end(), true);

p.process(mf.begin(), mf.end(), false);
p.finish();
return 0;
}

Expand Down Expand Up @@ -227,7 +227,7 @@ int main(int argc, char **argv) {
if (cflag) {
std::string s(cflag);
s.push_back('\n');
p1.process(s.data(), s.data() + s.length(), true);
p1.process(s, true);
p2.finish();
exit(e.status());
}
Expand Down
4 changes: 2 additions & 2 deletions phase1.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class phase1 {
process((const unsigned char *)begin, (const unsigned char *)end, final);
}

void process(const std::string &s) { process(s.data(), s.data() + s.size()); }
void process(const std::string &s, bool final = false) { process(s.data(), s.data() + s.size(), final); }

void finish() { const char *tmp = ""; process(tmp, tmp, true); }
void finish() { const char *tmp = "\n"; process(tmp, tmp+1, true); }

void reset();

Expand Down

0 comments on commit 09ed342

Please sign in to comment.