mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
GF.Grammar.Macros: add function collectPattOp
collectPattOp :: (Patt -> [a]) -> Patt -> [a]
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user