summaryrefslogtreecommitdiff
path: root/src/GF/Canon/CanonToJS.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-12-13 20:19:47 +0000
committeraarne <aarne@cs.chalmers.se>2007-12-13 20:19:47 +0000
commitb447cf1a047a6f6e1c4945e809bffa57c88a08af (patch)
tree4b6792997f34b764796a8b787b3e8a9638c6ff49 /src/GF/Canon/CanonToJS.hs
parenta311dda5392ac1d019bc4f60bd94b37df01a1411 (diff)
new GFCC concrete syntax in place everywhere
Diffstat (limited to 'src/GF/Canon/CanonToJS.hs')
-rw-r--r--src/GF/Canon/CanonToJS.hs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/GF/Canon/CanonToJS.hs b/src/GF/Canon/CanonToJS.hs
index 3bd44eedd..a88a2f46a 100644
--- a/src/GF/Canon/CanonToJS.hs
+++ b/src/GF/Canon/CanonToJS.hs
@@ -7,7 +7,8 @@ import GF.Data.ErrM
import GF.Infra.Option
import qualified GF.GFCC.Macros as M
import qualified GF.GFCC.DataGFCC as D
-import qualified GF.GFCC.AbsGFCC as C
+import qualified GF.GFCC.DataGFCC as C
+import GF.GFCC.Raw.AbsGFCCRaw (CId(CId))
import qualified GF.JavaScript.AbsJS as JS
import qualified GF.JavaScript.PrintJS as JS
@@ -32,28 +33,28 @@ gfcc2js start gfcc =
as = D.abstract gfcc
cs = Map.assocs (D.concretes gfcc)
-abstract2js :: String -> C.CId -> D.Abstr -> [JS.Element]
-abstract2js start (C.CId n) ds =
+abstract2js :: String -> CId -> D.Abstr -> [JS.Element]
+abstract2js start (CId n) ds =
[JS.ElStmt $ JS.SDeclOrExpr $ JS.Decl [JS.DInit a (new "Abstract" [JS.EStr start])]]
++ concatMap (absdef2js a) (Map.assocs (D.funs ds))
where a = JS.Ident n
-absdef2js :: JS.Ident -> (C.CId,(C.Type,C.Exp)) -> [JS.Element]
-absdef2js a (C.CId f,(typ,_)) =
- let (args,C.CId cat) = M.catSkeleton typ in
+absdef2js :: JS.Ident -> (CId,(C.Type,C.Exp)) -> [JS.Element]
+absdef2js a (CId f,(typ,_)) =
+ let (args,CId cat) = M.catSkeleton typ in
[JS.ElStmt $ JS.SDeclOrExpr $ JS.DExpr $ JS.ECall (JS.EMember (JS.EVar a) (JS.Ident "addType"))
- [JS.EStr f, JS.EArray [JS.EStr x | C.CId x <- args], JS.EStr cat]]
+ [JS.EStr f, JS.EArray [JS.EStr x | CId x <- args], JS.EStr cat]]
-concrete2js :: C.CId -> (C.CId,D.Concr) -> [JS.Element]
-concrete2js (C.CId a) (C.CId c, cnc) =
+concrete2js :: CId -> (CId,D.Concr) -> [JS.Element]
+concrete2js (CId a) (CId c, cnc) =
[JS.ElStmt $ JS.SDeclOrExpr $ JS.Decl [JS.DInit l (new "Concrete" [JS.EVar (JS.Ident a)])]]
++ concatMap (cncdef2js l) ds
where
l = JS.Ident c
ds = concatMap Map.assocs [D.lins cnc, D.opers cnc, D.lindefs cnc]
-cncdef2js :: JS.Ident -> (C.CId,C.Term) -> [JS.Element]
-cncdef2js l (C.CId f, t) =
+cncdef2js :: JS.Ident -> (CId,C.Term) -> [JS.Element]
+cncdef2js l (CId f, t) =
[JS.ElStmt $ JS.SDeclOrExpr $ JS.DExpr $ JS.ECall (JS.EMember (JS.EVar l) (JS.Ident "addRule")) [JS.EStr f, JS.EFun [children] [JS.SReturn (term2js l t)]]]
term2js :: JS.Ident -> C.Term -> JS.Expr
@@ -67,7 +68,7 @@ term2js l t = f t
C.K t -> tokn2js t
C.V i -> JS.EIndex (JS.EVar children) (JS.EInt i)
C.C i -> new "Int" [JS.EInt i]
- C.F (C.CId f) -> JS.ECall (JS.EMember (JS.EVar l) (JS.Ident "rule")) [JS.EStr f, JS.EVar children]
+ C.F (CId f) -> JS.ECall (JS.EMember (JS.EVar l) (JS.Ident "rule")) [JS.EStr f, JS.EVar children]
C.FV xs -> new "Variants" (map f xs)
C.W str x -> new "Suffix" [JS.EStr str, f x]
C.RP x y -> new "Rp" [f x, f y]