nl_tokens: Extracts from \ k<foo > pattern either a backreference to a named capturing group ( if it presents ) or parses it as a list of char : \ k < f etc .
pl_tokens: function NamedGroupRefOrChars ( text , textLoc ) { const groupName = text . slice ( 3 , - 1 ) ; if ( namedGroups . hasOwnProperty ( groupName ) ) { return Node ( { type : 'Backreference' , kind : 'name' , number : namedGroups [ groupName ] , reference : groupName , } , textLoc ) ; } // Else `\k<foo>` should be parsed as a list of `Char`s. // This is really a 0.01% edge case, but we should handle it. let startOffset = null ; let startLine = null ; let endLine = null ; let startColumn = null ; if ( textLoc ) { startOffset = textLoc . startOffset ; startLine = textLoc . startLine ; endLine = textLoc . endLine ; startColumn = textLoc . startColumn ; } const charRe = / ^[\w$<>] / ; let loc ; const chars = [ // Init to first \k, taking 2 symbols. Char ( text . slice ( 1 , 2 ) , 'simple' , startOffset ? { startLine , endLine , startColumn , startOffset , endOffset : startOffset += 2 , endColumn : startColumn += 2 , } : null ) , ] ; // For \k chars [ 0 ] . escaped = true ; // Other symbols. text = text . slice ( 2 ) ; while ( text . length > 0 ) { let matched = null ; // Unicode, \u003B or \u{003B} if ( ( <mask> = text . match ( uRe ) ) || ( matched = text . match ( ucpRe ) ) ) { if ( startOffset ) { loc = { startLine , endLine , startColumn , startOffset , endOffset : ( startOffset += matched [ 0 ] . length ) , endColumn : ( startColumn += matched [ 0 ] . length ) , } ; } chars . push ( Char ( matched [ 0 ] , 'unicode' , loc ) ) ; text = text . slice ( matched [ 0 ] . length ) ; } // Simple char. else if ( ( matched = text . match ( charRe ) ) ) { if ( startOffset ) { loc = { startLine , endLine , startColumn , startOffset , endOffset : ++ startOffset , endColumn : ++ startColumn , } ; } chars . push ( Char ( matched [ 0 ] , 'simple' , loc ) ) ; text = text . slice ( 1 ) ; } } return chars ; }