[HN Gopher] Parser Combinators in Elixir
___________________________________________________________________
Parser Combinators in Elixir
Author : ltrapr
Score : 130 points
Date : 2021-04-06 14:15 UTC (8 hours ago)
(HTM) web link (serokell.io)
(TXT) w3m dump (serokell.io)
| brightball wrote:
| This is a solid intro. I hadn't seen a good write up on
| NimbleParsec yet either. Kudos to the author.
| dnautics wrote:
| A few protips for nimble_parsec:
|
| - ninja in a struct for your context, just generally a better
| choice due to the stronger typing.
|
| - decide if your parser is a transformer or an analyzer. If it
| only analyzes text, then throw away all of the text after you use
| it and use the text stream as a contextual buffer. If it
| transforms, be consistent about the tokens you return in the
| stream. Use structs if you can.
|
| - build intermediate defparsecs which create testable functions
| that you can test. If you like, fence them in `if Mix.env ==
| :test` blocks to keep them from being compiled except in test.
|
| Example:
| https://github.com/ityonemo/zigler/blob/master/lib/zig/parse...
___________________________________________________________________
(page generated 2021-04-06 23:00 UTC)