]> granicus.if.org Git - re2c/commitdiff
- Add --case-inverted
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Thu, 14 Feb 2008 19:39:33 +0000 (19:39 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Thu, 14 Feb 2008 19:39:33 +0000 (19:39 +0000)
- Add tests
- Prepare for release later today

15 files changed:
re2c/CHANGELOG
re2c/bootstrap/scanner.cc
re2c/globals.h
re2c/htdocs/index.html
re2c/htdocs/manual.html
re2c/main.cc
re2c/re2c.1.in
re2c/run_tests.sh.in
re2c/scanner.re
re2c/test/casing-flags.i--case-insensitive.c [moved from re2c/test/long-flag.-case-insensitive.c with 55% similarity]
re2c/test/casing-flags.i--case-insensitive.re [moved from re2c/test/long-flag.-case-insensitive.re with 100% similarity]
re2c/test/casing-flags.i--case-inverted.c [new file with mode: 0755]
re2c/test/casing-flags.i--case-inverted.re [new file with mode: 0755]
re2c/test/casing-flags.i.c [new file with mode: 0755]
re2c/test/casing-flags.i.re [new file with mode: 0755]

index 171624060519e9f22b8e94ef2af0b861becc56cf..e719f5b1da64bcc305dedd71aa24fe9f9e313167 100644 (file)
@@ -1,5 +1,6 @@
-Version 0.13.2 (2008-??-??)
+Version 0.13.2 (2008-02-14)
 ---------------------------
+- Added flag --case-inverted.
 - Added flag --case-insensitive.
 - Added support for '<!...>' to enable rule setup.
 - Added support for '=>' style rules.
index 264d08799b7e5857a3a05394574f5d8e8e6092ad..97d1f05931d930a614fa5138a828dbf6d69c1f07 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.2.dev on Wed Feb 13 14:12:34 2008 */
+/* Generated by re2c 0.13.2.dev on Thu Feb 14 20:22:44 2008 */
 /* $Id$ */
 #include <stdlib.h>
 #include <string.h>
@@ -855,7 +855,14 @@ yy138:
        ++YYCURSOR;
        {
                                        cur = cursor;
-                                       yylval.regexp = strToCaseInsensitiveRE(token());
+                                       if (bCaseInverted)
+                                       {
+                                               yylval.regexp = strToRE(token());
+                                       }
+                                       else
+                                       {
+                                               yylval.regexp = strToCaseInsensitiveRE(token());
+                                       }
                                        return STRING;
                                }
 yy140:
@@ -877,7 +884,7 @@ yy143:
        ++YYCURSOR;
        {
                                        cur = cursor;
-                                       if (bCaseInsensitive)
+                                       if (bCaseInsensitive || bCaseInverted)
                                        {
                                                yylval.regexp = strToCaseInsensitiveRE(token());
                                        }
index d48bc0fe98fccf8a0aaa4b3c3ccaad69efd573a4..eb79e908d73e8342377be2c5ab0003b02e70488e 100644 (file)
@@ -73,6 +73,7 @@ extern bool bUseYYGetStateNaked;
 extern bool bWroteGetState;
 extern bool bWroteCondCheck;
 extern bool bCaseInsensitive;
+extern bool bCaseInverted;
 
 extern uint asc2ebc[256];
 extern uint ebc2asc[256];
index 4c792025537aa2e41a0126fa354eb8c78fa978fd..77c8970b1e085e8f76bf29c39889cbff2df27443 100755 (executable)
@@ -80,7 +80,8 @@ fixes which were incorporated. <a href=
 </ul>
 <hr />
 <h1>Changelog</h1>
-<h2>2008-??-??: 0.13.2</h2>
+<h2>2008-02-14: 0.13.2</h2>
+<li>Added flag --case-inverted.</li>
 <li>Added flag --case-insensitive.</li>
 <li>Added support for '&lt;!...&gt;' to enable rule setup.</li>
 <li>Added support for '=&gt;' style rules.</li>
index 26cd68ca1476e3ad5daaa41ea1022013acfe3608..85fbb44485a8ec06932a088087e418f09a17db3f 100755 (executable)
@@ -144,6 +144,10 @@ version.<br /><br /></dd>
 <dt><b>--case-insensitive</b></dt>
 <dd>All strings are case insensitive, so all "-expressions are treated
 in the same way '-expressions are.<br /><br /></dd>
+<dt><b>--case-inverted</b></dt>
+<dd>Invert the meaning of single and double quoted strings.
+With this switch single quotes are case sensitive and
+double quotes are case insensitive.<br /><br /></dd>
 </dl>
 <br />
 <br />
@@ -207,7 +211,7 @@ information in YYMARKER. Some easy scanners might not use this.<br /><br /></dd>
 <dt>YYMAXFILL</dt>
 <dd>This will be automatically defined by /*!max:re2c */ blocks as explained
 above.<br /><br /></dd>
-<dt>YYSETCONDITION</dt>(<i>c</i>)
+<dt>YYSETCONDITION(<i>c</i>)</dt>
 <dd>This define is used to set the condition in transition rules. This is only
 being used when <b>-c</b> is active and transition rules are being used.</dd>
 <dt>YYSETSTATE(<i>s</i>)</dt>
@@ -297,11 +301,11 @@ There is another kind of special rules that allow to prepend code to any code
 block of all rules of a certain set of conditions or to all code blocks to all
 rules. This can be helpful when some operation is common among rules. For
 instance this can be used to store the length of the scanned string. These
-special prefix rules start with an exclamation mark followed by either a list
+special setup rules start with an exclamation mark followed by either a list
 of conditions <b>&lt;! condition, ... &gt;</b> or a star <b>&lt;!*&gt;</b>.
 When <b>re2c</b> generates the code for a rule whose state does not have a
-prefix rule and a star'd prefix rule is present, than that code will be used
-as prefix code.
+setup rule and a star'd setup rule is present, than that code will be used
+as setup code.
 </p>
 <a name="lbAI" id="lbAI">&nbsp;</a>
 <h2>SCANNER SPECIFICATIONS</h2>
index a31d8521f83a5ca56e6e1f8887294b1fc889e6bd..6d3beea4158b014854576e89e70d5cd572b8d874 100644 (file)
@@ -79,6 +79,7 @@ bool bUseStateAbort = false;
 bool bWroteGetState = false;
 bool bWroteCondCheck = false;
 bool bCaseInsensitive = false;
+bool bCaseInverted = false;
 
 uint nRealChars = 256;
 
@@ -117,6 +118,7 @@ static const mbo_opt_struct OPTIONS[] =
        mbo_opt_struct('1', 0, "single-pass"),
        mbo_opt_struct(10,  0, "no-generation-date"),
        mbo_opt_struct(11,  0, "case-insensitive"),
+       mbo_opt_struct(12,  0, "case-inverted"),
        mbo_opt_struct('-', 0, NULL) /* end of args */
 };
 
@@ -173,6 +175,10 @@ static void usage()
        "\n"
        "--case-insensitive      All strings are case insensitive, so all \"-expressions\n"
        "                        are treated in the same way '-expressions are.\n"
+       "\n"
+       "--case-inverted         Invert the meaning of single and double quoted strings.\n"
+       "                        With this switch single quotes are case sensitive and\n"
+       "                        double quotes are case insensitive.\n"
        ;
 }
 
@@ -299,6 +305,10 @@ int main(int argc, char *argv[])
                        case 11:
                        bCaseInsensitive = true;
                        break;
+
+                       case 12:
+                       bCaseInverted = true;
+                       break;
                }
        }
 
index 8b969d27921521ace5e9289a8c6468ad69c7d95e..809b2b2ed1ae6fa9e4a6780e4cb6f19e52558629 100644 (file)
@@ -166,6 +166,12 @@ version.
 \fb--case-insensitive\fP
 All strings are case insensitive, so all "-expressions are treated
 in the same way '-expressions are.
+.TP
+\fB--case-inverted\fP
+Invert the meaning of single and double quoted strings.
+With this switch single quotes are case sensitive and
+double quotes are case insensitive.
+
 .SH "INTERFACE CODE"
 Unlike other scanner generators, \*(re does not generate complete scanners:
 the user must supply some interface code.
@@ -338,11 +344,11 @@ There is another kind of special rules that allow to prepend code to any code
 block of all rules of a certain set of conditions or to all code blocks to all
 rules. This can be helpful when some operation is common among rules. For
 instance this can be used to store the length of the scanned string. These
-special prefix rules start with an exclamation mark followed by either a list
+special setup rules start with an exclamation mark followed by either a list
 of conditions \fB<! condition, ... >\fP or a star \fB<!*>\fP.
 When \*(re generates the code for a rule whose state does not have a
-prefix rule and a star'd prefix rule is present, than that code will be used
-as prefix code.
+setup rule and a star'd setup rule is present, than that code will be used
+as setup code.
 
 .SH "SCANNER SPECIFICATIONS"
 Each scanner specification consists of a set of \fIrules\fP, \fInamed
index 71f030442edd466251106b90b89af196e897f323..542833820e1056f8a79e2b47c8dfa2e236c5e24b 100644 (file)
@@ -27,9 +27,9 @@ tests="$@"
 fi;
 for x in $tests; do
        tstcnt=$(($tstcnt+1))
-       switches=`basename $x|sed -e 's/^[^.]*\.\(.*\)\.re$/-\1/g' -e 's/^[^-].*//g'`
-       genname=`echo $switches|sed -e 's,^.[^o]*$,,g' -e 's,^--.*$,,g' -e 's,^[^ot]*t.*o.*$,,g' -e 's,^-[^o]*o\(.*\),@builddir@/test/\1,g'`
-       headers=`echo $switches|sed -e 's,^.[^t]*$,,g' -e 's,^--.*$,,g' -e 's,^[^ot]*o.*t.*$,,g' -e 's,^-[^t]*t\(.*\),@builddir@/test/\1,g'`
+       switches=`basename $x|sed -e 's/^[^.]*\.\(.*\)\.re$/-\1/g' -e 's/^[^-].*//g' -e 's/\([^ ]\)--/\1 --/g'`
+       genname=`echo $switches|sed -e 's,--.*$,,g' -e 's,^.[^o]*$,,g' -e 's,^[^ot]*t.*o.*$,,g' -e 's,^-[^o]*o\(.*\),@builddir@/test/\1,g'`
+       headers=`echo $switches|sed -e 's,--.*$,,g' -e 's,^.[^t]*$,,g' -e 's,^[^ot]*o.*t.*$,,g' -e 's,^-[^t]*t\(.*\),@builddir@/test/\1,g'`
        switches=`echo $switches|sed -e 's,^-\([^ot-]*[ot]\)\(.*\)$,-\1@builddir@/test/\2,g'`
        # don't use the -o flag, since it makes it harder to diff.
        echo $x: $switches
index ca5100a9afd3627df5120884f931c4711612c7c9..fc92db1e0f80c19627f96650eaba1adf4abf5eac 100644 (file)
@@ -271,7 +271,7 @@ scan:
 
        dstring         {
                                        cur = cursor;
-                                       if (bCaseInsensitive)
+                                       if (bCaseInsensitive || bCaseInverted)
                                        {
                                                yylval.regexp = strToCaseInsensitiveRE(token());
                                        }
@@ -284,7 +284,14 @@ scan:
 
        sstring         {
                                        cur = cursor;
-                                       yylval.regexp = strToCaseInsensitiveRE(token());
+                                       if (bCaseInverted)
+                                       {
+                                               yylval.regexp = strToRE(token());
+                                       }
+                                       else
+                                       {
+                                               yylval.regexp = strToCaseInsensitiveRE(token());
+                                       }
                                        return STRING;
                                }
 
similarity index 55%
rename from re2c/test/long-flag.-case-insensitive.c
rename to re2c/test/casing-flags.i--case-insensitive.c
index a61e8bce0f67bc64deb6917aec8bbbb831f66d39..186ea97c5cd09e5104566368b076cf5ef99192e0 100755 (executable)
@@ -1,7 +1,5 @@
 /* Generated by re2c */
-#line 1 "long-flag.-case-insensitive.re"
 
-#line 5 "<stdout>"
 {
        YYCTYPE yych;
 
 yy2:
 yy3:
        ++YYCURSOR;
-#line 2 "long-flag.-case-insensitive.re"
        {return 'a';}
-#line 23 "<stdout>"
 yy5:
        ++YYCURSOR;
-#line 3 "long-flag.-case-insensitive.re"
        {return 'b';}
-#line 28 "<stdout>"
 }
-#line 4 "long-flag.-case-insensitive.re"
 
 }
diff --git a/re2c/test/casing-flags.i--case-inverted.c b/re2c/test/casing-flags.i--case-inverted.c
new file mode 100755 (executable)
index 0000000..9a647ec
--- /dev/null
@@ -0,0 +1,23 @@
+/* Generated by re2c */
+
+{
+       YYCTYPE yych;
+
+       if (YYLIMIT == YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'A':
+       case 'a':       goto yy3;
+       case 'b':       goto yy5;
+       default:        goto yy2;
+       }
+yy2:
+yy3:
+       ++YYCURSOR;
+       {return 'a';}
+yy5:
+       ++YYCURSOR;
+       {return 'b';}
+}
+
+}
diff --git a/re2c/test/casing-flags.i--case-inverted.re b/re2c/test/casing-flags.i--case-inverted.re
new file mode 100755 (executable)
index 0000000..6b22a15
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+       "a"     {return 'a';}
+       'b'     {return 'b';}
+*/
+}
diff --git a/re2c/test/casing-flags.i.c b/re2c/test/casing-flags.i.c
new file mode 100755 (executable)
index 0000000..5807673
--- /dev/null
@@ -0,0 +1,23 @@
+/* Generated by re2c */
+
+{
+       YYCTYPE yych;
+
+       if (YYLIMIT == YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'B':
+       case 'b':       goto yy5;
+       case 'a':       goto yy3;
+       default:        goto yy2;
+       }
+yy2:
+yy3:
+       ++YYCURSOR;
+       {return 'a';}
+yy5:
+       ++YYCURSOR;
+       {return 'b';}
+}
+
+}
diff --git a/re2c/test/casing-flags.i.re b/re2c/test/casing-flags.i.re
new file mode 100755 (executable)
index 0000000..6b22a15
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+       "a"     {return 'a';}
+       'b'     {return 'b';}
+*/
+}