mirror of
https://github.com/github/semantic.git
synced 2025-01-09 00:56:32 +03:00
Define the error cases with guard clauses.
This commit is contained in:
parent
dc9bfe28d1
commit
11e83f0413
@ -267,8 +267,8 @@ runAssignment toNode source assignment state = go assignment state >>= requireEx
|
||||
(Alt a b, _) -> either (yield b . setStateError state . Just) Right (yield a state)
|
||||
(Throw e, _) -> Left e
|
||||
(Catch during handler, _) -> either (flip yield state . handler) Right (yield during state)
|
||||
(_, []) -> Left (Error (statePos state) (UnexpectedEndOfInput expectedSymbols))
|
||||
(_, ast:_) -> let Node symbol _ (Info.Span spanStart _) = toNode (F.project ast) in Left (Error spanStart (UnexpectedSymbol expectedSymbols symbol))
|
||||
_ | node : _ <- stateNodes state, Node symbol _ (Info.Span spanStart _) <- toNode (F.project node) -> Left (Error spanStart (UnexpectedSymbol expectedSymbols symbol))
|
||||
| otherwise -> Left (Error (statePos state) (UnexpectedEndOfInput expectedSymbols))
|
||||
where state | any ((/= Regular) . symbolType) expectedSymbols = dropAnonymous initialState
|
||||
| otherwise = initialState
|
||||
expectedSymbols | Choose choices <- assignment = choiceSymbols choices
|
||||
|
Loading…
Reference in New Issue
Block a user