summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2014-04-01 10:54:41 +0000
committerhallgren <hallgren@chalmers.se>2014-04-01 10:54:41 +0000
commit23c9a042cb69fc7f2a058b752f5248528f74bc2c (patch)
treee6d40d8627034feb26d6c9211dd274bde0b5a30a /src
parent13d4e01ecbd5a195b4505d8890b699c08a3ac1e5 (diff)
Bug fix for pattern macros in pre{}
This bug was introduced sometime between 2013-08-21 and 2013-11-01 and caused the function convertTerm in GF.Compile.GeneratePMCFG to encounter a EPatt where it expected Strs. I fixed it by applying the function getPatts (from the old partial evaluator) to the pattern.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Compile/GeneratePMCFG.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/GF/Compile/GeneratePMCFG.hs b/src/compiler/GF/Compile/GeneratePMCFG.hs
index 72e280b07..6eaaa9bff 100644
--- a/src/compiler/GF/Compile/GeneratePMCFG.hs
+++ b/src/compiler/GF/Compile/GeneratePMCFG.hs
@@ -397,8 +397,9 @@ convertTerm opts sel ctype (C t1 t2) = do v1 <- convertTerm opts sel ctype t1
convertTerm opts sel ctype (K t) = return (CStr [SymKS t])
convertTerm opts sel ctype Empty = return (CStr [])
convertTerm opts sel ctype (Alts s alts)= do CStr s <- convertTerm opts CNil ctype s
- alts <- forM alts $ \(u,Strs ps) -> do
+ alts <- forM alts $ \(u,alt) -> do
CStr u <- convertTerm opts CNil ctype u
+ Strs ps <- unPatt alt
ps <- mapM (convertTerm opts CNil ctype) ps
return (u,map unSym ps)
return (CStr [SymKP s alts])
@@ -407,6 +408,18 @@ convertTerm opts sel ctype (Alts s alts)= do CStr s <- convertTerm opts CNil cty
unSym (CStr [SymKS t]) = t
unSym _ = ppbug $ hang (text "invalid prefix in pre expression:") 4 (ppU 0 (Alts s alts))
+ unPatt (EPatt p) = fmap Strs (getPatts p)
+ unPatt u = return u
+
+ getPatts p = case p of
+ PAlt a b -> liftM2 (++) (getPatts a) (getPatts b)
+ PString s -> return [K s]
+ PSeq a b -> do
+ as <- getPatts a
+ bs <- getPatts b
+ return [K (s ++ t) | K s <- as, K t <- bs]
+ _ -> fail (render (text "not valid pattern in pre expression" <+> ppPatt Unqualified 0 p))
+
convertTerm opts sel ctype (Q (m,f))
| m == cPredef &&
f == cNonExist = return (CStr [SymNE])