Added EOF symbol, making the getTable() saner for ACCEPT and lookahead support in ParseRule
This commit is contained in:
24
src/Lexer.cpp
Normal file
24
src/Lexer.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "Lexer.h"
|
||||
|
||||
Lexer::Lexer() {
|
||||
//Do nothing
|
||||
}
|
||||
|
||||
Lexer::Lexer(std::string inputString) {
|
||||
reader.setString(inputString);
|
||||
}
|
||||
|
||||
Lexer::~Lexer() {
|
||||
//No cleanup necessary
|
||||
}
|
||||
|
||||
void Lexer::setInput(std::string inputString) {
|
||||
reader.setString(inputString);
|
||||
}
|
||||
|
||||
Symbol* Lexer::next() {
|
||||
std::string token = reader.word();
|
||||
if (token != "")
|
||||
return new Symbol("\""+token+"\"", true);
|
||||
return new Symbol("$EOF$", false);
|
||||
}
|
||||
Reference in New Issue
Block a user