1
0
forked from GitHub/gf-core

changed js and hs file names in gfcc output to expected ones

This commit is contained in:
aarne
2007-11-09 10:08:07 +00:00
parent 1ad7527f65
commit e66aab0978
2 changed files with 14 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ tree2exp t = case t of
TId c -> tree (AC (i2i c)) [] TId c -> tree (AC (i2i c)) []
TInt i -> tree (AI i) [] TInt i -> tree (AI i) []
TStr s -> tree (AS s) [] TStr s -> tree (AS s) []
-- TFloat d -> TFloat d -> tree (AF d) []
where where
i2i (Ident s) = CId s i2i (Ident s) = CId s
@@ -32,4 +32,7 @@ exp2tree (DTr xs at ts) = tabs (map i4i xs) (tapp at (map exp2tree ts))
tapp (AC f) [] = TId (i4i f) tapp (AC f) [] = TId (i4i f)
tapp (AC f) vs = TApp (i4i f) vs tapp (AC f) vs = TApp (i4i f) vs
tapp (AI i) [] = TInt i tapp (AI i) [] = TInt i
tapp (AS i) [] = TStr i
tapp (AF i) [] = TFloat i
tapp (AM i) [] = TId (Ident "?") ----
i4i (CId s) = Ident s i4i (CId s) = Ident s

View File

@@ -16,7 +16,7 @@ main = do
xx <- getArgs xx <- getArgs
let (opts,fs) = getOptions "-" xx let (opts,fs) = getOptions "-" xx
case opts of case opts of
_ | oElem (iOpt "help") opts -> putStrLn "usage: gfc (--make) FILES" _ | oElem (iOpt "help") opts -> putStrLn usageMsg
_ | oElem (iOpt "-make") opts -> do _ | oElem (iOpt "-make") opts -> do
gr <- batchCompile opts fs gr <- batchCompile opts fs
let name = justModuleName (last fs) let name = justModuleName (last fs)
@@ -50,14 +50,20 @@ file2gfcc f =
---- TODO: nicer and richer print options ---- TODO: nicer and richer print options
alsoPrint opts abs gr (opt,suff) = alsoPrint opts abs gr (opt,name) =
if oElem (iOpt opt) opts if oElem (iOpt opt) opts
then do then do
let outfile = abs ++ "." ++ suff let outfile = name
let output = prGFCC opt gr let output = prGFCC opt gr
writeFile outfile output writeFile outfile output
putStrLn $ "wrote file " ++ outfile putStrLn $ "wrote file " ++ outfile
else return () else return ()
printOptions = [("haskell","hs"),("haskell_gadt","hs"),("js","js")] printOptions = [
("haskell","GSyntax.hs"),
("haskell_gadt","GSyntax.hs"),
("js","grammar.js")
]
usageMsg =
"usage: gfc (-h | --make (-noopt) (-js | -haskell | -haskell_gadt)) (-src) FILES"