Conversation
sash070
left a comment
There was a problem hiding this comment.
basic lexer implementation except error handling and indentation stack.
|
Can you rebase and squash the commits. I will have a look at this in a while. |
I have done this for now. No worries ! |
src/lexer/keywords.hpp
Outdated
| {"=", TokenType::ASSIGN}, | ||
| {"+", TokenType::PLUS}, | ||
| {"-", TokenType::MINUS}, | ||
| {"*", TokenType::STAR}, | ||
| {"/", TokenType::SLASH}, | ||
| {"(", TokenType::LPAREN}, | ||
| {")", TokenType::RPAREN}, | ||
| {":", TokenType::COLON}, | ||
| {",", TokenType::COMMA}, | ||
| {"\n", TokenType::NEWLINE}, | ||
| {"\t", TokenType::INDENT}, | ||
| {" ", TokenType::SPACE} |
There was a problem hiding this comment.
Do you think these are keywords?
I assume its better if we split it out before even entering keywords, I am not very sure but they don't seem to fit in the 'keywords'.
There was a problem hiding this comment.
Yea the keywords map needs to be cleaned up. Maybe we can have another unordered map for operators and such..
src/lexer/lexer.cpp
Outdated
| tokens.push_back(token); | ||
| } | ||
|
|
||
| void Lexer::scanIdentifier(std::string curr){ |
There was a problem hiding this comment.
Better naming required here for curr
src/lexer/lexer.cpp
Outdated
| } | ||
| std::string curr = ""; | ||
| curr += advance(); | ||
| if (keywords.count(curr)){ |
There was a problem hiding this comment.
will something else like .find or .contains be better than .count
There was a problem hiding this comment.
yea you're right. I think contains() is best for C++20 and later.
Removed unnecessary steps from the CI workflow.
|
Update the PR Description properly with what is being done in this PR, you can change the title also, I have changed it to something more suitable for now. A few more things are
|
Implemented Lexer
PS: I don't think indentation.hpp and indentation.cpp are required.