3 ms·
Fun post. I hadn't connected Elm decoders and parser combinators before, despite having used them both. What I love about parser combinators is that they are j
by pharmakom 5y ago
Fun post. I hadn't connected Elm decoders and parser combinators before, despite having used them both.
What I love about parser combinators is that they are just code, in your language. They are also highly composable.
What I hate about parser combinators is how easy it is to accidental generate infinite loops or miss a crucial backtracking point.
Are there any parser combinators libraries that avoid these traps, particularly around recursion?
- recursive 5y agoSprache for .net detects "left recursion" that would cause infinite descent. It fails early in that case.
- slimsag 5y agoGeneralized LL parsers[0] (effectively, memoized parser combinators) can effectively handle backtracking for you, supporting both left and right recursive grammars without issue. I'll leave some links that were particularly useful when I was learning about them[1][2] [0] https://github.com/hexops/zorex/tree/main/src/combn#combn-runtime-gll-parser-combinators-for-zig- https://github.com/hexops/zorex/tree/main/src/combn#combn-ru... [1] https://epsil.github.io/gll/ https://epsil.github.io/gll/ [2] https://github.com/robey/packrattle https://github.com/robey/packrattle