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")); 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 () void CLI2::handleTerminator ()
{ {
@ -424,6 +447,7 @@ void CLI2::analyze ()
_args.clear (); _args.clear ();
handleArg0 (); handleArg0 ();
lexArguments (); lexArguments ();
demoteDOM ();
handleTerminator (); handleTerminator ();
// Process _args. // Process _args.

View file

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