summaryrefslogtreecommitdiffhomepage
path: root/minicc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'minicc.cpp')
-rw-r--r--minicc.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/minicc.cpp b/minicc.cpp
index 48d2a15..d180517 100644
--- a/minicc.cpp
+++ b/minicc.cpp
@@ -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);
+}