From: helly Date: Sun, 20 Jan 2008 15:55:06 +0000 (+0000) Subject: - Add configurable state deviders X-Git-Tag: 0.13.6~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1823bb0ec765ba6ffffada7140df7c3ec627edbb;p=re2c - Add configurable state deviders --- diff --git a/re2c/bootstrap/scanner.cc b/re2c/bootstrap/scanner.cc index 07cf0f1c..f2c13f1b 100644 --- a/re2c/bootstrap/scanner.cc +++ b/re2c/bootstrap/scanner.cc @@ -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 #include @@ -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 { diff --git a/re2c/code.cc b/re2c/code.cc index b7100133..a1ac9364 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -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; diff --git a/re2c/globals.h b/re2c/globals.h index b313d1c8..1ef8e5b7 100644 --- a/re2c/globals.h +++ b/re2c/globals.h @@ -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; diff --git a/re2c/main.cc b/re2c/main.cc index b659b171..243b7222 100644 --- a/re2c/main.cc +++ b/re2c/main.cc @@ -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 index 00000000..081134fd --- /dev/null +++ b/re2c/test/condition_01a.c.c @@ -0,0 +1,54 @@ +/* Generated by re2c */ +#line 1 "condition_01a.c.re" + +#line 5 "" +{ + 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 "" +/**** 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 "" +} +#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 index 00000000..ca10ac03 --- /dev/null +++ b/re2c/test/condition_01a.c.re @@ -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 index 00000000..9fca14bf --- /dev/null +++ b/re2c/test/condition_01b.c.c @@ -0,0 +1,52 @@ +/* Generated by re2c */ +#line 1 "condition_01b.c.re" + +#line 5 "" +{ + 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 "" +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 "" +} +#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 index 00000000..0289fc0d --- /dev/null +++ b/re2c/test/condition_01b.c.re @@ -0,0 +1,5 @@ +/*!re2c +re2c:cond:devider = ; +< a , b > "ab" { } + +*/