summaryrefslogtreecommitdiff
path: root/src/GF/Devel/GFCCtoJS.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/Devel/GFCCtoJS.hs
parenta311dda5392ac1d019bc4f60bd94b37df01a1411 (diff)
new GFCC concrete syntax in place everywhere
Diffstat (limited to 'src/GF/Devel/GFCCtoJS.hs')
-rw-r--r--src/GF/Devel/GFCCtoJS.hs58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/GF/Devel/GFCCtoJS.hs b/src/GF/Devel/GFCCtoJS.hs
index 5ec438bc7..542f2dfa7 100644
--- a/src/GF/Devel/GFCCtoJS.hs
+++ b/src/GF/Devel/GFCCtoJS.hs
@@ -2,7 +2,7 @@ module GF.Devel.GFCCtoJS (gfcc2js,gfcc2grammarRef) where
import qualified GF.GFCC.Macros as M
import qualified GF.GFCC.DataGFCC as D
-import qualified GF.GFCC.AbsGFCC as C
+import GF.GFCC.Raw.AbsGFCCRaw (CId (..))
import qualified GF.JavaScript.AbsJS as JS
import qualified GF.JavaScript.PrintJS as JS
@@ -24,50 +24,50 @@ gfcc2js gfcc =
cs = Map.assocs (D.concretes gfcc)
start = M.lookAbsFlag gfcc (M.cid "startcat")
-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,(D.Type,D.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,D.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
+term2js :: JS.Ident -> D.Term -> JS.Expr
term2js l t = f t
where
f t =
case t of
- C.R xs -> new "Arr" (map f xs)
- C.P x y -> JS.ECall (JS.EMember (f x) (JS.Ident "sel")) [f y]
- C.S xs -> mkSeq (map f xs)
- 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.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]
- C.TM -> new "Meta" []
-
-tokn2js :: C.Tokn -> JS.Expr
-tokn2js (C.KS s) = mkStr s
-tokn2js (C.KP ss vs) = mkSeq (map mkStr ss) -- FIXME
+ D.R xs -> new "Arr" (map f xs)
+ D.P x y -> JS.ECall (JS.EMember (f x) (JS.Ident "sel")) [f y]
+ D.S xs -> mkSeq (map f xs)
+ D.K t -> tokn2js t
+ D.V i -> JS.EIndex (JS.EVar children) (JS.EInt i)
+ D.C i -> new "Int" [JS.EInt i]
+ D.F (CId f) -> JS.ECall (JS.EMember (JS.EVar l) (JS.Ident "rule")) [JS.EStr f, JS.EVar children]
+ D.FV xs -> new "Variants" (map f xs)
+ D.W str x -> new "Suffix" [JS.EStr str, f x]
+ D.RP x y -> new "Rp" [f x, f y]
+ D.TM -> new "Meta" []
+
+tokn2js :: D.Tokn -> JS.Expr
+tokn2js (D.KS s) = mkStr s
+tokn2js (D.KP ss vs) = mkSeq (map mkStr ss) -- FIXME
mkStr :: String -> JS.Expr
mkStr s = new "Str" [JS.EStr s]
@@ -91,7 +91,7 @@ gfcc2grammarRef :: D.GFCC -> String
gfcc2grammarRef gfcc =
encodeUTF8 $ refs
where
- C.CId abstr = D.absname gfcc
+ CId abstr = D.absname gfcc
refs = unlines $ [
"// Grammar Reference",
"function concreteReference(concreteSyntax, concreteSyntaxName) {",
@@ -102,5 +102,5 @@ gfcc2grammarRef gfcc =
"var myConcrete = new Array();"
] ++ [
"myConcrete.push(new concreteReference(" ++ c ++ ",\"" ++ c ++ "\"));"
- | C.CId c <- D.cncnames gfcc]
+ | CId c <- D.cncnames gfcc]