diff --git a/src/CLI.cpp b/src/CLI.cpp index ce1e66bfe..53ee31559 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -489,7 +489,8 @@ void CLI::addArg (const std::string& arg) isIDSequence (arg) || isID (arg) || isPattern (arg) || - isSubstitution (arg)) + isSubstitution (arg) || + isAttribute (arg)) { _original_args.push_back (arg); } @@ -850,7 +851,7 @@ void CLI::desugarAttributes () } //////////////////////////////////////////////////////////////////////////////// -// .[:=]['"]['"] --> name value +// .[~][:=]['"]['"] --> name value void CLI::desugarAttributeModifiers () { std::vector reconstructed; @@ -1816,3 +1817,47 @@ bool CLI::isSubstitution (const std::string& raw) const } //////////////////////////////////////////////////////////////////////////////// +// Covers attribute and attribute modifiers. +// .[~][:=]... +bool CLI::isAttribute (const std::string& raw) const +{ + std::string::size_type colon = raw.find (":"); + std::string::size_type equal = raw.find ("="); + + std::string attr = ""; + if (colon != std::string::npos) + attr = raw.substr (0, colon); + else if (equal != std::string::npos) + attr = raw.substr (0, equal); + else + return false; + + std::string::size_type dot = attr.find ("."); + std::string mod = ""; + if (dot != std::string::npos) + { + mod = attr.substr (dot + 1); + attr = attr.substr (0, dot); + + if (mod[0] == '~') + mod = mod.substr (1); + +/* + TODO Entities are not loaded yet. Hmm. + + if (! canonicalize (mod, "modifier", mod)) + return false; +*/ + } + +/* + TODO Entities are not loaded yet. Hmm. + + if (! canonicalize (attr, "attribute", attr)) + return false; +*/ + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/CLI.h b/src/CLI.h index 016a854fa..610f4b0ce 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -107,6 +107,7 @@ private: bool isID (const std::string&) const; bool isPattern (const std::string&) const; bool isSubstitution (const std::string&) const; + bool isAttribute (const std::string&) const; public: std::multimap _entities;