Hi, everyone! I’m super excited to announce an initial release of purescript-language-cst-parser
. It’s a parser for the PureScript language (based off of current master) written in PureScript. It supports error recovery, and is fast enough (hopefully) for common tooling. I originally wrote the compiler’s CST parser so the community could develop syntactic tooling, but I think having to write and distribute Haskell to do it has been a huge barrier. No excuses anymore!
Writing a performant, stack-safe parser-combinator-based parser in PureScript is extremely difficult . My initial attempt used purescript-parsing with a trampoline, and the slowest file in the package set parsed in 15s!
So I’ve been on a journey writing a faster parser combinator interpreter, and I’ve gotten that time down to about 1.1s. That’s still obviously not great in absolute terms for a single file, but the mean time for the 0.13 package set is about 9ms. Note this is all on my (several year old) machine so YMMV.
I’d like to thank @thomashoneyman, @colinwahl, @garyb, and @kritzcreek for helping me get to this release. There’s still work to do to improve error recovery. Right now it only works in layout contexts (top-level declarations, do/ado statements, let/where), and lexer errors do not currently recover at all. It’s also likely that things might change with the types and interface, so I’m keeping it at 0.x for now.