mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
Move the Alt rule down to reflect constructor order.
This commit is contained in:
parent
89b30a5124
commit
d2da6e1ad7
@ -98,8 +98,6 @@ runAssignment :: forall grammar a. (Symbol grammar, Enum grammar, Eq grammar, Sh
|
|||||||
runAssignment = iterFreer run . fmap (\ a state -> Result (state, a))
|
runAssignment = iterFreer run . fmap (\ a state -> Result (state, a))
|
||||||
where run :: AssignmentF (Node grammar) x -> (x -> AssignmentState grammar -> Result (AssignmentState grammar, a)) -> AssignmentState grammar -> Result (AssignmentState grammar, a)
|
where run :: AssignmentF (Node grammar) x -> (x -> AssignmentState grammar -> Result (AssignmentState grammar, a)) -> AssignmentState grammar -> Result (AssignmentState grammar, a)
|
||||||
run assignment yield initialState = case (assignment, stateNodes) of
|
run assignment yield initialState = case (assignment, stateNodes) of
|
||||||
-- Nullability: some rules, e.g. 'pure a' and 'many a', should match at the end of input. Either side of an alternation may be nullable, ergo Alt can match at the end of input.
|
|
||||||
(Alt a b, _) -> yield a state <|> yield b state
|
|
||||||
(Location, Rose (_ :. location) _ : _) -> yield location state
|
(Location, Rose (_ :. location) _ : _) -> yield location state
|
||||||
(Location, []) -> yield (Info.Range stateOffset stateOffset :. Info.SourceSpan statePos statePos :. Nil) state
|
(Location, []) -> yield (Info.Range stateOffset stateOffset :. Info.SourceSpan statePos statePos :. Nil) state
|
||||||
(Source, Rose (_ :. range :. _) _ : _) -> yield (Source.sourceText (Source.slice (offsetRange range (negate stateOffset)) stateSource)) (advanceState state)
|
(Source, Rose (_ :. range :. _) _ : _) -> yield (Source.sourceText (Source.slice (offsetRange range (negate stateOffset)) stateSource)) (advanceState state)
|
||||||
@ -112,6 +110,8 @@ runAssignment = iterFreer run . fmap (\ a state -> Result (state, a))
|
|||||||
Just a -> yield a state
|
Just a -> yield a state
|
||||||
Nothing -> Error ["Expected one of " <> showChoices choices <> " but got " <> show symbol]
|
Nothing -> Error ["Expected one of " <> showChoices choices <> " but got " <> show symbol]
|
||||||
(Choose choices, []) -> Error [ "Expected one of " <> showChoices choices <> " but got end of input." ]
|
(Choose choices, []) -> Error [ "Expected one of " <> showChoices choices <> " but got end of input." ]
|
||||||
|
-- Nullability: some rules, e.g. 'pure a' and 'many a', should match at the end of input. Either side of an alternation may be nullable, ergo Alt can match at the end of input.
|
||||||
|
(Alt a b, _) -> yield a state <|> yield b state
|
||||||
(assignment, subtree : _) -> case assignment of
|
(assignment, subtree : _) -> case assignment of
|
||||||
_ -> Error ["No rule to match " <> show subtree]
|
_ -> Error ["No rule to match " <> show subtree]
|
||||||
_ -> Error ["No rule to match at end of input."]
|
_ -> Error ["No rule to match at end of input."]
|
||||||
|
Loading…
Reference in New Issue
Block a user