- Implemented RegX class to maintain a separate compile, and match
  method, thereby allowing efficient re-use of the regex.  This is
  critical to Expression::eval, where an identical regex might be
  applied to every task.
- Obsoleted rx.{h,cpp}, which combined the compile and match steps
  into a single call, and is therefore not efficient when used in
  the context of filtering.
- Fixed some unit tests that weren't building.  Now they do.  They
  don't work of course (don't be silly) but that's a problem for
  another day.
- Modified all code that relies on rx.h to use RegX.h.
This commit is contained in:
Paul Beckingham 2011-06-21 01:43:57 -04:00
parent aa8d872466
commit b49523c06d
14 changed files with 249 additions and 490 deletions

View file

@ -33,7 +33,7 @@
#include <inttypes.h>
#include <Nibbler.h>
#include <Date.h>
#include <rx.h>
#include <RegX.h>
const char* c_digits = "0123456789";
@ -146,9 +146,10 @@ bool Nibbler::getUntilRx (const std::string& regex, std::string& result)
else
modified_regex = regex;
RegX r (modified_regex, true);
std::vector <int> start;
std::vector <int> end;
if (regexMatch (start, end, mInput.substr (mCursor), modified_regex, true))
if (r.match (start, end, mInput.substr (mCursor)))
{
result = mInput.substr (mCursor, start[0]);
mCursor += start[0];
@ -450,8 +451,9 @@ bool Nibbler::getRx (const std::string& regex, std::string& result)
else
modified_regex = regex;
RegX r (modified_regex, true);
std::vector <std::string> results;
if (regexMatch (results, mInput.substr (mCursor), modified_regex, true))
if (r.match (results, mInput.substr (mCursor)))
{
result = results[0];
mCursor += result.length ();
@ -1010,8 +1012,9 @@ bool Nibbler::skipRx (const std::string& regex)
else
modified_regex = regex;
RegX r (modified_regex, true);
std::vector <std::string> results;
if (regexMatch (results, mInput.substr (mCursor), modified_regex, true))
if (r.match (results, mInput.substr (mCursor)))
{
mCursor += results[0].length ();
return true;