added RuleDefinition class
This commit is contained in:
parent
5a220b91d0
commit
448b26a767
6
Parser.h
6
Parser.h
@ -6,6 +6,7 @@
|
||||
|
||||
#include "refptr/refptr.h"
|
||||
#include "TokenDefinition.h"
|
||||
#include "RuleDefinition.h"
|
||||
|
||||
class Parser
|
||||
{
|
||||
@ -15,9 +16,14 @@ class Parser
|
||||
{
|
||||
m_tokens.push_back(td);
|
||||
}
|
||||
void addRuleDefinition(refptr<RuleDefinition> rd)
|
||||
{
|
||||
m_rules.push_back(rd);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector< refptr< TokenDefinition > > m_tokens;
|
||||
std::vector< refptr< RuleDefinition > > m_rules;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
9
RuleDefinition.cc
Normal file
9
RuleDefinition.cc
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#include "RuleDefinition.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool RuleDefinition::create(const string & name, const string & definition)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
16
RuleDefinition.h
Normal file
16
RuleDefinition.h
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
#ifndef RULEDEFINITION_H
|
||||
#define RULEDEFINITION_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class RuleDefinition
|
||||
{
|
||||
public:
|
||||
bool create(const std::string & name, const std::string & definition);
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
#endif
|
@ -153,7 +153,17 @@ bool parse_input(char * buff, int size, Parser & parser)
|
||||
string name(line, ovector[2], ovector[3] - ovector[2]);
|
||||
string definition(line,
|
||||
ovector[4], ovector[5] - ovector[4]);
|
||||
/* TODO: process rule */
|
||||
refptr<RuleDefinition> rd = new RuleDefinition();
|
||||
if (rd->create(name, definition))
|
||||
{
|
||||
parser.addRuleDefinition(rd);
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Error in rule definition ending on line "
|
||||
<< lineno << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user