-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Hey Christophe,
first of all thanks for the great library. My attempt to follow Russ Cox implementation sadly isn't as elegant as good as yours. I was wondering if you are planning or thinking of implementing a failure object as a return value instead of 'nil'.
This goes in the lines of 'instaparse' where if the input doesn't match the parser description then a failure object is returned indicating at which point did the match process fail and what was expected.
Something like:
parse failed with input 'hello-word'
^^^^
Expected any of:
- chao
- return
I would also be willing to work on this in case you are quite busy. I have some basic understanding of how the algorithm works but I have yet to understand your full implementation, some guidance tips would be very helpfull.
So far I guess that the change should be done in these lines:
(reduce (fn [threads pc]
(let [[op arg] (nth insts pc)
registers (ctxs pc)]
(case op
:pred (if (arg x)
(add-thread threads (inc pc) (cons idx xs) registers insts)
threads))))
But I'm confused about your use of the 'run' function in the loop for the longest match :/