void MatchOp::calcSize (Char * rep)
{
size = 1;
- for (Range * r = match; r; r = r->next)
+ for (Range * r = match; r; r = r->next ())
{
- for (uint32_t c = r->lb; c < r->ub; ++c)
+ for (uint32_t c = r->lower (); c < r->upper (); ++c)
{
if (rep[c] == c)
{
i->i.link = &i[size];
Ins *j = &i[1];
uint32_t bump = size;
- for (Range *r = match; r; r = r->next)
+ for (Range *r = match; r; r = r->next ())
{
- for (uint32_t c = r->lb; c < r->ub; ++c)
+ for (uint32_t c = r->lower (); c < r->upper (); ++c)
{
if (rep[c] == c)
{
void MatchOp::split (CharSet & s)
{
- for (Range *r = match; r; r = r->next)
+ for (Range *r = match; r; r = r->next ())
{
- for (uint32_t c = r->lb; c < r->ub; ++c)
+ for (uint32_t c = r->lower (); c < r->upper (); ++c)
{
CharPtn * x = s.rep[c];
CharPtn * a = x->nxt;
RegExp * UTF16Range(const Range * r)
{
RangeSuffix * root = NULL;
- for (; r != NULL; r = r->next)
- UTF16splitByRuneLength(root, r->lb, r->ub - 1);
+ for (; r != NULL; r = r->next ())
+ UTF16splitByRuneLength(root, r->lower (), r->upper () - 1);
return emit(root, NULL);
}
RegExp * UTF8Range(const Range * r)
{
RangeSuffix * root = NULL;
- for (; r != NULL; r = r->next)
- UTF8splitByRuneLength(root, r->lb, r->ub - 1);
+ for (; r != NULL; r = r->next ())
+ UTF8splitByRuneLength(root, r->lower (), r->upper () - 1);
return emit(root, NULL);
}
uint32_t ub = r1->ub;
if (r2->lb < r1->ub)
{
- for (; r2 && r2->lb < r1->ub; r2 = r2->next)
+ for (; r2 && r2->lb < r1->ub; r2 = r2->nx)
{
if (r1->ub < r2->ub)
{
}
}
* p = new Range (r1->lb, ub);
- p = &(* p)->next;
- r1 = r1->next;
+ p = &(* p)->nx;
+ r1 = r1->nx;
}
return r;
}
{
Range * r = NULL;
Range ** p = &r;
- for (; r1; r1 = r1->next)
+ for (; r1; r1 = r1->nx)
{
- for (; r2 && r2->ub <= r1->lb; r2 = r2->next);
+ for (; r2 && r2->ub <= r1->lb; r2 = r2->nx);
uint32_t lb = r1->lb;
- for (; r2 && r2->lb < r1->ub; r2 = r2->next)
+ for (; r2 && r2->lb < r1->ub; r2 = r2->nx)
{
if (lb < r2->lb)
{
* p = new Range(lb, r2->lb);
- p = &(* p)->next;
+ p = &(* p)->nx;
}
lb = r2->ub;
}
if (lb < r1->ub)
{
* p = new Range(lb, r1->ub);
- p = &(* p)->next;
+ p = &(* p)->nx;
}
}
return r;
namespace re2c
{
-struct Range
+class Range
{
+public:
static free_list<Range*> vFreeList;
- Range * next;
+private:
+ Range * nx;
// [lb,ub)
uint32_t lb;
uint32_t ub;
+public:
Range (uint32_t l, uint32_t u)
- : next (NULL)
+ : nx (NULL)
, lb (l)
, ub (u)
{
{
vFreeList.erase (this);
}
+ Range * next () const { return nx; }
+ uint32_t lower () const { return lb; }
+ uint32_t upper () const { return ub; }
+ friend Range * range_union (Range * r1, Range * r2);
+ friend Range * range_diff (Range * r1, Range * r2);
FORBID_COPY (Range);
};
-Range * range_union (Range * r1, Range * r2);
-Range * range_diff (Range * r1, Range * r2);
-
} // end namespace re2c
#endif // _RE2C_UTIL_RANGE_