1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 12:51:52 +03:00

Uncommitted choices backtrack.

This commit is contained in:
Rob Rix 2017-08-06 09:13:33 -04:00
parent 4cba3fd2fc
commit ac1adfe5bc

View File

@ -294,9 +294,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 stateOffset :. Info.Span statePos statePos :. Nil) state Location -> yield (Info.Range stateOffset stateOffset :. Info.Span statePos statePos :. Nil) state
Many rule -> fix (\ recur state -> (go rule state >>= \ (a, state') -> first (a:) <$> if state == state' then pure ([], state') else recur state') `catchError` const (pure ([], state))) state >>= uncurry yield Many rule -> fix (\ recur state -> (go rule state >>= \ (a, state') -> first (a:) <$> if state == state' then pure ([], state') else recur state') `catchError` const (pure ([], state))) state >>= uncurry yield
Alt as -> foldr (\ each next -> case yield each state of Alt as -> Some as >>= flip yield state
None (err, state') -> if state == state' then next else None (err, state')
Some as -> Some as) (None (makeError node, state)) as
Throw e -> None (e, state) Throw e -> None (e, state)
Catch during _ -> go during state >>= uncurry yield Catch during _ -> go during state >>= uncurry yield
Choose{} -> None (makeError node, state) Choose{} -> None (makeError node, state)