News for hackers. Stuff that matters.
Re:Parsing Text with Nom by oever on Wednesday January 12, 2022 @07:37AM (#29905508)
You can use lazy_static to have global Regex and call that from a Nom function. There is no special support from Nom required.

Alternatively one can build a parser combinator library that compiles to a large Regex. That Regex would return a big Matcher, so a convenience wrapper for that would need to be made usable by a wrapper created from the same parser combinator.

Re:Parsing Text with Nom by woodruffw on Wednesday January 12, 2022 @09:56AM (#29907113)
> Alternatively one can build a parser combinator library that compiles to a large Regex.

Maybe I'm misunderstanding what you meant, but I don't think you can do this in the general case (since parser combinators can describe languages that are more complicated than/not describable within regular languages).

Re:Parsing Text with Nom by DFHippie on Wednesday January 12, 2022 @10:37AM (#29907823)
I wrote a crate to facilitate this:*

https://github.com/dfhoughton/pidgin

As it says there, you can only build non-recursive grammars this way.

And the reason I wrote that crate:

https://github.com/dfhoughton/two-timer

And the reason I wrote that crate:

https://github.com/dfhoughton/jobrog

And having written these crates, I went back to writing Ruby for my day job. I am not a very experienced rustacean, and what skill I developed writing these things has faded, but I use the last one daily, so the regex-based parser is still working pretty well.

* It's a "parser combinator library" inasmuch as it allows you to write reusable parsing rules that can be components of other rules.