summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-10-25 16:12:21 +0000
committerhallgren <hallgren@chalmers.se>2012-10-25 16:12:21 +0000
commitb2965730f1f052cfc956448728ad391a0082c0ae (patch)
tree710df039d8b74954ac4ca0fe5c8a5606dd456774 /src
parentd18593895294b3d2203f7e6fab253f1b5835ff85 (diff)
GF.Grammar.Macros: add function collectPattOp
collectPattOp :: (Patt -> [a]) -> Patt -> [a]
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Grammar/Macros.hs17
1 files changed, 16 insertions, 1 deletions
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