Cleaned up Lexer

This commit is contained in:
Pasha Bibko
2025-05-07 18:10:15 +01:00
parent 6783564f10
commit 98fc4589ab
11 changed files with 246 additions and 203 deletions

View File

@@ -57,4 +57,19 @@ namespace LX
// Returns the string between start and end //
return src.substr(start, end - start);
}
// Util function for turning a a char to a string. Used to stop '\t' being printed as a tab //
inline std::string CharAsStrLit(const char c)
{
switch (c)
{
// Stores them as pure string literals //
case '\n': return R"(\n)";
case '\t': return R"(\t)";
case '\r': return R"(\r)";
// Else returns a string of length one with the char inside //
default: return std::string(1, c);
}
}
}