Spell-check element kinds and parameter group names#64
Merged
Conversation
A misspelling in a name PALS draws from a fixed vocabulary is invisible: `kind: marker` and a `FlorP` group are valid YAML and simply go unrecognised downstream, so the lattice quietly comes out wrong. Check both against the vocabulary and report what does not belong. The new pals_check.cpp holds the two tables -- every element kind from lattice-element-kinds.md plus the structural and definition kinds, and every parameter group from source/parameters -- and walks the combined tree, where each definition appears exactly once as written, so a mistake is reported once and against the name the user typed rather than a copy expansion made. Group names are recognised by shape: strict CamelCase ending in `P`, which is the one part of an element written that way. Letters only, so a vendor name like `L20_BLW_P` reads as outside the standard rather than misspelled. Where a near match exists it is offered. A name differing only in case wins outright, that being the mistake the CamelCase convention invites; otherwise the nearest name within a couple of edits, and nothing when two are equally close. Extension data is exempt, as the standard requires: a dictionary holding an `extension` key, and any name registered under `PALS: extension_labels` -- by full name, prefix, or suffix -- including one used as an enum value such as `kind: Rotator`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
A misspelling in a name PALS draws from a fixed vocabulary is invisible:
kind: markerand aFlorPgroup are valid YAML and simply go unrecognised downstream, so the lattice quietly comes out wrong. Both are now checked and reported.What is checked
New
src/pals_check.cppholds the two tables and walks the combined tree — where each definition appears exactly once as written, so a mistake is reported once, against the name the user typed rather than a copy expansion made of it.lattice-element-kinds.md, plusBeamLineandLattice, plus the definition kindsconstant(fundamentals.md),variable(pals#240) andController(pals#237).source/parameters, plusForkFromP(pals#272).Group names are recognised by shape — strict CamelCase ending in
P, the one part of an element written that way. Letters only, so a vendor name likeL20_BLW_Preads as outside the standard rather than misspelled. Plain lower-case parameters (length,to_line) are not checked; they are not drawn from a fixed vocabulary.Suggestions
A name differing only in case wins outright — that is the mistake the CamelCase convention invites. Otherwise the nearest name within a couple of edits (and never more than a third of the name's length), and nothing at all when two candidates are equally close.
Extensions
Exempt, as the standard requires (
extensions.md, s:extension-syntax): a dictionary holding anextensionkey, and any name registered underPALS: extension_labels— matched in full, by prefix, or by suffix — including one used as an enum value such askind: Rotator.What it finds in this repo's own lattice files
Not fixed here, since they are inputs rather than code:
bta.pals.yamlkind: SBend×2 (Bmad's name forBend);BmadP×3convert.pals.yamlkind: Aperture×2;kind: SBendinclude.pals.yamlkind: SBend;kind: Beamline;BmadPThe
BmadPgroups are genuine extension data and would go quiet once registered underextension_labels.Beamlinealso appears as a typo in the standard, atlattice-construction.md:198.Tests
New
tests/test_check.cpp: five cases covering a misspelled kind, a misspelled group, a clean file reporting nothing, extension exemption in all four forms, and a name too far gone to guess at. 152/152 ctest pass; the PALSJulia suite passes against the rebuilt library.🤖 Generated with Claude Code