mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Lexer2
- Stubbed ::isDate and ::isDuration methods.
This commit is contained in:
parent
1128ad8259
commit
0d23511cee
2 changed files with 27 additions and 4 deletions
|
@ -59,8 +59,7 @@ bool Lexer2::token (std::string& token, Lexer2::Type& type)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// The sequence is specific, and must follow these rules:
|
// The sequence is specific, and must follow these rules:
|
||||||
// - date < uuid < identifier
|
// - date < duration < uuid < identifier
|
||||||
// - duration < identifier
|
|
||||||
// - url < pair < identifier
|
// - url < pair < identifier
|
||||||
// - hex < number
|
// - hex < number
|
||||||
// - separator < tag < operator
|
// - separator < tag < operator
|
||||||
|
@ -68,6 +67,8 @@ bool Lexer2::token (std::string& token, Lexer2::Type& type)
|
||||||
// - word last
|
// - word last
|
||||||
if (isString (token, type, '\'') ||
|
if (isString (token, type, '\'') ||
|
||||||
isString (token, type, '"') ||
|
isString (token, type, '"') ||
|
||||||
|
isDate (token, type) ||
|
||||||
|
isDuration (token, type) ||
|
||||||
isUUID (token, type) ||
|
isUUID (token, type) ||
|
||||||
isHexNumber (token, type) ||
|
isHexNumber (token, type) ||
|
||||||
isNumber (token, type) ||
|
isNumber (token, type) ||
|
||||||
|
@ -124,6 +125,8 @@ const std::string Lexer2::typeName (const Lexer2::Type& type)
|
||||||
case Lexer2::Type::op: return "op";
|
case Lexer2::Type::op: return "op";
|
||||||
case Lexer2::Type::identifier: return "identifier";
|
case Lexer2::Type::identifier: return "identifier";
|
||||||
case Lexer2::Type::word: return "word";
|
case Lexer2::Type::word: return "word";
|
||||||
|
case Lexer2::Type::date: return "date";
|
||||||
|
case Lexer2::Type::duration: return "duration";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,6 +386,22 @@ bool Lexer2::isString (std::string& token, Lexer2::Type& type, int quote)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Lexer2::Type::date
|
||||||
|
//
|
||||||
|
bool Lexer2::isDate (std::string& token, Lexer2::Type& type)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Lexer2::Type::duration
|
||||||
|
//
|
||||||
|
bool Lexer2::isDuration (std::string& token, Lexer2::Type& type)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Lexer2::Type::uuid
|
// Lexer2::Type::uuid
|
||||||
// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
||||||
|
@ -867,7 +886,9 @@ std::string Lexer2::typeToString (Lexer2::Type type)
|
||||||
else if (type == Lexer2::Type::op) return std::string ("\033[38;5;7m\033[48;5;203m") + "op" + "\033[0m";
|
else if (type == Lexer2::Type::op) return std::string ("\033[38;5;7m\033[48;5;203m") + "op" + "\033[0m";
|
||||||
else if (type == Lexer2::Type::identifier) return std::string ("\033[38;5;15m\033[48;5;244m") + "identifier" + "\033[0m";
|
else if (type == Lexer2::Type::identifier) return std::string ("\033[38;5;15m\033[48;5;244m") + "identifier" + "\033[0m";
|
||||||
else if (type == Lexer2::Type::word) return std::string ("\033[38;5;15m\033[48;5;236m") + "word" + "\033[0m";
|
else if (type == Lexer2::Type::word) return std::string ("\033[38;5;15m\033[48;5;236m") + "word" + "\033[0m";
|
||||||
else return std::string ("\033[37;41m") + "unknown" + "\033[0m";
|
else if (type == Lexer2::Type::date) return std::string ("\033[38;5;15m\033[48;5;34") + "date" + "\033[0m";
|
||||||
|
else if (type == Lexer2::Type::duration) return std::string ("\033[38;5;15m\033[48;5;34") + "duration" + "\033[0m";
|
||||||
|
else return std::string ("\033[37;41m") + "unknown" + "\033[0m";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
substitution, pattern,
|
substitution, pattern,
|
||||||
op,
|
op,
|
||||||
identifier, word,
|
identifier, word,
|
||||||
/*date,*/ /*duration,*/ };
|
date, duration };
|
||||||
|
|
||||||
Lexer2 (const std::string&);
|
Lexer2 (const std::string&);
|
||||||
~Lexer2 ();
|
~Lexer2 ();
|
||||||
|
@ -75,6 +75,8 @@ public:
|
||||||
|
|
||||||
// Classifiers.
|
// Classifiers.
|
||||||
bool isString (std::string&, Lexer2::Type&, int quote);
|
bool isString (std::string&, Lexer2::Type&, int quote);
|
||||||
|
bool isDate (std::string&, Lexer2::Type&);
|
||||||
|
bool isDuration (std::string&, Lexer2::Type&);
|
||||||
bool isUUID (std::string&, Lexer2::Type&);
|
bool isUUID (std::string&, Lexer2::Type&);
|
||||||
bool isNumber (std::string&, Lexer2::Type&);
|
bool isNumber (std::string&, Lexer2::Type&);
|
||||||
bool isHexNumber (std::string&, Lexer2::Type&);
|
bool isHexNumber (std::string&, Lexer2::Type&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue