mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-10 19:52:50 -06:00
the embedded grammars now work with both the pure Haskell and the Haskell binding API
This commit is contained in:
@@ -56,21 +56,20 @@ haskPreamble gadt name =
|
|||||||
"import Data.Monoid"
|
"import Data.Monoid"
|
||||||
] else []) ++
|
] else []) ++
|
||||||
[
|
[
|
||||||
"import PGF hiding (Tree)",
|
"import PGF",
|
||||||
"import qualified PGF",
|
|
||||||
"----------------------------------------------------",
|
"----------------------------------------------------",
|
||||||
"-- automatic translation from GF to Haskell",
|
"-- automatic translation from GF to Haskell",
|
||||||
"----------------------------------------------------",
|
"----------------------------------------------------",
|
||||||
"",
|
"",
|
||||||
"class Gf a where",
|
"class Gf a where",
|
||||||
" gf :: a -> PGF.Tree",
|
" gf :: a -> Expr",
|
||||||
" fg :: PGF.Tree -> a",
|
" fg :: Expr -> a",
|
||||||
"",
|
"",
|
||||||
predefInst gadt "GString" "String" "unStr" "mkStr",
|
predefInst gadt "GString" "String" "unStr" "mkStr",
|
||||||
"",
|
"",
|
||||||
predefInst gadt "GInt" "Int" "unInt" "mkInt",
|
predefInst gadt "GInt" "Int" "unInt" "mkInt",
|
||||||
"",
|
"",
|
||||||
predefInst gadt "GFloat" "Double" "unDouble" "mkDouble",
|
predefInst gadt "GFloat" "Double" "unFloat" "mkFloat",
|
||||||
"",
|
"",
|
||||||
"----------------------------------------------------",
|
"----------------------------------------------------",
|
||||||
"-- below this line machine-generated",
|
"-- below this line machine-generated",
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ module PGF2 (-- * PGF
|
|||||||
mkInt,unInt,
|
mkInt,unInt,
|
||||||
mkFloat,unFloat,
|
mkFloat,unFloat,
|
||||||
mkMeta,unMeta,
|
mkMeta,unMeta,
|
||||||
|
mkCId,
|
||||||
-- ** Types
|
-- ** Types
|
||||||
Type, Hypo, BindType(..), startCat,
|
Type, Hypo, BindType(..), startCat,
|
||||||
readType, showType,
|
readType, showType,
|
||||||
|
|||||||
@@ -176,6 +176,9 @@ unMeta (Expr expr touch) =
|
|||||||
touch
|
touch
|
||||||
return (Just (fromIntegral (id :: CInt)))
|
return (Just (fromIntegral (id :: CInt)))
|
||||||
|
|
||||||
|
-- | this functions is only for backward compatibility with the old Haskell runtime
|
||||||
|
mkCId x = x
|
||||||
|
|
||||||
-- | parses a 'String' as an expression
|
-- | parses a 'String' as an expression
|
||||||
readExpr :: String -> Maybe Expr
|
readExpr :: String -> Maybe Expr
|
||||||
readExpr str =
|
readExpr str =
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ module PGF(
|
|||||||
mkStr, unStr,
|
mkStr, unStr,
|
||||||
mkInt, unInt,
|
mkInt, unInt,
|
||||||
mkDouble, unDouble,
|
mkDouble, unDouble,
|
||||||
|
mkFloat, unFloat,
|
||||||
mkMeta, unMeta,
|
mkMeta, unMeta,
|
||||||
-- extra
|
-- extra
|
||||||
pExpr,
|
pExpr,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ module PGF.Expr(Tree, BindType(..), Expr(..), Literal(..), Patt(..), Equation(..
|
|||||||
mkStr, unStr,
|
mkStr, unStr,
|
||||||
mkInt, unInt,
|
mkInt, unInt,
|
||||||
mkDouble, unDouble,
|
mkDouble, unDouble,
|
||||||
|
mkFloat, unFloat,
|
||||||
mkMeta, unMeta,
|
mkMeta, unMeta,
|
||||||
|
|
||||||
normalForm,
|
normalForm,
|
||||||
@@ -154,6 +155,9 @@ unDouble (ETyped e ty) = unDouble e
|
|||||||
unDouble (EImplArg e) = unDouble e
|
unDouble (EImplArg e) = unDouble e
|
||||||
unDouble _ = Nothing
|
unDouble _ = Nothing
|
||||||
|
|
||||||
|
mkFloat = mkDouble
|
||||||
|
unFloat = unDouble
|
||||||
|
|
||||||
-- | Constructs an expression which is meta variable
|
-- | Constructs an expression which is meta variable
|
||||||
mkMeta :: Int -> Expr
|
mkMeta :: Int -> Expr
|
||||||
mkMeta i = EMeta i
|
mkMeta i = EMeta i
|
||||||
|
|||||||
Reference in New Issue
Block a user