Commit 357b2921 by Zachary Snow

restrict enum conversion to parts

parent ec766657
...@@ -36,24 +36,13 @@ convert :: [AST] -> [AST] ...@@ -36,24 +36,13 @@ convert :: [AST] -> [AST]
convert = map $ concatMap convertDescription convert = map $ concatMap convertDescription
convertDescription :: Description -> [Description] convertDescription :: Description -> [Description]
convertDescription (Package ml name items) =
[Package ml name $ concatMap convertPackageItem items]
convertDescription (description @ Part{}) = convertDescription (description @ Part{}) =
[Part attrs extern kw lifetime name ports items'] [Part attrs extern kw lifetime name ports items']
where where
items' = inject enumItems items -- only keep what's used items' = inject enumItems items -- only keep what's used
Part attrs extern kw lifetime name ports items = description' Part attrs extern kw lifetime name ports items = description'
(description', enumItems) = convertDescription' description (description', enumItems) = convertDescription' description
convertDescription (PackageItem item) = convertDescription other = [other]
map PackageItem $ convertPackageItem item
-- explode a package item with its corresponding enum items
convertPackageItem :: PackageItem -> [PackageItem]
convertPackageItem item = do
item' : enumItems
where
(PackageItem item', enumItems) =
convertDescription' $ PackageItem item
-- replace and collect the enum types in a description -- replace and collect the enum types in a description
convertDescription' :: Description -> (Description, [PackageItem]) convertDescription' :: Description -> (Description, [PackageItem])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment