From 8c47cb46b2dd6592281b31452dba360caebc4dd6 Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 7 Nov 2007 13:07:02 +0000 Subject: moved gfcc program to gfi, wrote document gf3.txt --- src/GF/Devel/GFI.hs | 71 +++++++++++++++++++++++++++++++++++++++++++++++ src/GF/Devel/Shell.hs | 71 ----------------------------------------------- src/GF/Devel/gf3.txt | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile | 8 +++--- 4 files changed, 151 insertions(+), 75 deletions(-) create mode 100644 src/GF/Devel/GFI.hs delete mode 100644 src/GF/Devel/Shell.hs create mode 100644 src/GF/Devel/gf3.txt (limited to 'src') diff --git a/src/GF/Devel/GFI.hs b/src/GF/Devel/GFI.hs new file mode 100644 index 000000000..1d88a24a0 --- /dev/null +++ b/src/GF/Devel/GFI.hs @@ -0,0 +1,71 @@ +module Main where + +import GF.Command.Interpreter +import GF.Command.Commands +import GF.GFCC.API +import System (getArgs) +import Data.Char (isDigit) + +-- Simple translation application built on GFCC. AR 7/9/2006 -- 19/9/2007 + +main :: IO () +main = do + file:_ <- getArgs + grammar <- file2grammar file + let env = CommandEnv grammar (allCommands grammar) + printHelp grammar + loop env + +loop :: CommandEnv -> IO () +loop env = do + s <- getLine + if s == "q" then return () else do + interpretCommandLine env s + loop env + +printHelp grammar = do + putStrLn $ "languages: " ++ unwords (languages grammar) + putStrLn $ "categories: " ++ unwords (categories grammar) +--- putStrLn commands + +{- obsolete + +commands = unlines [ + "Commands:", + " (gt | gtt | gr | grt) Cat Num - generate all or random", + " p Lang Cat String - parse (unquoted) string", + " l Tree - linearize in all languages", + " h - help", + " q - quit" + ] + +treat :: MultiGrammar -> String -> IO () +treat mgr s = case words s of + "gt" :cat:n:_ -> mapM_ prlinonly $ take (read1 n) $ generateAll mgr cat + "gtt":cat:n:_ -> mapM_ prlin $ take (read1 n) $ generateAll mgr cat + "gr" :cat:n:_ -> generateRandom mgr cat >>= mapM_ prlinonly . take (read1 n) + "grt":cat:n:_ -> generateRandom mgr cat >>= mapM_ prlin . take (read1 n) + "p":lang:cat:ws -> do + let ts = parse mgr lang cat $ unwords ws + mapM_ (putStrLn . showTree) ts + "h":_ -> printHelp mgr + "l" : ws -> lins $ readTree mgr $ unwords ws + where + grammar = gfcc mgr + langs = languages mgr + lins t = mapM_ (lint t) $ langs + lint t lang = do +---- putStrLn $ showTree $ linExp grammar lang t + lin t lang + lin t lang = do + putStrLn $ linearize mgr lang t + prlins t = do + putStrLn $ showTree t + lins t + prlin t = do + putStrLn $ showTree t + prlinonly t + prlinonly t = mapM_ (lin t) $ langs + read1 s = if all isDigit s then read s else 1 +-} + diff --git a/src/GF/Devel/Shell.hs b/src/GF/Devel/Shell.hs deleted file mode 100644 index 1d88a24a0..000000000 --- a/src/GF/Devel/Shell.hs +++ /dev/null @@ -1,71 +0,0 @@ -module Main where - -import GF.Command.Interpreter -import GF.Command.Commands -import GF.GFCC.API -import System (getArgs) -import Data.Char (isDigit) - --- Simple translation application built on GFCC. AR 7/9/2006 -- 19/9/2007 - -main :: IO () -main = do - file:_ <- getArgs - grammar <- file2grammar file - let env = CommandEnv grammar (allCommands grammar) - printHelp grammar - loop env - -loop :: CommandEnv -> IO () -loop env = do - s <- getLine - if s == "q" then return () else do - interpretCommandLine env s - loop env - -printHelp grammar = do - putStrLn $ "languages: " ++ unwords (languages grammar) - putStrLn $ "categories: " ++ unwords (categories grammar) ---- putStrLn commands - -{- obsolete - -commands = unlines [ - "Commands:", - " (gt | gtt | gr | grt) Cat Num - generate all or random", - " p Lang Cat String - parse (unquoted) string", - " l Tree - linearize in all languages", - " h - help", - " q - quit" - ] - -treat :: MultiGrammar -> String -> IO () -treat mgr s = case words s of - "gt" :cat:n:_ -> mapM_ prlinonly $ take (read1 n) $ generateAll mgr cat - "gtt":cat:n:_ -> mapM_ prlin $ take (read1 n) $ generateAll mgr cat - "gr" :cat:n:_ -> generateRandom mgr cat >>= mapM_ prlinonly . take (read1 n) - "grt":cat:n:_ -> generateRandom mgr cat >>= mapM_ prlin . take (read1 n) - "p":lang:cat:ws -> do - let ts = parse mgr lang cat $ unwords ws - mapM_ (putStrLn . showTree) ts - "h":_ -> printHelp mgr - "l" : ws -> lins $ readTree mgr $ unwords ws - where - grammar = gfcc mgr - langs = languages mgr - lins t = mapM_ (lint t) $ langs - lint t lang = do ----- putStrLn $ showTree $ linExp grammar lang t - lin t lang - lin t lang = do - putStrLn $ linearize mgr lang t - prlins t = do - putStrLn $ showTree t - lins t - prlin t = do - putStrLn $ showTree t - prlinonly t - prlinonly t = mapM_ (lin t) $ langs - read1 s = if all isDigit s then read s else 1 --} - diff --git a/src/GF/Devel/gf3.txt b/src/GF/Devel/gf3.txt new file mode 100644 index 000000000..3eb2d6e35 --- /dev/null +++ b/src/GF/Devel/gf3.txt @@ -0,0 +1,76 @@ +GF Version 3.0 +Aarne Ranta +7 November 2007 + + +==Overview== + +GF 3 results from the following needs: +- refactor GF to make it more maintainable +- provide a simple command-line batch compiler +- replace the gfcc by the much simpler gfcc format for embedded grammars + + +The current implementation of GF 3 has three binaries: +- gfc, batch compiler, for building grammar applications +- gfi, interpreter for gfcc grammars, for using grammars +- gf, interactive compiler with interpreter, for developing grammars + + +Thus, roughly, gf = gfc + gfi. + +Question: should we have, like current GF, just one binary, gf, and +implement the others by shell scripts calling gf with suitable options? +- +: one binary is less code altogether +- +: one binary is easier to distribute and update +- -: each of the components is less code by itself +- -: many users might only need either the compiler or the interpreter +- -: those users could avoid installation problems such as readline + + +There are some analogies in other languages: + + || GF | Haskell | Java || + | gfc | ghc | javac | + | gfi | ghci* | java | + | gf | ghci* | - | + +In Haskell, ghci makes more than gfi since it reads source files, but +less than gf since it does not compile them to externally usable target +code. + + + + +==Status of code and functionalities== + +GF executable v. 2.8 +- gf: 263 modules, executable 7 MB + + +Current status of GF 3.0 alpha: +- gf3: 94 modules, executable 4 MB +- gfc: 71 modules, executable 3 MB +- gfi: 35 modules, executable 1 MB + + +Missing functionalities +- in gfc: + - input formats: cf, ebnf, gfe, old gf + - output formats: speech grammars, bnfc + + +- in gfi: + - command cc (computing with resource) + - morphological analysis, linearization with tables + - quizzes, treebanks + - syntax editor + - readline + + +==Additional feature options== + +Native Haskell readline + +Binary formats for gfo and gfcc + diff --git a/src/Makefile b/src/Makefile index 6cda7d458..99a8c9304 100644 --- a/src/Makefile +++ b/src/Makefile @@ -198,10 +198,10 @@ gfc: strip gfc mv gfc ../bin/ -gfcc: - $(GHMAKE) $(GHCOPTFLAGS) -o gfcc GF/Devel/Shell.hs - strip gfcc - mv gfcc ../bin/ +gfi: + $(GHMAKE) $(GHCOPTFLAGS) -o gfi GF/Devel/GFI.hs + strip gfi + mv gfi ../bin/ gf3: $(GHMAKE) $(GHCOPTFLAGS) -o gf3 GF/Devel/GF3.hs -- cgit v1.2.3