mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-30 23:02:50 -06:00
since now we don't do common subexpression elimination for PGF we could simplify the PMCFG generation
This commit is contained in:
@@ -57,30 +57,6 @@ concrete2js (c,cnc) =
|
||||
JS.Prop (JS.StringPropName "String") (JS.EFun [children] [JS.SReturn $ new "Arr" [JS.EIndex (JS.EVar children) (JS.EInt 0)]])]
|
||||
cats (c,CncCat start end _) = JS.Prop (JS.IdentPropName (JS.Ident (showCId c))) (JS.EObj [JS.Prop (JS.IdentPropName (JS.Ident "s")) (JS.EInt start)
|
||||
,JS.Prop (JS.IdentPropName (JS.Ident "e")) (JS.EInt end)])
|
||||
|
||||
cncdef2js :: String -> String -> (CId,Term) -> JS.Property
|
||||
cncdef2js n l (f, t) = JS.Prop (JS.IdentPropName (JS.Ident (showCId f))) (JS.EFun [children] [JS.SReturn (term2js n l t)])
|
||||
|
||||
term2js :: String -> String -> Term -> JS.Expr
|
||||
term2js n l t = f t
|
||||
where
|
||||
f t =
|
||||
case t of
|
||||
R xs -> new "Arr" (map f xs)
|
||||
P x y -> JS.ECall (JS.EMember (f x) (JS.Ident "sel")) [f y]
|
||||
S xs -> mkSeq (map f xs)
|
||||
K t -> tokn2js t
|
||||
V i -> JS.EIndex (JS.EVar children) (JS.EInt i)
|
||||
C i -> new "Int" [JS.EInt i]
|
||||
F f -> JS.ECall (JS.EMember (JS.EIndex (JS.EMember (JS.EVar $ JS.Ident n) (JS.Ident "concretes")) (JS.EStr l)) (JS.Ident "rule")) [JS.EStr (showCId f), JS.EVar children]
|
||||
FV xs -> new "Variants" (map f xs)
|
||||
W str x -> new "Suffix" [JS.EStr str, f x]
|
||||
TM _ -> new "Meta" []
|
||||
|
||||
tokn2js :: Tokn -> JS.Expr
|
||||
tokn2js (KS s) = mkStr s
|
||||
tokn2js (KP ss vs) = mkSeq (map mkStr ss) -- FIXME
|
||||
|
||||
mkStr :: String -> JS.Expr
|
||||
mkStr s = new "Str" [JS.EStr s]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user