From bddb8ceaffb26b53dce1ea74117da4ba2add6ca2 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Fri, 8 Mar 2019 17:01:49 -0500 Subject: [PATCH] fix multiple instantiations on one line --- src/Language/SystemVerilog/Parser/ParseDecl.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Language/SystemVerilog/Parser/ParseDecl.hs b/src/Language/SystemVerilog/Parser/ParseDecl.hs index 83375b3..14983c2 100644 --- a/src/Language/SystemVerilog/Parser/ParseDecl.hs +++ b/src/Language/SystemVerilog/Parser/ParseDecl.hs @@ -124,7 +124,7 @@ parseDTsAsModuleItems tokens = -- internal; parser for module instantiations parseDTsAsIntantiations :: [DeclToken] -> [ModuleItem] parseDTsAsIntantiations (DTIdent name : tokens) = - if not (all isInstance rest) + if not (all isInstanceOrComma rest) then error $ "instantiations mixed with other items: " ++ (show rest) else map (uncurry $ Instance name params) instances where @@ -132,10 +132,13 @@ parseDTsAsIntantiations (DTIdent name : tokens) = case head tokens of DTParams ps -> (ps, tail tokens) _ -> ([], tokens) - instances = map (\(DTInstance inst) -> inst) rest - isInstance :: DeclToken -> Bool - isInstance (DTInstance _) = True - isInstance _ = False + instances = + map (\(DTInstance inst) -> inst) $ + filter (DTComma /=) $ rest + isInstanceOrComma :: DeclToken -> Bool + isInstanceOrComma (DTInstance _) = True + isInstanceOrComma DTComma = True + isInstanceOrComma _ = False parseDTsAsIntantiations tokens = error $ "DeclTokens contain instantiations, but start with non-ident: "