1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Skip anonymous nodes at the end of input.

This commit is contained in:
Rob Rix 2017-04-13 11:02:23 -04:00
parent 1943d62dbf
commit 3b9c53c4c2

View File

@ -66,8 +66,9 @@ data Result a = Result a | Error [Text]
-- | Run an assignment of nodes in a grammar onto terms in a syntax, discarding any unparsed nodes. -- | Run an assignment of nodes in a grammar onto terms in a syntax, discarding any unparsed nodes.
assignAll :: (Symbol grammar, Eq grammar, Show grammar) => Assignment grammar a -> [AST grammar] -> Result a assignAll :: (Symbol grammar, Eq grammar, Show grammar) => Assignment grammar a -> [AST grammar] -> Result a
assignAll assignment nodes = case runAssignment assignment nodes of assignAll assignment nodes = case runAssignment assignment nodes of
Result ([], a) -> Result a Result (rest, a) -> case dropAnonymous rest of
Result (c:_, _) -> Error ["Expected end of input, but got: " <> show c] [] -> Result a
c:_ -> Error ["Expected end of input, but got: " <> show c]
Error e -> Error e Error e -> Error e
-- | Run an assignment of nodes in a grammar onto terms in a syntax. -- | Run an assignment of nodes in a grammar onto terms in a syntax.