Support MATLAB-style leading-dot float literals#216
Closed
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
gneeri
approved these changes
Mar 24, 2026
Contributor
gneeri
left a comment
There was a problem hiding this comment.
You need to fix the clippy things that are causing CI to fail, but otherwise, looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
.1), causing parsing failures in normal scripts and range expressions like0:.1:10.obj.field,1..3,.*, etc.).Description
tokenize_detailed()incrates/runmat-lexer/src/lib.rsto contextually merge a standalone.into aToken::Floatwhen it is followed by a valid fractional/exponent suffix, by detectingToken::Dotand scanning the remainder for a fractional/exponent sequence and underscores as digit separators.can_start_leading_dot_float,leading_dot_float_suffix_len,scan_decimal_digits, andscan_float_exponentto safely identify valid leading-dot float suffixes and ensure the dot is not being used for adjacent member/transpose-style syntax.obj.field,.*,1..3) and normalize underscore-separated digits in the emitted float lexeme consistently with other numeric tokens.crates/runmat-lexer/tests/lexer.rs, parser tests incrates/runmat-parser/tests/range_parsing.rs, and runtime/ignition test incrates/runmat-ignition/tests/ranges.rsto cover standalone leading-dot literals, range-step forms like0:.1:1, and ensure property-access dots are unchanged.Testing
cargo fmtto ensure formatting completed successfully.cargo test -p runmat-lexer --test lexerand all lexer tests (including new leading-dot tests) passed.cargo test -p runmat-parser --test range_parsingand parser range tests (including leading-dot forms) passed.cargo test -p runmat-ignition --test rangesand runtime/ignition range tests (including a leading-dot step execution test) passed.Codex Task
Note
Medium Risk
Touches core lexing behavior by rewriting
.intoFloatin specific contexts, which could subtly affect dot-based syntax (property access/operators) if the heuristics are wrong; changes are guarded and covered by new tests.Overview
Adds MATLAB-style leading-dot float support (e.g.,
.1,.25e-2,.3_5) by teachingtokenize_detailed()to contextually merge a standaloneToken::Dotplus a following digit/exponent sequence into a singleToken::Float(with underscore normalization), while avoiding rewrites when the dot is adjacent to a prior value/transpose.Extends test coverage across lexer, parser, and runtime execution to ensure leading-dot floats work in assignments and range steps (e.g.,
0:.1:1) and thatobj.field-style property access remains tokenized asIdent Dot Ident.Written by Cursor Bugbot for commit ee12f68. This will update automatically on new commits. Configure here.