diff options
| author | krasimir <krasimir@chalmers.se> | 2010-03-24 11:11:55 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2010-03-24 11:11:55 +0000 |
| commit | 68482aa7e9882ab8d65fb5fe261efc0e807f6dfd (patch) | |
| tree | b818f5c25002f0be2eefad441e62aa08c959cbe6 /src/compiler/GF/Compile/GrammarToPGF.hs | |
| parent | 76d155af0eb6174e479ec6c2023554984c14106f (diff) | |
now for every category we store, in PGF, the list of functions for it in source-code order. The order matters for the termination of the exhaustive generation with dependent types.
Diffstat (limited to 'src/compiler/GF/Compile/GrammarToPGF.hs')
| -rw-r--r-- | src/compiler/GF/Compile/GrammarToPGF.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/compiler/GF/Compile/GrammarToPGF.hs b/src/compiler/GF/Compile/GrammarToPGF.hs index cb447f536..3c4e0445b 100644 --- a/src/compiler/GF/Compile/GrammarToPGF.hs +++ b/src/compiler/GF/Compile/GrammarToPGF.hs @@ -25,6 +25,7 @@ import GF.Infra.Option import GF.Data.Operations import Data.List +import Data.Function import Data.Char (isDigit,isSpace) import qualified Data.Map as Map import qualified Data.ByteString.Char8 as BS @@ -56,7 +57,7 @@ canon2pgf opts pars cgr@(M.MGrammar ((a,abm):cms)) = do where -- abstract an = (i2i a) - abs = D.Abstr aflags funs cats Map.empty + abs = D.Abstr aflags funs cats gflags = Map.empty aflags = Map.fromList [(mkCId f,C.LStr x) | (f,x) <- optionsPGF (M.flags abm)] @@ -70,11 +71,12 @@ canon2pgf opts pars cgr@(M.MGrammar ((a,abm):cms)) = do lfuns = [(f', (mkType [] ty, mkArrity ma, mkDef pty)) | (f,AbsFun (Just (L _ ty)) ma pty) <- tree2list (M.jments abm), let f' = i2i f] funs = Map.fromAscList lfuns - lcats = [(i2i c, snd (mkContext [] cont)) | + lcats = [(i2i c, (snd (mkContext [] cont),catfuns c)) | (c,AbsCat (Just (L _ cont))) <- tree2list (M.jments abm)] cats = Map.fromAscList lcats - catfuns = Map.fromList - [(cat,[f | (f, (C.DTyp _ c _,_,_)) <- lfuns, c==cat]) | (cat,_) <- lcats] + catfuns cat = + (map snd . sortBy (compare `on` fst)) + [(loc,i2i f) | (f,AbsFun (Just (L loc ty)) _ _) <- tree2list (M.jments abm), snd (GM.valCat ty) == cat] mkConcr lang0 lang mo = do lins' <- case mapM (checkLin (funs,lins,lincats) lang) (Map.toList lins) of |
