1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

Factor out the list & state.

This commit is contained in:
Rob Rix 2017-08-03 22:46:46 -04:00
parent e9e9c54fa1
commit 9d1ade2654

View File

@ -280,7 +280,7 @@ runAssignment toNode source = (\ assignment state -> go assignment state >>= req
anywhere node = case assignment of
Location -> yield (Info.Range (stateOffset state) (stateOffset state) :. Info.Span (statePos state) (statePos state) :. Nil) state
Choose _ (Just atEnd) -> yield atEnd state
Many rule -> fix (\ recur list state -> (go rule state >>= \ (a, state') -> if stateOffset state == stateOffset state' then yield (list <> [a]) state' else recur (list <> [a]) state') <> yield list state) [] state
Many rule -> fix (\ recur list state -> (go rule state >>= \ (a, state') -> (if stateOffset state == stateOffset state' then yield else recur) (list <> [a]) state') <> yield list state) [] state
Alt as -> Some as >>= flip yield state
Throw e -> None e
Catch during handler -> let partial = go during state >>= uncurry yield in partial <> partial `catchError` ((>>= uncurry yield) . flip go state { stateErrorCounter = succ (stateErrorCounter state) } . handler)