djspiewak / parseback

A Scala implementation of parsing with derivatives
http://parseback.io
Apache License 2.0
197 stars 22 forks source link

Unbounded recursion on unexpected characters with left recursive grammars #5

Closed dcsobral closed 7 years ago

dcsobral commented 7 years ago

The following grammar:

  lazy val grammar: Parser[String] = Literal("a") | (grammar ~ Literal("a") ^^ { case (_, x ~ y) => x + y })

will fail with:

Left(List(UnboundedRecursion(Union(parseback.Parser$Union$$Lambda$20/922872566@86be70a,parseback.Parser$Union$$Lambda$21/1651855867@480bdb19))))

when supplied an input that does not start with an "a".