From 80fe693546552eed32135cf01195954f4f812760 Mon Sep 17 00:00:00 2001 From: hallgren Date: Sat, 16 Mar 2013 13:36:23 +0000 Subject: Fix a problem with pattern macros in pre { } expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old partial evaluator has special rules to convert pattern macros in pre { } expressions. These rules were missing in the new partial evaluator. --- src/compiler/GF/Compile/GeneratePMCFG.hs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/compiler/GF/Compile/GeneratePMCFG.hs') diff --git a/src/compiler/GF/Compile/GeneratePMCFG.hs b/src/compiler/GF/Compile/GeneratePMCFG.hs index d1765729e..2db007635 100644 --- a/src/compiler/GF/Compile/GeneratePMCFG.hs +++ b/src/compiler/GF/Compile/GeneratePMCFG.hs @@ -374,12 +374,22 @@ convertTerm opts sel ctype (K t) = return (CStr [SymKS [t]]) convertTerm opts sel ctype Empty = return (CStr []) convertTerm opts sel ctype (Alts s alts) = return (CStr [SymKP (strings s) [Alt (strings u) (strings v) | (u,v) <- alts]]) - where - strings (K s) = [s] - strings (C u v) = strings u ++ strings v - strings (Strs ss) = concatMap strings ss - strings Empty = [] -- ?? - strings t = bug $ "strings "++show t + where + strings (K s) = [s] + strings (C u v) = strings u ++ strings v + strings (Strs ss) = concatMap strings ss + strings (EPatt p) = getPatts p + strings Empty = [] -- ?? + strings t = bug $ "strings "++show t + + getPatts p = + case p of + PAlt a b -> getPatts a ++ getPatts b + PString s -> [s] + PSeq a b -> [s ++ t | s <- getPatts a, t <- getPatts b] + _ -> ppbug $ hang (text "not valid pattern in pre expression:") + 4 + (ppPatt Unqualified 0 p) convertTerm opts sel@(CProj l _) ctype (ExtR t1 t2@(R rs2)) | l `elem` map fst rs2 = convertTerm opts sel ctype t2 -- cgit v1.2.3