mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-09 00:30:36 +02:00
Entity Lists
- LRParser::addEntity accumulates categorized entities for the parser.
This commit is contained in:
parent
888a77213a
commit
66bcf26aa0
3 changed files with 18 additions and 2 deletions
|
@ -62,6 +62,12 @@ Tree* LRParser::parse (const std::string& tokens)
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void LRParser::addEntity (const std::string& name, const std::string& value)
|
||||||
|
{
|
||||||
|
_entities.insert (std::pair <std::string, std::string> (name, value));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Wraps calls to matchRule, while properly handling the quantifier.
|
// Wraps calls to matchRule, while properly handling the quantifier.
|
||||||
bool LRParser::matchRuleQuant (
|
bool LRParser::matchRuleQuant (
|
||||||
|
|
|
@ -28,13 +28,15 @@
|
||||||
#ifndef INCLUDED_LRPARSER
|
#ifndef INCLUDED_LRPARSER
|
||||||
#define INCLUDED_LRPARSER
|
#define INCLUDED_LRPARSER
|
||||||
|
|
||||||
#include "Parser.h"
|
#include <map>
|
||||||
|
#include <Parser.h>
|
||||||
|
|
||||||
class LRParser : public Parser
|
class LRParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LRParser ();
|
LRParser ();
|
||||||
Tree* parse (const std::string&);
|
Tree* parse (const std::string&);
|
||||||
|
void addEntity (const std::string&, const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool matchRuleQuant (const std::string&, char, unsigned int&, const std::string&, Tree*);
|
bool matchRuleQuant (const std::string&, char, unsigned int&, const std::string&, Tree*);
|
||||||
|
@ -46,6 +48,9 @@ private:
|
||||||
bool tokenMatchLiteral (const Token&, unsigned int&, const std::string&, Tree*);
|
bool tokenMatchLiteral (const Token&, unsigned int&, const std::string&, Tree*);
|
||||||
bool tokenMatchRegex (const Token&, unsigned int&, const std::string&, Tree*);
|
bool tokenMatchRegex (const Token&, unsigned int&, const std::string&, Tree*);
|
||||||
bool tokenMatchRule (const std::string&, char, unsigned int, unsigned int, const Token&, unsigned int&, const std::string&, Tree*);
|
bool tokenMatchRule (const std::string&, char, unsigned int, unsigned int, const Token&, unsigned int&, const std::string&, Tree*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::multimap <std::string, std::string> _entities;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,9 +103,14 @@ int main (int argc, char** argv)
|
||||||
LRParser p;
|
LRParser p;
|
||||||
if (verbose) p.verbose ();
|
if (verbose) p.verbose ();
|
||||||
|
|
||||||
p.grammar (grammar);
|
// TODO Initialize entity lists.
|
||||||
|
p.addEntity ("report", "list");
|
||||||
|
|
||||||
|
// Load and verify grammar.
|
||||||
|
p.grammar (grammar);
|
||||||
if (verbose) p.dump ();
|
if (verbose) p.dump ();
|
||||||
|
|
||||||
|
// Either returns a parse-tree or throws.
|
||||||
Tree* t = p.parse (commandLine);
|
Tree* t = p.parse (commandLine);
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue