From a6b5fa06342b8a53514a33409ca6d77f300f30a3 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 26 Apr 2017 13:33:52 -0400 Subject: [PATCH] Pull the Source case up a level. --- src/Data/Syntax/Assignment.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Syntax/Assignment.hs b/src/Data/Syntax/Assignment.hs index 3656eaead..2fe08e811 100644 --- a/src/Data/Syntax/Assignment.hs +++ b/src/Data/Syntax/Assignment.hs @@ -102,8 +102,9 @@ runAssignment = iterFreer run . fmap (\ a state -> Result (state, a)) (Alt a b, _) -> yield a state <|> yield b state (Location, Rose (_ :. location) _ : _) -> yield location state (Location, []) -> yield (Info.Range stateOffset stateOffset :. Info.SourceSpan statePos statePos :. Nil) state - (assignment, subtree@(Rose (symbol :. range :. _ :. Nil) children) : _) -> case assignment of - Source -> 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) + (Source, []) -> Error [ "Expected leaf node but got end of input." ] + (assignment, subtree@(Rose (symbol :. _) children) : _) -> case assignment of Children childAssignment -> do c <- assignAllFrom childAssignment state { stateNodes = children } yield c (advanceState state) @@ -111,7 +112,6 @@ runAssignment = iterFreer run . fmap (\ a state -> Result (state, a)) Just a -> yield a state Nothing -> Error ["Expected one of " <> showChoices choices <> " but got " <> show symbol] _ -> Error ["No rule to match " <> show subtree] - (Source, []) -> Error [ "Expected leaf node but got end of input." ] (Children _, []) -> Error [ "Expected branch node but got end of input." ] (Choose choices, []) -> Error [ "Expected one of " <> showChoices choices <> " but got end of input." ] _ -> Error ["No rule to match at end of input."]