added token classes and token class process() methods to Imbecile-generated parser

This commit is contained in:
Josh Holtrop committed 2010-05-20 17:08:03 -04:00
1 parent 449a510671
commit c6cc8e57d1
5 files changed
+46 -5

No files matched your search

+4 -2
View File
@@ -121,7 +121,7 @@ bool I_CLASSNAME::parse(istream & i)
}
if (longest_match_index >= 0)
{
MatchesRef matches = new Matches(tokens[longest_match_index].re,
Matches matches(tokens[longest_match_index].re,
&buff[0], ovector, ovector_size);
TokenRef token = buildToken(longest_match_index);
buff_pos += longest_match_length;
@@ -149,7 +149,7 @@ refptr<Node> Node::operator[](const std::string & index)
: NULL;
}
void Token::process(MatchesRef matches)
void Token::process(Matches matches)
{
{%token_code%}
}
@@ -187,6 +187,8 @@ std::string Matches::operator[](const std::string & index)
return "";
}
{%token_classes_code%}
#ifdef I_NAMESPACE
};
#endif
+6 -2
View File
@@ -3,11 +3,16 @@
#define IMBECILE_PARSER_HEADER
#include <pcre.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <iostream>
#include <map>
#include <vector>
{%user_includes%}
{%defines%}
#ifdef I_NAMESPACE
@@ -138,7 +143,6 @@ class Matches
int * m_ovector;
int m_ovec_size;
};
typedef refptr<Matches> MatchesRef;
class Node
{
@@ -155,7 +159,7 @@ typedef refptr<Node> NodeRef;
class Token : public Node
{
public:
virtual void process(MatchesRef matches);
virtual void process(Matches matches);
protected:
{%token_data%}