1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

Use text in constructorForProductions

This commit is contained in:
joshvera 2015-12-18 14:43:45 -05:00
parent cfc4a97f9d
commit f07e2de9a5

View File

@ -12,10 +12,10 @@ import qualified Data.Text as T
type Parser = T.Text -> IO (Term T.Text Info) type Parser = T.Text -> IO (Term T.Text Info)
-- | Given a source string and a terms annotation & production/child pairs, construct the term. -- | Given a source string and a terms annotation & production/child pairs, construct the term.
type Constructor = String -> Info -> [(String, Term String Info)] -> Term String Info type Constructor = T.Text -> Info -> [(T.Text, Term T.Text Info)] -> Term T.Text Info
-- | Given two sets of production names, produce a Constructor. -- | Given two sets of production names, produce a Constructor.
constructorForProductions :: Set.Set String -> Set.Set String -> Constructor constructorForProductions :: Set.Set T.Text -> Set.Set T.Text -> Constructor
constructorForProductions keyed fixed source info@(Info range categories) = (info :<) . construct constructorForProductions keyed fixed source info@(Info range categories) = (info :<) . construct
where construct [] = Leaf (substring range source) where construct [] = Leaf (substring range source)
construct children | not . Set.null $ Set.intersection fixed categories = Fixed $ fmap snd children construct children | not . Set.null $ Set.intersection fixed categories = Fixed $ fmap snd children