mirror of https://github.com/zachjs/sv2v.git
enums in packages are expanded in place
This commit is contained in:
parent
661703a8c2
commit
369af00137
|
|
@ -33,13 +33,20 @@ convert :: [AST] -> [AST]
|
||||||
convert = map $ concatMap convertDescription
|
convert = map $ concatMap convertDescription
|
||||||
|
|
||||||
convertDescription :: Description -> [Description]
|
convertDescription :: Description -> [Description]
|
||||||
convertDescription (description @ Package{}) =
|
convertDescription (Package ml name items) =
|
||||||
[Package ml name (items ++ enumItems)]
|
[Package ml name $ concatMap convertPackageItem items]
|
||||||
where (Package ml name items, enumItems) = convertDescription' description
|
|
||||||
convertDescription description =
|
convertDescription description =
|
||||||
(map PackageItem enumItems) ++ [description']
|
(map PackageItem enumItems) ++ [description']
|
||||||
where (description', enumItems) = convertDescription' description
|
where (description', enumItems) = convertDescription' description
|
||||||
|
|
||||||
|
-- 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])
|
||||||
convertDescription' description =
|
convertDescription' description =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue