From f2e533d013ce7106987f30050afdf26f412a891f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 20 Oct 2014 01:33:42 -0400 Subject: [PATCH] CLI - Implemented ::decomposeModAttributeModifiers. --- src/CLI.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++------ src/CLI.h | 1 + 2 files changed, 95 insertions(+), 11 deletions(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index 05d7e4106..9f24cc091 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -302,6 +302,7 @@ void CLI::analyze () // Decompose the elements for MODIFICATIONs. decomposeModAttributes (); + decomposeModAttributeModifiers (); } //////////////////////////////////////////////////////////////////////////////// @@ -1214,17 +1215,6 @@ void CLI::decomposeModAttributes () found = true; } - else if (canonicalize (canonical, "pseudo", name)) - { - A attr ("argUDA", name); - attr.attribute ("name", canonical); - attr.attribute ("value", value); - attr.tag ("PSEUDO"); - attr.tag ("MODIFICATION"); - reconstructed.push_back (attr); - found = true; - } - else if (canonicalize (canonical, "attribute", name)) { A attr ("argAtt", name); @@ -1259,3 +1249,96 @@ void CLI::decomposeModAttributes () } //////////////////////////////////////////////////////////////////////////////// +void CLI::decomposeModAttributeModifiers () +{ + std::vector reconstructed; + std::vector ::iterator a; + for (a = _args.begin (); a != _args.end (); ++a) + { + if (a->hasTag ("MODIFICATION")) + { + // Look for a valid attribute name. + bool found = false; + Nibbler n (a->attribute ("raw")); + std::string name; + if (n.getUntil (".", name) && + name.length ()) + { + std::string canonical; + if (canonicalize (canonical, "attribute", name) || + canonicalize (canonical, "uda", name)) + { + if (n.skip ('.')) + { + std::string sense = "+"; + if (n.skip ('~')) + sense = "-"; + + std::string modifier; + n.getUntilOneOf (":=", modifier); + + if (n.skip (':') || + n.skip ('=')) + { + std::string value; + if (n.getQuoted ('"', value) || + n.getQuoted ('\'', value) || + n.getUntilEOS (value) || + n.depleted ()) + { + if (value == "") + value = "''"; + + std::string canonical; + if (canonicalize (canonical, "uda", name)) + { + A attmod ("argUDA", name); + attmod.attribute ("name", canonical); + attmod.attribute ("modifier", modifier); + attmod.attribute ("sense", sense); + attmod.attribute ("value", value); + attmod.tag ("UDA"); + attmod.tag ("MODIFIABLE"); + attmod.tag ("MODIFICATION"); + reconstructed.push_back (attmod); + found = true; + } + + else if (canonicalize (canonical, "attribute", name)) + { + A attmod ("argAtt", name); + attmod.attribute ("name", canonical); + attmod.attribute ("modifier", modifier); + attmod.attribute ("sense", sense); + attmod.attribute ("value", value); + attmod.tag ("ATTMOD"); + attmod.tag ("MODIFICATION"); + + std::map ::const_iterator col; + col = context.columns.find (canonical); + if (col != context.columns.end () && + col->second->modifiable ()) + { + attmod.tag ("MODIFIABLE"); + } + + reconstructed.push_back (attmod); + found = true; + } + } + } + } + } + } + + if (!found) + reconstructed.push_back (*a); + } + else + reconstructed.push_back (*a); + } + + _args = reconstructed; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/CLI.h b/src/CLI.h index 0e1424432..5b0cc2b15 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -87,6 +87,7 @@ private: void desugarIDs (); void desugarUUIDs (); void decomposeModAttributes (); + void decomposeModAttributeModifiers (); public: std::multimap _entities;