regular expression patterns

This commit is contained in:
aarne
2006-01-07 14:39:40 +00:00
parent 16a4868efa
commit 69e1668f16
18 changed files with 173 additions and 137 deletions

View File

@@ -224,6 +224,7 @@ data Patt =
| PSeq Patt Patt
| PRep Patt
| PAs Ident Patt
| PNeg Patt
deriving (Eq,Ord,Show)
data PattAss =

View File

@@ -225,6 +225,7 @@ PDisj. Patt ::= Patt "|" Patt1 ;
PSeq. Patt ::= Patt "+" Patt1 ;
PRep. Patt1 ::= Patt2 "*" ;
PAs. Patt1 ::= Ident "@" Patt2 ;
PNeg. Patt1 ::= "-" Patt2 ;
coercions Patt 2 ;

View File

@@ -202,6 +202,7 @@ trp p = case p of
PAlt p q -> P.PDisj (trp p) (trp q)
PSeq p q -> P.PSeq (trp p) (trp q)
PRep p -> P.PRep (trp p)
PNeg p -> P.PNeg (trp p)
trAssign (lab, (mty, t)) = maybe (P.LDDef x t') (\ty -> P.LDFull x (trt ty) t') mty

File diff suppressed because one or more lines are too long

View File

@@ -456,6 +456,7 @@ Patt1 : Ident ListPatt { PC $1 $2 }
| Ident '.' Ident ListPatt { PQC $1 $3 $4 }
| Patt2 '*' { PRep $1 }
| Ident '@' Patt2 { PAs $1 $3 }
| '-' Patt2 { PNeg $2 }
| Patt2 { $1 }

View File

@@ -402,6 +402,7 @@ instance Print Patt where
PSeq patt0 patt -> prPrec i 0 (concatD [prt 0 patt0 , doc (showString "+") , prt 1 patt])
PRep patt -> prPrec i 1 (concatD [prt 2 patt , doc (showString "*")])
PAs id patt -> prPrec i 1 (concatD [prt 0 id , doc (showString "@") , prt 2 patt])
PNeg patt -> prPrec i 1 (concatD [doc (showString "-") , prt 2 patt])
prtList es = case es of
[x] -> (concatD [prt 2 x])

View File

@@ -559,7 +559,8 @@ transPatt x = case x of
PDisj p1 p2 -> liftM2 G.PAlt (transPatt p1) (transPatt p2)
PSeq p1 p2 -> liftM2 G.PSeq (transPatt p1) (transPatt p2)
PRep p -> liftM G.PRep (transPatt p)
PAs x p -> liftM2 G.PAs (transIdent x) (transPatt p)
PNeg p -> liftM G.PNeg (transPatt p)
PAs x p -> liftM2 G.PAs (transIdent x) (transPatt p)