From 78b324254557545a1abf02a211a56ab336b2394a Mon Sep 17 00:00:00 2001 From: helly Date: Sat, 22 Mar 2008 23:50:26 +0000 Subject: [PATCH] - Better Any/Dot implementation --- re2c/actions.cc | 16 ++++++++++++++-- re2c/scanner.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/re2c/actions.cc b/re2c/actions.cc index bfa2cfea..c733b8eb 100644 --- a/re2c/actions.cc +++ b/re2c/actions.cc @@ -854,12 +854,24 @@ RegExp * Scanner::ranToRE(SubStr s) const return new MatchOp(r); } +RegExp * Scanner::getAnyRE() const +{ + if (eFlag) + { + return ranToRE(SubStr("[\\000-\\377]")); + } + else + { + return new MatchOp(new Range(0, nRealChars)); + } +} + RegExp * Scanner::invToRE(SubStr s) const { s.len--; s.str++; - RegExp * any = ranToRE(SubStr(wFlag ? "[\\X0000-\\XFFFF]" : "[\\000-\\377]")); + RegExp * any = getAnyRE(); if (s.len <= 2) { @@ -877,7 +889,7 @@ RegExp * Scanner::invToRE(SubStr s) const RegExp * Scanner::mkDot() const { - RegExp * any = ranToRE(SubStr(wFlag ? "[\\X0000-\\XFFFF]" : "[\\000-\\377]")); + RegExp * any = getAnyRE(); RegExp * ran = matchChar(xlat('\n')); RegExp * inv = mkDiff(any, ran); diff --git a/re2c/scanner.h b/re2c/scanner.h index f03604f1..9a646e22 100644 --- a/re2c/scanner.h +++ b/re2c/scanner.h @@ -66,6 +66,7 @@ public: RegExp * strToRE(SubStr s) const; RegExp * strToCaseInsensitiveRE(SubStr s) const; RegExp * ranToRE(SubStr s) const; + RegExp * getAnyRE() const; RegExp * invToRE(SubStr s) const; RegExp * mkDot() const; }; -- 2.40.0