Better help.

This commit is contained in:
aarne
2004-03-26 20:08:30 +00:00
parent 2433403b62
commit 6719aedde3
11 changed files with 81 additions and 26 deletions

View File

@@ -1,12 +1,12 @@
#! /bin/sh #! /bin/sh
# change the value of GFHOME to the directory where you have the gf binary # 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 # /.../chalmers.se/fs/cab/cs/.users/markus/home/GF1
JGUILIB=$GFHOME/java/ JGUILIB=$GFHOME/java/
GF=$GFHOME/gf2 GF=/usr/local/bin/gf
JGUI=GFEditor JGUI=GFEditor2
java -cp $JGUILIB $JGUI "$GF -java $*" java -cp $JGUILIB $JGUI "$GF -java $*"

View File

@@ -58,10 +58,11 @@ markSubterm (beg, end) t = case t of
R rs -> R $ map markField rs R rs -> R $ map markField rs
T ty cs -> T ty [Cas p (mark v) | Cas p v <- cs] T ty cs -> T ty [Cas p (mark v) | Cas p v <- cs]
FV ts -> FV $ map mark ts 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 where
mark = markSubterm (beg, end) mark = markSubterm (beg, end)
markField lt@(Ass l t) = if isLinLabel l then (Ass l (mark t)) else lt 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 :: String -> Term
tK = K . KS tK = K . KS

View File

@@ -311,6 +311,12 @@ type WParser a b = [a] -> [(b,[a])] -- old Wadler style parser
wParseResults :: WParser a b -> [a] -> [b] wParseResults :: WParser a b -> [a] -> [b]
wParseResults p aa = [b | (b,[]) <- p aa] 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 -- printing
indent :: Int -> String -> String indent :: Int -> String -> String

View File

@@ -128,6 +128,20 @@ unComputed t = case t of
Computed v -> unComputed v Computed v -> unComputed v
_ -> t --- composSafeOp unComputed t _ -> 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 computed = Computed
termForm :: Term -> Err ([(Ident)], Term, [Term]) termForm :: Term -> Err ([(Ident)], Term, [Term])

View File

@@ -160,6 +160,8 @@ doCompute = iOpt "c"
optimizeCanon = iOpt "opt" optimizeCanon = iOpt "opt"
stripQualif = iOpt "strip" stripQualif = iOpt "strip"
nostripQualif = iOpt "nostrip" nostripQualif = iOpt "nostrip"
showAll = iOpt "all"
fromSource = iOpt "src"
-- mainly for stand-alone -- mainly for stand-alone
useUnicode = iOpt "unicode" useUnicode = iOpt "unicode"

View File

