[ANN] Instaparse 1.4.4

133 views
Skip to first unread message

Mark Engelberg

unread,
Dec 23, 2016, 7:52:48 PM12/23/16
to clojure, insta...@googlegroups.com
Instaparse is a library for generating parsers from context-free grammars.
The big news for this release is that Alex Engelberg has combined the Clojure version with the Clojurescript version of instaparse (initiated by Lucas Bradstreet in 2014) so that moving forward, we can maintain both versions as part of the same codebase.  Instaparse leverages a number of Clojure interfaces and subtle features that differ between Clojure and Clojurescript, so merging the ports was a significant effort.

Also, to achieve backwards compatibility, Alex wrote the cljsee leiningen plugin which splits cljc files into clj and cljs files for compatibility with Clojure 1.5 and 1.6.  Check out cljsee if you are interested in maintaining backwards compatibility in your own cljc-based projects.  (https://github.com/aengelberg/cljsee)

The one new feature is a defparser macro, especially relevant to the Clojurescript port because it makes it possible to build the parser at compile time so the Clojurescript code will execute more quickly.

Other than that one addition, the behavior should be identical to the prior release. 

Jeaye

unread,
Dec 24, 2016, 6:13:46 PM12/24/16
to clo...@googlegroups.com, insta...@googlegroups.com
This is great to see; instaparse is crucial for some of my projects and I appreciate the ongoing development.

I've noticed two issues with 1.4.4 which I want to run by you:

1. insta/parser has a breaking change, in that it no longer accepts resources directly

I can work around this easily by slurping before hand, but this may've been an accidental breakage.

2. insta/defparser doesn't support the same optional parameters as insta/parser

Specifically, I've found that it doesn't like when I specify :auto-whitespace, which is a feature on which I rely heavily for my grammar.

Finally, given the possible performance benefits, do you recommend everyone (Clojure and ClojureScript) prefer defparser, where possible?

Thanks!
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
signature.asc

Alex Engelberg

unread,
Dec 25, 2016, 12:18:37 AM12/25/16
to clo...@googlegroups.com, insta...@googlegroups.com
Hi Jeaye,

1. That's indeed a mistaken breakage, I will fix it. Note that specifically the java.net.URL input is what's not properly handled, so if you call (str (io/resource "...")) that will still work as expected.

2. That's also a bug, due to how defparser quotes all of its arguments and tries to use them as arguments to insta/parser. I will fix it, and add more thorough tests for the macro.

To answer your more general question: I don't think Clojure users of Instaparse should really have to think about defparser, since I think most JVM use cases don't suffer from the small extra one-time startup cost. I made it primarily with ClojureScript in mind, since being able to now slurp the grammar adds some power that's non-trivial to implement otherwise. But I made it available to both clj and cljs for completeness and cross-compatibility.

Thanks for the reports.
--Alex


> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages