From 6a66fc5d71747c1009590e68887a9bbd6f44e598 Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 10 Jun 2005 20:04:00 +0000 Subject: gfe as preprocessing to compiler --- src/GF.hs | 43 ++++++++++++++++++++++++++++++------------- src/GF/Compile/Compile.hs | 33 +++++++++++++++++++++++++++++---- src/GF/Compile/MkConcrete.hs | 34 ++++++++++++++++++++++++---------- src/GF/Infra/Option.hs | 6 ++++-- src/GF/Shell.hs | 10 ++++++++-- src/GF/Shell/HelpFile.hs | 8 +++++--- src/GF/Shell/ShellCommands.hs | 8 ++++---- src/HelpFile | 2 ++ 8 files changed, 106 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/GF.hs b/src/GF.hs index 96cf33661..ed07ede8b 100644 --- a/src/GF.hs +++ b/src/GF.hs @@ -5,9 +5,9 @@ -- Stability : (stability) -- Portability : (portability) -- --- > CVS $Date: 2005/06/03 21:51:58 $ +-- > CVS $Date: 2005/06/10 21:04:01 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.27 $ +-- > CVS $Revision: 1.28 $ -- -- The Main module of GF program. ----------------------------------------------------------------------------- @@ -20,6 +20,7 @@ import GF.Infra.UseIO import GF.Infra.Option import GF.API.IOGrammar import GF.Compile.ShellState +import GF.Compile.Compile import GF.Compile.MkConcrete import GF.Shell import GF.Shell.SubShell @@ -30,19 +31,22 @@ import GF.Text.UTF8 import GF.Today (today,version) import GF.System.Arch -import System (getArgs) -import Control.Monad (foldM) +import System (getArgs,system) +import Control.Monad (foldM,liftM) +import Data.List (nub) -- AR 19/4/2000 -- 28/4/2005 main :: IO () main = do xs <- getArgs - let (os,fs) = getOptions "-" xs - opt j = oElem j os - st0 = optInitShellState os - ifNotSil c = if oElem beSilent os then return () else c - case 0 of + let + (os,fs) = getOptions "-" xs + opt j = oElem j os + st0 = optInitShellState os + ifNotSil c = if oElem beSilent os then return () else c + + doGF os fs = case 0 of _ | opt getHelp -> do putStrLnFlush $ encodeUTF8 helpMsg @@ -62,6 +66,10 @@ main = do _ | opt makeConcrete -> do mkConcretes fs + _ | opt openEditor -> do + system $ "jgf" +++ unwords xs + return () + _ | opt doBatch -> do if opt beSilent then return () else putStrLnFlush "" st <- useIOE st0 $ @@ -77,17 +85,26 @@ main = do if null fs then return () else (ifNotSil putCPU) gfInteract (initHState st) return () + -- preprocessing gfe + if opt fromExamples + then do + es <- liftM (nub . concat) $ mapM (getGFEFiles os) fs + mkConcretes es + doGF (removeOption fromExamples os) fs + else doGF os fs helpMsg = unlines [ "Usage: gf