diff --git a/doc/gf-history.html b/doc/gf-history.html index 1a6cb98b9..a6b3b970b 100644 --- a/doc/gf-history.html +++ b/doc/gf-history.html @@ -11,6 +11,34 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2 +
+ +14/11 (AR) Functions can be made unparsable (or "internal" as +in BNFC). This is done by i -noparse=file, where +the nonparsable functions are given in file using the +line format --# noparse Funs. This can be used e.g. to +rule out expensive parsing rules. It is used in +lib/resource/abstract/LangVP.gf to get parse values +structured with VP, which is obtained via transfer. +So far only the default (= old) parser generator supports this. + +
+ +14/11 (AR) Removed the restrictions how a lincat may look like. +Now any record type that has a value in GFC (i.e. without any +functions in it) can be used, e.g. {np : NP ; cn : Bool => CN}. +To display linearization values, only l -record shows +nice results. + +
+ +9/11 (AR) GF shell state can now have several abstract syntaxes with +their associated concrete syntaxes. This allows e.g. parsing with +resource while testing an application. One can also have a +parse-transfer-lin chain from one abstract syntax to another. + +
+ 1/11 (AR) Yet another method for adding probabilities: append --# prob Double to the end of a line defining a function. diff --git a/src/GF/API.hs b/src/GF/API.hs index b0953e083..7f2d95770 100644 --- a/src/GF/API.hs +++ b/src/GF/API.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/10/12 12:38:29 $ +-- > CVS $Date: 2005/11/14 16:03:40 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.38 $ +-- > CVS $Revision: 1.39 $ -- -- Application Programmer's Interface to GF; also used by Shell. AR 10/11/2001 ----------------------------------------------------------------------------- @@ -226,6 +226,8 @@ optLinearizeTree opts0 gr t = case getOptVal opts transferFun of | oElem showRecord opts = liftM prt . linearizeNoMark g c | oElem tableLin opts = liftM (unlines . map untok . prLinTable True) . allLinTables g c + | oElem showFields opts = liftM (unlines . map untok) . + allLinBranchFields g c | oElem showAll opts = liftM (unlines . map untok . prLinTable False) . allLinTables g c | otherwise = return . unlines . map untok . optIntOrOne . linTree2strings mk g c diff --git a/src/GF/API/IOGrammar.hs b/src/GF/API/IOGrammar.hs index f06799da1..ce522a9e5 100644 --- a/src/GF/API/IOGrammar.hs +++ b/src/GF/API/IOGrammar.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/10/31 19:02:35 $ +-- > CVS $Date: 2005/11/14 16:03:40 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.19 $ +-- > CVS $Revision: 1.20 $ -- -- for reading grammars and terms from strings and files ----------------------------------------------------------------------------- @@ -21,6 +21,7 @@ import GF.Compile.PGrammar import GF.Grammar.TypeCheck import GF.Compile.Compile import GF.Compile.ShellState +import GF.Compile.NoParse import GF.Probabilistic.Probabilistic import GF.Infra.Modules @@ -52,15 +53,16 @@ string2annotTree gr m = annotate gr . string2absTerm (prt m) ---- prt shellStateFromFiles :: Options -> ShellState -> FilePath -> IOE ShellState shellStateFromFiles opts st file = do + ign <- ioeIO $ getNoparseFromFile opts file let top = identC $ justModuleName file sh <- case fileSuffix file of "gfcm" -> do cenv <- compileOne opts (compileEnvShSt st []) file - ioeErr $ updateShellState opts Nothing st cenv + ioeErr $ updateShellState opts ign Nothing st cenv s | elem s ["cf","ebnf"] -> do let osb = addOptions (options []) opts grts <- compileModule osb st file - ioeErr $ updateShellState opts Nothing st grts + ioeErr $ updateShellState opts ign Nothing st grts _ -> do b <- ioeIO $ isOldFile file let opts' = if b then (addOption showOld opts) else opts @@ -70,7 +72,7 @@ shellStateFromFiles opts st file = do else addOptions (options [emitCode]) opts' grts <- compileModule osb st file let mtop = if oElem showOld opts' then Nothing else Just top - ioeErr $ updateShellState opts' mtop st grts + ioeErr $ updateShellState opts' ign mtop st grts if (isSetFlag opts probFile || oElem (iOpt "prob") opts) then do probs <- ioeIO $ getProbsFromFile opts file diff --git a/src/GF/CF/CFIdent.hs b/src/GF/CF/CFIdent.hs index 30b9f857d..fe1f1b663 100644 --- a/src/GF/CF/CFIdent.hs +++ b/src/GF/CF/CFIdent.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/21 16:21:08 $ --- > CVS $Author: bringert $ --- > CVS $Revision: 1.12 $ +-- > CVS $Date: 2005/11/14 16:03:40 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.13 $ -- -- symbols (categories, functions) for context-free grammars. ----------------------------------------------------------------------------- @@ -23,7 +23,8 @@ module GF.CF.CFIdent (-- * Tokens and categories mkCFFun, varCFFun, consCFFun, string2CFFun, stringCFFun, intCFFun, dummyCFFun, cfFun2String, cfFun2Ident, cfFun2Profile, metaCFFun, -- * CF Categories - mkCIdent, ident2CFCat, string2CFCat, catVarCF, cat2CFCat, cfCatString, cfCatInt, + mkCIdent, ident2CFCat, labels2CFCat, string2CFCat, + catVarCF, cat2CFCat, cfCatString, cfCatInt, moduleOfCFCat, cfCat2Cat, cfCat2Ident, lexCFCat, -- * CF Tokens string2CFTok, str2cftoks, @@ -40,6 +41,7 @@ import GF.Grammar.Macros (ident2label) import GF.Grammar.PrGrammar import GF.Data.Str import Data.Char (toLower, toUpper) +import Data.List (intersperse) -- | this type should be abstract data CFTok = @@ -144,6 +146,9 @@ mkCIdent m c = CIQ (identC m) (identC c) ident2CFCat :: CIdent -> Ident -> CFCat ident2CFCat mc d = CFCat (mc, L d) +labels2CFCat :: CIdent -> [Label] -> CFCat +labels2CFCat mc d = CFCat (mc, L (identC (concat (intersperse "." (map prt d))))) ---- + -- | standard way of making cf cat: label s string2CFCat :: String -> String -> CFCat string2CFCat m c = ident2CFCat (mkCIdent m c) (identC "s") diff --git a/src/GF/CF/CanonToCF.hs b/src/GF/CF/CanonToCF.hs index a0ec72cd9..44cec0fbb 100644 --- a/src/GF/CF/CanonToCF.hs +++ b/src/GF/CF/CanonToCF.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/05/31 12:47:52 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.14 $ +-- > CVS $Revision: 1.15 $ -- -- AR 27\/1\/2000 -- 3\/12\/2001 -- 8\/6\/2003 ----------------------------------------------------------------------------- @@ -36,28 +36,30 @@ import Control.Monad -- | The main function: for a given cnc module 'm', build the CF grammar with all the -- rules coming from modules that 'm' extends. The categories are qualified by -- the abstract module name 'a' that 'm' is of. -canon2cf :: Options -> CanonGrammar -> Ident -> Err CF -canon2cf opts gr c = tracePrt "#size of CF" (err id (show.length.rulesOfCF)) $ do -- peb 8/6-04 +-- The ign argument tells what rules not to generate a parser for. +canon2cf :: Options -> (Ident -> Bool) -> CanonGrammar -> Ident -> Err CF +canon2cf opts ign gr c = tracePrt "#size of CF" (err id (show.length.rulesOfCF)) $ do -- peb 8/6-04 let ms = M.allExtends gr c a <- M.abstractOfConcrete gr c let cncs = [m | (n, M.ModMod m) <- M.modules gr, elem n ms] let mms = [(a, tree2list (M.jments m)) | m <- cncs] cnc <- liftM M.jments $ M.lookupModMod gr c - rules0 <- liftM concat $ mapM (uncurry (cnc2cfCond opts cnc)) mms + rules0 <- liftM concat $ mapM (uncurry (cnc2cfCond opts ign cnc)) mms let bindcats = map snd $ allBindCatsOf gr let rules = filter (not . isCircularCF) rules0 ---- temporarily here let grules = groupCFRules rules let predef = mkCFPredef opts bindcats grules return $ CF predef -cnc2cfCond :: Options -> BinTree Ident Info -> +cnc2cfCond :: Options -> (Ident -> Bool) -> BinTree Ident Info -> Ident -> [(Ident,Info)] -> Err [CFRule] -cnc2cfCond opts cnc m gr = +cnc2cfCond opts ign cnc m gr = liftM concat $ mapM lin2cf [(m,fun,cat,args,lin) | - (fun, CncFun cat args lin _) <- gr, is fun] + (fun, CncFun cat args lin _) <- gr, notign fun, is fun] where is f = isInBinTree f cnc + notign = not . ign type IFun = Ident type ICat = CIdent @@ -65,24 +67,24 @@ type ICat = CIdent -- | all CF rules corresponding to a linearization rule lin2cf :: (Ident, IFun, ICat, [ArgVar], Term) -> Err [CFRule] lin2cf (m,fun,cat,args,lin) = errIn ("building CF rule for" +++ prt fun) $ do - rhss0 <- allLinValues lin -- :: [(Label, [([Patt],Term)])] - rhss1 <- mapM (mkCFItems m) (concat rhss0) -- :: [(Label, [[PreCFItem]])] + let rhss0 = allLinBranches lin -- :: [([Label], Term)] + rhss1 <- mapM (mkCFItems m) rhss0 -- :: [([Label], [[PreCFItem]])] mapM (mkCfRules m fun cat args) rhss1 >>= return . nub . concat -- | making sequences of CF items from every branch in a linearization -mkCFItems :: Ident -> (Label, [([Patt],Term)]) -> Err (Label, [[PreCFItem]]) -mkCFItems m (lab,pts) = do - itemss <- mapM (term2CFItems m) (map snd pts) - return (lab, concat itemss) ---- combinations? (test!) +mkCFItems :: Ident -> ([Label], Term) -> Err ([Label], [[PreCFItem]]) +mkCFItems m (labs,t) = do + items <- term2CFItems m t + return (labs, items) -- | making CF rules from sequences of CF items -mkCfRules :: Ident -> IFun -> ICat -> [ArgVar] -> (Label, [[PreCFItem]]) -> Err [CFRule] +mkCfRules :: Ident -> IFun -> ICat -> [ArgVar] -> ([Label], [[PreCFItem]]) -> Err [CFRule] mkCfRules m fun cat args (lab, itss) = mapM mkOneRule itss where mkOneRule its = do let nonterms = zip [0..] [(pos,d,v) | PNonterm _ pos d v <- its] profile = mkProfile nonterms - cfcat = CFCat (redirectIdent m cat,lab) + cfcat = labels2CFCat (redirectIdent m cat) lab cffun = CFFun (AC (CIQ m fun), profile) cfits = map precf2cf its return (cffun,(cfcat,cfits)) @@ -91,17 +93,17 @@ mkCfRules m fun cat args (lab, itss) = mapM mkOneRule itss mkOne (A c i) = mkOne (AB c 0 i) mkOne (AB _ b i) = (map mkB [0..b-1], [k | (k,(j,_,True)) <- nonterms, j==i]) where - mkB x = [k | (k,(j, LV y,False)) <- nonterms, j == i, y == x] + mkB x = [k | (k,(j, [LV y], False)) <- nonterms, j == i, y == x] -- | intermediate data structure of CFItems with information for profiles data PreCFItem = - PTerm RegExp -- ^ like ordinary Terminal - | PNonterm CIdent Integer Label Bool -- ^ cat, position, part\/bind, whether arg + PTerm RegExp -- ^ like ordinary Terminal + | PNonterm CIdent Integer [Label] Bool -- ^ cat, position, part\/bind, whether arg deriving Eq precf2cf :: PreCFItem -> CFItem precf2cf (PTerm r) = CFTerm r -precf2cf (PNonterm cm _ (L c) True) = CFNonterm (ident2CFCat cm c) +precf2cf (PNonterm cm _ ls True) = CFNonterm (labels2CFCat cm ls) precf2cf (PNonterm _ _ _ False) = CFNonterm catVarCF @@ -137,7 +139,7 @@ term2CFItems m t = errIn "forming cf items" $ case t of let itss = [[PTerm (RegAlts [s]) | s <- t] | Var t _ <- vs] tryMkCFTerm (its : itss) - _ -> prtBad "no cf for" t ---- + _ -> return [] ---- prtBad "no cf for" t ---- where @@ -163,13 +165,19 @@ term2CFItems m t = errIn "forming cf items" $ case t of counterparts ll = [map (!! i) ll | i <- [0..length (head ll) - 1]] tryMkCFTerm itss = return itss - extrR arg lab = case (arg,lab) of - (Arg (A cat pos), l@(L _)) -> return [[PNonterm (cIQ cat) pos l True]] - (Arg (A cat pos), l@(LV _)) -> return [[PNonterm (cIQ cat) pos l False]] - (Arg (AB cat b pos), l@(L _)) -> return [[PNonterm (cIQ cat) pos l True]] - (Arg (AB cat b pos), l@(LV _)) -> return [[PNonterm (cIQ cat) pos l False]] + extrR arg lab = case (arg0,labs) of + (Arg (A cat pos), [(LV _)]) -> return [[PNonterm (cIQ cat) pos labs False]] + (Arg (AB cat b pos), [(LV _)]) -> return [[PNonterm (cIQ cat) pos labs False]] + (Arg (A cat pos), _) -> return [[PNonterm (cIQ cat) pos labs True]] + (Arg (AB cat b pos), _) -> return [[PNonterm (cIQ cat) pos labs True]] ---- ?? _ -> prtBad "cannot extract record field from" arg + where + (arg0,labs) = headProj arg [lab] + + headProj r ls = case r of + P r0 l0 -> headProj r0 (l0:ls) + _ -> (r,ls) cIQ c = if isPredefCat c then CIQ cPredefAbs c else CIQ m c mkCFPredef :: Options -> [Ident] -> [CFRuleGroup] -> ([CFRuleGroup],CFPredef) diff --git a/src/GF/Canon/CMacros.hs b/src/GF/Canon/CMacros.hs index a89d13611..609e8e869 100644 --- a/src/GF/Canon/CMacros.hs +++ b/src/GF/Canon/CMacros.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/09/16 13:56:12 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.28 $ +-- > CVS $Revision: 1.29 $ -- -- Macros for building and analysing terms in GFC concrete syntax. -- @@ -225,6 +225,15 @@ allLinValues trm = do lts <- allLinFields trm mapM (mapPairsM (return . allCaseValues)) lts +-- | to gather all linearizations, even from nested records; params ignored +allLinBranches :: Term -> [([Label],Term)] +allLinBranches trm = case trm of + R rs -> [(l:ls,u) | Ass l t <- rs, (ls,u) <- allLinBranches t] + FV ts -> concatMap allLinBranches ts + T _ ts -> concatMap allLinBranches [t | Cas _ t <- ts] + V _ ts -> concatMap allLinBranches ts + _ -> [([],trm)] + redirectIdent :: A.Ident -> CIdent -> CIdent redirectIdent n f@(CIQ _ c) = CIQ n c diff --git a/src/GF/Compile/NoParse.hs b/src/GF/Compile/NoParse.hs new file mode 100644 index 000000000..0e37c9f95 --- /dev/null +++ b/src/GF/Compile/NoParse.hs @@ -0,0 +1,47 @@ +---------------------------------------------------------------------- +-- | +-- Module : NoParse +-- Maintainer : AR +-- Stability : (stable) +-- Portability : (portable) +-- +-- > CVS $Date: 2005/11/14 16:03:41 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.1 $ +-- +-- Probabilistic abstract syntax. AR 30\/10\/2005 +-- +-- (c) Aarne Ranta 2005 under GNU GPL +-- +-- Contents: decide what lin rules no parser is generated. +-- Usually a list of noparse idents from 'i -boparse=file'. + +----------------------------------------------------------------------------- + +module GF.Compile.NoParse ( + NoParse -- = Ident -> Bool + ,getNoparseFromFile -- :: Opts -> IO NoParse + ,doParseAll -- :: NoParse + ) where + +import GF.Infra.Ident +import GF.Data.Operations +import GF.Infra.Option + + +type NoParse = (Ident -> Bool) + +doParseAll :: NoParse +doParseAll = const False + +getNoparseFromFile :: Options -> FilePath -> IO NoParse +getNoparseFromFile opts file = do + let f = maybe file id $ getOptVal opts noparseFile + s <- readFile f + return $ igns s + where + igns s i = isInBinTree i $ buildTree $ flip zip (repeat ()) $ concat $ map getIgnores $ lines s +-- where +getIgnores s = case dropWhile (/="--#") (words s) of + _:"noparse":fs -> map identC fs + _ -> [] diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs index 3773d59f9..16285c44c 100644 --- a/src/GF/Compile/ShellState.hs +++ b/src/GF/Compile/ShellState.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/11/11 23:24:34 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.52 $ +-- > CVS $Revision: 1.53 $ -- -- (Description of the module) ----------------------------------------------------------------------------- @@ -32,6 +32,7 @@ import GF.CF.CFIdent import GF.CF.CanonToCF import GF.UseGrammar.Morphology import GF.Probabilistic.Probabilistic +import GF.Compile.NoParse import GF.Infra.Option import GF.Infra.Ident import GF.System.Arch (ModTime) @@ -174,14 +175,14 @@ cncModuleIdST = stateGrammarST -- | form a shell state from a canonical grammar grammar2shellState :: Options -> (CanonGrammar, G.SourceGrammar) -> Err ShellState grammar2shellState opts (gr,sgr) = - updateShellState opts Nothing emptyShellState ((0,sgr,gr),[]) --- is 0 safe? + updateShellState opts doParseAll Nothing emptyShellState ((0,sgr,gr),[]) --- is 0 safe? -- | update a shell state from a canonical grammar -updateShellState :: Options -> Maybe Ident -> ShellState -> +updateShellState :: Options -> NoParse -> Maybe Ident -> ShellState -> ((Int,G.SourceGrammar,CanonGrammar),[(FilePath,ModTime)]) -> ---- (CanonGrammar,(G.SourceGrammar,[(FilePath,ModTime)])) -> Err ShellState -updateShellState opts mcnc sh ((_,sgr,gr),rts) = do +updateShellState opts ign mcnc sh ((_,sgr,gr),rts) = do let cgr0 = M.updateMGrammar (canModules sh) gr -- a0 = abstract of old state @@ -210,7 +211,7 @@ updateShellState opts mcnc sh ((_,sgr,gr),rts) = do concr0 = ifNull Nothing (return . head) concrs notInrts f = notElem f $ map fst rts subcgr = unSubelimCanon cgr - cfs <- mapM (canon2cf opts subcgr) concrs --- why need to update all... + cfs <- mapM (canon2cf opts ign subcgr) concrs --- why need to update all... let morphos = map (mkMorpho subcgr) concrs let probss = [] ----- diff --git a/src/GF/IDE/IDECommands.hs b/src/GF/IDE/IDECommands.hs index f879a87cd..56d392a71 100644 --- a/src/GF/IDE/IDECommands.hs +++ b/src/GF/IDE/IDECommands.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/11/09 22:34:01 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.1 $ +-- > CVS $Revision: 1.2 $ -- -- Commands usable in grammar-writing IDE. ----------------------------------------------------------------------------- @@ -57,6 +57,10 @@ execIDECommand c state = case c of return $ emptyIDEState env IDEAbstract a -> return $ state {ideAbstract = Just a} ---- check a exists or import it + IDEConcrete a -> + return $ state {ideCurrentCnc = Just a} ---- check a exists or import it + IDELin a -> + return $ state {ideCurrentLin = Just a} ---- check a exists IDEEdit s -> execEdit s IDEShell s -> diff --git a/src/GF/Infra/Option.hs b/src/GF/Infra/Option.hs index bf364ba50..6dc68e257 100644 --- a/src/GF/Infra/Option.hs +++ b/src/GF/Infra/Option.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/10/30 23:44:00 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.33 $ +-- > CVS $Revision: 1.34 $ -- -- Options and flags used in GF shell commands and files. -- @@ -251,6 +251,7 @@ optimizeValues = iOpt "val" stripQualif = iOpt "strip" nostripQualif = iOpt "nostrip" showAll = iOpt "all" +showFields = iOpt "fields" showMulti = iOpt "multi" fromSource = iOpt "src" makeConcrete = iOpt "examples" @@ -311,6 +312,7 @@ extractGr = aOpt "extract" pathList = aOpt "path" uniCoding = aOpt "coding" probFile = aOpt "probs" +noparseFile = aOpt "noparse" -- peb 16/3-05: gfcConversion :: String -> Option diff --git a/src/GF/Shell/HelpFile.hs b/src/GF/Shell/HelpFile.hs index 7daac5816..61532737b 100644 --- a/src/GF/Shell/HelpFile.hs +++ b/src/GF/Shell/HelpFile.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/11/01 20:09:04 $ --- > CVS $Author: bringert $ --- > CVS $Revision: 1.19 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.20 $ -- -- Help on shell commands. Generated from HelpFile by 'make help'. -- PLEASE DON'T EDIT THIS FILE. @@ -72,6 +72,7 @@ txtHelpFile = "\n -optimize select an optimization to override file-defined flags" ++ "\n -conversion select parsing method (values strict|nondet)" ++ "\n -probs read probabilities from file (format (--# prob) Fun Double)" ++ + "\n -noparse read nonparsable functions from file (format --# noparse Funs) " ++ "\n examples:" ++ "\n i English.gf -- ordinary import of Concrete" ++ "\n i -retain german/ParadigmsGer.gf -- import of Resource to test" ++ diff --git a/src/GF/Shell/ShellCommands.hs b/src/GF/Shell/ShellCommands.hs index c5b0c479e..56cedc202 100644 --- a/src/GF/Shell/ShellCommands.hs +++ b/src/GF/Shell/ShellCommands.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/10/31 19:02:35 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.45 $ +-- > CVS $Revision: 1.46 $ -- -- The datatype of shell commands and the list of their options. ----------------------------------------------------------------------------- @@ -166,7 +166,7 @@ optionsOfCommand co = case co of "cat lang lexer parser number depth rawtrees unlexer optimize path conversion printer" CImport _ -> both "old v s src retain nocf nocheckcirc cflexer noemit o ex prob" - "abs cnc res path optimize conversion cat probs" + "abs cnc res path optimize conversion cat probs noparse" CRemoveLanguage _ -> none CEmptyState -> none CStripState -> none diff --git a/src/GF/UseGrammar/Linear.hs b/src/GF/UseGrammar/Linear.hs index 6de767a06..24f7312c5 100644 --- a/src/GF/UseGrammar/Linear.hs +++ b/src/GF/UseGrammar/Linear.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/06/29 16:27:56 $ +-- > CVS $Date: 2005/11/14 16:03:41 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.18 $ +-- > CVS $Revision: 1.19 $ -- -- Linearization for canonical GF. AR 7\/6\/2003 ----------------------------------------------------------------------------- @@ -212,6 +212,16 @@ allLinTables gr c t = do gets (ps,t) = liftM (curry id ps . cc . map str2strings) $ strsFromTerm t cc = concat . intersperse ["/"] +-- | the value is a list of strings gathered from all fields + +allLinBranchFields :: CanonGrammar -> Ident -> A.Tree -> Err [String] +allLinBranchFields gr c trm = do + r <- linearizeNoMark gr c trm >>= expandLinTables gr + return [s | (_,t) <- allLinBranches r, s <- gets t] + where + gets t = concat [cc (map str2strings s) | Ok s <- [strsFromTerm t]] + cc = concat . intersperse ["/"] + prLinTable :: Bool -> [[(Label,[([Patt],[String])])]] -> [String] prLinTable pars = concatMap prOne . concat where prOne (lab,pss) = (if pars then ((prt lab) :) else id) (map pr pss) ---- diff --git a/src/HelpFile b/src/HelpFile index 68f23aee1..08cd01074 100644 --- a/src/HelpFile +++ b/src/HelpFile @@ -43,6 +43,7 @@ i, import: i File -optimize select an optimization to override file-defined flags -conversion select parsing method (values strict|nondet) -probs read probabilities from file (format (--# prob) Fun Double) + -noparse read nonparsable functions from file (format --# noparse Funs) examples: i English.gf -- ordinary import of Concrete i -retain german/ParadigmsGer.gf -- import of Resource to test