From a1ee44ac17eadc63bf032c4b91dafc03c4253e81 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 May 2014 14:11:53 -0400 Subject: [PATCH] Parser - ::findPlainArgs will now only upgrade an arg to a search if the arg itself cannot be lexed into subtokens. --- src/Parser.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index 6b64cb95e..b59c14c1e 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -1377,21 +1377,33 @@ void Parser::findPlainArgs () (*i)->hasTag ("ORIGINAL") && // TODO Wrong, can come in through alias/filter (*i)->countTags () <= 2) { - // This tag also prevents further expanѕion. - (*i)->tag ("PATTERN"); + // 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 lexed; + Lexer::token_split (lexed, raw); - std::string pattern = (*i)->attribute ("raw"); + if (lexed.size () == 1) + { + // This tag also prevents further expanѕion. + (*i)->tag ("PATTERN"); - Tree* branch = (*i)->addBranch (new Tree ("argPat")); - branch->attribute ("raw", "description"); + Tree* branch = (*i)->addBranch (new Tree ("argPat")); + branch->attribute ("raw", "description"); - branch = (*i)->addBranch (new Tree ("argPat")); - branch->attribute ("raw", "~"); - branch->tag ("OP"); + branch = (*i)->addBranch (new Tree ("argPat")); + branch->attribute ("raw", "~"); + branch->tag ("OP"); - branch = (*i)->addBranch (new Tree ("argPat")); - branch->attribute ("raw", pattern); - branch->tag ("STRING"); + branch = (*i)->addBranch (new Tree ("argPat")); + branch->attribute ("raw", raw); + branch->tag ("STRING"); + } + else + { + std::cout << "# ::findPlainArgs '" << raw << "' is compounded\n"; + // TODO Add the lexed elements as separate tokens. + } } } }