Verified Commit d8635595 authored by Camil Staps's avatar Camil Staps 🙂

Fix character class parsing; escape .

parent 29cd0d76
......@@ -122,8 +122,9 @@ charClass cls cs = (try_chars <|> shorthandClass cs) >>=
\(cls`,cs`) -> charClass (cls ++ cls`) cs`
where
try_chars = singleChar cs >>= \(c1,cs`) -> case cs` of
['-':cs``] = (\(c2,cs) -> ([(c1,c2)],cs)) <$> singleChar cs``
_ = Just ([(c1,c1)], cs`)
['-':']':cs``] = Just ([(c1,c1),('-','-')], [']':cs``])
['-':cs``] = (\(c2,cs) -> ([(c1,c2)],cs)) <$> singleChar cs``
_ = Just ([(c1,c1)], cs`)
shorthandClass :: [Char] -> Maybe ([(Char,Char)], [Char])
shorthandClass ['\\':c:cs] = (\cc -> (cc,cs)) <$> lookup c shorthand_classes
......
......@@ -80,6 +80,7 @@ where
where (c1`,c2`) = (escape c1, escape c2)
escape :: Char -> String
escape '.' = "\\."
escape c
| isMember c $ map snd escape_sequences
= hd [{'\\',n} \\ (n,c`) <- escape_sequences | c == c`]
......
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