CLI2: Implemented ::lexFilterArgs

- Now spots filter elements that need to be Lexed.
This commit is contained in:
Paul Beckingham 2015-07-12 17:57:52 -04:00
parent c2c53fa668
commit 694323a8f1
2 changed files with 39 additions and 0 deletions

View file

@ -650,6 +650,7 @@ void CLI2::prepareFilter (bool applyContext)
context.debug (dump ("CLI2::prepareFilter categorize"));
// Remove all the syntactic sugar for FILTERs.
lexFilterArgs ();
findIDs ();
findUUIDs ();
insertIDExpr ();
@ -1523,6 +1524,43 @@ void CLI2::insertIDExpr ()
}
}
////////////////////////////////////////////////////////////////////////////////
// FILTER Lexer::Type::word args will become part of an expression, and so they
// need to be Lexed.
void CLI2::lexFilterArgs ()
{
bool changes = false;
std::vector <A2> reconstructed;
for (auto& a : _args)
{
if (a._lextype == Lexer::Type::word &&
a.hasTag ("FILTER"))
{
changes = true;
std::string lexeme;
Lexer::Type type;
Lexer lex (a.attribute ("raw"));
while (lex.token (lexeme, type))
{
A2 extra (lexeme, type);
extra.tag ("FILTER");
reconstructed.push_back (extra);
}
}
else
reconstructed.push_back (a);
}
if (changes)
{
_args = reconstructed;
if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::prepareFilter lexFilterArgs"));
}
}
////////////////////////////////////////////////////////////////////////////////
// FILTER, Lexer::Type::word args are treated as search terms.
//

View file

@ -101,6 +101,7 @@ private:
void findIDs ();
void findUUIDs ();
void insertIDExpr ();
void lexFilterArgs ();
void desugarFilterPlainArgs ();
void insertJunctions ();
void defaultCommand ();