mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parser
- Only lex arguments into sub-branches if there is more than one lexeme per argument. Of course, you have to do the lex first, otherwise you don't know.
This commit is contained in:
parent
531e490e44
commit
4a063843b1
1 changed files with 16 additions and 5 deletions
|
@ -83,22 +83,33 @@ void Parser::initialize (int argc, const char** argv)
|
|||
if (! noSpaces (raw))
|
||||
branch->tag ("QUOTED");
|
||||
|
||||
// Lex each argument. If there are multiple lexemes, create sub branches,
|
||||
// otherwise no change.
|
||||
std::string lexeme;
|
||||
Lexer::Type type;
|
||||
Lexer lex (raw);
|
||||
lex.ambiguity (false);
|
||||
|
||||
std::vector <std::pair <std::string, Lexer::Type> > lexemes;
|
||||
while (lex.token (lexeme, type))
|
||||
lexemes.push_back (std::pair <std::string, Lexer::Type> (lexeme, type));
|
||||
|
||||
if (lexemes.size () > 1)
|
||||
{
|
||||
std::vector <std::pair <std::string, Lexer::Type> >::iterator l;
|
||||
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
||||
{
|
||||
Tree* sub = branch->addBranch (new Tree ("argSub"));
|
||||
sub->attribute ("raw", lexeme);
|
||||
sub->attribute ("raw", l->first);
|
||||
|
||||
if (type == Lexer::typeOperator)
|
||||
if (l->second == Lexer::typeOperator)
|
||||
sub->tag ("OP");
|
||||
|
||||
// TODO More types needed.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Parser::clear ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue