Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/numen/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ std::optional<Lexer::Token> 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: {
Expand Down
6 changes: 6 additions & 0 deletions tests/corpus/arithmetic.corpus
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading