CLI2: Added ::demoteDOM to demote unrecognized DOM args to words

This commit is contained in:
Paul Beckingham 2015-07-01 18:02:48 -04:00
parent 2402ec8d6e
commit 1b83734392
2 changed files with 25 additions and 0 deletions

View file

@ -381,6 +381,29 @@ void CLI2::lexArguments ()
context.debug (dump ("CLI2::analyze lexArguments"));
}
////////////////////////////////////////////////////////////////////////////////
void CLI2::demoteDOM ()
{
bool changes = false;
for (auto& a : _args)
{
if (a._lextype == Lexer::Type::dom)
{
std::string canonicalized;
if (! canonicalize (canonicalized, "attribute", a.attribute ("raw")))
{
a._lextype = Lexer::Type::word;
changes = true;
}
}
}
if (changes)
if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::analyze demoteDOM"));
}
////////////////////////////////////////////////////////////////////////////////
void CLI2::handleTerminator ()
{
@ -424,6 +447,7 @@ void CLI2::analyze ()
_args.clear ();
handleArg0 ();
lexArguments ();
demoteDOM ();
handleTerminator ();
// Process _args.

View file

@ -86,6 +86,7 @@ public:
private:
void handleArg0 ();
void lexArguments ();
void demoteDOM ();
void handleTerminator ();
void aliasExpansion ();
void findOverrides ();