From 9d4ab245bb40cab56686571b82ecf3fd9f15d416 Mon Sep 17 00:00:00 2001 From: Nikhil Kapila <12816113+nkapila6@users.noreply.github.com> Date: Thu, 22 Oct 2026 09:56:58 +0400 Subject: [PATCH 1/2] fix(lexer): end an operator where the next token starts --- src/numen/lexer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/numen/lexer.cpp b/src/numen/lexer.cpp index 4cd16c6..536368d 100644 --- a/src/numen/lexer.cpp +++ b/src/numen/lexer.cpp @@ -204,7 +204,11 @@ std::optional Lexer::next() { return tryCommit(); } - if (isAlnum(c) || isSpace(c)) { return tryCommit(); } + // anything that starts another token ends the operator: '*.5', '*$5', '*"a"' + if (isAlnum(c) || isSpace(c) || isValidChar(c) || c == '"' || c == '\'' || + (isFractionDelim(c) && m_cursor + 1 < m_data.size() && isDigit(m_data[m_cursor + 1]))) { + return tryCommit(); + } break; } case State::String: { From f0915276cf33c4f1daf7ff370f7b03058965c00d Mon Sep 17 00:00:00 2001 From: Nikhil Kapila <12816113+nkapila6@users.noreply.github.com> Date: Thu, 22 Oct 2026 10:12:09 +0400 Subject: [PATCH 2/2] test(corpus): cover operators glued to leading-dot decimals --- tests/corpus/arithmetic.corpus | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/corpus/arithmetic.corpus b/tests/corpus/arithmetic.corpus index 5ff39e3..756179e 100644 --- a/tests/corpus/arithmetic.corpus +++ b/tests/corpus/arithmetic.corpus @@ -222,6 +222,12 @@ pi => 3.141593 -.5 => -0.5 .25 * 4 => 1 +# an operator glued to a following leading-dot decimal reads the same as the spaced form +3*.3 => 0.9 +2**.5 => 1.414214 +2<.5 => false +1!=.5 => true + # whole results stay exact past the 64 bit signed range 2 ^ 64 => 18,446,744,073,709,551,616 10000000000 * 1000000000 => 10,000,000,000,000,000,000