What does HackerNews think of instaparse?

Language: Clojure

This is great, JQ is brilliant.

I love JQ so much we implemented a subset of JQ in Clojure so that our users could use it to munge/filter data in our product (JVM and browser based Kafka tooling). One of the most fun coding pieces I've done, though I am a bit odd and I love writing grammars (big shoutout to Instaparse![1]).

I learned through my implementation that JQ is a LISP-2[2] which surprised me as it didn't feel obvious from the grammar.

[1] https://github.com/Engelberg/instaparse

[2] https://github.com/jqlang/jq/wiki/jq-Language-Description#:~....

You might enjoy checking out Instaparse, a Clojure library. Its project page reads, “What if context-free grammars were as easy to use as regular expressions?”

It’s not over-promising, either. I went from never having heard of it before to getting complete and correct parse trees of some ancient JSP Expression Language in about 20 minutes. Most of that time was spent typing in the BNF description that I could find only in an image.

https://github.com/Engelberg/instaparse

It's a Clojure(Script) library, but it's still so good it's worth mentioning: Instaparse[0] generates a parser for you from a BNF-y grammar specification. Sample from the readme:

    (def as-and-bs
      (insta/parser
        "S = AB*
         AB = A B
         A = 'a'+
         B = 'b'+"))

    => (as-and-bs "aaaaabbbaaaabb")
    [:S
     [:AB [:A "a" "a" "a" "a" "a"] [:B "b" "b" "b"]]
     [:AB [:A "a" "a" "a" "a"] [:B "b" "b"]]]
[0]: https://github.com/Engelberg/instaparse
May I ask what kind of criteria you have in mind for being “more generally useful”? Parsers are something I know next to nothing about and hardly ever have to reach for. Is it mostly speed and power? Is the current crop not sufficient to parse any BNF, or is it that people want something to handle more permissive grammars?

The only parsing library I’ve played with recently is Instaparse in Clojure, which is apparently GLL. It was a delight to use. I found a PDF of the old version of Apache Expression Language that I needed to interpret, typed it almost verbatim into a quite readable text file, and Instaparse did the rest. It was an exciting experience to have unlocked this embedded DSL with about three lines of code, not counting the grammar definition.

https://github.com/Engelberg/instaparse