3 ms·
My somewhat neglected library Clearley (https://github.com/mthvedt/clearley https://github.com/mthvedt/clearley) uses a macro system, that lets you write parser
by cynicalkane 12y ago
My somewhat neglected library Clearley (https://github.com/mthvedt/clearley https://github.com/mthvedt/clearley) uses a macro system, that lets you write parsers that look a little like pattern-matching functions. To do this, you need to be able to introspect, bind and lookup symbols, and data structures containing symbols, at compile time. You can't do this in Haskell. Template Haskell doesn't help, since IIRC it doesn't support looking up symbols in the same file.
With Clojure, If you understand the JVM type system and performance, you can also write high performance DSLs using Clojure macros. https://github.com/clojure/core.logic https://github.com/clojure/core.logic allegedly is a project along these lines, but I haven't looked too much into it. It heavily uses Clojure protocols (which map to Java interfaces) for performance. I had been working on a code generator for Clearley, which sits neglected on my hard drive, but is able to perform just a little slower than unoptimized hand-written parsers. Since in Clojure compile/runtime separation is optional and off by default, you can use Clojure to generate Clojure code, making life a lot easier.
- Peaker 12y agoTemplate Haskell does support looking up the namespace in the same file.