pomsky-lang / pomsky

A new, portable, regular expression language
https://pomsky-lang.org
Apache License 2.0
1.28k stars 19 forks source link

Backreferences followed by a literal digit are miscompiled #97

Closed Aloso closed 10 months ago

Aloso commented 10 months ago

Describe the bug

Backreferences compile to something like \2. But backreferences can't be directly followed by a digit, since \20 is interpreted either as the 20th capturing group, or as an octal escape.

To Reproduce

:() ::1 "0"

produces ()\10

Expected behavior

Either the backreference must be wrapped in a non-capturing group, or the following digit must be put in a character set:

Additional context

Version 0.10