Make Lexer use constant Tokens
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-06-13 18:49:38 +02:00
parent 5910cbbfa9
commit 3e00f750ef
10 changed files with 162 additions and 137 deletions

View File

@@ -14,8 +14,8 @@ Lexer::Lexer(const string& scriptString, class Script* script)
}
vector<IToken*> Lexer::Lex() {
vector<IToken*> tokens;
vector<const IToken*> Lexer::Lex() {
vector<const IToken*> tokens;
while (true){
IToken* next = this -> LexNext(this -> Next());
auto nextKind = next -> GetKind();
@@ -215,11 +215,11 @@ IToken * Lexer::LexIdentifierOrKeyword() {
case HashedString::ConstHash("then"): return new SimpleToken(TokenKind::ThenKeyword, start, 4);
case HashedString::ConstHash("true"): return new SimpleToken(TokenKind::TrueKeyword, start, 4);
case HashedString::ConstHash("while"): return new SimpleToken(TokenKind::WhileKeyword, start, 5);
default: return new IdentifierToken(s, start, s.length());
default: return new IdentifierToken(HashedString(s), start, s.length());
}
}
const unordered_map<char, char> ControlCharacters{
const unordered_map<char, char> ControlCharacters{ // NOLINT(cert-err58-cpp)
{'0', '\0'},
{'a', '\a'},
{'b', '\b'},