forked from GitHub/gf-core
floats in GF and GFC (parsing user input still doesn't work)
This commit is contained in:
@@ -164,6 +164,7 @@ data Exp =
|
||||
| ESort Sort
|
||||
| EString String
|
||||
| EInt Integer
|
||||
| EFloat Double
|
||||
| EMeta
|
||||
| EEmpty
|
||||
| EData
|
||||
@@ -213,6 +214,7 @@ data Patt =
|
||||
| PCon Ident
|
||||
| PQ Ident Ident
|
||||
| PInt Integer
|
||||
| PFloat Double
|
||||
| PStr String
|
||||
| PR [PattAss]
|
||||
| PTup [PattTupleComp]
|
||||
|
||||
@@ -156,6 +156,7 @@ ECons. Exp4 ::= "%" Ident "%" ;
|
||||
ESort. Exp4 ::= Sort ;
|
||||
EString. Exp4 ::= String ;
|
||||
EInt. Exp4 ::= Integer ;
|
||||
EFloat. Exp4 ::= Double ;
|
||||
EMeta. Exp4 ::= "?" ;
|
||||
EEmpty. Exp4 ::= "[" "]" ;
|
||||
EData. Exp4 ::= "data" ;
|
||||
@@ -210,6 +211,7 @@ PV. Patt1 ::= Ident ;
|
||||
PCon. Patt1 ::= "{" Ident "}" ;
|
||||
PQ. Patt1 ::= Ident "." Ident ;
|
||||
PInt. Patt1 ::= Integer ;
|
||||
PFloat. Patt1 ::= Double ;
|
||||
PStr. Patt1 ::= String ;
|
||||
PR. Patt1 ::= "{" [PattAss] "}" ;
|
||||
PTup. Patt1 ::= "<" [PattTupleComp] ">" ;
|
||||
|
||||
@@ -172,7 +172,8 @@ trt trm = case trm of
|
||||
K a -> P.EString a
|
||||
C a b -> P.EConcat (trt a) (trt b)
|
||||
|
||||
EInt i -> P.EInt $ toInteger i
|
||||
EInt i -> P.EInt i
|
||||
EFloat i -> P.EFloat i
|
||||
|
||||
Glue a b -> P.EGlue (trt a) (trt b)
|
||||
Alts (t, tt) -> P.EPre (trt t) [P.Alt (trt v) (trt c) | (v,c) <- tt]
|
||||
@@ -192,7 +193,8 @@ trp p = case p of
|
||||
PP p c a -> P.PQC (tri p) (tri c) (map trp a)
|
||||
PR r -> P.PR [P.PA [trLabelIdent l] (trp p) | (l,p) <- r]
|
||||
PString s -> P.PStr s
|
||||
PInt i -> P.PInt $ toInteger i
|
||||
PInt i -> P.PInt i
|
||||
PFloat i -> P.PFloat i
|
||||
PT t p -> trp p ---- prParenth (prt p +++ ":" +++ prt t)
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -335,6 +335,7 @@ instance Print Exp where
|
||||
ESort sort -> prPrec i 4 (concatD [prt 0 sort])
|
||||
EString str -> prPrec i 4 (concatD [prt 0 str])
|
||||
EInt n -> prPrec i 4 (concatD [prt 0 n])
|
||||
EFloat n -> prPrec i 4 (concatD [prt 0 n])
|
||||
EMeta -> prPrec i 4 (concatD [doc (showString "?")])
|
||||
EEmpty -> prPrec i 4 (concatD [doc (showString "[") , doc (showString "]")])
|
||||
EData -> prPrec i 4 (concatD [doc (showString "data")])
|
||||
@@ -390,6 +391,7 @@ instance Print Patt where
|
||||
PCon id -> prPrec i 1 (concatD [doc (showString "{0") , prt 0 id , doc (showString "}0")]) -- H
|
||||
PQ id0 id -> prPrec i 1 (concatD [prt 0 id0 , doc (showString ".") , prt 0 id])
|
||||
PInt n -> prPrec i 1 (concatD [prt 0 n])
|
||||
PFloat n -> prPrec i 1 (concatD [prt 0 n])
|
||||
PStr str -> prPrec i 1 (concatD [prt 0 str])
|
||||
PR pattasss -> prPrec i 1 (concatD [doc (showString "{") , prt 0 pattasss , doc (showString "}")])
|
||||
PTup patttuplecomps -> prPrec i 1 (concatD [doc (showString "<") , prt 0 patttuplecomps , doc (showString ">")])
|
||||
|
||||
@@ -396,7 +396,8 @@ transExp x = case x of
|
||||
EQCons m c -> liftM2 G.Q (transIdent m) (transIdent c)
|
||||
EString str -> return $ G.K str
|
||||
ESort sort -> liftM G.Sort $ transSort sort
|
||||
EInt n -> return $ G.EInt $ fromInteger n
|
||||
EInt n -> return $ G.EInt n
|
||||
EFloat n -> return $ G.EFloat n
|
||||
EMeta -> return $ M.meta $ M.int2meta 0
|
||||
EEmpty -> return G.Empty
|
||||
-- [ C x_1 ... x_n ] becomes (ListC x_1 ... x_n)
|
||||
@@ -522,7 +523,8 @@ transPatt x = case x of
|
||||
PV id -> liftM G.PV $ transIdent id
|
||||
PC id patts -> liftM2 G.PC (transIdent id) (mapM transPatt patts)
|
||||
PCon id -> liftM2 G.PC (transIdent id) (return [])
|
||||
PInt n -> return $ G.PInt (fromInteger n)
|
||||
PInt n -> return $ G.PInt n
|
||||
PFloat n -> return $ G.PFloat n
|
||||
PStr str -> return $ G.PString str
|
||||
PR pattasss -> do
|
||||
let (lss,ps) = unzip [(ls,p) | PA ls p <- pattasss]
|
||||
|
||||
Reference in New Issue
Block a user