Verified Commit 29cd0d76 authored by Camil Staps's avatar Camil Staps 🙂

Fix escape sequences; parse pipe; cleanup dcl

parent 24d29590
......@@ -5,4 +5,3 @@ from Data.Maybe import :: Maybe
from Regex import :: Regex
compile :: [Char] -> Maybe Regex
parse :: [Regex] [Char] -> Maybe ([Regex], [Char])
......@@ -40,6 +40,10 @@ parse [r:rs] ['*':cs] = Just ([Many True r:rs], cs)
parse [r:rs] ['?':'?':cs] = Just ([Optional False r:rs], cs)
parse [r:rs] ['?':cs] = Just ([Optional True r:rs], cs)
parse [Any rs:rs`] ['|':cs] = (\(r,cs)->([Any $ rs++r:rs`],cs)) <$> parse [] cs
parse [r:rs] ['|':cs] = (\(r`,cs)->([Any [r:r`]:rs],cs)) <$> parse [] cs
parse _ ['|':_] = Nothing
parse [r:rs] ['{':cs]
| isNothing fr = Nothing
| hd cs` == '}'
......@@ -99,7 +103,7 @@ singleChar ['\\':c:cs]
| otherwise
= Nothing
where
escapable = ['\\+*?()[]{}^$.']
escapable = ['\\+*?()[]{}^$.|']
(octs,nonocts) = spanMax 3 isOctDigit [c:cs]
......
definition module Regex.Util
escape_sequences :==
[ ('a', '\a')
, ('b', '\b')
, ('f', '\f')
, ('n', '\n')
, ('r', '\r')
, ('t', '\t')
, ('v', '\v')
[ ('a', '\x07')
, ('b', '\x08')
, ('f', '\x0c')
, ('n', '\x0a')
, ('r', '\x0d')
, ('t', '\x09')
, ('v', '\x0b')
, ('\\', '\\')
]
shorthand_classes :==
[ ('d', [('0','9')])
, ('D', [('\0','/'),(':','\255')])
, ('w', [('A','Z'),('a','z'),('0','9'),('_','_')])
[ ('w', [('A','Z'),('a','z'),('0','9'),('_','_')])
, ('W', [('\0','/'),(':','@'),('[','^'),('`','`'),('{','\255')])
, ('d', [('0','9')])
, ('D', [('\0','/'),(':','\255')])
, ('s', [(' ',' '),('\t','\n'),('\f','\r')])
, ('S', [('\0','\8'),('\11','\11'),('\14','\31'),('!','\255')])
]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment