Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on pcre-light #12

Open
rehno-lindeque opened this issue Jun 1, 2014 · 2 comments
Open

Remove dependency on pcre-light #12

rehno-lindeque opened this issue Jun 1, 2014 · 2 comments

Comments

@rehno-lindeque
Copy link

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?

@rehno-lindeque rehno-lindeque changed the title Remove dependency on PCRE-light Remove dependency on pcre-light Jun 1, 2014
@rehno-lindeque
Copy link
Author

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?

rehno-lindeque added a commit to rehno-lindeque/mysql-simple that referenced this issue Jun 2, 2014
rehno-lindeque added a commit to rehno-lindeque/mysql-simple that referenced this issue Jun 2, 2014
mgmeier referenced this issue in mgmeier/mysql-simple Sep 29, 2015
@dvzrv
Copy link

dvzrv commented Jun 9, 2024

@paul-rouse hi! 👋

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants