rewrite-clj icon indicating copy to clipboard operation
rewrite-clj copied to clipboard

Explore using edamame for parsing

Open lread opened this issue 1 year ago • 0 comments

Both edamame and rewrite-clj parse Clojure code. Under the hood, they both use clojure tools reader.

Occasionally, @borkdude and I wonder if the parsing code could be shared more. For example, rewrite-clj implemented parsing of new clojure 1.12 array class syntax, and then edamame did so too. What if we just implemented once in edamame and rewrite-clj took advantage of it?

Initial high-level thoughts:

  • pro: when rewrite-clj decides it needs a parsing update, we would implement it in edamame, and edamame would, therefore, also benefit
  • pro: some parsing tweaks are a bit complex, and dig into clojure tools reader internals. It could be nice to only implement this code once in one place.
  • pro: fix a parsing bug in edamame and rewrite-clj bumps and benefits.
  • pro: rewrite-clj could choose to take advantage of existing edamame features, like maybe reader conditional parsing and incomplete expression parsing
  • pro: borkdude is very involved in both projects, very reasonable, and lovely to work with
  • pro: lee would get a deep understanding of edamame
  • con: this new rewrite-clj dependency means folks could be including a different version of edamame, which could lead to some confusion
  • potential con: would this mean any (even minor) breaking changes to rewrite-clj? TBD

I've opened this issue to explore and track what it might mean to use edamame for parsing in rewrite-clj.

I'll experiment sometime soon to learn more about what issues we need to address, and if it still seems like a good idea, we can work out a plan.

lread avatar Aug 07 '24 15:08 lread