djspiewak / parseback

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

introduce Trampoline to mutual recursion. #41

Closed osiire closed 5 years ago

osiire commented 5 years ago

I got a stack overflow when parsing a little bit long string. this commit has fixed it.

djspiewak commented 5 years ago

TIL about TailCalls

So looking at the implementation, it appears to simply be a naive Free monad. This is a lot slower than Eval in cats, which should be on the classpath here. I would rather use that trampoline, rather than TailCalls, since this is a performance-sensitive part of the code.

Speaking of which, it's probably worth running the JMH benchmarks before and after to see if performance has been materially affected.

Otherwise though, this looks like a really good change!