]> granicus.if.org Git - re2c/commitdiff
- Better Any/Dot implementation
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sat, 22 Mar 2008 23:50:26 +0000 (23:50 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sat, 22 Mar 2008 23:50:26 +0000 (23:50 +0000)
re2c/actions.cc
re2c/scanner.h

index bfa2cfea38984282672df64e045ba348a144c26b..c733b8ebf68e20a9199abe422ec2b1724cea6f26 100644 (file)
@@ -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);
        
index f03604f18c8ace67554b9694ce7647ef098bd211..9a646e223ac2996ce183b80148e7b6f0e427e1fa 100644 (file)
@@ -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;
 };