From: helly
Date: Thu, 14 Feb 2008 19:39:33 +0000 (+0000)
Subject: - Add --case-inverted
X-Git-Tag: 0.13.6~92
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cbfb08eb27080146b468ce77e6eb360bf85a0aab;p=re2c
- Add --case-inverted
- Add tests
- Prepare for release later today
---
diff --git a/re2c/CHANGELOG b/re2c/CHANGELOG
index 17162406..e719f5b1 100644
--- a/re2c/CHANGELOG
+++ b/re2c/CHANGELOG
@@ -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.
diff --git a/re2c/bootstrap/scanner.cc b/re2c/bootstrap/scanner.cc
index 264d0879..97d1f059 100644
--- a/re2c/bootstrap/scanner.cc
+++ b/re2c/bootstrap/scanner.cc
@@ -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
#include
@@ -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());
}
diff --git a/re2c/globals.h b/re2c/globals.h
index d48bc0fe..eb79e908 100644
--- a/re2c/globals.h
+++ b/re2c/globals.h
@@ -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];
diff --git a/re2c/htdocs/index.html b/re2c/htdocs/index.html
index 4c792025..77c8970b 100755
--- a/re2c/htdocs/index.html
+++ b/re2c/htdocs/index.html
@@ -80,7 +80,8 @@ fixes which were incorporated.
Changelog
-2008-??-??: 0.13.2
+2008-02-14: 0.13.2
+Added flag --case-inverted.
Added flag --case-insensitive.
Added support for '<!...>' to enable rule setup.
Added support for '=>' style rules.
diff --git a/re2c/htdocs/manual.html b/re2c/htdocs/manual.html
index 26cd68ca..85fbb444 100755
--- a/re2c/htdocs/manual.html
+++ b/re2c/htdocs/manual.html
@@ -144,6 +144,10 @@ version.
--case-insensitive
All strings are case insensitive, so all "-expressions are treated
in the same way '-expressions are.
+--case-inverted
+Invert the meaning of single and double quoted strings.
+With this switch single quotes are case sensitive and
+double quotes are case insensitive.
@@ -207,7 +211,7 @@ information in YYMARKER. Some easy scanners might not use this.
YYMAXFILL
This will be automatically defined by /*!max:re2c */ blocks as explained
above.
-YYSETCONDITION(c)
+YYSETCONDITION(c)
This define is used to set the condition in transition rules. This is only
being used when -c is active and transition rules are being used.
YYSETSTATE(s)
@@ -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 <! condition, ... > or a star <!*>.
When re2c 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.
SCANNER SPECIFICATIONS
diff --git a/re2c/main.cc b/re2c/main.cc
index a31d8521..6d3beea4 100644
--- a/re2c/main.cc
+++ b/re2c/main.cc
@@ -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;
}
}
diff --git a/re2c/re2c.1.in b/re2c/re2c.1.in
index 8b969d27..809b2b2e 100644
--- a/re2c/re2c.1.in
+++ b/re2c/re2c.1.in
@@ -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\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
diff --git a/re2c/run_tests.sh.in b/re2c/run_tests.sh.in
index 71f03044..54283382 100644
--- a/re2c/run_tests.sh.in
+++ b/re2c/run_tests.sh.in
@@ -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
diff --git a/re2c/scanner.re b/re2c/scanner.re
index ca5100a9..fc92db1e 100644
--- a/re2c/scanner.re
+++ b/re2c/scanner.re
@@ -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;
}
diff --git a/re2c/test/long-flag.-case-insensitive.c b/re2c/test/casing-flags.i--case-insensitive.c
similarity index 55%
rename from re2c/test/long-flag.-case-insensitive.c
rename to re2c/test/casing-flags.i--case-insensitive.c
index a61e8bce..186ea97c 100755
--- a/re2c/test/long-flag.-case-insensitive.c
+++ b/re2c/test/casing-flags.i--case-insensitive.c
@@ -1,7 +1,5 @@
/* Generated by re2c */
-#line 1 "long-flag.-case-insensitive.re"
-#line 5 ""
{
YYCTYPE yych;
@@ -17,15 +15,10 @@
yy2:
yy3:
++YYCURSOR;
-#line 2 "long-flag.-case-insensitive.re"
{return 'a';}
-#line 23 ""
yy5:
++YYCURSOR;
-#line 3 "long-flag.-case-insensitive.re"
{return 'b';}
-#line 28 ""
}
-#line 4 "long-flag.-case-insensitive.re"
}
diff --git a/re2c/test/long-flag.-case-insensitive.re b/re2c/test/casing-flags.i--case-insensitive.re
similarity index 100%
rename from re2c/test/long-flag.-case-insensitive.re
rename to re2c/test/casing-flags.i--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
index 00000000..9a647ec1
--- /dev/null
+++ b/re2c/test/casing-flags.i--case-inverted.c
@@ -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
index 00000000..6b22a154
--- /dev/null
+++ b/re2c/test/casing-flags.i--case-inverted.re
@@ -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
index 00000000..5807673b
--- /dev/null
+++ b/re2c/test/casing-flags.i.c
@@ -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
index 00000000..6b22a154
--- /dev/null
+++ b/re2c/test/casing-flags.i.re
@@ -0,0 +1,5 @@
+/*!re2c
+ "a" {return 'a';}
+ 'b' {return 'b';}
+*/
+}