1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 17:04:47 +03:00
This commit is contained in:
Patrick Thomson 2018-06-04 11:27:04 -04:00
parent b20ca6c997
commit 7b774d764c

View File

@ -167,12 +167,9 @@ symbol s = tracing (Choose (Table.singleton s location) Nothing Nothing) `Then`
rawSource :: HasCallStack => Assignment ast grammar ByteString
rawSource = tracing Source `Then` return
-- | A rule to produce a node's source as Text. Fails if the node's source
-- can't be parsed as UTF-8.
-- | A rule to produce a node's source as Text. Fails if the node's source can't be parsed as UTF-8.
source :: HasCallStack => Assignment ast grammar Text
source = rawSource >>= \b -> case decodeUtf8' b of
Right t -> pure t
Left e -> fail ("UTF-8 decoding failed: " <> show e)
source = fmap decodeUtf8' rawSource >>= either (\e -> fail ("UTF-8 decoding failed: " <> show e)) pure
-- | Match a node by applying an assignment to its children.
children :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar a