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

Choices’ errors note the choice.

This commit is contained in:
Rob Rix 2017-04-26 12:07:33 -04:00
parent 77fe6aff31
commit 677031daaa

View File

@ -111,13 +111,13 @@ runAssignment = iterFreer (\ assignment yield state -> case (assignment, dropAno
yield c (advanceState state) yield c (advanceState state)
Choose choices -> case IntMap.lookup (fromEnum symbol) choices of Choose choices -> case IntMap.lookup (fromEnum symbol) choices of
Just a -> yield a state Just a -> yield a state
Nothing -> Error ["Expected " <> showChoices choices <> " but got " <> show symbol] Nothing -> Error ["Expected one of " <> showChoices choices <> " but got " <> show symbol]
_ -> Error ["No rule to match " <> show subtree] _ -> Error ["No rule to match " <> show subtree]
(Symbol s, AssignmentState{}) -> Error [ "Expected " <> show s <> " but got end of input." ] (Symbol s, AssignmentState{}) -> Error [ "Expected " <> show s <> " but got end of input." ]
(Location, state@AssignmentState{..}) -> yield (Info.Range stateOffset stateOffset :. Info.SourceSpan statePos statePos :. Nil) state (Location, state@AssignmentState{..}) -> yield (Info.Range stateOffset stateOffset :. Info.SourceSpan statePos statePos :. Nil) state
(Source, AssignmentState{}) -> Error [ "Expected leaf node but got end of input." ] (Source, AssignmentState{}) -> Error [ "Expected leaf node but got end of input." ]
(Children _, AssignmentState{}) -> Error [ "Expected branch node but got end of input." ] (Children _, AssignmentState{}) -> Error [ "Expected branch node but got end of input." ]
(Choose choices, AssignmentState{}) -> Error [ "Expected " <> showChoices choices <> " but got end of input." ] (Choose choices, AssignmentState{}) -> Error [ "Expected one of " <> showChoices choices <> " but got end of input." ]
_ -> Error ["No rule to match at end of input."]) _ -> Error ["No rule to match at end of input."])
. fmap (\ a state -> Result (state, a)) . fmap (\ a state -> Result (state, a))
where showChoices :: IntMap.IntMap b -> Text where showChoices :: IntMap.IntMap b -> Text