bitwalker / bitwalker/combine

Recursive grammars

Open
#12 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
Elixir
Stars
200
Forks
20
PR merge metrics
No merged PRs in 30d

Description

So I was thinking about `combine` a bit recently and it seems to me unlike its haskell older brother it has a problem parsing recursive grammars. Take this example of a parenthesis matching parser that's "translated" from [parsec's documentation](https://hackage.haskell.org/package/parsec):

``` elixir
defmodule Parens do
use Combine

def parser, do: many(parens())
defp parens, do: sequence([char("("), many(parens()), char(")")])
end
```

`Parens.parser` of course results in an infinite loop. I think this works in parsec, because everything is a thunk in haskell so the particular parsers are only evaluated as needed. In this case however we're trying to build a whole infinite parser at once. Or maybe there's a way to achieve this currently?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.