CLI2: Added ::desugarFilterPatterns

This commit is contained in:
Paul Beckingham 2015-06-20 12:15:11 -07:00
parent 20d259a129
commit 8229d29100
2 changed files with 20 additions and 27 deletions

View file

@ -521,7 +521,9 @@ void CLI2::prepareFilter (bool applyContext)
/* /*
desugarFilterAttributes (); desugarFilterAttributes ();
desugarFilterAttributeModifiers (); desugarFilterAttributeModifiers ();
*/
desugarFilterPatterns (); desugarFilterPatterns ();
/*
findAttributes (); findAttributes ();
desugarFilterPlainArgs (); desugarFilterPlainArgs ();
insertJunctions (); // Deliberately after all desugar calls. insertJunctions (); // Deliberately after all desugar calls.
@ -1179,42 +1181,34 @@ void CLI2::desugarFilterAttributeModifiers ()
context.debug (dump ("CLI2::analyze desugarFilterAttributeModifiers")); context.debug (dump ("CLI2::analyze desugarFilterAttributeModifiers"));
} }
} }
*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// /pattern/ --> description ~ 'pattern' // /pattern/ --> description ~ 'pattern'
void CLI2::desugarFilterPatterns () void CLI2::desugarFilterPatterns ()
{ {
bool changes = false; bool changes = false;
std::vector <A> reconstructed; std::vector <A2> reconstructed;
for (auto& a : _args) for (auto& a : _args)
{ {
if (a.hasTag ("FILTER")) if (a.hasTag ("FILTER") &&
a._lextype == Lexer::Type::pattern)
{ {
Nibbler n (a.attribute ("raw")); changes = true;
std::string pattern; std::string raw = a.attribute ("raw");
std::string pattern = raw.substr (1, raw.length () - 2);
if (n.getQuoted ('/', pattern) && A2 lhs ("description", Lexer::Type::dom);
n.depleted () &&
pattern.length () > 0)
{
A lhs ("argPattern", "description");
lhs.tag ("ATTRIBUTE");
lhs.tag ("FILTER"); lhs.tag ("FILTER");
reconstructed.push_back (lhs); reconstructed.push_back (lhs);
A op ("argPattern", "~"); A2 op ("~", Lexer::Type::op);
op.tag ("OP");
op.tag ("FILTER"); op.tag ("FILTER");
reconstructed.push_back (op); reconstructed.push_back (op);
A rhs ("argPattern", "'" + pattern + "'"); A2 rhs (pattern, Lexer::Type::string);
rhs.tag ("LITERAL");
rhs.tag ("FILTER"); rhs.tag ("FILTER");
reconstructed.push_back (rhs); reconstructed.push_back (rhs);
changes = true;
}
else
reconstructed.push_back (a);
} }
else else
reconstructed.push_back (a); reconstructed.push_back (a);
@ -1225,10 +1219,9 @@ void CLI2::desugarFilterPatterns ()
_args = reconstructed; _args = reconstructed;
if (context.config.getInteger ("debug.parser") >= 3) if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::analyze desugarFilterPatterns")); context.debug (dump ("CLI2::prepareFilter desugarFilterPatterns"));
} }
} }
*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// An ID sequence can be: // An ID sequence can be:

View file

@ -105,8 +105,8 @@ private:
/* /*
void desugarFilterAttributes (); void desugarFilterAttributes ();
void desugarFilterAttributeModifiers (); void desugarFilterAttributeModifiers ();
void desugarFilterPatterns ();
*/ */
void desugarFilterPatterns ();
void findIDs (); void findIDs ();
void findUUIDs (); void findUUIDs ();
void insertIDExpr (); void insertIDExpr ();