Skip to content

Scanner update: Character-based; kind-type removal; unit tests - #187

Merged
marshallward merged 4 commits into
mainfrom
scanner-tests
Jul 17, 2026
Merged

Scanner update: Character-based; kind-type removal; unit tests#187
marshallward merged 4 commits into
mainfrom
scanner-tests

Conversation

@marshallward

Copy link
Copy Markdown
Owner

This is a minor update to the scanner parser:

  • The main loop is now character-based, rather than line-based, which is in closer alignment with namelist parsing. Files will still default to line-based units, although this is not recognized in-loop.
  • Kind-parsing has been eliminated, since these are not supported in namelists.
  • Handling of Unicode characters (or, more accurately, anything unspecified in the machine) has been simplified to handle
  • Independent scanner unit tests have been implemented.

In namelists, endlines have no semantic meaning (outside of strings, and
even that is tricky), so the line-based iteration was a bit unintuitive
in some places.

And the comment line-complete optimization made less sense, since we
want the endline and following whitespace to join the comment token.

In order to better align with these facts, and line-based logic has been
dropped and the iterator is now solely per-character.
First draft of a few scanner unit tests.  Needs work.

Several new tests by Codex (but needs polishing)

Also found some bugs :O
The simpler nature of multiline strings in namelists, along with other
changes in the DFA machine, mean that we no longer need to check against
\n when running the Unicode KeyError exception test.

This block has been simplified and the endline is no longer tested.
Kind-type specification with _ is not supported in either namelists or
list-directed IO.  This tokenization was leftover from the Fortran
scanner.  This patch eliminates this content.

Tests have been added to ensure that lexemes like `1_8` are not formed.
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.63%. Comparing base (420c780) to head (03e5967).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
tests/test_scanner.py 97.20% 2 Missing and 2 partials ⚠️
f90nml/scanner.py 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
+ Coverage   97.21%   97.63%   +0.42%     
==========================================
  Files           9       10       +1     
  Lines        2152     2666     +514     
  Branches      358      466     +108     
==========================================
+ Hits         2092     2603     +511     
- Misses         35       36       +1     
- Partials       25       27       +2     
Flag Coverage Δ
python2.7 97.25% <96.66%> (+0.57%) ⬆️
python3.5 97.44% <96.66%> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marshallward
marshallward merged commit 1a5def3 into main Jul 17, 2026
57 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant