forked from GitHub/gf-core
bugfixes in the parser for PGF.Type.Type
This commit is contained in:
@@ -36,7 +36,10 @@ instance Read CId where
|
|||||||
readsPrec _ = RP.readP_to_S pCId
|
readsPrec _ = RP.readP_to_S pCId
|
||||||
|
|
||||||
pCId :: RP.ReadP CId
|
pCId :: RP.ReadP CId
|
||||||
pCId = fmap mkCId pIdent
|
pCId = do s <- pIdent
|
||||||
|
if s == "_"
|
||||||
|
then RP.pfail
|
||||||
|
else return (mkCId s)
|
||||||
|
|
||||||
pIdent :: RP.ReadP String
|
pIdent :: RP.ReadP String
|
||||||
pIdent = liftM2 (:) (RP.satisfy isIdentFirst) (RP.munch isIdentRest)
|
pIdent = liftM2 (:) (RP.satisfy isIdentFirst) (RP.munch isIdentRest)
|
||||||
|
|||||||
@@ -41,32 +41,30 @@ showType = PP.render . ppType 0
|
|||||||
pType :: RP.ReadP Type
|
pType :: RP.ReadP Type
|
||||||
pType = do
|
pType = do
|
||||||
RP.skipSpaces
|
RP.skipSpaces
|
||||||
hyps <- RP.sepBy (pHypo >>= \h -> RP.string "->" >> return h) RP.skipSpaces
|
hyps <- RP.sepBy (pHypo >>= \h -> RP.skipSpaces >> RP.string "->" >> return h) RP.skipSpaces
|
||||||
RP.skipSpaces
|
RP.skipSpaces
|
||||||
(cat,args) <- pAtom
|
(cat,args) <- pAtom
|
||||||
return (DTyp hyps cat args)
|
return (DTyp (concat hyps) cat args)
|
||||||
where
|
where
|
||||||
pHypo =
|
pHypo =
|
||||||
do (cat,args) <- pAtom
|
do (cat,args) <- pAtom
|
||||||
return (Hyp (DTyp [] cat args))
|
return [Hyp (DTyp [] cat args)]
|
||||||
RP.<++
|
RP.<++
|
||||||
(RP.between (RP.char '(') (RP.char ')') $ do
|
(RP.between (RP.char '(') (RP.char ')') $ do
|
||||||
var <- RP.option wildCId $ do
|
hyp <- RP.option (\ty -> [Hyp ty]) $ do
|
||||||
v <- pCId
|
vs <- RP.sepBy (RP.skipSpaces >> pCId) (RP.skipSpaces >> RP.char ',')
|
||||||
RP.skipSpaces
|
RP.skipSpaces
|
||||||
RP.string ":"
|
RP.char ':'
|
||||||
return v
|
return (\ty -> [HypV v ty | v <- vs])
|
||||||
ty <- pType
|
ty <- pType
|
||||||
return (HypV var ty))
|
return (hyp ty))
|
||||||
RP.<++
|
RP.<++
|
||||||
(RP.between (RP.char '{') (RP.char '}') $ do
|
(RP.between (RP.char '{') (RP.char '}') $ do
|
||||||
var <- RP.option wildCId $ do
|
vs <- RP.sepBy1 (RP.skipSpaces >> pCId) (RP.skipSpaces >> RP.char ',')
|
||||||
v <- pCId
|
RP.skipSpaces
|
||||||
RP.skipSpaces
|
RP.char ':'
|
||||||
RP.string ":"
|
|
||||||
return v
|
|
||||||
ty <- pType
|
ty <- pType
|
||||||
return (HypI var ty))
|
return [HypI v ty | v <- vs])
|
||||||
|
|
||||||
pAtom = do
|
pAtom = do
|
||||||
cat <- pCId
|
cat <- pCId
|
||||||
|
|||||||
Reference in New Issue
Block a user