00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef __IRE_NODE_BUILDER_HH__
00044 #define __IRE_NODE_BUILDER_HH__
00045
00046
00047 #include <string>
00048 #include <vector>
00049 using namespace std;
00050
00051 #include "debug.h"
00052 #include "parse_util.hh"
00053
00054
00055 class ReNode;
00056
00057
00062 typedef struct t_CharClassDescriptor
00063 {
00064 unsigned char first;
00065 unsigned char last;
00066
00070 t_CharClassDescriptor (unsigned char first_, unsigned char last_) :
00071 first(first_), last(last_)
00072 {
00073 ASSERT(first <= last, "Bad character descriptor: reversed range");
00074 }
00075
00079 t_CharClassDescriptor (unsigned char c = 0) :
00080 first(c), last(c)
00081 {}
00082
00083 } CharClassDescriptor;
00084
00095 class IReNodeBuilder
00096 {
00097 public:
00098
00102 virtual ReNode* createOrNode (ReNode *pre, ReNode *post,
00103 const Position &pos) = 0;
00104
00108 virtual ReNode* createCatNode (ReNode *pre, ReNode *post,
00109 const Position &pos) = 0;
00110
00114 virtual ReNode* createPlusNode (ReNode *in, const Position &pos) = 0;
00115
00116
00120 virtual ReNode* createOptionalNode (ReNode *in, const Position &pos) = 0;
00121
00125 virtual ReNode* createStarNode (ReNode *in, const Position &pos) = 0;
00126
00130 virtual ReNode* createStringLiteralNode (const string& s,
00131 const Position &pos) = 0;
00132
00138 virtual ReNode* createCharListNode (bool negated,
00139 const vector<CharClassDescriptor> &chars,
00140 const Position &pos) = 0;
00141 };
00142
00143 #endif