GF.Grammar.Macros: add function collectPattOp

collectPattOp :: (Patt -> [a]) -> Patt -> [a]
This commit is contained in:
hallgren
2012-10-25 16:12:21 +00:00
parent d185938952
commit b2965730f1

View File

@@ -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