Hejsil / mecha

A parser combinator library for Zig
MIT License
473 stars 21 forks source link

Documentation #33

Open rishavs opened 2 years ago

rishavs commented 2 years ago

Hi

I am very interested in using mecha for a toy language. I have never used a parser combinator before and as such am struggling with how to use it. Is there any documentation or a more robust example of mecha (something like a small language like mini-c, lua etc)?

Or can you point me to any article/tutorial which explains the kind of parser mecha is, with hopefully more examples for me to read through. I did try to read the through the source, but mecha is super tiny and I am not sure how would I go about crafting a parser using those fundamental building blocks.

Hejsil commented 2 years ago

Mecha is what you call a "parser combinator" library. It works by composing functions into new functions and is a functional programming concept (have a look at functional programming function composition).

You can have a look at the json example for something more complete. It basically maps 1 to 1 with the json parsing expression grammar (ofc, the json example is only a json validator. It does not produce a json value).

I hope you have some terms you can research from here. Mecha very much assumes that the users knows what parser combinators are and how to use them right now, so there is no "newbie" (for a lack of a better word) docs. Feel free to ask more questions here, though. I'll probably leave this issue open, so people can look at this thread for answers to common questions.

Hejsil commented 1 month ago

Maybe I should add an "Installation" section like I have for zig-clap

https://github.com/Hejsil/zig-clap?tab=readme-ov-file#installation