X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=utils%2Fext-core%2FLanguage%2FCore%2FParsecParser.hs;h=ff2333c6babff6aaa132795546dd7e93cdde770c;hb=e6232609a0b08ff7136a479f2e2d7d2be5040b1d;hp=40609e3421ebad33fce7f1329c3f4844c05ed573;hpb=553df2d31fa2b211f3673e83e30a6c04687972c0;p=ghc-hetmet.git diff --git a/utils/ext-core/Language/Core/ParsecParser.hs b/utils/ext-core/Language/Core/ParsecParser.hs index 40609e3..ff2333c 100644 --- a/utils/ext-core/Language/Core/ParsecParser.hs +++ b/utils/ext-core/Language/Core/ParsecParser.hs @@ -132,7 +132,7 @@ coreTbindGen sep = (parens (do (sep >> identifier >>= (return . (\ tv -> (tv,Klifted)))) coreCdefs :: Parser [Cdef] -coreCdefs = sepBy1 coreCdef (symbol ";") +coreCdefs = sepBy coreCdef (symbol ";") coreCdef :: Parser Cdef coreCdef = do @@ -472,14 +472,23 @@ coreAlt = conAlt <|> litAlt <|> defaultAlt conAlt :: Parser Alt conAlt = do conName <- coreQualifiedCon - tBinds <- many (parens coreAtTbind) - whiteSpace -- necessary b/c otherwise we parse the next list as empty - vBinds <- many (parens lambdaBind) whiteSpace + (tBinds, vBinds) <- caseVarBinds try (symbol "->") rhs <- try coreFullExp return $ Acon conName tBinds vBinds rhs +caseVarBinds :: Parser ([Tbind], [Vbind]) +caseVarBinds = do + maybeFirstTbind <- optionMaybe coreAtTbind + case maybeFirstTbind of + Just tb -> do + (tbs,vbs) <- caseVarBinds + return (tb:tbs, vbs) + Nothing -> do + vbs <- many (parens lambdaBind) + return ([], vbs) + litAlt :: Parser Alt litAlt = do l <- parens coreLiteral