]> code.bitgloo.com Git - clyne/forspll.git/commitdiff
add basic character literals main
authorClyne Sullivan <clyne@bitgloo.com>
Sat, 29 Jun 2024 14:48:25 +0000 (10:48 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Sat, 29 Jun 2024 14:48:25 +0000 (10:48 -0400)
parser.cpp

index eb585f0605342cb2ab1650f9bf531fddff292e49..317bc872e5d15bfdc0b1501dad4fead542f54601 100644 (file)
@@ -70,6 +70,9 @@ std::pair<std::string_view, Token> nextToken(std::string_view sv)
         return {extractName(sv.substr(1)), Token::PushVar};
     } else if (isdigit(ch) || (ch == '-' && sv.size() > 1 && isdigit(sv[1]))) {
         return {extractName(sv), Token::Number};
         return {extractName(sv.substr(1)), Token::PushVar};
     } else if (isdigit(ch) || (ch == '-' && sv.size() > 1 && isdigit(sv[1]))) {
         return {extractName(sv), Token::Number};
+    } else if (ch == '\\' && sv.size() > 1) {
+        name = std::to_string(static_cast<int>(sv[1]));
+        return {sv.substr(2), Token::Number};
     } else if (isname(ch)) {
         return {extractName(sv), Token::Var};
     }
     } else if (isname(ch)) {
         return {extractName(sv), Token::Var};
     }