1
0
forked from GitHub/gf-core

Fix pre token bug in JS, both in gf and gfc. Pre tokens are still treated like normal tokens, but at least the generated code should be correct now.

This commit is contained in:
bringert
2007-11-09 15:09:09 +00:00
parent ad96ff1822
commit 6568ac4aea
2 changed files with 20 additions and 6 deletions

View File

@@ -63,7 +63,7 @@ term2js l t = 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 -> new "Seq" (map f xs)
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]
@@ -74,8 +74,15 @@ term2js l t = f t
C.TM -> new "Meta" []
tokn2js :: C.Tokn -> JS.Expr
tokn2js (C.KS s) = new "Str" [JS.EStr s]
tokn2js (C.KP ss vs) = new "Seq" (map JS.EStr ss) -- FIXME
tokn2js (C.KS s) = mkStr s
tokn2js (C.KP ss vs) = mkSeq (map mkStr ss) -- FIXME
mkStr :: String -> JS.Expr
mkStr s = new "Str" [JS.EStr s]
mkSeq :: [JS.Expr] -> JS.Expr
mkSeq [x] = x
mkSeq xs = new "Seq" xs
argIdent :: Integer -> JS.Ident
argIdent n = JS.Ident ("x" ++ show n)

View File

@@ -55,7 +55,7 @@ term2js l t = 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 -> new "Seq" (map f xs)
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]
@@ -66,8 +66,15 @@ term2js l t = f t
C.TM -> new "Meta" []
tokn2js :: C.Tokn -> JS.Expr
tokn2js (C.KS s) = new "Str" [JS.EStr s]
tokn2js (C.KP ss vs) = new "Seq" (map JS.EStr ss) -- FIXME
tokn2js (C.KS s) = mkStr s
tokn2js (C.KP ss vs) = mkSeq (map mkStr ss) -- FIXME
mkStr :: String -> JS.Expr
mkStr s = new "Str" [JS.EStr s]
mkSeq :: [JS.Expr] -> JS.Expr
mkSeq [x] = x
mkSeq xs = new "Seq" xs
argIdent :: Integer -> JS.Ident
argIdent n = JS.Ident ("x" ++ show n)