diff --git a/bin/jgf2 b/bin/jgf2 index 7543b699b..9b2ac7152 100644 --- a/bin/jgf2 +++ b/bin/jgf2 @@ -1,12 +1,12 @@ #! /bin/sh # change the value of GFHOME to the directory where you have the gf binary -GFHOME=/home/aarne/GF2/bin +GFHOME=/home/aarne/GF/bin # /.../chalmers.se/fs/cab/cs/.users/markus/home/GF1 JGUILIB=$GFHOME/java/ -GF=$GFHOME/gf2 -JGUI=GFEditor +GF=/usr/local/bin/gf +JGUI=GFEditor2 java -cp $JGUILIB $JGUI "$GF -java $*" diff --git a/src/GF/Canon/CMacros.hs b/src/GF/Canon/CMacros.hs index 85a465871..0a8b360be 100644 --- a/src/GF/Canon/CMacros.hs +++ b/src/GF/Canon/CMacros.hs @@ -58,11 +58,12 @@ markSubterm (beg, end) t = case t of R rs -> R $ map markField rs T ty cs -> T ty [Cas p (mark v) | Cas p v <- cs] FV ts -> FV $ map mark ts - _ -> foldr1 C [tK beg, t, tK end] -- t : Str guaranteed? + _ -> foldr1 C (tk beg ++ [t] ++ tk end) -- t : Str guaranteed? where mark = markSubterm (beg, end) markField lt@(Ass l t) = if isLinLabel l then (Ass l (mark t)) else lt - + tk s = if null s then [] else [tK s] + tK :: String -> Term tK = K . KS diff --git a/src/GF/Data/Operations.hs b/src/GF/Data/Operations.hs index 08ebdd45c..dd8e37380 100644 --- a/src/GF/Data/Operations.hs +++ b/src/GF/Data/Operations.hs @@ -311,6 +311,12 @@ type WParser a b = [a] -> [(b,[a])] -- old Wadler style parser wParseResults :: WParser a b -> [a] -> [b] wParseResults p aa = [b | (b,[]) <- p aa] +paragraphs :: String -> [String] +paragraphs = map unlines . chop . lines where + chop [] = [] + chop ss = let (ps,rest) = break empty ss in ps : chop (dropWhile empty rest) + empty = all isSpace + -- printing indent :: Int -> String -> String diff --git a/src/GF/Grammar/Macros.hs b/src/GF/Grammar/Macros.hs index cc43377cb..075da2a9d 100644 --- a/src/GF/Grammar/Macros.hs +++ b/src/GF/Grammar/Macros.hs @@ -128,6 +128,20 @@ unComputed t = case t of Computed v -> unComputed v _ -> t --- composSafeOp unComputed t + +{- +--- defined (better) in compile/PrOld + +stripTerm :: Term -> Term +stripTerm t = case t of + Q _ c -> Cn c + QC _ c -> Cn c + T ti psts -> T ti [(stripPatt p, stripTerm v) | (p,v) <- psts] + _ -> composSafeOp stripTerm t + where + stripPatt p = errVal p $ term2patt $ stripTerm $ patt2term p +-} + computed = Computed termForm :: Term -> Err ([(Ident)], Term, [Term]) diff --git a/src/GF/Infra/Option.hs b/src/GF/Infra/Option.hs index a46127f16..fe56c23fc 100644 --- a/src/GF/Infra/Option.hs +++ b/src/GF/Infra/Option.hs @@ -160,6 +160,8 @@ doCompute = iOpt "c" optimizeCanon = iOpt "opt" stripQualif = iOpt "strip" nostripQualif = iOpt "nostrip" +showAll = iOpt "all" +fromSource = iOpt "src" -- mainly for stand-alone useUnicode = iOpt "unicode" diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs index e6a0880ff..5136a00d0 100644 --- a/src/GF/Shell.hs +++ b/src/GF/Shell.hs @@ -80,7 +80,7 @@ data Command = | CPrintCanonXML | CPrintCanonXMLStruct | CPrintHistory - | CHelp + | CHelp (Maybe String) | CImpure ImpureCommand @@ -177,7 +177,7 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = case comm of CTestTokenizer -> changeArg (AString . optTokenizer opts gro . prCommandArg) sa CComputeConcrete m t -> - justOutput (putStrLn (err id prt ( + justOutput (putStrLn (err id (prt . stripTerm) ( string2srcTerm src m t >>= Co.computeConcrete src))) sa CTranslationQuiz il ol -> justOutput (teachTranslation opts (sgr il) (sgr ol)) sa @@ -201,7 +201,10 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = case comm of CSetFlag -> changeState (addGlobalOptions opts0) sa ---- deprec! CSetLocalFlag lang -> changeState (addLocalOptions lang opts0) sa - CHelp -> returnArg (AString txtHelpFile) sa + CHelp (Just c) -> returnArg (AString (txtHelpCommand c)) sa + CHelp _ + | oElem showAll opts -> returnArg (AString txtHelpFile) sa + | otherwise -> returnArg (AString txtHelpFileSummary) sa CPrintGrammar | oElem showOld opts -> returnArg (AString $ printGrammarOld (canModules st)) sa diff --git a/src/GF/Shell/PShell.hs b/src/GF/Shell/PShell.hs index f890a8dcf..0157112c8 100644 --- a/src/GF/Shell/PShell.hs +++ b/src/GF/Shell/PShell.hs @@ -104,7 +104,8 @@ pCommand ws = case ws of "pm" : [] -> aUnit CPrintMultiGrammar "po" : [] -> aUnit CPrintGlobalOptions "pl" : [] -> aUnit CPrintLanguages - "h" : [] -> aUnit CHelp + "h" : c : [] -> aUnit $ CHelp (Just (abbrevCommand c)) + "h" : [] -> aUnit $ CHelp Nothing "q" : [] -> aImpure ICQuit "eh" : f : [] -> aImpure (ICExecuteHistory f) diff --git a/src/HelpFile b/src/HelpFile index c99c999e5..523f69a7c 100644 --- a/src/HelpFile +++ b/src/HelpFile @@ -5,9 +5,11 @@ -- arguments. Commands are sorted by functionality. The short name is -- given first. +-- Type "h -all" for full help file, "h " for full help on a command. + -- commands that change the state -i, import: i File +i, import: i File Reads a grammar from File and compiles it into a GF runtime grammar. Files "include"d in File are read recursively, nubbing repetitions. If a grammar with the same language name is already in the state, @@ -140,7 +142,7 @@ cc, compute_concrete: cc Ident Term N.B.' The resulting Term is not a term in the sense of abstract syntax, and hence not a valid input to a Tree-demanding command. -t, translate: t Lang Lang String +t, translate: t Lang Lang String Parses String in Lang1 and linearizes the resulting Trees in Lang2. flags: -cat @@ -282,8 +284,11 @@ sa, speak_aloud: sa String flags: -language -h, help: h - Displays this help message. +h, help: h Command? + Displays the paragraph concerning the command from this help file. + Without the argument, shows the first lines of all paragraphs. + options + -all show the whole help file q, quit: q Exits GF. diff --git a/src/HelpFile.hs b/src/HelpFile.hs index b4ba4f58a..0cbfb026c 100644 --- a/src/HelpFile.hs +++ b/src/HelpFile.hs @@ -1,5 +1,15 @@ module HelpFile where +import Operations + +txtHelpFileSummary = + unlines $ map (concat . take 1 . lines) $ paragraphs txtHelpFile + +txtHelpCommand c = + case lookup c [(takeWhile (/=',') p,p) | p <- paragraphs txtHelpFile] of + Just s -> s + _ -> "Command not found." + txtHelpFile = "\n-- GF help file updated for GF 2.0, 24/3/2004." ++ "\n-- *: Commands and options marked with * are not yet implemented." ++ @@ -8,9 +18,11 @@ txtHelpFile = "\n-- arguments. Commands are sorted by functionality. The short name is" ++ "\n-- given first." ++ "\n" ++ + "\n-- Type \"h -all\" for full help file, \"h \" for full help on a command. " ++ + "\n" ++ "\n-- commands that change the state" ++ "\n" ++ - "\ni, import: i File" ++ + "\ni, import: i File" ++ "\n Reads a grammar from File and compiles it into a GF runtime grammar." ++ "\n Files \"include\"d in File are read recursively, nubbing repetitions." ++ "\n If a grammar with the same language name is already in the state," ++ @@ -21,7 +33,7 @@ txtHelpFile = "\n .gfr precompiled GF resource " ++ "\n .gfcm multilingual canonical GF" ++ "\n *.ebnf Extended BNF format" ++ - "\n *.cf Context-free (BNF) format" ++ + "\n .cf Context-free (BNF) format" ++ "\n options:" ++ "\n -old old: parse in GF<2.0 format" ++ "\n -v verbose: give lots of messages " ++ @@ -36,7 +48,7 @@ txtHelpFile = "\n -cnc set the name used for concrete syntax (with -old option)" ++ "\n -res set the name used for resource (with -old option)" ++ "\n " ++ - "\nrl, remove_language: rl Language" ++ + "\n* rl, remove_language: rl Language" ++ "\n Takes away the language from the state." ++ "\n" ++ "\ne, empty: e" ++ @@ -68,7 +80,8 @@ txtHelpFile = "\n" ++ "\npm, print_multigrammar: pm" ++ "\n Prints the current multilingual grammar into a .gfcm file." ++ - "\n " ++ + "\n (Automatically executes the strip command (s) before doing this.)" ++ + "\n" ++ "\npo, print_options: po" ++ "\n Print what modules there are in the state. Also" ++ "\n prints those flag values in the current state that differ from defaults." ++ @@ -142,7 +155,7 @@ txtHelpFile = "\n N.B.' The resulting Term is not a term in the sense of abstract syntax," ++ "\n and hence not a valid input to a Tree-demanding command." ++ "\n" ++ - "\nt, translate: t Lang Lang String" ++ + "\nt, translate: t Lang Lang String" ++ "\n Parses String in Lang1 and linearizes the resulting Trees in Lang2." ++ "\n flags:" ++ "\n -cat" ++ @@ -184,7 +197,7 @@ txtHelpFile = "\n -transform transform the result by this term processor" ++ "\n -number generate this number of terms at most" ++ "\n" ++ - "\nst, show_tree: st Tree" ++ + "\n* st, show_tree: st Tree" ++ "\n Prints the tree as a string. Unlike pt, this command cannot be" ++ "\n used in a pipe to produce a tree, since its output is a string." ++ "\n flags:" ++ @@ -209,7 +222,7 @@ txtHelpFile = "\n flags:" ++ "\n -cat" ++ "\n" ++ - "\n* tq, translation_quiz: tq Lang Lang" ++ + "\ntq, translation_quiz: tq Lang Lang" ++ "\n Random-generates translation exercises from Lang1 to Lang2," ++ "\n keeping score of success." ++ "\n To interrupt, type a full stop (.) alone on a line." ++ @@ -217,13 +230,13 @@ txtHelpFile = "\n flags:" ++ "\n -cat" ++ "\n" ++ - "\n* tl, translation_list: tl Lang Lang Int" ++ + "\ntl, translation_list: tl Lang Lang Int" ++ "\n Random-generates a list of Int translation exercises from Lang1 to Lang2." ++ "\n HINT: use wf to save the exercises in a file." ++ "\n flags:" ++ "\n -cat" ++ "\n" ++ - "\n* mq, morphology_quiz: mq" ++ + "\nmq, morphology_quiz: mq" ++ "\n Random-generates morphological exercises," ++ "\n keeping score of success." ++ "\n To interrupt, type a full stop (.) alone on a line." ++ @@ -233,7 +246,7 @@ txtHelpFile = "\n -cat" ++ "\n -lang" ++ "\n" ++ - "\n* ml, morphology_list: tl Int" ++ + "\nml, morphology_list: ml Int" ++ "\n Random-generates a list of Int morphological exercises," ++ "\n keeping score of success." ++ "\n HINT: use wf to save the exercises in a file." ++ @@ -284,8 +297,11 @@ txtHelpFile = "\n flags:" ++ "\n -language" ++ "\n" ++ - "\nh, help: h" ++ - "\n Displays this help message." ++ + "\nh, help: h Command?" ++ + "\n Displays the paragraph concerning the command from this help file." ++ + "\n Without the argument, shows the first lines of all paragraphs." ++ + "\n options" ++ + "\n -all show the whole help file" ++ "\n" ++ "\nq, quit: q" ++ "\n Exits GF." ++ diff --git a/src/Today.hs b/src/Today.hs index e947e5ef0..e8b0bfc69 100644 --- a/src/Today.hs +++ b/src/Today.hs @@ -1 +1 @@ -module Today where today = "Wed Mar 24 17:14:49 CET 2004" +module Today where today = "Fri Mar 26 19:27:07 CET 2004" diff --git a/src/tools/MkHelpFile.hs b/src/tools/MkHelpFile.hs index 9355a688e..3b88525a9 100644 --- a/src/tools/MkHelpFile.hs +++ b/src/tools/MkHelpFile.hs @@ -7,6 +7,13 @@ main = do mkHsFile ss = "module HelpFile where\n\n" ++ + "import Operations\n\n" ++ + "txtHelpFileSummary =\n" ++ + " unlines $ map (concat . take 1 . lines) $ paragraphs txtHelpFile\n\n" ++ + "txtHelpCommand c =\n" ++ + " case lookup c [(takeWhile (/=',') p,p) | p <- paragraphs txtHelpFile] of\n" ++ + " Just s -> s\n" ++ + " _ -> \"Command not found.\"\n\n" ++ "txtHelpFile =\n" ++ unlines (map mkOne ss) ++ " []"