- ::findPlainArgs will now only upgrade an arg to a search if the arg itself
  cannot be lexed into subtokens.
This commit is contained in:
Paul Beckingham 2014-05-31 14:11:53 -04:00
parent cf5eb73f04
commit a1ee44ac17

View file

@ -1376,12 +1376,18 @@ void Parser::findPlainArgs ()
if ((*i)->hasTag ("FILTER") && if ((*i)->hasTag ("FILTER") &&
(*i)->hasTag ("ORIGINAL") && // TODO Wrong, can come in through alias/filter (*i)->hasTag ("ORIGINAL") && // TODO Wrong, can come in through alias/filter
(*i)->countTags () <= 2) (*i)->countTags () <= 2)
{
// A word can be upgraded to a pattern only if it does not itself contain
// multiple tokens.
std::string raw = (*i)->attribute ("raw");
std::vector <std::string> lexed;
Lexer::token_split (lexed, raw);
if (lexed.size () == 1)
{ {
// This tag also prevents further expanѕion. // This tag also prevents further expanѕion.
(*i)->tag ("PATTERN"); (*i)->tag ("PATTERN");
std::string pattern = (*i)->attribute ("raw");
Tree* branch = (*i)->addBranch (new Tree ("argPat")); Tree* branch = (*i)->addBranch (new Tree ("argPat"));
branch->attribute ("raw", "description"); branch->attribute ("raw", "description");
@ -1390,9 +1396,15 @@ void Parser::findPlainArgs ()
branch->tag ("OP"); branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argPat")); branch = (*i)->addBranch (new Tree ("argPat"));
branch->attribute ("raw", pattern); branch->attribute ("raw", raw);
branch->tag ("STRING"); branch->tag ("STRING");
} }
else
{
std::cout << "# ::findPlainArgs '" << raw << "' is compounded\n";
// TODO Add the lexed elements as separate tokens.
}
}
} }
} }