From b2965730f1f052cfc956448728ad391a0082c0ae Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 25 Oct 2012 16:12:21 +0000 Subject: [PATCH] GF.Grammar.Macros: add function collectPattOp collectPattOp :: (Patt -> [a]) -> Patt -> [a] --- src/compiler/GF/Grammar/Macros.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/compiler/GF/Grammar/Macros.hs b/src/compiler/GF/Grammar/Macros.hs index 37054b98a..97146b197 100644 --- a/src/compiler/GF/Grammar/Macros.hs +++ b/src/compiler/GF/Grammar/Macros.hs @@ -496,7 +496,7 @@ composPattOp op patt = PAlt p1 p2 -> liftM2 PAlt (op p1) (op p2) PSeq p1 p2 -> liftM2 PSeq (op p1) (op p2) PRep p -> liftM PRep (op p) - _ -> return patt -- converts cases without subpatterns + _ -> return patt -- covers cases without subpatterns getTableType :: TInfo -> Err Type getTableType i = case i of @@ -533,6 +533,21 @@ collectOp co trm = case trm of Strs tt -> concatMap co tt _ -> [] -- covers K, Vr, Cn, Sort +collectPattOp :: (Patt -> [a]) -> Patt -> [a] +collectPattOp op patt = + case patt of + PC c ps -> concatMap op ps + PP qc ps -> concatMap op ps + PR as -> concatMap (op.snd) as + PT ty p -> op p + PAs x p -> op p + PImplArg p -> op p + PNeg p -> op p + PAlt p1 p2 -> op p1++op p2 + PSeq p1 p2 -> op p1++op p2 + PRep p -> op p + _ -> [] -- covers cases without subpatterns + -- | to find the word items in a term wordsInTerm :: Term -> [String] wordsInTerm trm = filter (not . null) $ case trm of