Help with Regex Expression Parsing

I am trying to write a grammar file that would help me parse a Regex expression. I’ve already spent several evenings trying to do that. I was using the https://lezer-playground.vercel.app/ playground, but it looks like the browser storage was cleared, so I can’t access my work anymore.
Has anyone tried writing a regex grammar and would be willing to share? Or someone can offer help with writing one?

I did a casual search for this a few days ago, but didn’t come up with much. The closest I saw was Regexr which uses CodeMirror v5, but not Lezer. Regex101 uses CodeMirror too but isn’t open source. Searching github for regex.grammar and its variants didn’t yield much, and afaik gitlab doesn’t support file global search.

So I went with what’s in Javascript and called it good. Some reasoning for it is given at the bottom of this article.

Note that grammar is more interested in tokenization than correctness.

Please LMK if you find/build something better :slight_smile:

Also FWIW I use a clipboard manager and have a habit of copying things, so even if my browser/computer crashes or whatever I won’t lose literally everything. I used to use a Chrome extension for form recovery, but it no longer works. Maybe I should try to find another; haven’t bothered.