Created How to use Lark (markdown)

Erez Shinan 2017-10-31 20:59:48 +02:00
parent 7b129a678c
commit 050d33c036
1 changed files with 15 additions and 0 deletions

15
How-to-use-Lark.md Normal file

@ -0,0 +1,15 @@
This is the recommended process for working with Lark:
1. Collect or create input samples, that demonstrate key features or behaviors in the language you're trying to parse.
2. Write a grammar. Try to aim for a structure that is intuitive, and in way that imitates how you would explain your language to a fellow human.
3. Try your grammar in Lark against each input sample. Make sure the resulting parse-trees make sense.
- You can perform steps 1-3 together, gradually growing your grammar to include more sentences.
4. Use Lark's grammar features to [[shape the tree|Tree Construction]]: Get rid of superfluous rules by inlining them, and use aliases when specific cases need clarification.
5. Create a transformer to evaluate the parse-tree into a structure you'll be comfortable to work with. This may include evaluate literals, merging branches, or even converting the entire tree into your own set of AST classes.
Of course, some specific use-cases may deviate from this process. Feel free to suggest these cases, and I'll add them to this page.