NULL range represents empty range: range union and difference functions
return NULL for empty ranges. Thus NULL can be passed to functions
that construct regexp from range ('MatchOp', 'UTF8Range' and 'UTF16Range').
All these functions must behave return non-NULL for NULL ranges, since
further code relies on this.
namespace re2c {
+static RegExp * emit (RangeSuffix * p, RegExp * re);
+
free_list<RangeSuffix *> RangeSuffix::freeList;
+RegExp * to_regexp (RangeSuffix * p)
+{
+ return p
+ ? emit (p, NULL)
+ : new MatchOp (NULL);
+}
+
/*
* Build regexp from suffix tree.
*/
FORBID_COPY (RangeSuffix);
};
-RegExp * emit(RangeSuffix * p, RegExp * re);
+RegExp * to_regexp (RangeSuffix * p);
} // namespace re2c
RangeSuffix * root = NULL;
for (; r != NULL; r = r->next ())
UTF16splitByRuneLength(root, r->lower (), r->upper () - 1);
- return emit(root, NULL);
+ return to_regexp (root);
}
} // namespace re2c
RangeSuffix * root = NULL;
for (; r != NULL; r = r->next ())
UTF8splitByRuneLength(root, r->lower (), r->upper () - 1);
- return emit(root, NULL);
+ return to_regexp (root);
}
} // namespace re2c