djspiewak / parseback

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

Reencode memoization to avoid thread unsafety #18

Closed djspiewak closed 7 years ago

djspiewak commented 7 years ago

Right now, we're using the Adams, Hollenbeck, Might trick of encoding parser memoization directly on the Parser instance using vars. This is extremely cool and efficient-like and stuff, but it appears to be causing problems with simultaneous use of the same parser across multiple threads, even just in the test suite. I had originally thought that this would only cause problems in so far as it would make things less efficient (effectively a cache miss), but it seems to be affecting the correctness of the algorithm