feat: fix \N escape handling (bare \N, \N{U+HHHH}, quantifier)#33
Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
feat: fix \N escape handling (bare \N, \N{U+HHHH}, quantifier)#33toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
…iguation
Three bugs fixed in \N handling:
1. Bare \N now parses as "not newline" (Perl 5.12+) instead of erroring.
Creates a nonnewline node type. Still errors inside character classes,
matching Perl's behavior.
2. \N{U+HHHH} no longer produces "isn't numeric in chr" warnings.
The nchar() method now detects U+HHHH format and uses chr(hex())
directly instead of passing through charnames::vianame() which
returns the character (not code point) for this format.
3. \N{3,5} is now correctly parsed as \N + quantifier {3,5}, not as
a named character lookup for "3,5". The handler checks if braced
content looks like a quantifier pattern before consuming it.
Co-Authored-By: Claude Opus 4.6 <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.
What
Fix three bugs in
\Nescape sequence handling to match modern Perl behavior.Why
\N(meaning "not newline", Perl 5.12+) was rejected with an error instead of being parsed\N{U+0041}produced "Argument isn't numeric in chr" warnings becausecharnames::vianame()returns the character (not code point) forU+HHHHformat\N{3,5}was misinterpreted as a named character lookup instead of\N+ quantifier{3,5}How
nonnewlinenode type for bare\N, modeled afterlnbreaknchar()detectsU+HHHHformat and useschr(hex())directly\Nhandler checks if braced content matches quantifier pattern before consuming it as a name\Ninside character classes still errors, matching Perl's behaviorTesting
All 1203 tests pass (46 new). New
t/18nonnewline.tcovers bare\N,\N{NAME},\N{U+HHHH}, quantifier disambiguation, round-trips, and error cases. Existing round-trip and error tests updated.🤖 Generated with Claude Code
Quality Report
Changes: 7 files changed, 251 insertions(+), 9 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline