Make Lexer use constant Tokens
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -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'},
|
||||
|
||||
Reference in New Issue
Block a user