@@ -80,7 +80,7 @@ data Command =
| CPrintCanonXML | CPrintCanonXML
| CPrintCanonXMLStruct | CPrintCanonXMLStruct
| CPrintHistory | CPrintHistory
| CHelp | CHelp (Maybe String)
| CImpure ImpureCommand | 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 CTestTokenizer -> changeArg (AString . optTokenizer opts gro . prCommandArg) sa
CComputeConcrete m t -> CComputeConcrete m t ->
justOutput (putStrLn (err id prt ( justOutput (putStrLn (err id (prt . stripTerm) (
string2srcTerm src m t >>= Co.computeConcrete src))) sa string2srcTerm src m t >>= Co.computeConcrete src))) sa
CTranslationQuiz il ol -> justOutput (teachTranslation opts (sgr il) (sgr ol)) 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 CSetFlag -> changeState (addGlobalOptions opts0) sa
---- deprec! CSetLocalFlag lang -> changeState (addLocalOptions lang 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 CPrintGrammar
| oElem showOld opts -> returnArg (AString $ printGrammarOld (canModules st)) sa | oElem showOld opts -> returnArg (AString $ printGrammarOld (canModules st)) sa

View File

@@ -104,7 +104,8 @@ pCommand ws = case ws of
"pm" : [] -> aUnit CPrintMultiGrammar "pm" : [] -> aUnit CPrintMultiGrammar
"po" : [] -> aUnit CPrintGlobalOptions "po" : [] -> aUnit CPrintGlobalOptions
"pl" : [] -> aUnit CPrintLanguages "pl" : [] -> aUnit CPrintLanguages
"h" : [] -> aUnit CHelp "h" : c : [] -> aUnit $ CHelp (Just (abbrevCommand c))
"h" : [] -> aUnit $ CHelp Nothing
"q" : [] -> aImpure ICQuit "q" : [] -> aImpure ICQuit
"eh" : f : [] -> aImpure (ICExecuteHistory f) "eh" : f : [] -> aImpure (ICExecuteHistory f)

View File

@@ -5,9 +5,11 @@
-- arguments. Commands are sorted by functionality. The short name is -- arguments. Commands are sorted by functionality. The short name is
-- given first. -- given first.
-- Type "h -all" for full help file, "h <CommandName>" for full help on a command.
-- commands that change the state -- 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. Reads a grammar from File and compiles it into a GF runtime grammar.
Files "include"d in File are read recursively, nubbing repetitions. Files "include"d in File are read recursively, nubbing repetitions.
If a grammar with the same language name is already in the state, 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, 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. 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. Parses String in Lang1 and linearizes the resulting Trees in Lang2.
flags: flags:
-cat -cat
@@ -282,8 +284,11 @@ sa, speak_aloud: sa String
flags: flags:
-language -language
h, help: h h, help: h Command?
Displays this help message. 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 q, quit: q
Exits GF. Exits GF.

View File

@@ -1,5 +1,15 @@
module HelpFile where 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 = txtHelpFile =
"\n-- GF help file updated for GF 2.0, 24/3/2004." ++ "\n-- GF help file updated for GF 2.0, 24/3/2004." ++
"\n-- *: Commands and options marked with * are not yet implemented." ++ "\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-- arguments. Commands are sorted by functionality. The short name is" ++
"\n-- given first." ++ "\n-- given first." ++
"\n" ++ "\n" ++
"\n-- Type \"h -all\" for full help file, \"h <CommandName>\" for full help on a command. " ++
"\n" ++
"\n-- commands that change the state" ++ "\n-- commands that change the state" ++
"\n" ++ "\n" ++
"\ni, import: i File" ++ "\ni, import: i File" ++
"\n Reads a grammar from File and compiles it into a GF runtime grammar." ++ "\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 Files \"include\"d in File are read recursively, nubbing repetitions." ++
"\n If a grammar with the same language name is already in the state," ++ "\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 .gfr precompiled GF resource " ++
"\n .gfcm multilingual canonical GF" ++ "\n .gfcm multilingual canonical GF" ++
"\n *.ebnf Extended BNF format" ++ "\n *.ebnf Extended BNF format" ++
"\n *.cf Context-free (BNF) format" ++ "\n .cf Context-free (BNF) format" ++
"\n options:" ++ "\n options:" ++
"\n -old old: parse in GF<2.0 format" ++ "\n -old old: parse in GF<2.0 format" ++
"\n -v verbose: give lots of messages " ++ "\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 -cnc set the name used for concrete syntax (with -old option)" ++
"\n -res set the name used for resource (with -old option)" ++ "\n -res set the name used for resource (with -old option)" ++
"\n " ++ "\n " ++
"\nrl, remove_language: rl Language" ++ "\n* rl, remove_language: rl Language" ++
"\n Takes away the language from the state." ++ "\n Takes away the language from the state." ++
"\n" ++ "\n" ++
"\ne, empty: e" ++ "\ne, empty: e" ++
@@ -68,7 +80,8 @@ txtHelpFile =
"\n" ++ "\n" ++
"\npm, print_multigrammar: pm" ++ "\npm, print_multigrammar: pm" ++
"\n Prints the current multilingual grammar into a .gfcm file." ++ "\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" ++ "\npo, print_options: po" ++
"\n Print what modules there are in the state. Also" ++ "\n Print what modules there are in the state. Also" ++
"\n prints those flag values in the current state that differ from defaults." ++ "\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 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 and hence not a valid input to a Tree-demanding command." ++
"\n" ++ "\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 Parses String in Lang1 and linearizes the resulting Trees in Lang2." ++
"\n flags:" ++ "\n flags:" ++
"\n -cat" ++ "\n -cat" ++
@@ -184,7 +197,7 @@ txtHelpFile =
"\n -transform transform the result by this term processor" ++ "\n -transform transform the result by this term processor" ++
"\n -number generate this number of terms at most" ++ "\n -number generate this number of terms at most" ++
"\n" ++ "\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 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 used in a pipe to produce a tree, since its output is a string." ++
"\n flags:" ++ "\n flags:" ++
@@ -209,7 +222,7 @@ txtHelpFile =
"\n flags:" ++ "\n flags:" ++
"\n -cat" ++ "\n -cat" ++
"\n" ++ "\n" ++
"\n* tq, translation_quiz: tq Lang Lang" ++ "\ntq, translation_quiz: tq Lang Lang" ++
"\n Random-generates translation exercises from Lang1 to Lang2," ++ "\n Random-generates translation exercises from Lang1 to Lang2," ++
"\n keeping score of success." ++ "\n keeping score of success." ++
"\n To interrupt, type a full stop (.) alone on a line." ++ "\n To interrupt, type a full stop (.) alone on a line." ++
@@ -217,13 +230,13 @@ txtHelpFile =
"\n flags:" ++ "\n flags:" ++
"\n -cat" ++ "\n -cat" ++
"\n" ++ "\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 Random-generates a list of Int translation exercises from Lang1 to Lang2." ++
"\n HINT: use wf to save the exercises in a file." ++ "\n HINT: use wf to save the exercises in a file." ++
"\n flags:" ++ "\n flags:" ++
"\n -cat" ++ "\n -cat" ++
"\n" ++ "\n" ++
"\n* mq, morphology_quiz: mq" ++ "\nmq, morphology_quiz: mq" ++
"\n Random-generates morphological exercises," ++ "\n Random-generates morphological exercises," ++
"\n keeping score of success." ++ "\n keeping score of success." ++
"\n To interrupt, type a full stop (.) alone on a line." ++ "\n To interrupt, type a full stop (.) alone on a line." ++
@@ -233,7 +246,7 @@ txtHelpFile =
"\n -cat" ++ "\n -cat" ++
"\n -lang" ++ "\n -lang" ++
"\n" ++ "\n" ++
"\n* ml, morphology_list: tl Int" ++ "\nml, morphology_list: ml Int" ++
"\n Random-generates a list of Int morphological exercises," ++ "\n Random-generates a list of Int morphological exercises," ++
"\n keeping score of success." ++ "\n keeping score of success." ++
"\n HINT: use wf to save the exercises in a file." ++ "\n HINT: use wf to save the exercises in a file." ++
@@ -284,8 +297,11 @@ txtHelpFile =
"\n flags:" ++ "\n flags:" ++
"\n -language" ++ "\n -language" ++
"\n" ++ "\n" ++
"\nh, help: h" ++ "\nh, help: h Command?" ++
"\n Displays this help message." ++ "\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" ++ "\n" ++
"\nq, quit: q" ++ "\nq, quit: q" ++
"\n Exits GF." ++ "\n Exits GF." ++

View File

@@ -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"

View File

@@ -7,6 +7,13 @@ main = do
mkHsFile ss = mkHsFile ss =
"module HelpFile where\n\n" ++ "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" ++ "txtHelpFile =\n" ++
unlines (map mkOne ss) ++ unlines (map mkOne ss) ++
" []" " []"