]> granicus.if.org Git - re2c/commitdiff
- Add configurable state deviders
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sun, 20 Jan 2008 15:55:06 +0000 (15:55 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sun, 20 Jan 2008 15:55:06 +0000 (15:55 +0000)
re2c/bootstrap/scanner.cc
re2c/code.cc
re2c/globals.h
re2c/main.cc
re2c/test/condition_01a.c.c [new file with mode: 0755]
re2c/test/condition_01a.c.re [new file with mode: 0755]
re2c/test/condition_01b.c.c [new file with mode: 0755]
re2c/test/condition_01b.c.re [new file with mode: 0755]

index 07cf0f1c2dd0b014978a7cbe0b23bd8f4bbae233..f2c13f1b3b2eacf214cd7cf21fc1a8903c1a44b5 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.2.dev on Sat Jan 19 21:52:28 2008 */
+/* Generated by re2c 0.13.2.dev on Sun Jan 20 16:36:17 2008 */
 /* $Id$ */
 #include <stdlib.h>
 #include <string.h>
@@ -1030,7 +1030,7 @@ code:
        {
                                        if (depth == 0)
                                        {
-                                               fatal("Curly braces are not allowed after #:='");
+                                               fatal("Curly braces are not allowed after ':='");
                                        }
                                        else if (--depth == 0)
                                        {
@@ -1045,7 +1045,7 @@ yy172:
        {
                                        if (depth == 0)
                                        {
-                                               fatal("Curly braces are not allowed after #:='");
+                                               fatal("Curly braces are not allowed after ':='");
                                        }
                                        else
                                        {
index b710013327c064644ddabe6449b188937344c0db..a1ac9364bd38b77e0c397c8ae37940fb1ccf323b 100644 (file)
@@ -1715,8 +1715,10 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std::
 
        if (cFlag && !condName.empty())
        {
-               // TODO: Drop marker
-               o << "/* *********************************** */\n";
+               if (condDevider.length())
+               {
+                       o << replaceParam(condDevider, condDeviderState, condName) << "\n";
+               }
                o << condPrefix << condName << ":\n";
        }
        if (cFlag && bFlag && BitMap::first)
@@ -2128,6 +2130,14 @@ void Scanner::config(const Str& cfg, const Str& val)
        {
                condEnumPrefix = strVal;
        }
+       else if (cfg.to_string() == "cond:devider")
+       {
+               condDevider = strVal;
+       }
+       else if (cfg.to_string() == "cond:devider@state")
+       {
+               condDeviderState = strVal;
+       }
        else if (cfg.to_string() == "define:YYFILL@len")
        {
                yyFillLength = strVal;
index b313d1c823aa694eeb6c857964d20c0f3e906596..1ef8e5b76f291a6f22a590d4df35c778c760a4d9 100644 (file)
@@ -43,6 +43,8 @@ extern std::string startLabelName;
 extern std::string labelPrefix;
 extern std::string condPrefix;
 extern std::string condEnumPrefix;
+extern std::string condDevider;
+extern std::string condDeviderState;
 extern std::string yychConversion;
 extern std::string yyFillLength;
 extern std::string yySetConditionParam;
index b659b17139613948024eacd89a3dd6004c00b2f2..243b72226337297160c4087a3ed493744236d129 100644 (file)
@@ -59,6 +59,8 @@ std::string startLabelName;
 std::string labelPrefix("yy");
 std::string condPrefix("yyc_");
 std::string condEnumPrefix("yyc");
+std::string condDevider("/* *********************************** */");
+std::string condDeviderState("@@");
 std::string yychConversion("");
 std::string yyFillLength("@@");
 std::string yySetConditionParam("@@");
diff --git a/re2c/test/condition_01a.c.c b/re2c/test/condition_01a.c.c
new file mode 100755 (executable)
index 0000000..081134f
--- /dev/null
@@ -0,0 +1,54 @@
+/* Generated by re2c */
+#line 1 "condition_01a.c.re"
+
+#line 5 "<stdout>"
+{
+       YYCTYPE yych;
+       switch(YYGETCONDITION()) {
+       case yyca: goto yyc_a;
+       case yycb: goto yyc_b;
+       }
+/**** State a ***/
+yyc_a:
+
+       if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch(yych) {
+       case 'a':       goto yy3;
+       default:        goto yy2;
+       }
+yy2:
+yy3:
+       yych = *++YYCURSOR;
+       switch(yych) {
+       case 'b':       goto yy4;
+       default:        goto yy2;
+       }
+yy4:
+       ++YYCURSOR;
+#line 3 "condition_01a.c.re"
+       { }
+#line 32 "<stdout>"
+/**** State b ***/
+yyc_b:
+       if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch(yych) {
+       case 'a':       goto yy9;
+       default:        goto yy8;
+       }
+yy8:
+yy9:
+       yych = *++YYCURSOR;
+       switch(yych) {
+       case 'b':       goto yy10;
+       default:        goto yy8;
+       }
+yy10:
+       ++YYCURSOR;
+#line 3 "condition_01a.c.re"
+       { }
+#line 52 "<stdout>"
+}
+#line 5 "condition_01a.c.re"
+
diff --git a/re2c/test/condition_01a.c.re b/re2c/test/condition_01a.c.re
new file mode 100755 (executable)
index 0000000..ca10ac0
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+re2c:cond:devider = "/**** State @@ ***\/";
+< a , b >      "ab"    { }
+
+*/
diff --git a/re2c/test/condition_01b.c.c b/re2c/test/condition_01b.c.c
new file mode 100755 (executable)
index 0000000..9fca14b
--- /dev/null
@@ -0,0 +1,52 @@
+/* Generated by re2c */
+#line 1 "condition_01b.c.re"
+
+#line 5 "<stdout>"
+{
+       YYCTYPE yych;
+       switch(YYGETCONDITION()) {
+       case yyca: goto yyc_a;
+       case yycb: goto yyc_b;
+       }
+yyc_a:
+
+       if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch(yych) {
+       case 'a':       goto yy3;
+       default:        goto yy2;
+       }
+yy2:
+yy3:
+       yych = *++YYCURSOR;
+       switch(yych) {
+       case 'b':       goto yy4;
+       default:        goto yy2;
+       }
+yy4:
+       ++YYCURSOR;
+#line 3 "condition_01b.c.re"
+       { }
+#line 31 "<stdout>"
+yyc_b:
+       if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch(yych) {
+       case 'a':       goto yy9;
+       default:        goto yy8;
+       }
+yy8:
+yy9:
+       yych = *++YYCURSOR;
+       switch(yych) {
+       case 'b':       goto yy10;
+       default:        goto yy8;
+       }
+yy10:
+       ++YYCURSOR;
+#line 3 "condition_01b.c.re"
+       { }
+#line 50 "<stdout>"
+}
+#line 5 "condition_01b.c.re"
+
diff --git a/re2c/test/condition_01b.c.re b/re2c/test/condition_01b.c.re
new file mode 100755 (executable)
index 0000000..0289fc0
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+re2c:cond:devider = ;
+< a , b >      "ab"    { }
+
+*/