Closed birkenfeld closed 7 years ago
Hm, a stack overflow. Interesting...
I made the Parser monad use FnBox instead of Fn, so that all closures can take ownership and drop values after they are called.
Excellent. Earlier passes at this (literally, while I was learning monads) made use of FnBox, though I struggled to make it work. Using it complicates the path to stable a bit but that's a secondary concern.
I made the Parser monad use
FnBox
instead ofFn
, so that all closures can take ownership and drop values after they are called. This works becauseP<T>
values are only used once - that's an important property for closure-based monads in Haskell as well (to get the desired sequencing).My clones of Alex/Happy have been updated to generate the code that is in these commits.
Another very important change is in
input_stream
, which keeps a cloneable stream by just referring to anRc<Vec<u8>>
. This gets rid of the huge burden of cloning the input string (potentially multiple times) for every char the lexer sees...