com-lihaoyi / fastparse

Writing Fast Parsers Fast in Scala
https://com-lihaoyi.github.io/fastparse
MIT License
1.09k stars 164 forks source link

easy stacktrace redux #293

Closed tballard closed 1 year ago

tballard commented 1 year ago

You suggested earlier that a stacktrace I was getting might have been caused by bad parser design. Here is a similar, simpler parser that fails, although this one just runs forever. The problem seems to arise when a pattern with a ".rep" is nested in another with a ".rep".

import $ivy.`com.lihaoyi::fastparse:3.0.2`
import fastparse._, NoWhitespace._

def lots[$: P] = P( CharPred('X' == _).rep).log. // remove this ".rep" and it finishes
def manyLots[$: P] = P( (lots).rep )
parse("", manyLots(_) )

result:

-lots:1:1:Success(1:1)
+lots:1:1
-lots:1:1:Success(1:1)
+lots:1:1
-lots:1:1:Success(1:1)
+lots:1:1
etc ...
lihaoyi commented 1 year ago

This is expected behavior. Please open a discussion if you want to discuss it, the issue tracker is not meant for this kind of discussion