mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
Transfer: Added Double type.
This commit is contained in:
@@ -59,7 +59,8 @@ data Tree :: * -> * where
|
||||
EVar :: CIdent -> Tree Exp_
|
||||
EType :: Tree Exp_
|
||||
EStr :: String -> Tree Exp_
|
||||
EInt :: Integer -> Tree Exp_
|
||||
EInteger :: Integer -> Tree Exp_
|
||||
EDouble :: Double -> Tree Exp_
|
||||
EMeta :: TMeta -> Tree Exp_
|
||||
LetDef :: CIdent -> Exp -> Exp -> Tree LetDef_
|
||||
FieldType :: CIdent -> Exp -> Tree FieldType_
|
||||
@@ -163,7 +164,8 @@ instance Show (Tree c) where
|
||||
EVar cident -> opar n . showString "EVar" . showChar ' ' . showsPrec 1 cident . cpar n
|
||||
EType -> showString "EType"
|
||||
EStr str -> opar n . showString "EStr" . showChar ' ' . showsPrec 1 str . cpar n
|
||||
EInt n -> opar n . showString "EInt" . showChar ' ' . showsPrec 1 n . cpar n
|
||||
EInteger n -> opar n . showString "EInteger" . showChar ' ' . showsPrec 1 n . cpar n
|
||||
EDouble d -> opar n . showString "EDouble" . showChar ' ' . showsPrec 1 d . cpar n
|
||||
EMeta tmeta -> opar n . showString "EMeta" . showChar ' ' . showsPrec 1 tmeta . cpar n
|
||||
LetDef cident exp0 exp1 -> opar n . showString "LetDef" . showChar ' ' . showsPrec 1 cident . showChar ' ' . showsPrec 1 exp0 . showChar ' ' . showsPrec 1 exp1 . cpar n
|
||||
FieldType cident exp -> opar n . showString "FieldType" . showChar ' ' . showsPrec 1 cident . showChar ' ' . showsPrec 1 exp . cpar n
|
||||
@@ -202,7 +204,8 @@ johnMajorEq (ERec fieldvalues) (ERec fieldvalues_) = fieldvalues == fieldvalues_
|
||||
johnMajorEq (EVar cident) (EVar cident_) = cident == cident_
|
||||
johnMajorEq EType EType = True
|
||||
johnMajorEq (EStr str) (EStr str_) = str == str_
|
||||
johnMajorEq (EInt n) (EInt n_) = n == n_
|
||||
johnMajorEq (EInteger n) (EInteger n_) = n == n_
|
||||
johnMajorEq (EDouble d) (EDouble d_) = d == d_
|
||||
johnMajorEq (EMeta tmeta) (EMeta tmeta_) = tmeta == tmeta_
|
||||
johnMajorEq (LetDef cident exp0 exp1) (LetDef cident_ exp0_ exp1_) = cident == cident_ && exp0 == exp0_ && exp1 == exp1_
|
||||
johnMajorEq (FieldType cident exp) (FieldType cident_ exp_) = cident == cident_ && exp == exp_
|
||||
@@ -240,14 +243,15 @@ instance Ord (Tree c) where
|
||||
index (EVar _) = 22
|
||||
index (EType ) = 23
|
||||
index (EStr _) = 24
|
||||
index (EInt _) = 25
|
||||
index (EMeta _) = 26
|
||||
index (LetDef _ _ _) = 27
|
||||
index (FieldType _ _) = 28
|
||||
index (FieldValue _ _) = 29
|
||||
index (Case _ _) = 30
|
||||
index (TMeta _) = 31
|
||||
index (CIdent _) = 32
|
||||
index (EInteger _) = 25
|
||||
index (EDouble _) = 26
|
||||
index (EMeta _) = 27
|
||||
index (LetDef _ _ _) = 28
|
||||
index (FieldType _ _) = 29
|
||||
index (FieldValue _ _) = 30
|
||||
index (Case _ _) = 31
|
||||
index (TMeta _) = 32
|
||||
index (CIdent _) = 33
|
||||
compareSame (Module decls) (Module decls_) = compare decls decls_
|
||||
compareSame (DataDecl cident exp consdecls) (DataDecl cident_ exp_ consdecls_) = mappend (compare cident cident_) (mappend (compare exp exp_) (compare consdecls consdecls_))
|
||||
compareSame (TypeDecl cident exp) (TypeDecl cident_ exp_) = mappend (compare cident cident_) (compare exp exp_)
|
||||
@@ -273,7 +277,8 @@ instance Ord (Tree c) where
|
||||
compareSame (EVar cident) (EVar cident_) = compare cident cident_
|
||||
compareSame EType EType = EQ
|
||||
compareSame (EStr str) (EStr str_) = compare str str_
|
||||
compareSame (EInt n) (EInt n_) = compare n n_
|
||||
compareSame (EInteger n) (EInteger n_) = compare n n_
|
||||
compareSame (EDouble d) (EDouble d_) = compare d d_
|
||||
compareSame (EMeta tmeta) (EMeta tmeta_) = compare tmeta tmeta_
|
||||
compareSame (LetDef cident exp0 exp1) (LetDef cident_ exp0_ exp1_) = mappend (compare cident cident_) (mappend (compare exp0 exp0_) (compare exp1 exp1_))
|
||||
compareSame (FieldType cident exp) (FieldType cident_ exp_) = mappend (compare cident cident_) (compare exp exp_)
|
||||
|
||||
@@ -77,7 +77,9 @@ EType. Exp5 ::= "Type" ;
|
||||
-- String literal expressions.
|
||||
EStr. Exp5 ::= String ;
|
||||
-- Integer literal expressions.
|
||||
EInt. Exp5 ::= Integer ;
|
||||
EInteger. Exp5 ::= Integer ;
|
||||
-- Double literal expressions.
|
||||
EDouble. Exp5 ::= Double ;
|
||||
-- Meta variables
|
||||
EMeta. Exp5 ::= TMeta ;
|
||||
|
||||
|
||||
@@ -32,6 +32,12 @@ except \terminal{"}\ unless preceded by \verb6\6.
|
||||
Integer literals \nonterminal{Int}\ are nonempty sequences of digits.
|
||||
|
||||
|
||||
Double-precision float literals \nonterminal{Double}\ have the structure
|
||||
indicated by the regular expression $\nonterminal{digit}+ \mbox{{\it `.'}} \nonterminal{digit}+ (\mbox{{\it `e'}} \mbox{{\it `-'}}? \nonterminal{digit}+)?$ i.e.\
|
||||
two sequences of digits separated by a decimal point, optionally
|
||||
followed by an unsigned or negative exponent.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -165,6 +171,7 @@ All other symbols are terminals.\\
|
||||
& {\delimit} &{\terminal{Type}} \\
|
||||
& {\delimit} &{\nonterminal{String}} \\
|
||||
& {\delimit} &{\nonterminal{Integer}} \\
|
||||
& {\delimit} &{\nonterminal{Double}} \\
|
||||
& {\delimit} &{\nonterminal{TMeta}} \\
|
||||
& {\delimit} &{\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} \\
|
||||
\end{tabular}\\
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -31,7 +31,7 @@ $l $i* { tok (\p s -> PT p (eitherResIdent (TV . share) s)) }
|
||||
\" ([$u # [\" \\ \n]] | (\\ (\" | \\ | \' | n | t)))* \"{ tok (\p s -> PT p (TL $ share $ unescapeInitTail s)) }
|
||||
|
||||
$d+ { tok (\p s -> PT p (TI $ share s)) }
|
||||
|
||||
$d+ \. $d+ (e (\-)? $d+)? { tok (\p s -> PT p (TD $ share s)) }
|
||||
|
||||
{
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@ import Transfer.ErrM
|
||||
|
||||
L_quoted { PT _ (TL $$) }
|
||||
L_integ { PT _ (TI $$) }
|
||||
L_doubl { PT _ (TD $$) }
|
||||
L_TMeta { PT _ (T_TMeta $$) }
|
||||
L_CIdent { PT _ (T_CIdent $$) }
|
||||
L_err { _ }
|
||||
@@ -46,6 +47,7 @@ L_err { _ }
|
||||
|
||||
String :: { String } : L_quoted { $1 }
|
||||
Integer :: { Integer } : L_integ { (read $1) :: Integer }
|
||||
Double :: { Double } : L_doubl { (read $1) :: Double }
|
||||
TMeta :: { TMeta} : L_TMeta { TMeta ($1)}
|
||||
CIdent :: { CIdent} : L_CIdent { CIdent ($1)}
|
||||
|
||||
@@ -142,7 +144,8 @@ Exp5 : 'sig' '{' ListFieldType '}' { ERecType $3 }
|
||||
| CIdent { EVar $1 }
|
||||
| 'Type' { EType }
|
||||
| String { EStr $1 }
|
||||
| Integer { EInt $1 }
|
||||
| Integer { EInteger $1 }
|
||||
| Double { EDouble $1 }
|
||||
| TMeta { EMeta $1 }
|
||||
| '(' Exp ')' { $2 }
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@ instance Print (Tree c) where
|
||||
EVar cident -> prPrec _i 5 (concatD [prt 0 cident])
|
||||
EType -> prPrec _i 5 (concatD [doc (showString "Type")])
|
||||
EStr str -> prPrec _i 5 (concatD [prt 0 str])
|
||||
EInt n -> prPrec _i 5 (concatD [prt 0 n])
|
||||
EInteger n -> prPrec _i 5 (concatD [prt 0 n])
|
||||
EDouble d -> prPrec _i 5 (concatD [prt 0 d])
|
||||
EMeta tmeta -> prPrec _i 5 (concatD [prt 0 tmeta])
|
||||
LetDef cident exp0 exp1 -> prPrec _i 0 (concatD [prt 0 cident , doc (showString ":") , prt 0 exp0 , doc (showString "=") , prt 0 exp1])
|
||||
FieldType cident exp -> prPrec _i 0 (concatD [prt 0 cident , doc (showString ":") , prt 0 exp])
|
||||
|
||||
@@ -36,7 +36,8 @@ transTree t = case t of
|
||||
EVar cident -> failure t
|
||||
EType -> failure t
|
||||
EStr str -> failure t
|
||||
EInt n -> failure t
|
||||
EInteger n -> failure t
|
||||
EDouble d -> failure t
|
||||
EMeta tmeta -> failure t
|
||||
LetDef cident exp0 exp1 -> failure t
|
||||
FieldType cident exp -> failure t
|
||||
@@ -90,7 +91,8 @@ transExp t = case t of
|
||||
EVar cident -> failure t
|
||||
EType -> failure t
|
||||
EStr str -> failure t
|
||||
EInt n -> failure t
|
||||
EInteger n -> failure t
|
||||
EDouble d -> failure t
|
||||
EMeta tmeta -> failure t
|
||||
|
||||
transLetDef :: LetDef -> Result
|
||||
|
||||
Reference in New Issue
Block a user