mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Lexer
- Renamed Lexer2 to Lexer, it looks good enough to assume control.
This commit is contained in:
parent
e1c0d5b130
commit
745aad0d27
15 changed files with 553 additions and 553 deletions
40
src/CLI.cpp
40
src/CLI.cpp
|
@ -29,7 +29,7 @@
|
|||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <Nibbler.h>
|
||||
#include <Lexer2.h>
|
||||
#include <Lexer.h>
|
||||
#include <CLI.h>
|
||||
#include <Color.h>
|
||||
#include <text.h>
|
||||
|
@ -661,13 +661,13 @@ void CLI::addArg (const std::string& arg)
|
|||
// that cause the lexemes to be ignored, and the original arugment used
|
||||
// intact.
|
||||
std::string lexeme;
|
||||
Lexer2::Type type;
|
||||
Lexer2 lex (raw);
|
||||
Lexer::Type type;
|
||||
Lexer lex (raw);
|
||||
lex.ambiguity (false);
|
||||
|
||||
std::vector <std::pair <std::string, Lexer2::Type> > lexemes;
|
||||
std::vector <std::pair <std::string, Lexer::Type> > lexemes;
|
||||
while (lex.token (lexeme, type))
|
||||
lexemes.push_back (std::pair <std::string, Lexer2::Type> (lexeme, type));
|
||||
lexemes.push_back (std::pair <std::string, Lexer::Type> (lexeme, type));
|
||||
|
||||
if (disqualifyInsufficientTerms (lexemes) ||
|
||||
disqualifyNoOps (lexemes) ||
|
||||
|
@ -681,7 +681,7 @@ void CLI::addArg (const std::string& arg)
|
|||
{
|
||||
// How often have I said to you that when you have eliminated the
|
||||
// impossible, whatever remains, however improbable, must be the truth?
|
||||
std::vector <std::pair <std::string, Lexer2::Type> >::iterator l;
|
||||
std::vector <std::pair <std::string, Lexer::Type> >::iterator l;
|
||||
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
||||
_original_args.push_back (l->first);
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ void CLI::aliasExpansion ()
|
|||
{
|
||||
if (_aliases.find (raw) != _aliases.end ())
|
||||
{
|
||||
std::vector <std::string> lexed = Lexer2::split (_aliases[raw]);
|
||||
std::vector <std::string> lexed = Lexer::split (_aliases[raw]);
|
||||
std::vector <std::string>::iterator l;
|
||||
for (l = lexed.begin (); l != lexed.end (); ++l)
|
||||
{
|
||||
|
@ -1636,7 +1636,7 @@ void CLI::desugarFilterPlainArgs ()
|
|||
reconstructed.push_back (op);
|
||||
|
||||
std::string pattern = a->attribute ("raw");
|
||||
Lexer2::dequote (pattern);
|
||||
Lexer::dequote (pattern);
|
||||
A rhs ("argPattern", "'" + pattern + "'");
|
||||
rhs.tag ("LITERAL");
|
||||
rhs.tag ("FILTER");
|
||||
|
@ -1812,7 +1812,7 @@ void CLI::injectDefaults ()
|
|||
if (defaultCommand != "")
|
||||
{
|
||||
// Split the defaultCommand into separate args.
|
||||
std::vector <std::string> tokens = Lexer2::split (defaultCommand);
|
||||
std::vector <std::string> tokens = Lexer::split (defaultCommand);
|
||||
|
||||
// Modify _args to be: <args0> [<def0> ...] <args1> [...]
|
||||
std::vector <A> reconstructed;
|
||||
|
@ -2302,9 +2302,9 @@ bool CLI::isName (const std::string& raw) const
|
|||
{
|
||||
for (int i = 0; i < raw.length (); ++i)
|
||||
{
|
||||
if (i == 0 && ! Lexer2::isIdentifierStart (raw[i]))
|
||||
if (i == 0 && ! Lexer::isIdentifierStart (raw[i]))
|
||||
return false;
|
||||
else if (! Lexer2::isIdentifierNext (raw[i]))
|
||||
else if (! Lexer::isIdentifierNext (raw[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2316,19 +2316,19 @@ bool CLI::isName (const std::string& raw) const
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI::disqualifyInsufficientTerms (
|
||||
const std::vector <std::pair <std::string, Lexer2::Type> >& lexemes) const
|
||||
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
||||
{
|
||||
return lexemes.size () < 3 ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI::disqualifyNoOps (
|
||||
const std::vector <std::pair <std::string, Lexer2::Type> >& lexemes) const
|
||||
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
||||
{
|
||||
bool foundOP = false;
|
||||
std::vector <std::pair <std::string, Lexer2::Type> >::const_iterator l;
|
||||
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator l;
|
||||
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
||||
if (l->second == Lexer2::Type::op)
|
||||
if (l->second == Lexer::Type::op)
|
||||
foundOP = true;
|
||||
|
||||
return ! foundOP;
|
||||
|
@ -2336,16 +2336,16 @@ bool CLI::disqualifyNoOps (
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI::disqualifyOnlyParenOps (
|
||||
const std::vector <std::pair <std::string, Lexer2::Type> >& lexemes) const
|
||||
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
||||
{
|
||||
int opCount = 0;
|
||||
int opSugarCount = 0;
|
||||
int opParenCount = 0;
|
||||
|
||||
std::vector <std::pair <std::string, Lexer2::Type> >::const_iterator l;
|
||||
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator l;
|
||||
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
||||
{
|
||||
if (l->second == Lexer2::Type::op)
|
||||
if (l->second == Lexer::Type::op)
|
||||
{
|
||||
++opCount;
|
||||
|
||||
|
@ -2372,7 +2372,7 @@ bool CLI::disqualifyOnlyParenOps (
|
|||
// as there are no operators in between, which includes syntactic sugar that
|
||||
// hides operators.
|
||||
bool CLI::disqualifyFirstLastBinary (
|
||||
const std::vector <std::pair <std::string, Lexer2::Type> >& lexemes) const
|
||||
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
||||
{
|
||||
bool firstBinary = false;
|
||||
bool lastBinary = false;
|
||||
|
@ -2391,7 +2391,7 @@ bool CLI::disqualifyFirstLastBinary (
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Disqualify terms when there operators hidden by syntactic sugar.
|
||||
bool CLI::disqualifySugarFree (
|
||||
const std::vector <std::pair <std::string, Lexer2::Type> >& lexemes) const
|
||||
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
||||
{
|
||||
bool sugared = true;
|
||||
for (unsigned int i = 1; i < lexemes.size () - 1; ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue