ocaml / ocaml-re

Pure OCaml regular expressions, with support for Perl and POSIX-style strings
Other
233 stars 60 forks source link

Suggestion: Printing the Regexes #193

Open Galfour opened 3 years ago

Galfour commented 3 years ago

Hello,

Currently, there are parsers for multiple syntaxes of Regex. I was wondering how complicated it would be to add printers too.

This would be quite useful for https://ligolang.org/ : we are currently writing syntax highlighter generators, and we need to produce Regex strings in a variety of contexts.

If this is not too complicated and you are open to a PR for this, we might write one.

Cheers,

rgrinberg commented 3 years ago

Feel free to add printers. Although note that the parsing of regular expressions does some simplifications (e.g. desugaring + into *), so whatever you print back isn't going to map 1-1 to the re you started with.