mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
Need aeson>=1.3
Also remove ununsed GF.Compile.PGFtoAbstract
This commit is contained in:
9
gf.cabal
9
gf.cabal
@@ -80,11 +80,6 @@ Library
|
||||
utf8-string,
|
||||
random,
|
||||
pretty,
|
||||
aeson,
|
||||
yaml,
|
||||
unordered-containers,
|
||||
scientific,
|
||||
text,
|
||||
mtl,
|
||||
exceptions
|
||||
hs-source-dirs: src/runtime/haskell
|
||||
@@ -148,7 +143,8 @@ Library
|
||||
---- GF compiler as a library:
|
||||
|
||||
build-depends: filepath, directory, time, time-compat,
|
||||
process, haskeline, parallel>=3
|
||||
process, haskeline, parallel>=3,
|
||||
aeson>=1.3, yaml, unordered-containers, scientific, text
|
||||
|
||||
hs-source-dirs: src/compiler
|
||||
exposed-modules:
|
||||
@@ -191,7 +187,6 @@ Library
|
||||
GF.Compile.Multi
|
||||
GF.Compile.Optimize
|
||||
GF.Compile.PGFtoHaskell
|
||||
-- GF.Compile.PGFtoAbstract
|
||||
GF.Compile.PGFtoJava
|
||||
GF.Haskell
|
||||
GF.Compile.ConcreteToHaskell
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
-- | Extract the abstract syntax from a PGF and convert to it
|
||||
-- the AST for canonical GF grammars
|
||||
module GF.Compile.PGFtoAbstract(abstract2canonical) where
|
||||
import qualified Data.Map as M
|
||||
import PGF(CId,mkCId,showCId,wildCId,unType,abstractName)
|
||||
import PGF.Internal(abstract,cats,funs)
|
||||
import GF.Grammar.Canonical
|
||||
|
||||
|
||||
abstract2canonical pgf = Abstract (gId (abstractName pgf)) cs fs
|
||||
where
|
||||
abstr = abstract pgf
|
||||
cs = [CatDef (gId c) (convHs' hs) |
|
||||
(c,(hs,_,_)) <- M.toList (cats abstr),
|
||||
c `notElem` predefCat]
|
||||
fs = [FunDef (gId f) (convT ty) | (f,(ty,ar,_,_)) <- M.toList (funs abstr)]
|
||||
|
||||
predefCat = map mkCId ["Float","Int","String"]
|
||||
|
||||
convHs' = map convH'
|
||||
convH' (bt,name,ty) =
|
||||
case unType ty of
|
||||
([],name,[]) -> gId name -- !!
|
||||
|
||||
convT t =
|
||||
case unType t of
|
||||
(hypos,name,[]) -> Type (convHs hypos) (TypeApp (gId name) []) -- !!
|
||||
|
||||
convHs = map convH
|
||||
|
||||
convH (bt,name,ty) = TypeBinding (gId name) (convT ty)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
class FromCId i where gId :: CId -> i
|
||||
|
||||
instance FromCId FunId where gId = FunId . showCId
|
||||
instance FromCId CatId where gId = CatId . showCId
|
||||
instance FromCId ModId where gId = ModId . showCId
|
||||
|
||||
instance FromCId VarId where
|
||||
gId i = if i==wildCId then Anonymous else VarId (showCId i)
|
||||
Reference in New Issue
Block a user