feat: introduce arrow tokens

Refs: #16
This commit is contained in:
2026-06-24 15:50:37 +02:00
parent 1965ab26af
commit d497e2de45
2 changed files with 9 additions and 0 deletions
+7
View File
@@ -54,6 +54,9 @@ enum class token_t {
GreaterThan, /**< `>` */
LessEq, /**< `<=` */
GreaterEq, /**< `>=` */
SlimArrow, /**< `->` */
FatArrow, /**< `=>` */
};
static inline std::ostream& operator<<(std::ostream& os, token_t type) {
@@ -92,6 +95,8 @@ static inline std::ostream& operator<<(std::ostream& os, token_t type) {
case token_t::GreaterThan: return os << ">";
case token_t::LessEq: return os << "<=";
case token_t::GreaterEq: return os << ">=";
case token_t::SlimArrow: return os << "->";
case token_t::FatArrow: return os << "=>";
}
return os;
}
@@ -132,6 +137,8 @@ static inline std::string operator+(const std::string& str, token_t type) {
case token_t::GreaterThan: return str + ">";
case token_t::LessEq: return str + "<=";
case token_t::GreaterEq: return str + ">=";
case token_t::SlimArrow: return str + "->";
case token_t::FatArrow: return str + "=>";
}
return str;
}
+2
View File
@@ -144,6 +144,8 @@ token_r lexer::next_token() {
{ ">", token_t::GreaterThan },
{ "<=", token_t::LessEq },
{ ">=", token_t::GreaterEq },
{ "->", token_t::SlimArrow },
{ "=>", token_t::FatArrow },
};
token_t type = token_t::None;