CLI: Added ::identifyIds

This commit is contained in:
Paul Beckingham 2016-06-04 10:33:32 -04:00
parent c9af6fa37b
commit 5ee1aa8c9c
2 changed files with 31 additions and 7 deletions

View file

@ -27,6 +27,7 @@
#include <cmake.h> #include <cmake.h>
#include <CLI.h> #include <CLI.h>
#include <Color.h> #include <Color.h>
#include <Pig.h>
#include <shared.h> #include <shared.h>
#include <format.h> #include <format.h>
#include <sstream> #include <sstream>
@ -119,6 +120,7 @@ std::string A2::dump () const
else if (tag == "HINT") tags += "\033[1;37;43m" + tag + "\033[0m "; else if (tag == "HINT") tags += "\033[1;37;43m" + tag + "\033[0m ";
else if (tag == "FILTER") tags += "\033[1;37;45m" + tag + "\033[0m "; else if (tag == "FILTER") tags += "\033[1;37;45m" + tag + "\033[0m ";
else if (tag == "CONFIG") tags += "\033[1;37;101m" + tag + "\033[0m "; else if (tag == "CONFIG") tags += "\033[1;37;101m" + tag + "\033[0m ";
else if (tag == "ID") tags += "\033[38;5;7m\033[48;5;34m" + tag + "\033[0m ";
else tags += "\033[32m" + tag + "\033[0m "; else tags += "\033[32m" + tag + "\033[0m ";
} }
@ -387,6 +389,27 @@ void CLI::identifyOverrides ()
} }
} }
////////////////////////////////////////////////////////////////////////////////
// Scan all arguments and identify instances of '@<integer>'.
void CLI::identifyIds ()
{
for (auto& a : _args)
{
if (a._lextype == Lexer::Type::word)
{
Pig pig (a.attribute ("raw"));
int digits;
if (pig.skipLiteral ("@") &&
pig.getDigits (digits) &&
pig.eos ())
{
a.tag ("ID");
a.attribute ("value", digits);
}
}
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Scan all arguments and canonicalize names that need it. // Scan all arguments and canonicalize names that need it.
void CLI::canonicalizeNames () void CLI::canonicalizeNames ()

View file

@ -70,6 +70,7 @@ private:
void handleArg0 (); void handleArg0 ();
void lexArguments (); void lexArguments ();
void identifyOverrides (); void identifyOverrides ();
void identifyIds ();
void canonicalizeNames (); void canonicalizeNames ();
void identifyFilter (); void identifyFilter ();
bool exactMatch (const std::string&, const std::string&) const; bool exactMatch (const std::string&, const std::string&) const;