Open rehno-lindeque opened 10 years ago
I'm having a little trouble understanding the first group ([^?]+\bvalues\s*)
in the regex though (my perl is a bit novice). I've implemented this as skipWhile1 (/= '?') *> take 1 *> stringCI "values" *> skipSpace
in attoparsec, but I'm almost sure this must be wrong - I'm not sure how to parse [^?]+\b
correctly. I'd be grateful for any help!
For reference here's the full regex
re = compile "^([^?]+\\bvalues\\s*)\
\(\\(\\s*[?](?:\\s*,\\s*[?])*\\s*\\))\
\([^?]*)$"
[caseless]
and my attoparsec implementation
skipWhile1 f = satisfy f *> skipWhile f
parser :: Parser (ByteString, ByteString, ByteString)
parser = do
-- Skip VALUES keyword
skipWhile1 (/= '?') *> take 1 *> stringCI "values" *> skipSpace
-- Take (...?
before <- char '(' *> takeTill (== '?')
-- Skip ?,?,?,...
skipMany (skipSpace *> char ',' *> skipSpace *> char '?')
-- Take )
qbits <- takeWhile (== ' ') <* char ')'
after <- takeWhile (/= '?')
endOfInput
return ('(' `cons` before, qbits `snoc` ')', after)
does that look ok?
@paul-rouse hi! :wave:
I'm packaging pcre2 for Arch Linux and we are currently working on moving from pcre (now unmaintained) to pcre2. Would it be possible to prioritize the removal of pcre or alternatively to switch to e.g. https://github.com/sjshuck/hs-pcre2?
Pcre-light is a bit of an annoyance when deploying code since it requires carrying along libpcre. It's only used in one place:
http://github.com/bos/mysql-simple/blob/e0c79e6c8a6874709565cca6de6c6ce6d1dcc8ce/Database/MySQL/Simple.hs#L165
I'm hoping to replace that regular expression with an attoparsec parser so that we can drop the dependency. Would that make sense @bos?