summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-06-17 09:51:10 +0000
committerkrasimir <krasimir@chalmers.se>2010-06-17 09:51:10 +0000
commit183c87817394aad6adf6eb7e1bf3e297e1982e6f (patch)
tree19671789286a729f632eb45f54319a74c529d436 /src/compiler
parentd8284f61bf033fed293bbdeeed9c09a379a86100 (diff)
GF.Grammar.Lookup.allParamValues now works for table types as well
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/GF/Grammar/Lookup.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/compiler/GF/Grammar/Lookup.hs b/src/compiler/GF/Grammar/Lookup.hs
index c355056d5..d1473bbcd 100644
--- a/src/compiler/GF/Grammar/Lookup.hs
+++ b/src/compiler/GF/Grammar/Lookup.hs
@@ -133,15 +133,20 @@ lookupParamValues gr c = do
_ -> Bad $ render (ppQIdent Qualified c <+> text "has no parameter values defined")
allParamValues :: SourceGrammar -> Type -> Err [Term]
-allParamValues cnc ptyp = case ptyp of
- _ | Just n <- isTypeInts ptyp -> return [EInt i | i <- [0..n]]
- QC c -> lookupParamValues cnc c
- Q c -> lookupResDef cnc c >>= allParamValues cnc
- RecType r -> do
+allParamValues cnc ptyp =
+ case ptyp of
+ _ | Just n <- isTypeInts ptyp -> return [EInt i | i <- [0..n]]
+ QC c -> lookupParamValues cnc c
+ Q c -> lookupResDef cnc c >>= allParamValues cnc
+ RecType r -> do
let (ls,tys) = unzip $ sortByFst r
tss <- mapM (allParamValues cnc) tys
return [R (zipAssign ls ts) | ts <- combinations tss]
- _ -> Bad (render (text "cannot find parameter values for" <+> ppTerm Unqualified 0 ptyp))
+ Table pt vt -> do
+ pvs <- allParamValues cnc pt
+ vvs <- allParamValues cnc vt
+ return [V pt ts | ts <- combinations (replicate (length pvs) vvs)]
+ _ -> Bad (render (text "cannot find parameter values for" <+> ppTerm Unqualified 0 ptyp))
where
-- to normalize records and record types
sortByFst = sortBy (\ x y -> compare (fst x) (fst y))