diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-03-15 18:19:49 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-03-15 18:19:49 +0100 |
commit | 9f69b006dde3c3fbe19ed3e0275d3b7348f2aa87 (patch) | |
tree | 6ac42793568339463f913cf39474794c8613d0b6 /minicc.cpp | |
parent | 3a7006fcf5f8ecffd852fbba6d8ee03ce8a35dce (diff) |
New lexer
Diffstat (limited to 'minicc.cpp')
-rw-r--r-- | minicc.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -14,6 +14,8 @@ #include <utility> #include <vector> +using namespace std::string_literals; + std::vector<std::string> split(std::string s) { std::vector<std::string> result; @@ -37,3 +39,18 @@ std::ostream& operator<<(std::ostream& os, const Token& token) { return os << token.type << ": " << token.value << "(" << token.location.line << ":" << token.location.column << ")"; } +void Location::advance(bool newline) +{ + pos++; + if (newline) { + line++; + column = 1; + } else { + column++; + } +} + +std::string Location::toString() +{ + return std::to_string(line) + ":"s + std::to_string(column); +} |