mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 01:22:51 -06:00
GF.Grammar.Lookup.allParamValues now works for table types as well
This commit is contained in:
@@ -133,7 +133,8 @@ lookupParamValues gr c = do
|
|||||||
_ -> Bad $ render (ppQIdent Qualified c <+> text "has no parameter values defined")
|
_ -> Bad $ render (ppQIdent Qualified c <+> text "has no parameter values defined")
|
||||||
|
|
||||||
allParamValues :: SourceGrammar -> Type -> Err [Term]
|
allParamValues :: SourceGrammar -> Type -> Err [Term]
|
||||||
allParamValues cnc ptyp = case ptyp of
|
allParamValues cnc ptyp =
|
||||||
|
case ptyp of
|
||||||
_ | Just n <- isTypeInts ptyp -> return [EInt i | i <- [0..n]]
|
_ | Just n <- isTypeInts ptyp -> return [EInt i | i <- [0..n]]
|
||||||
QC c -> lookupParamValues cnc c
|
QC c -> lookupParamValues cnc c
|
||||||
Q c -> lookupResDef cnc c >>= allParamValues cnc
|
Q c -> lookupResDef cnc c >>= allParamValues cnc
|
||||||
@@ -141,6 +142,10 @@ allParamValues cnc ptyp = case ptyp of
|
|||||||
let (ls,tys) = unzip $ sortByFst r
|
let (ls,tys) = unzip $ sortByFst r
|
||||||
tss <- mapM (allParamValues cnc) tys
|
tss <- mapM (allParamValues cnc) tys
|
||||||
return [R (zipAssign ls ts) | ts <- combinations tss]
|
return [R (zipAssign ls ts) | ts <- combinations tss]
|
||||||
|
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))
|
_ -> Bad (render (text "cannot find parameter values for" <+> ppTerm Unqualified 0 ptyp))
|
||||||
where
|
where
|
||||||
-- to normalize records and record types
|
-- to normalize records and record types
|
||||||
|
|||||||
Reference in New Issue
Block a user