Change lexer code to use an option instead of ignoring the variant when no value is needed

This commit is contained in:
2025-10-02 17:19:51 +03:00
committed by Emin Arslan
parent d0eae97771
commit 47f33f3dc0
3 changed files with 12 additions and 11 deletions

View File

@@ -6,7 +6,7 @@ TEST_CASE("Lexer lexes doubles correctly", "[Lexer]") {
SECTION("double and negative syntax") {
Lexer l("(1.0 0.1 -.1 -1. . - -. .-)");
REQUIRE(l.next() == Token({OpenParen}));
REQUIRE(l.next() == Token({OpenParen, nullopt}));
REQUIRE(l.next() == Token({Double, 1.0}));
REQUIRE(l.next() == Token({Double, 0.1}));
REQUIRE(l.next() == Token({Double, -0.1}));
@@ -15,7 +15,7 @@ TEST_CASE("Lexer lexes doubles correctly", "[Lexer]") {
REQUIRE(l.next() == Token({Symbol, "-"}));
REQUIRE(l.next() == Token({Symbol, "-."}));
REQUIRE(l.next() == Token({Symbol, ".-"}));
REQUIRE(l.next() == Token({CloseParen}));
REQUIRE(l.next() == Token({CloseParen, nullopt}));
}
}