Conversation
Replace RegexTerminal("AF_[A-Z0-9_]+") with a FlexibleLiteralChoiceTerminal of
the 48 address families systemd's af_from_name accepts (the AF_* macros from
<sys/socket.h>, minus AF_UNSPEC/AF_MAX). Unknown names like AF_BOGUS are now
correctly rejected, and the exact name set is the foundation for grammar-based
completion and a future deprecation annotator for kernel-removed families
(AF_DECnet, AF_IRDA, AF_ECONET, AF_WANPIPE).
FlexibleLiteralChoiceTerminal keeps loose syntactic matching (so error
localization still highlights the offending token) but requires an exact choice
to be semantically valid.
Adds a golden test suite (valid families incl. alias/mixed-case/~-inversion,
plus a raw-value regression guard that unknown AF_ names are flagged) to anchor
the upcoming grammar-engine rework.
Refs #467 #345 #343
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Test Results1 112 tests 1 112 ✅ 48s ⏱️ Results for commit 8b48357. |
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.
What
Replace the loose
RegexTerminal("AF_[A-Z0-9_]+")in theRestrictAddressFamilies=validator with aFlexibleLiteralChoiceTerminalenumerating the 48 address families systemd'saf_from_nameactually accepts — theAF_*macros from<sys/socket.h>, minusAF_UNSPEC/AF_MAX(the same set systemd generates viagenerate-af-list.sh).Why
The old regex accepted any
AF_-prefixed token, so bogus names likeAF_BOGUSpassed validation. Enumerating the real names:AF_BOGUS,AF_INETZ, wrong-caseAF_DECNETare now flagged);FlexibleLiteralChoiceTerminalmatches loosely for syntax (so the offending token is highlighted, not the whole line) but requires an exact choice to be semantically valid;AF_DECnet,AF_IRDA,AF_ECONET,AF_WANPIPE).Tests
Adds a golden test suite that anchors the upcoming grammar-engine rework:
testValidValues/testInvalidValues— existing behavior preserved.testValidEnumeratedFamilies— alias (AF_LOCAL), mixed-case real name (AF_DECnet), newest families (AF_VSOCK AF_XDP AF_MCTP), and a~-inverted multi-family list.testUnknownFamiliesAreNowRejected— raw-value regression guard that unknownAF_names are flagged (raw values so it doesn't depend on test-framework<error>markup stripping).This is step 1 of the grammar-engine rework tracked in #467, and the canary suite the new
parse()engine must keep green.Refs #467 #345 #343
🤖 Generated with Claude Code