Nibbler: Removed unused ::getRx method

This commit is contained in:
Paul Beckingham 2015-10-29 23:23:41 -04:00
parent de66200028
commit 1e8eac0e3d
3 changed files with 0 additions and 57 deletions

View file

@ -32,9 +32,6 @@
#include <Lexer.h>
#include <Nibbler.h>
#include <util.h>
#ifdef NIBBLER_FEATURE_REGEX
#include <RX.h>
#endif
#include <Lexer.h>
#include <util.h>
#include <memory>
@ -492,34 +489,6 @@ bool Nibbler::getLiteral (const std::string& literal)
return false;
}
////////////////////////////////////////////////////////////////////////////////
#ifdef NIBBLER_FEATURE_REGEX
bool Nibbler::getRx (const std::string& regex, std::string& result)
{
if (_cursor < _length)
{
// Regex may be anchored to the beginning and include capturing parentheses,
// otherwise they are added.
std::string modified_regex;
if (regex.substr (0, 2) != "^(")
modified_regex = "^(" + regex + ")";
else
modified_regex = regex;
RX r (modified_regex, true);
std::vector <std::string> results;
if (r.match (results, _input->substr (_cursor)))
{
result = results[0];
_cursor += result.length ();
return true;
}
}
return false;
}
#endif
////////////////////////////////////////////////////////////////////////////////
bool Nibbler::getUUID (std::string& result)
{

View file

@ -27,9 +27,6 @@
#ifndef INCLUDED_NIBBLER
#define INCLUDED_NIBBLER
#define NIBBLER_FEATURE_REGEX
//#undef NIBBLER_FEATURE_REGEX
#include <string>
#include <vector>
#include <time.h>
@ -63,9 +60,6 @@ public:
bool getNumber (std::string&);
bool getNumber (double&);
bool getLiteral (const std::string&);
#ifdef NIBBLER_FEATURE_REGEX
bool getRx (const std::string&, std::string&);
#endif
bool getUUID (std::string&);
bool getPartialUUID (std::string&);
bool getOneOf (const std::vector <std::string>&, std::string&);

View file

@ -35,11 +35,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int, char**)
{
#ifdef NIBBLER_FEATURE_REGEX
UnitTest t (325);
#else
UnitTest t (315);
#endif
// Ensure environment has no influence.
unsetenv ("TASKDATA");
@ -290,22 +286,6 @@ int main (int, char**)
t.ok (n.getLiteral ("bar"), " 'bar' : getLiteral ('bar') -> true");
t.ok (n.depleted (), " '' : depleted () -> true");
#ifdef NIBBLER_FEATURE_REGEX
// bool getRx (const std::string&, std::string&);
t.diag ("Nibbler::getRx");
n = Nibbler ("one two three");
t.ok (n.getRx ("^(o..)", s), "'one two three' : getRx ('^(o..)') -> true");
t.is (s, "one", "'one two three' : getRx ('^(o..)') -> 'one'");
t.ok (n.skip (' '), " ' two three' : skip (' ') -> true");
t.ok (n.getRx ("t..", s), " 'two three' : getRx ('t..') -> true");
t.is (s, "two", " 'two three' : getRx ('t..') -> 'two'");
t.notok (n.getRx ("th...", s), " ' three' : getRx ('th...') -> false");
t.ok (n.skip (' '), " ' three' : skip (' ') -> true");
t.ok (n.getRx ("th...", s), " 'three' : getRx ('th...') -> true");
t.is (s, "three", " 'three' : getRx ('th...') -> 'three'");
t.ok (n.depleted (), " '' : depleted () -> true");
#endif
// bool getUUID (std::string&);
t.diag ("Nibbler::getUUID");
n = Nibbler ("a0b1c2d3-e4f5-A6B7-C8D9-E0F1a2b3c4d5");