Open uscitp-rongcuid opened 8 years ago
Hello,
If I have something like this: [\dabcd], the library does not generate correctly. Problem is probably here(marked as comment):
[\dabcd]
atchOne :: (?pat :: Pattern) => SChar -> SBool matchOne cur = case ?pat of PChar {getPatternChar = ch} -> isChar ch PDot{} -> isDot PGroup Nothing p -> let ?pat = p in matchOne cur PAny {getPatternSet = pset} -> case pset of PatternSet (Just cset) _ _ _ -> oneOf $ toList cset _ -> error "TODO" PAnyNot {getPatternSet = pset} -> case pset of PatternSet (Just cset) _ _ _ -> noneOf $ toList cset _ -> error "TODO" PEscape {getPatternChar = ch} -> case ch of 'n' -> isChar '\n' 't' -> isChar '\t' 'r' -> isChar '\r' 'f' -> isChar '\f' 'a' -> isChar '\a' 'e' -> isChar '\ESC' 'd' -> isDigit 'w' -> isWordChar 's' -> isWhiteSpace 'W' -> (isDot &&& bnot isWordChar) 'S' -> (isDot &&& bnot isWhiteSpace) 'D' -> (isDot &&& bnot isDigit) _ -> isChar ch _ -> false where ord = toEnum . Data.Char.ord isChar ch = cur .== ord ch isDot = (cur .>= ord ' ' &&& cur .<= ord '~') oneOf cs = bOr [ ord ch .== cur | ch <- cs ] -- <<< Here noneOf cs = bAnd ((cur .>= ord ' ') : (cur .<= ord '~') : [ ord ch ./= cur | ch <- cs ]) isDigit = (ord '0' .<= cur &&& ord '9' .>= cur) isWordChar = (cur .>= ord 'A' &&& cur .<= ord 'Z') ||| (cur .>= ord 'a' &&& cur .<= ord 'z') ||| (cur .== ord '_') isWhiteSpace = cur .== 32 ||| (9 .<= cur &&& 13 .>= cur &&& 11 ./= cur)
Apparently the function does not account for escapes inside.
Indeed. pull requests welcome!
Hello,
If I have something like this:
[\dabcd]
, the library does not generate correctly. Problem is probably here(marked as comment):Apparently the function does not account for escapes inside.