mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-14 13:42:50 -06:00
now the abstract syntax in PGF allows the same syntax for integers, floats and strings as in Haskell. This includes negative integers and exponents in the floats
This commit is contained in:
@@ -39,9 +39,9 @@ pOption = do
|
|||||||
RP.option (OOpt flg) (fmap (OFlag flg) (RP.char '=' >> pValue))
|
RP.option (OOpt flg) (fmap (OFlag flg) (RP.char '=' >> pValue))
|
||||||
|
|
||||||
pValue = do
|
pValue = do
|
||||||
fmap (VInt . read) (RP.munch1 isDigit)
|
fmap VInt (RP.readS_to_P reads)
|
||||||
RP.<++
|
RP.<++
|
||||||
fmap VStr pStr
|
fmap VStr (RP.readS_to_P reads)
|
||||||
RP.<++
|
RP.<++
|
||||||
fmap VId pFilename
|
fmap VId pFilename
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module PGF.Expr(Tree, BindType(..), Expr(..), Literal(..), Patt(..), Equation(..
|
|||||||
MetaId,
|
MetaId,
|
||||||
|
|
||||||
-- helpers
|
-- helpers
|
||||||
pMeta,pStr,pArg,pLit,freshName,ppMeta,ppLit,ppParens
|
pMeta,pArg,pLit,freshName,ppMeta,ppLit,ppParens
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import PGF.CId
|
import PGF.CId
|
||||||
@@ -194,16 +194,11 @@ pMeta = do RP.char '?'
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
pLit :: RP.ReadP Literal
|
pLit :: RP.ReadP Literal
|
||||||
pLit = pNum RP.<++ liftM LStr pStr
|
pLit = liftM LStr (RP.readS_to_P reads)
|
||||||
|
RP.<++
|
||||||
pNum = do x <- RP.munch1 isDigit
|
liftM LInt (RP.readS_to_P reads)
|
||||||
((RP.char '.' >> RP.munch1 isDigit >>= \y -> return (LFlt (read (x++"."++y))))
|
RP.<++
|
||||||
RP.<++
|
liftM LFlt (RP.readS_to_P reads)
|
||||||
(return (LInt (read x))))
|
|
||||||
|
|
||||||
pStr = RP.char '"' >> (RP.manyTill (pEsc RP.<++ RP.get) (RP.char '"'))
|
|
||||||
where
|
|
||||||
pEsc = RP.char '\\' >> RP.get
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user