1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Build up repetitions right-recursively.

This commit is contained in:
Rob Rix 2017-08-04 10:03:38 -04:00
parent 8406ba35c2
commit da988a4c6f

View File

@ -281,7 +281,7 @@ runAssignment toNode source = (\ assignment state -> disamb Left (Right . minimu
anywhere node = case assignment of anywhere node = case assignment of
Location -> yield (Info.Range (stateOffset state) (stateOffset state) :. Info.Span (statePos state) (statePos state) :. Nil) state Location -> yield (Info.Range (stateOffset state) (stateOffset state) :. Info.Span (statePos state) (statePos state) :. Nil) state
Choose _ (Just atEnd) -> yield atEnd 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 else recur) (list <> [a]) state') <> yield list state) [] state Many rule -> fix (\ recur state -> (go rule state >>= \ (a, state') -> if stateOffset state == stateOffset state' then pure ([a], state') else first (a:) <$> recur state') <> pure ([], state)) state >>= uncurry yield
Alt as -> Some as >>= flip yield state Alt as -> Some as >>= flip yield state
Throw e -> None e Throw e -> None e
Catch during handler -> go during state `catchError` (flip go state { stateErrorCounter = succ (stateErrorCounter state) } . handler) >>= uncurry yield Catch during handler -> go during state `catchError` (flip go state { stateErrorCounter = succ (stateErrorCounter state) } . handler) >>= uncurry yield