- Removed obsolete ::sequence method.
This commit is contained in:
Paul Beckingham 2014-05-25 09:26:32 -04:00
parent 543651055f
commit ecd64456ae
2 changed files with 0 additions and 89 deletions

View file

@ -759,94 +759,6 @@ const A3 A3::tokenize (const A3& input) const
return output;
}
////////////////////////////////////////////////////////////////////////////////
// Convert: 1-3,5 7 92bea814-2e3f-487b-92a1-3286dd1a7eda
// To: (id=1 or id=2 or id=3 or id=5 or id=7 or
// uuid=92bea814-2e3f-487b-92a1-3286dd1a7eda)
const A3 A3::sequence (const A3& input) const
{
A3 sequenced;
// Extract all the components of a sequence.
std::vector <int> ids;
std::vector <std::string> uuids;
std::vector <Arg>::const_iterator arg;
for (arg = input.begin (); arg != input.end (); ++arg)
{
if (arg->_category == Arg::cat_id)
extract_id (arg->_raw, ids);
else if (arg->_category == Arg::cat_uuid)
extract_uuid (arg->_raw, uuids);
}
// If there is no sequence, we're done.
if (ids.size () == 0 && uuids.size () == 0)
return input;
if (ids.size () == 1 && ids[0] < 1)
throw format (STRING_A3_ZERO_ID, ids[0]);
// Copy everything up to the first id/uuid.
for (arg = input.begin (); arg != input.end (); ++arg)
{
if (arg->_category == Arg::cat_id || arg->_category == Arg::cat_uuid)
break;
sequenced.push_back (*arg);
}
// Insert the algebraic form.
sequenced.push_back (Arg ("(", Arg::cat_op));
for (unsigned int i = 0; i < ids.size (); ++i)
{
if (i)
sequenced.push_back (Arg ("or", Arg::cat_op));
sequenced.push_back (Arg ("id", Arg::type_number, Arg::cat_dom));
sequenced.push_back (Arg ("=", Arg::cat_op));
sequenced.push_back (Arg (format(ids[i]), Arg::type_number, Arg::cat_literal));
}
for (unsigned int i = 0; i < uuids.size (); ++i)
{
if (ids.size () + i > 0)
sequenced.push_back (Arg ("or", Arg::cat_op));
// A full-length UUID requires a string comparison.
if (uuids[i].length () == 36)
{
sequenced.push_back (Arg ("uuid", Arg::type_string, Arg::cat_dom));
sequenced.push_back (Arg ("=", Arg::cat_op));
sequenced.push_back (Arg (uuids[i], Arg::type_string, Arg::cat_literal));
}
// A UUID fragment is a leftmost comparison.
else
{
sequenced.push_back (Arg ("uuid", Arg::type_string, Arg::cat_dom));
sequenced.push_back (Arg ("~", Arg::cat_op));
sequenced.push_back (Arg ("^" + uuids[i], Arg::type_string, Arg::cat_rx));
}
}
sequenced.push_back (Arg (")", Arg::cat_op));
// Now copy everything after the last id/uuid.
bool found_id = false;
for (arg = input.begin (); arg != input.end (); ++arg)
{
if (arg->_category == Arg::cat_id || arg->_category == Arg::cat_uuid)
found_id = true;
else if (found_id)
sequenced.push_back (*arg);
}
sequenced.dump ("A3::sequence");
return sequenced;
}
////////////////////////////////////////////////////////////////////////////////
// Dijkstra Shunting Algorithm.
// http://en.wikipedia.org/wiki/Shunting-yard_algorithm

View file

@ -62,7 +62,6 @@ public:
const A3 extract_modifications () const;
const A3 tokenize (const A3&) const;
const A3 sequence (const A3&) const;
const A3 postfix (const A3&) const;
static bool is_attr (Nibbler&, Arg&);