diff options
| author | krasimir <krasimir@chalmers.se> | 2008-05-30 11:15:33 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2008-05-30 11:15:33 +0000 |
| commit | 8bb0c32a9cf2cbad0375ab5886b7f2be37109477 (patch) | |
| tree | 2290b07d391a1da4e94ee367b445a6b2f64ca2cd /src-3.0/GF/Command | |
| parent | 1172539a9544ed999c565053b79cf6a30ec14de4 (diff) | |
replace GFCC with PGF in (almost) all places
Diffstat (limited to 'src-3.0/GF/Command')
| -rw-r--r-- | src-3.0/GF/Command/Commands.hs | 42 | ||||
| -rw-r--r-- | src-3.0/GF/Command/Importing.hs | 20 | ||||
| -rw-r--r-- | src-3.0/GF/Command/Interpreter.hs | 2 |
3 files changed, 30 insertions, 34 deletions
diff --git a/src-3.0/GF/Command/Commands.hs b/src-3.0/GF/Command/Commands.hs index bf5c737cc..f3789d669 100644 --- a/src-3.0/GF/Command/Commands.hs +++ b/src-3.0/GF/Command/Commands.hs @@ -47,10 +47,10 @@ emptyCommandInfo = CommandInfo { lookCommand :: String -> Map.Map String CommandInfo -> Maybe CommandInfo lookCommand = Map.lookup -commandHelpAll :: MultiGrammar -> [Option] -> String -commandHelpAll mgr opts = unlines +commandHelpAll :: PGF -> [Option] -> String +commandHelpAll pgf opts = unlines [commandHelp (isOpt "full" opts) (co,info) - | (co,info) <- Map.assocs (allCommands mgr)] + | (co,info) <- Map.assocs (allCommands pgf)] commandHelp :: Bool -> (String,CommandInfo) -> String commandHelp full (co,info) = unlines $ [ @@ -82,14 +82,14 @@ isOpt :: String -> [Option] -> Bool isOpt o opts = elem o [x | OOpt (Ident x) <- opts] -- this list must be kept sorted by the command name! -allCommands :: MultiGrammar -> Map.Map String CommandInfo -allCommands mgr = Map.fromAscList [ +allCommands :: PGF -> Map.Map String CommandInfo +allCommands pgf = Map.fromAscList [ ("gr", emptyCommandInfo { longname = "generate_random", synopsis = "generates a list of random trees, by default one tree", flags = ["cat","number"], exec = \opts _ -> do - ts <- generateRandom mgr (optCat opts) + ts <- generateRandom pgf (optCat opts) return $ fromTrees $ take (optNum opts) ts }), ("gt", emptyCommandInfo { @@ -98,7 +98,7 @@ allCommands mgr = Map.fromAscList [ flags = ["cat","depth","number"], exec = \opts _ -> do let dp = return $ valIntOpts "depth" 4 opts - let ts = generateAllDepth mgr (optCat opts) dp + let ts = generateAllDepth pgf (optCat opts) dp return $ fromTrees $ take (optNumInf opts) ts }), ("h", emptyCommandInfo { @@ -107,10 +107,10 @@ allCommands mgr = Map.fromAscList [ options = ["full"], exec = \opts ts -> return ([], case ts of [t] -> let co = (showTree t) in - case lookCommand co (allCommands mgr) of ---- new map ??!! + case lookCommand co (allCommands pgf) of ---- new map ??!! Just info -> commandHelp True (co,info) _ -> "command not found" - _ -> commandHelpAll mgr opts) + _ -> commandHelpAll pgf opts) }), ("l", emptyCommandInfo { exec = \opts -> return . fromStrings . map (optLin opts), @@ -127,33 +127,31 @@ allCommands mgr = Map.fromAscList [ }) ] where - lin opts t = unlines [linearize mgr lang t | lang <- optLangs opts] - par opts s = concat [parse mgr lang (optCat opts) s | lang <- optLangs opts] + lin opts t = unlines [linearize pgf lang t | lang <- optLangs opts] + par opts s = concat [parse pgf lang (optCat opts) s | lang <- optLangs opts] optLin opts t = unlines [linea lang t | lang <- optLangs opts] where linea lang = case opts of - _ | isOpt "all" opts -> allLinearize gr (mkCId lang) - _ | isOpt "table" opts -> tableLinearize gr (mkCId lang) - _ | isOpt "term" opts -> termLinearize gr (mkCId lang) - _ | isOpt "record" opts -> recordLinearize gr (mkCId lang) - _ -> linearize mgr lang + _ | isOpt "all" opts -> allLinearize pgf (mkCId lang) + _ | isOpt "table" opts -> tableLinearize pgf (mkCId lang) + _ | isOpt "term" opts -> termLinearize pgf (mkCId lang) + _ | isOpt "record" opts -> recordLinearize pgf (mkCId lang) + _ -> linearize pgf lang optLangs opts = case valIdOpts "lang" "" opts of - "" -> languages mgr + "" -> languages pgf lang -> [lang] - optCat opts = valIdOpts "cat" (lookStartCat gr) opts + optCat opts = valIdOpts "cat" (lookStartCat pgf) opts optNum opts = valIntOpts "number" 1 opts optNumInf opts = valIntOpts "number" 1000000000 opts ---- 10^9 - gr = gfcc mgr - fromTrees ts = (ts,unlines (map showTree ts)) fromStrings ss = (map EStr ss, unlines ss) fromString s = ([EStr s], s) toStrings ts = [s | EStr s <- ts] prGrammar opts = case valIdOpts "printer" "" opts of - "cats" -> unwords $ categories mgr - v -> prGFCC (read v) gr + "cats" -> unwords $ categories pgf + v -> prPGF (read v) pgf diff --git a/src-3.0/GF/Command/Importing.hs b/src-3.0/GF/Command/Importing.hs index 91bcdcb73..d4eeb18ce 100644 --- a/src-3.0/GF/Command/Importing.hs +++ b/src-3.0/GF/Command/Importing.hs @@ -13,20 +13,18 @@ import Data.List (nubBy) import System.FilePath -- import a grammar in an environment where it extends an existing grammar -importGrammar :: MultiGrammar -> Options -> [FilePath] -> IO MultiGrammar -importGrammar mgr0 opts files = +importGrammar :: PGF -> Options -> [FilePath] -> IO PGF +importGrammar pgf0 opts files = case takeExtensions (last files) of s | elem s [".gf",".gfo"] -> do - res <- appIOE $ compileToGFCC opts files + res <- appIOE $ compileToPGF opts files case res of - Ok gfcc2 -> do let gfcc3 = unionGFCC (gfcc mgr0) gfcc2 - return $ MultiGrammar gfcc3 - Bad msg -> do putStrLn msg - return mgr0 - ".gfcc" -> do - gfcc2 <- mapM file2gfcc files >>= return . foldl1 unionGFCC - let gfcc3 = unionGFCC (gfcc mgr0) gfcc2 - return $ MultiGrammar gfcc3 + Ok pgf2 -> do return $ unionPGF pgf0 pgf2 + Bad msg -> do putStrLn msg + return pgf0 + ".pgf" -> do + pgf2 <- mapM file2pgf files >>= return . foldl1 unionPGF + return $ unionPGF pgf0 pgf2 importSource :: SourceGrammar -> Options -> [FilePath] -> IO SourceGrammar importSource src0 opts files = do diff --git a/src-3.0/GF/Command/Interpreter.hs b/src-3.0/GF/Command/Interpreter.hs index 825c2862b..c33d6453a 100644 --- a/src-3.0/GF/Command/Interpreter.hs +++ b/src-3.0/GF/Command/Interpreter.hs @@ -17,7 +17,7 @@ import GF.Data.ErrM ---- import qualified Data.Map as Map data CommandEnv = CommandEnv { - multigrammar :: MultiGrammar, + multigrammar :: PGF, commands :: Map.Map String CommandInfo } |
