mirror of
https://github.com/github/semantic.git
synced 2024-12-21 13:51:44 +03:00
Pull requireExhaustive out to the top level.
This commit is contained in:
parent
b14ec8b99a
commit
1f36dc6136
@ -280,10 +280,10 @@ runAssignment source = \ assignment state -> go assignment state >>= requireExha
|
|||||||
makeError :: HasCallStack => Maybe (Node grammar) -> Error (Either String grammar)
|
makeError :: HasCallStack => Maybe (Node grammar) -> Error (Either String grammar)
|
||||||
makeError = maybe (Error (Info.Span statePos statePos) (fmap Right expectedSymbols) Nothing) (nodeError (fmap Right expectedSymbols))
|
makeError = maybe (Error (Info.Span statePos statePos) (fmap Right expectedSymbols) Nothing) (nodeError (fmap Right expectedSymbols))
|
||||||
|
|
||||||
requireExhaustive :: HasCallStack => (result, State ast grammar) -> Either (Error (Either String grammar)) (result, State ast grammar)
|
requireExhaustive :: (Symbol grammar, HasCallStack) => (result, State ast grammar) -> Either (Error (Either String grammar)) (result, State ast grammar)
|
||||||
requireExhaustive (a, state) = let state' = skipTokens state in case stateNodes state' of
|
requireExhaustive (a, state) = let state' = skipTokens state in case stateNodes state' of
|
||||||
[] -> Right (a, state')
|
[] -> Right (a, state')
|
||||||
node : _ -> Left (nodeError [] (headF (runCofree node)))
|
node : _ -> Left (nodeError [] (headF (runCofree node)))
|
||||||
|
|
||||||
skipTokens :: Symbol grammar => State ast grammar -> State ast grammar
|
skipTokens :: Symbol grammar => State ast grammar -> State ast grammar
|
||||||
skipTokens state = state { stateNodes = dropWhile ((/= Regular) . symbolType . nodeSymbol . headF . runCofree) (stateNodes state) }
|
skipTokens state = state { stateNodes = dropWhile ((/= Regular) . symbolType . nodeSymbol . headF . runCofree) (stateNodes state) }
|
||||||
|
Loading…
Reference in New Issue
Block a user