summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Compile/GrammarToPGF.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-12-11 15:37:41 +0000
committerhallgren <hallgren@chalmers.se>2012-12-11 15:37:41 +0000
commit5e091d2e3dc428daa1d4b0d8df6e7b613adc22a9 (patch)
tree5c2c62eabdeab22d443cca85b9d7b48aec436c19 /src/compiler/GF/Compile/GrammarToPGF.hs
parent2623925e67b240f289b7ca507dd9c1ae194a93ce (diff)
partial evaluator work
* Evaluate operators once, not every time they are looked up * Remember the list of parameter values instead of recomputing it from the pattern type every time a table selection is made. * Quick fix for partial application of some predefined functions.
Diffstat (limited to 'src/compiler/GF/Compile/GrammarToPGF.hs')
-rw-r--r--src/compiler/GF/Compile/GrammarToPGF.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/compiler/GF/Compile/GrammarToPGF.hs b/src/compiler/GF/Compile/GrammarToPGF.hs
index 5515a8876..f9b008bf8 100644
--- a/src/compiler/GF/Compile/GrammarToPGF.hs
+++ b/src/compiler/GF/Compile/GrammarToPGF.hs
@@ -38,11 +38,13 @@ import Control.Monad.Identity
mkCanon2pgf :: Options -> SourceGrammar -> Ident -> IO D.PGF
mkCanon2pgf opts gr am = do
- (an,abs) <- mkAbstr gr am
- cncs <- mapM (mkConcr gr) (allConcretes gr am)
+ (an,abs) <- mkAbstr am
+ cncs <- mapM mkConcr (allConcretes gr am)
return $ updateProductionIndices (D.PGF Map.empty an abs (Map.fromList cncs))
where
- mkAbstr gr am = return (i2i am, D.Abstr flags funs cats bcode)
+ cenv = resourceValues gr
+
+ mkAbstr am = return (i2i am, D.Abstr flags funs cats bcode)
where
aflags =
concatOptions (reverse [mflags mo | (_,mo) <- modules gr, isModAbs mo])
@@ -64,7 +66,7 @@ mkCanon2pgf opts gr am = do
(map (\x -> (0,snd x)) . sortBy (compare `on` fst))
[(loc,i2i f) | ((m,f),AbsFun (Just (L loc ty)) _ _ (Just True),_) <- adefs, snd (GM.valCat ty) == cat]
- mkConcr gr cm = do
+ mkConcr cm = do
let cflags = concatOptions [mflags mo | (i,mo) <- modules gr, isModCnc mo,
Just r <- [lookup i (allExtendSpecs gr cm)]]
@@ -96,7 +98,7 @@ mkCanon2pgf opts gr am = do
-- we have to create the PMCFG code just before linking
addMissingPMCFGs seqs [] = return (seqs,[])
addMissingPMCFGs seqs (((m,id), info):is) = do
- (seqs,info) <- addPMCFG opts gr am cm seqs id info
+ (seqs,info) <- addPMCFG opts gr cenv am cm seqs id info
(seqs,is ) <- addMissingPMCFGs seqs is
return (seqs, ((m,id), info) : is)