I’ve been thinking about parser combinators lately…
There are some libraries out there but I have a feeling they are all a bit inefficient: they don’t use Char::Reader and they usually create a lot of intermediate arrays and objects. They also use some functional concepts that, eventually, in my taste, makes the code a bit hard to undertand.
I’ve been wanting to do a good and efficient parser combinator library, as a shard, a bit for fun and also because it could actually be useufl.
But… I’m curious…
Are you using one of the existing libraries for production purposes?
If not. why? Is it because you didn’t need them, or because you used them and they turned out to be slow or not fitting your exact purposes? Or because it was just easier to do a hand-written parser?
I’d only like to create a shard for this if it’s going to actually be useful. If it’s just for fun I can keep it to myself :-) (that way I don’t have to maintain it for others)
Just a note: me saying the existing libraries aren’t good enough for my taste isn’t necessary a bad thing. If these libraries exist just for fun then that’s totally fine. What I’d like to do is to create an efficient library like that, but only if someone is going to use it
I don’t have any serious use cases. But I think it would be useful for one of my hobby projects.
As part of developing a competitive snake for Battlesnake I have ended up creating a kinda customised chess notation (snake notation) for writing tests and logging.
It looks like this:
The performance and memory use for simple parser is better than the one I’ve based on Regex, but it can become slower as I add more features I think. We’ll see.
The name makes me laugh a lot, not on a negative sense, but because how clever it is. We can imagine the creativity process behind its authors, saying things like “how can we express the reason behind our courses”, haha.
Really interesting site, which I’m considering to subscribe
I hand built a parser for Mint (not really a parser combinator per-se), which now and then thinking about moving to a separate shard. You can check if for inspiration.
I played around with tree sitter and while it’s easy to get started it’s fundamentally limited and you have to write C code of you want something custom.
For mint how did you go about settling on a design. In the end it translates to js correct? Do you have any documentation, or other work that inspired your design and implementation?
Originally I started in Ruby with (parslet - About), but it turned out that I wanted to have better error messages and a static binary, so I started to write a parser by hand in Crystal with no prior research into parsers or compilers.
One weird thing about Mint parser is that it doesn’t have a tokenizer phase, parsing returns the AST directly, which is good and bad. It’s good because it gives you greater control, and it’s faster, and bad because it’s harder to implement some features like comments, for example.