Carp icon indicating copy to clipboard operation
Carp copied to clipboard

Something is rotten in the state of Pattern parsing

Open hellerve opened this issue 5 years ago • 3 comments

The parser for patterns seems not quite right; specifically there seems to be a problem with backlashes. Consider this example:

(Pattern.substitute #"\b" "w\b" "\\\\b" -1) ; => throws an error about an unexpected quote
(Pattern.substitute &(Pattern.init "\b") "w\b" "\\\\b" -1) ; => works fine

(This is courtesy of the famous, revered, and all around great guy @TimDeve)

I volunteer to look into this.

Cheers

hellerve avatar May 15 '20 15:05 hellerve

Could it be related to the Chars change?

jacereda avatar May 15 '20 17:05 jacereda

I don’t think so because the error happens at parse time. I think this is before Char plays a role, but I’ll dig into it this weekend and let you know!

hellerve avatar May 15 '20 17:05 hellerve

Actually, this is behaving as intended, since \b is a special escape sequence for patterns (used for balanced strings, and takes two arguments in the form of the next two characters). When used in a string, \b is made a backspace, however.

We should probably just document the pattern language better.

hellerve avatar Jan 27 '21 21:01 hellerve