mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Lexer: Dead code removal
This commit is contained in:
parent
a89c996334
commit
fed3b815a0
3 changed files with 5 additions and 59 deletions
|
@ -97,22 +97,6 @@ bool Lexer::token (std::string& token, Lexer::Type& type)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This static method tokenizes the input and provides a vector of token/type
|
||||
// results from a high-level lex.
|
||||
std::vector <std::pair <std::string, Lexer::Type>> Lexer::tokens (
|
||||
const std::string& text)
|
||||
{
|
||||
std::vector <std::pair <std::string, Lexer::Type>> all;
|
||||
std::string token;
|
||||
Lexer::Type type;
|
||||
Lexer l (text);
|
||||
while (l.token (token, type))
|
||||
all.push_back (std::pair <std::string, Lexer::Type> (token, type));
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This static method tokenizes the input, but discards the type information.
|
||||
std::vector <std::string> Lexer::split (const std::string& text)
|
||||
|
@ -1093,30 +1077,6 @@ bool Lexer::isWord (std::string& token, Lexer::Type& type)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Lexer::Type::word
|
||||
// [^\s]+
|
||||
bool Lexer::isContiguous (std::string& token, Lexer::Type& type)
|
||||
{
|
||||
std::size_t marker = _cursor;
|
||||
|
||||
while (_text[marker] &&
|
||||
! isWhitespace (_text[marker]) &&
|
||||
_text[marker] != '(' &&
|
||||
_text[marker] != ')')
|
||||
utf8_next_char (_text, marker);
|
||||
|
||||
if (marker > _cursor)
|
||||
{
|
||||
token = _text.substr (_cursor, marker - _cursor);
|
||||
type = Lexer::Type::word;
|
||||
_cursor = marker;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Static
|
||||
std::string Lexer::typeToString (Lexer::Type type)
|
||||
|
@ -1148,19 +1108,6 @@ bool Lexer::isAllDigits (const std::string& text)
|
|||
return text.find_first_not_of ("0123456789") == std::string::npos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Not escape-proof.
|
||||
bool Lexer::isOneWord (const std::string& text)
|
||||
{
|
||||
std::string::size_type i = 0;
|
||||
int character;
|
||||
while ((character = utf8_next_char (text, i)))
|
||||
if (Lexer::isWhitespace (character))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Full implementation of a quoted word. Includes:
|
||||
// '\''
|
||||
|
|
|
@ -54,7 +54,6 @@ public:
|
|||
Lexer (const std::string&);
|
||||
~Lexer ();
|
||||
bool token (std::string&, Lexer::Type&);
|
||||
static std::vector <std::pair <std::string, Lexer::Type>> tokens (const std::string&);
|
||||
static std::vector <std::string> split (const std::string&);
|
||||
static std::string typeToString (Lexer::Type);
|
||||
|
||||
|
@ -73,7 +72,6 @@ public:
|
|||
static bool isHardBoundary (int, int);
|
||||
static bool isPunctuation (int);
|
||||
static bool isAllDigits (const std::string&);
|
||||
static bool isOneWord (const std::string&);
|
||||
static void dequote (std::string&, const std::string& quotes = "'\"");
|
||||
static bool wasQuoted (const std::string&);
|
||||
static bool readWord (const std::string&, const std::string&, std::string::size_type&, std::string&);
|
||||
|
@ -106,7 +104,6 @@ public:
|
|||
bool isDOM (std::string&, Lexer::Type&);
|
||||
bool isIdentifier (std::string&, Lexer::Type&);
|
||||
bool isWord (std::string&, Lexer::Type&);
|
||||
bool isContiguous (std::string&, Lexer::Type&);
|
||||
|
||||
private:
|
||||
std::string _text;
|
||||
|
|
|
@ -12,9 +12,11 @@ int main (int argc, char** argv)
|
|||
{
|
||||
std::cout << "argument '" << argv[i] << "'\n";
|
||||
|
||||
auto all = Lexer::tokens (argv[i]);
|
||||
for (auto token : Lexer::tokens (argv[i]))
|
||||
std::cout << " token '" << token.first << "' " << Lexer::typeToString (token.second) << "\n";
|
||||
Lexer l (argv[i]);
|
||||
std::string token;
|
||||
Lexer::Type type;
|
||||
while (l.token (token, type))
|
||||
std::cout << " token '" << token << "' " << Lexer::typeToString (type) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue