return new CatOp (e1, e2);
}
-RegExp * mkDiff (RegExp * e1, RegExp * e2)
-{
- MatchOp * m1 = dynamic_cast<MatchOp *> (e1);
- MatchOp * m2 = dynamic_cast<MatchOp *> (e2);
- if (m1 == NULL || m2 == NULL)
- {
- return NULL;
- }
- Range * r = range_diff (m1->match, m2->match);
- return r
- ? (RegExp *) new MatchOp(r)
- : (RegExp *) new NullOp;
-}
-
Range * Scanner::getRange(SubStr &s) const
{
uint32_t lb = unescape(s), ub;
RegExp * Scanner::matchSymbolRange(Range * r) const
{
+ if (!r)
+ {
+ return new NullOp;
+ }
+
if (encoding.is(Enc::UTF16))
return UTF16Range(r);
else if (encoding.is(Enc::UTF8))
s.len -= 2;
s.str += 1;
- if (s.len == 0)
- return new NullOp;
+ Range * r = s.len == 0
+ ? NULL
+ : mkRange(s);
- return matchSymbolRange(mkRange(s));
+ return matchSymbolRange (r);
}
RegExp * Scanner::invToRE (SubStr & s) const
return matchSymbolRange(r);
}
+RegExp * Scanner::mkDiff (RegExp * e1, RegExp * e2) const
+{
+ MatchOp * m1 = dynamic_cast<MatchOp *> (e1);
+ MatchOp * m2 = dynamic_cast<MatchOp *> (e2);
+ if (m1 == NULL || m2 == NULL)
+ {
+ fatal("can only difference char sets");
+ }
+ Range * r = range_diff (m1->match, m2->match);
+
+ return matchSymbolRange (r);
+}
+
RegExp * Scanner::mkDot() const
{
Range * full = encoding.fullRange();
RegExp * doAlt (RegExp * e1, RegExp * e2);
RegExp * mkAlt (RegExp * e1, RegExp * e2);
RegExp * doCat (RegExp * e1, RegExp * e2);
-RegExp * mkDiff (RegExp * e1, RegExp * e2);
} // end namespace re2c
RegExp * strToCaseInsensitiveRE (SubStr & s) const;
RegExp * ranToRE (SubStr & s) const;
RegExp * invToRE (SubStr & s) const;
+ RegExp * mkDiff (RegExp * e1, RegExp * e2) const;
RegExp * mkDot () const;
RegExp * mkDefault () const;