jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
189 stars 61 forks source link

Regex engine: add support for `(?R)` recursive regex syntax #108

Closed jgm closed 3 years ago

jgm commented 3 years ago

This is used in scheme.xml. From pcre documentation:

(?R) or (?0): Recursive subpattern. Treat the contents of a given capture buffer in the current pattern as an independent subpattern and attempt to match it at the current position in the string. Information about capture state from the caller for things like backreferences is available to the subpattern, but capture buffers set by the subpattern are not visible to the caller.

jgm commented 3 years ago

Simpler explanation: The recursive syntax is simple. In PCRE and Perl, you just add (?R) anywhere you like in your pattern. Basically, (?R) means "paste the entire regular expression right here, replacing the original (?R). https://www.rexegg.com/regex-recursion.html

jgm commented 3 years ago

This is only used in scheme.xml.