diff options
| author | krasimir <krasimir@chalmers.se> | 2008-05-30 13:07:11 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2008-05-30 13:07:11 +0000 |
| commit | 150940b8704a6a61ed08c6bbd99ba4b05a42c59c (patch) | |
| tree | 277a97a4a3ba770e49e51a5526cf2e46bc2c6e1a /src-3.0/GF/Command | |
| parent | 8bb0c32a9cf2cbad0375ab5886b7f2be37109477 (diff) | |
cleaned up and documented PGF API
Diffstat (limited to 'src-3.0/GF/Command')
| -rw-r--r-- | src-3.0/GF/Command/Commands.hs | 10 | ||||
| -rw-r--r-- | src-3.0/GF/Command/Importing.hs | 2 | ||||
| -rw-r--r-- | src-3.0/GF/Command/Interpreter.hs | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src-3.0/GF/Command/Commands.hs b/src-3.0/GF/Command/Commands.hs index f3789d669..8761234cd 100644 --- a/src-3.0/GF/Command/Commands.hs +++ b/src-3.0/GF/Command/Commands.hs @@ -9,7 +9,7 @@ module GF.Command.Commands ( CommandOutput ) where -import GF.Command.AbsGFShell hiding (Tree) +import GF.Command.AbsGFShell import GF.Command.PPrTree import GF.Command.ParGFShell import PGF @@ -23,10 +23,10 @@ import GF.Data.ErrM ---- import qualified Data.Map as Map -type CommandOutput = ([Tree],String) ---- errors, etc +type CommandOutput = ([Exp],String) ---- errors, etc data CommandInfo = CommandInfo { - exec :: [Option] -> [Tree] -> IO CommandOutput, + exec :: [Option] -> [Exp] -> IO CommandOutput, synopsis :: String, explanation :: String, longname :: String, @@ -106,7 +106,7 @@ allCommands pgf = Map.fromAscList [ synopsis = "get description of a command, or a the full list of commands", options = ["full"], exec = \opts ts -> return ([], case ts of - [t] -> let co = (showTree t) in + [t] -> let co = showExp t in case lookCommand co (allCommands pgf) of ---- new map ??!! Just info -> commandHelp True (co,info) _ -> "command not found" @@ -146,7 +146,7 @@ allCommands pgf = Map.fromAscList [ optNum opts = valIntOpts "number" 1 opts optNumInf opts = valIntOpts "number" 1000000000 opts ---- 10^9 - fromTrees ts = (ts,unlines (map showTree ts)) + fromTrees ts = (ts,unlines (map showExp ts)) fromStrings ss = (map EStr ss, unlines ss) fromString s = ([EStr s], s) toStrings ts = [s | EStr s <- ts] diff --git a/src-3.0/GF/Command/Importing.hs b/src-3.0/GF/Command/Importing.hs index d4eeb18ce..48f07969d 100644 --- a/src-3.0/GF/Command/Importing.hs +++ b/src-3.0/GF/Command/Importing.hs @@ -23,7 +23,7 @@ importGrammar pgf0 opts files = Bad msg -> do putStrLn msg return pgf0 ".pgf" -> do - pgf2 <- mapM file2pgf files >>= return . foldl1 unionPGF + pgf2 <- mapM readPGF files >>= return . foldl1 unionPGF return $ unionPGF pgf0 pgf2 importSource :: SourceGrammar -> Options -> [FilePath] -> IO SourceGrammar diff --git a/src-3.0/GF/Command/Interpreter.hs b/src-3.0/GF/Command/Interpreter.hs index c33d6453a..a5da51f7e 100644 --- a/src-3.0/GF/Command/Interpreter.hs +++ b/src-3.0/GF/Command/Interpreter.hs @@ -4,7 +4,7 @@ module GF.Command.Interpreter ( ) where import GF.Command.Commands -import GF.Command.AbsGFShell hiding (Tree) +import GF.Command.AbsGFShell import GF.Command.PPrTree import GF.Command.ParGFShell import PGF @@ -40,7 +40,7 @@ interpretCommandLine env line = case (pCommandLine (myLexer line)) of interc = interpret env -- return the trees to be sent in pipe, and the output possibly printed -interpret :: CommandEnv -> [Tree] -> Command -> IO CommandOutput +interpret :: CommandEnv -> [Exp] -> Command -> IO CommandOutput interpret env trees0 comm = case lookCommand co comms of Just info -> do checkOpts info @@ -64,7 +64,7 @@ interpret env trees0 comm = case lookCommand co comms of os -> putStrLn $ "options not interpreted: " ++ unwords os -- analyse command parse tree to a uniform datastructure, normalizing comm name -getCommand :: Command -> [Tree] -> (String,[Option],[Tree]) +getCommand :: Command -> [Exp] -> (String,[Option],[Exp]) getCommand co ts = case co of Comm (Ident c) opts (ATree t) -> (getOp c,opts,[tree2exp t]) -- ignore piped CNoarg (Ident c) opts -> (getOp c,opts,ts) -- use piped |
