Entity Lists

- LRParser::addEntity accumulates categorized entities for the parser.
This commit is contained in:
Paul Beckingham 2013-08-30 11:40:38 -07:00
parent 888a77213a
commit 66bcf26aa0
3 changed files with 18 additions and 2 deletions

View file

@ -62,6 +62,12 @@ Tree* LRParser::parse (const std::string& tokens)
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.
bool LRParser::matchRuleQuant (

View file

@ -28,13 +28,15 @@
#ifndef INCLUDED_LRPARSER
#define INCLUDED_LRPARSER
#include "Parser.h"
#include <map>
#include <Parser.h>
class LRParser : public Parser
{
public:
LRParser ();
Tree* parse (const std::string&);
void addEntity (const std::string&, const std::string&);
private:
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 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*);
private:
std::multimap <std::string, std::string> _entities;
};
#endif

View file

@ -103,9 +103,14 @@ int main (int argc, char** argv)
LRParser p;
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 ();
// Either returns a parse-tree or throws.
Tree* t = p.parse (commandLine);
if (t)
{