From 2cd0494221bd80a055af209227391146aa01e4ab Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 20 May 2014 18:26:32 -0400 Subject: [PATCH] A3t - ::findAttributeModifier now creates sub nodes. --- src/A3t.cpp | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/src/A3t.cpp b/src/A3t.cpp index 59c457047..345dfd34e 100644 --- a/src/A3t.cpp +++ b/src/A3t.cpp @@ -980,11 +980,140 @@ void A3t::findAttributeModifier () { (*i)->unTag ("?"); (*i)->tag ("ATTMOD"); + (*i)->tag ("EXPANDED"); (*i)->attribute ("name", canonical); (*i)->attribute ("value", value); (*i)->attribute ("modifier", modifier); (*i)->attribute ("sense", sense); + Tree* branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", canonical); + + if (modifier == "before" || modifier == "under" || modifier == "below") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "<"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", value); + } + else if (modifier == "after" || modifier == "over" || modifier == "above") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", ">"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", value); + } + else if (modifier == "none") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "=="); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "''"); + } + else if (modifier == "any") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "!="); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "''"); + } + else if (modifier == "is" || modifier == "equals") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "=="); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", value); + } + else if (modifier == "isnt" || modifier == "not") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "!="); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", value); + } + else if (modifier == "has" || modifier == "contains") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "~"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", value); + } + else if (modifier == "hasnt") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "!~"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", value); + } + else if (modifier == "startswith" || modifier == "left") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "~"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "'^" + value + "'"); + } + else if (modifier == "endswith" || modifier == "right") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "~"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "'" + value + "$'"); + } + else if (modifier == "word") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "~"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + +#if defined (DARWIN) + branch->attribute ("value", value); +#elif defined (SOLARIS) + branch->attribute ("value", "'\\<" + value + "\\>'"); +#else + branch->attribute ("value", "'\\b" + value + "\\b'"); +#endif + } + else if (modifier == "noword") + { + branch = (*i)->addBranch (new Tree ("argAttmod")); + branch->attribute ("value", "!~"); + branch->tag ("OP"); + + branch = (*i)->addBranch (new Tree ("argAttmod")); + +#if defined (DARWIN) + branch->attribute ("value", value); +#elif defined (SOLARIS) + branch->attribute ("value", "'\\<" + value + "\\>'"); +#else + branch->attribute ("value", "'\\b" + value + "\\b'"); +#endif + } + else + throw format (STRING_A3_UNKNOWN_ATTMOD, modifier); + std::map ::const_iterator col; col = context.columns.find (canonical); if (col != context.columns.end () &&