Skip to content

Named back-references validated too early #17

@nbtrap

Description

@nbtrap

CL-PPCRE validates register names too early in the regex compilation phase. The converter should wait until it has seen all register names before asserting that named back-references refer to existing registers.

(setf *allow-named-registers* t)
==> T

(scan "\\k<regOne>(?<regOne>.)" "a")
; Evaluation aborted on #<PPCRE-SYNTAX-ERROR "Illegal back-reference: ~S." {1006D50F93}>.

(scan "\\1(.)" "a")
==> NIL

Compare this to Perl:

say 'a' =~ /\k<regOne>(?<regOne>.)/ ? 'true' : 'false';
==> false

say 'a' =~ /\k<regTwo>(?<regOne>.)/ ? 'true' : 'false';
==> Reference to nonexistent named group in regex...

I plan on fixing this in my subpattern references branch, which is nearing completion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions