diff options
| author | bjorn <bjorn@bringert.net> | 2008-05-28 15:10:36 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-05-28 15:10:36 +0000 |
| commit | 3fd1f5652a3af22e90a040a821d244a91a3553a0 (patch) | |
| tree | 15225df670e1fb1c55f4a9eb1ca45eae7952061f /src-3.0/GF/Compile/GrammarToGFCC.hs | |
| parent | 1bc74749aa7a9ec6ecfced68c0cdf38f43c7f9ef (diff) | |
Switch to new options handling.
This changes lots of stuff, let me know if it broke anything.
Comments:
- We use a local hacked version of GetOpt that allows long forms of commands to start with a single dash. This breaks other parts of GetOpt. For example, arguments to short options now require a =, and does not allo pace after the option character.
- The new command parsing is currently only used for the program command line, pragmas and the arguments for the 'i' shell command.
- I made a quick hack for the options for showTerm, which currently makes it impossible to use the print style flags for cc. This will be replaced by a facility for parsing command-specific options.
- The verbosity handling is broken in some places. I will fix that in a later patch.
Diffstat (limited to 'src-3.0/GF/Compile/GrammarToGFCC.hs')
| -rw-r--r-- | src-3.0/GF/Compile/GrammarToGFCC.hs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src-3.0/GF/Compile/GrammarToGFCC.hs b/src-3.0/GF/Compile/GrammarToGFCC.hs index c54e45c9d..4877ff556 100644 --- a/src-3.0/GF/Compile/GrammarToGFCC.hs +++ b/src-3.0/GF/Compile/GrammarToGFCC.hs @@ -61,16 +61,15 @@ addParsers gfcc = gfcc { D.concretes = Map.map conv (D.concretes gfcc) } canon2gfcc :: Options -> (Ident -> Ident -> C.Term) -> SourceGrammar -> D.GFCC canon2gfcc opts pars cgr@(M.MGrammar ((a,M.ModMod abm):cms)) = - (if (oElem (iOpt "show_canon") opts) then trace (prGrammar cgr) else id) $ + (if dump opts DumpCanon then trace (prGrammar cgr) else id) $ D.GFCC an cns gflags abs cncs where -- abstract an = (i2i a) cns = map (i2i . fst) cms abs = D.Abstr aflags funs cats catfuns - gflags = Map.fromList [(mkCId fg,x) | Just x <- [getOptVal opts (aOpt fg)]] - where fg = "firstlang" - aflags = Map.fromList [(mkCId f,x) | Opt (f,[x]) <- M.flags abm] + gflags = Map.empty + aflags = Map.fromList [(mkCId f,x) | (f,x) <- moduleOptionsGFO (M.flags abm)] mkDef pty = case pty of Yes t -> mkExp t _ -> CM.primNotion @@ -90,9 +89,9 @@ canon2gfcc opts pars cgr@(M.MGrammar ((a,M.ModMod abm):cms)) = (lang,D.Concr flags lins opers lincats lindefs printnames params fcfg) where js = tree2list (M.jments mo) - flags = Map.fromList [(mkCId f,x) | Opt (f,[x]) <- M.flags mo] + flags = Map.fromList [(mkCId f,x) | (f,x) <- moduleOptionsGFO (M.flags mo)] opers = Map.fromAscList [] -- opers will be created as optimization - utf = if elem (Opt ("coding",["utf8"])) (M.flags mo) + utf = if moduleFlag optEncoding (moduleOptions (M.flags mo)) == UTF_8 then D.convertStringsInTerm decodeUTF8 else id lins = Map.fromAscList [(i2i f, utf (mkTerm tr)) | (f,CncFun _ (Yes tr) _) <- js] @@ -227,14 +226,15 @@ reorder abs cg = M.MGrammar $ predefADefs ++ Look.allOrigInfos cg abs predefADefs = [(c, AbsCat (Yes []) Nope) | c <- [cFloat,cInt,cString]] - aflags = nubFlags $ - concat [M.flags mo | (_,mo) <- M.allModMod cg, M.isModAbs mo] + aflags = + concatModuleOptions [M.flags mo | (_,mo) <- M.allModMod cg, M.isModAbs mo] cncs = sortIds [(lang, concr lang) | lang <- M.allConcretes cg abs] - concr la = (nubFlags flags, + concr la = (flags, sortIds (predefCDefs ++ jments)) where jments = Look.allOrigInfos cg la - flags = concat [M.flags mo | + flags = concatModuleOptions + [M.flags mo | (i,mo) <- mos, M.isModCnc mo, Just r <- [lookup i (M.allExtendSpecs cg la)]] @@ -242,7 +242,6 @@ reorder abs cg = M.MGrammar $ [(c, CncCat (Yes GM.defLinType) Nope Nope) | c <- [cInt,cFloat,cString]] sortIds = sortBy (\ (f,_) (g,_) -> compare f g) - nubFlags = nubBy (\ (Opt (f,_)) (Opt (g,_)) -> f == g) -- one grammar per language - needed for symtab generation |
