]> granicus.if.org Git - re2c/commitdiff
add --emit-dot flag to produce Graphviz dot files
authornuno-lopes <nuno-lopes@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 19 Feb 2008 16:19:29 +0000 (16:19 +0000)
committernuno-lopes <nuno-lopes@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 19 Feb 2008 16:19:29 +0000 (16:19 +0000)
14 files changed:
re2c/CHANGELOG
re2c/bootstrap/scanner.cc
re2c/code.cc
re2c/dfa.cc
re2c/globals.h
re2c/htdocs/index.html
re2c/htdocs/manual.html
re2c/main.cc
re2c/re2c.1.in
re2c/scanner.re
re2c/test/dot.D.c [new file with mode: 0644]
re2c/test/dot.D.re [new file with mode: 0644]
re2c/test/dot_conditions.Dc.c [new file with mode: 0644]
re2c/test/dot_conditions.Dc.re [new file with mode: 0644]

index 5aa8a17693a61191774aed566926d1291b3da665..973301b773eee60b8eb1dfb75b81f3510a075fe1 100644 (file)
@@ -2,6 +2,7 @@ Version 0.13.3 (2008-??-??)
 ---------------------------
 - Partial support for flex syntax.
 - Changed to allow /* comments with -c switch.
+- Added flag -D/--emit-dot.
 
 Version 0.13.2 (2008-02-14)
 ---------------------------
index 7f9339df5c68332b8636048e26bec2834a4e2db8..3cad237e3fdb385067069cd147baed50a5457e36 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.3.dev on Mon Feb 18 22:23:11 2008 */
+/* Generated by re2c 0.13.3.dev on Tue Feb 19 13:00:29 2008 */
 /* $Id$ */
 #include <stdlib.h>
 #include <string.h>
@@ -125,7 +125,7 @@ yy5:
                                        {
                                                ignore_cnt++;
                                        }
-                                       else
+                                       else if (!DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
                                        }
@@ -136,7 +136,7 @@ yy5:
 yy7:
        ++YYCURSOR;
        {
-                                       if (!ignore_eoc)
+                                       if (!ignore_eoc && !DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok) - 1);
                                                // -1 so we don't write out the \0
@@ -165,7 +165,7 @@ yy11:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else
+                                       else if (!DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
                                        }
@@ -195,7 +195,7 @@ yy14:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else
+                                       else if (!DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
                                        }
@@ -243,7 +243,10 @@ yy22:
                                        {
                                                fatal("found scanner block after YYMAXFILL declaration");
                                        }
-                                       out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
+                                       if (!DFlag)
+                                       {
+                                               out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
+                                       }
                                        tok = cursor;
                                        RETURN(1);
                                }
@@ -266,7 +269,10 @@ yy27:
                                        {
                                                fatal("cannot generate YYMAXFILL twice");
                                        }
-                                       out << "#define YYMAXFILL " << maxFill << std::endl;
+                                       if (!DFlag)
+                                       {
+                                               out << "#define YYMAXFILL " << maxFill << std::endl;
+                                       }
                                        tok = pos = cursor;
                                        ignore_eoc = true;
                                        bUsedYYMaxFill = true;
@@ -352,7 +358,7 @@ yy59:
                                        }
                                        tok = pos = cursor;
                                        ignore_eoc = true;
-                                       if (bLastPass)
+                                       if (bLastPass && !DFlag)
                                        {
                                                out << outputFileInfo;
                                                out << "\n";
index 2add39e04dee403a2ed0e2da88904f27cc7baa27..7b3b04aeff53b882f5533257ba0393d95eba6cb7 100644 (file)
@@ -22,7 +22,7 @@ static std::string indent(uint ind)
 {
        std::string str;
 
-       while (ind-- > 0)
+       while (!DFlag && ind-- > 0)
        {
                str += indString;
        }
@@ -362,6 +362,12 @@ void BitMap::stats()
 
 void genGoTo(std::ostream &o, uint ind, const State *from, const State *to, bool & readCh)
 {
+       if (DFlag)
+       {
+               o << from->label << " -> " << to->label << "\n";
+               return;
+       }
+
        if (readCh && from->label + 1 != to->label)
        {
                o << indent(ind) << mapCodeName["yych"] << " = " << yychConversion << "*" << mapCodeName["YYCURSOR"] << ";\n";
@@ -392,6 +398,11 @@ void genIf(std::ostream &o, uint ind, const char *cmp, uint v, bool &readCh)
 
 static void need(std::ostream &o, uint ind, uint n, bool & readCh, bool bSetMarker)
 {
+       if (DFlag)
+       {
+               return;
+       }
+
        uint fillIndex = next_fill_index;
 
        if (fFlag)
@@ -442,6 +453,11 @@ static void need(std::ostream &o, uint ind, uint n, bool & readCh, bool bSetMark
 
 void Match::emit(std::ostream &o, uint ind, bool &readCh, const std::string&) const
 {
+       if (DFlag)
+       {
+               return;
+       }
+
        if (state->link)
        {
                o << indent(ind) << "++" << mapCodeName["YYCURSOR"] << ";\n";
@@ -536,6 +552,11 @@ void Initial::emit(std::ostream &o, uint ind, bool &readCh, const std::string&)
 
 void Save::emit(std::ostream &o, uint ind, bool &readCh, const std::string&) const
 {
+       if (DFlag)
+       {
+               return;
+       }
+
        if (bUsedYYAccept)
        {
                o << indent(ind) << mapCodeName["yyaccept"] << " = " << selector << ";\n";
@@ -614,7 +635,10 @@ void Accept::emit(std::ostream &o, uint ind, bool &readCh, const std::string&) c
        if (mapRules.size() > 0)
        {
                bUsedYYMarker = true;
-               o << indent(ind) << mapCodeName["YYCURSOR"] << " = " << mapCodeName["YYMARKER"] << ";\n";
+               if (!DFlag)
+               {
+                       o << indent(ind) << mapCodeName["YYCURSOR"] << " = " << mapCodeName["YYMARKER"] << ";\n";
+               }
 
                if (readCh) // shouldn't be necessary, but might become at some point
                {
@@ -643,6 +667,14 @@ void Accept::emit(std::ostream &o, uint ind, bool &readCh, const std::string&) c
                        {
                                emitBinary(o, ind, 0, mapRules.size() - 1, readCh);
                        }
+                       else if (DFlag)
+                       {
+                               for (RuleMap::const_iterator it = mapRules.begin(); it != mapRules.end(); ++it)
+                               {
+                                       o << state->label << " -> " << it->second->label;
+                                       o << " [label=\"yyaccept=" << it->first << "\"]\n";
+                               }
+                       }
                        else
                        {
                                o << indent(ind) << "switch (" << mapCodeName["yyaccept"] << ") {\n";
@@ -671,6 +703,12 @@ Rule::Rule(State *s, RuleOp *r) : Action(s), rule(r)
 
 void Rule::emit(std::ostream &o, uint ind, bool &, const std::string& condName) const
 {
+       if (DFlag)
+       {
+               o << state->label << " [label=\"" << sourceFileInfo.fname << ":" << rule->code->line << "\"];\n";
+               return;
+       }
+
        uint back = rule->ctx->fixedLength();
 
        if (back != 0u)
@@ -719,7 +757,7 @@ void doLinear(std::ostream &o, uint ind, Span *s, uint n, const State *from, con
                                        genIf(o, ind, "!=", s[0].ub, readCh);
                                        genGoTo(o, 0, from, bg, readCh);
                                }
-                               if (next->label != from->label + 1)
+                               if (next->label != from->label + 1 || DFlag)
                                {
                                        genGoTo(o, ind, from, next, readCh);
                                }
@@ -741,7 +779,7 @@ void doLinear(std::ostream &o, uint ind, Span *s, uint n, const State *from, con
                if (n == 1)
                {
                        //              if(bg != next){
-                       if (s[0].to->label != from->label + 1)
+                       if (s[0].to->label != from->label + 1 || DFlag)
                        {
                                genGoTo(o, ind, from, s[0].to, readCh);
                        }
@@ -755,7 +793,7 @@ void doLinear(std::ostream &o, uint ind, Span *s, uint n, const State *from, con
                                genIf(o, ind, ">=", s[0].ub, readCh);
                                genGoTo(o, 0, from, s[1].to, readCh);
                        }
-                       if (next->label != from->label + 1)
+                       if (next->label != from->label + 1 || DFlag)
                        {
                                genGoTo(o, ind, from, next, readCh);
                        }
@@ -773,7 +811,7 @@ void doLinear(std::ostream &o, uint ind, Span *s, uint n, const State *from, con
                }
        }
 
-       if (next->label != from->label + 1)
+       if (next->label != from->label + 1 || DFlag)
        {
                genGoTo(o, ind, from, next, readCh);
        }
@@ -784,7 +822,7 @@ void Go::genLinear(std::ostream &o, uint ind, const State *from, const State *ne
        doLinear(o, ind, span, nSpans, from, next, readCh, mask);
 }
 
-bool genCases(std::ostream &o, uint ind, uint lb, Span *s, bool &newLine, uint mask)
+bool genCases(std::ostream &o, uint ind, uint lb, Span *s, bool &newLine, uint mask, const State *from, const State *to)
 {
        bool used = false;
 
@@ -799,9 +837,19 @@ bool genCases(std::ostream &o, uint ind, uint lb, Span *s, bool &newLine, uint m
                {
                        if (!mask || lb > 0x00FF)
                        {
-                               o << indent(ind) << "case ";
-                               prtChOrHex(o, lb);
-                               o << ":";
+                               if (DFlag)
+                               {
+                                       o << from->label << " -> " << to->label;
+                                       o << " [label=";
+                                       prtChOrHex(o, lb);
+                                       o << "]";
+                               }
+                               else
+                               {
+                                       o << indent(ind) << "case ";
+                                       prtChOrHex(o, lb);
+                                       o << ":";
+                               }
                                newLine = false;
                                used = true;
                        }
@@ -841,19 +889,22 @@ void Go::genSwitch(std::ostream &o, uint ind, const State *from, const State *ne
                        }
                }
 
-               if (dFlag)
+               if (!DFlag)
                {
-                       o << indent(ind) << mapCodeName["YYDEBUG"] << "(-1, " << mapCodeName["yych"] << ");\n";
-               }
+                       if (dFlag)
+                       {
+                               o << indent(ind) << mapCodeName["YYDEBUG"] << "(-1, " << mapCodeName["yych"] << ");\n";
+                       }
 
-               if (readCh)
-               {
-                       o << indent(ind) << "switch ((" << mapCodeName["yych"] << " = " << yychConversion << "*" << mapCodeName["YYCURSOR"] << ")) {\n";
-                       readCh = false;
-               }
-               else
-               {
-                       o << indent(ind) << "switch (" << mapCodeName["yych"] << ") {\n";
+                       if (readCh)
+                       {
+                               o << indent(ind) << "switch ((" << mapCodeName["yych"] << " = " << yychConversion << "*" << mapCodeName["YYCURSOR"] << ")) {\n";
+                               readCh = false;
+                       }
+                       else
+                       {
+                               o << indent(ind) << "switch (" << mapCodeName["yych"] << ") {\n";
+                       }
                }
 
                while (t != &sP[0])
@@ -862,22 +913,22 @@ void Go::genSwitch(std::ostream &o, uint ind, const State *from, const State *ne
 
                        r = s = &sP[0];
 
+                       const State *to = (*s)->to;
+
                        if (*s == &span[0])
                        {
-                               used |= genCases(o, ind, 0, *s, newLine, mask);
+                               used |= genCases(o, ind, 0, *s, newLine, mask, from, to);
                        }
                        else
                        {
-                               used |= genCases(o, ind, (*s)[ -1].ub, *s, newLine, mask);
+                               used |= genCases(o, ind, (*s)[ -1].ub, *s, newLine, mask, from, to);
                        }
 
-                       State *to = (*s)->to;
-
                        while (++s < t)
                        {
                                if ((*s)->to == to)
                                {
-                                       used |= genCases(o, ind, (*s)[ -1].ub, *s, newLine, mask);
+                                       used |= genCases(o, ind, (*s)[ -1].ub, *s, newLine, mask, from, to);
                                }
                                else
                                {
@@ -885,7 +936,7 @@ void Go::genSwitch(std::ostream &o, uint ind, const State *from, const State *ne
                                }
                        }
 
-                       if (used)
+                       if (used && !DFlag)
                        {
                                genGoTo(o, newLine ? ind+1 : 1, from, to, readCh);
                                newLine = true;
@@ -893,9 +944,17 @@ void Go::genSwitch(std::ostream &o, uint ind, const State *from, const State *ne
                        t = r;
                }
 
-               o << indent(ind) << "default:";
-               genGoTo(o, 1, from, def, readCh);
-               o << indent(ind) << "}\n";
+               if (DFlag)
+               {
+                       o << "\n" << from->label << " -> " << def->label;
+                       o << " [label=default]\n" ;
+               }
+               else
+               {
+                       o << indent(ind) << "default:";
+                       genGoTo(o, 1, from, def, readCh);
+                       o << indent(ind) << "}\n";
+               }
 
                delete [] sP;
        }
@@ -1667,7 +1726,13 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std::
        if (bProlog)
        {
                o << "\n" << outputFileInfo;
-               if ((!fFlag && bUsedYYAccept)
+
+               if (DFlag)
+               {
+                       bPrologBrace = true;
+                       o << "digraph re2c {\n";
+               }
+               else if ((!fFlag && bUsedYYAccept)
                ||  (!fFlag && bEmitYYCh)
                ||  (bFlag && !cFlag && BitMap::first)
                ||  (cFlag && !bWroteCondCheck && gFlag && !specMap->empty())
@@ -1681,8 +1746,8 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std::
                {
                        ind = 1;
                }
-       
-               if (!fFlag)
+
+               if (!fFlag && !DFlag)
                {
                        if (bEmitYYCh)
                        {
@@ -1726,7 +1791,15 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std::
                {
                        o << replaceParam(condDivider, condDividerParam, condName) << "\n";
                }
-               o << condPrefix << condName << ":\n";
+
+               if (DFlag)
+               {
+                       o << condName << " -> " << (start_label+1) << "\n";
+               }
+               else
+               {
+                       o << condPrefix << condName << ":\n";
+               }
        }
        if (cFlag && bFlag && BitMap::first)
        {
@@ -1928,6 +2001,13 @@ void genCondGoto(std::ostream &o, uint ind, const RegExpMap& specMap)
                                }
                                genCondGotoSub(o, ind, vCondList, 0, vCondList.size() - 1);
                        }
+                       else if (DFlag)
+                       {
+                               for(RegExpMap::const_iterator it = specMap.begin(); it != specMap.end(); ++it)
+                               {
+                                       o << "0 -> " << it->first << " [label=\"state=" << it->first << "\"]\n";
+                               }
+                       }
                        else
                        {
                                o << indent(ind) << "switch (" << genGetCondition() << ") {\n";
index d7db03d5c74adfabf2a27f07f41a9577698dc449..249fa72a0d015aef1d8369a0a9f1066d0a0b1e05 100644 (file)
@@ -14,13 +14,15 @@ void prtChOrHex(std::ostream& o, uint c, bool useTalx)
 
        if ((oc < 256) && isprint(oc))
        {
-               o << '\'';
+               o << (DFlag ? '"' : '\'');
                prtCh(o, c);
-               o << '\'';
+               o << (DFlag ? '"' : '\'');
        }
        else
        {
+               if (DFlag) o << '"';
                prtHex(o, c);
+               if (DFlag) o << '"';
        }
 }
 
@@ -63,7 +65,11 @@ void prtCh(std::ostream& o, uint c, bool useTalx)
        switch (oc)
        {
                case '\'':
-               o << "\\'";
+               o << (DFlag ? "'" : "\\'");
+               break;
+
+               case '"':
+               o << (DFlag ? "\\\"" : "\"");
                break;
 
                case '\n':
index 35ae798c6ebc85d652d46ccedf4c06bcc3ce383e..d89be9246a2d25952a2c38436b9aec8ae36d52e6 100644 (file)
@@ -19,6 +19,7 @@ extern file_info headerFileInfo;
 extern bool bFlag;
 extern bool cFlag;
 extern bool dFlag;
+extern bool DFlag;
 extern bool eFlag;
 extern bool fFlag;
 extern bool FFlag;
index 92094e18507c318a36022de89ad89889a548d444..aa1819d8b0333ff1e95bb1452116f90191c961d6 100755 (executable)
@@ -83,6 +83,7 @@ fixes which were incorporated. <a href=
 <h2>2008-??-??: 0.13.3</h2>
 <ul>
 <li>Changed to allow /* comments with -c switch.</li>
+<li>Added flag -D/--emit-dot.</li>
 </ul>
 <h2>2008-02-14: 0.13.2</h2>
 <ul>
index 582c3d6187bcc882e9fe9616467cc140323c7475..8b83e5c87048e51fcbc4a531b577d79aa135a12a 100755 (executable)
@@ -100,6 +100,10 @@ parser issues and states. If you use this switch you need to define a macro
 <i>YYDEBUG</i> that is called like a function with two parameters: <i>void
 YYDEBUG(int state, char current)</i>. The first parameter receives the state or
 -1 and the second parameter receives the input at the current cursor.<br /><br /></dd>
+<dt><b>-D</b></dt>
+<dd>Emit Graphviz dot data. It can then be processed with e.g.
+"dot -Tpng input.dot > output.png". Please note that scanners with many states
+may crash dot.<br /><br /></dd>
 <dt><b>-e</b></dt>
 <dd>Cross-compile from an ASCII platform to an EBCDIC one.<br /><br /></dd>
 <dt><b>-f</b></dt>
index 9cd5785190e77333ab5c943638cfeeb5cd018143..0833f4b1658afc5a25ab7ec36cd11090aa22e48a 100644 (file)
@@ -25,6 +25,7 @@ file_info headerFileInfo;
 bool bFlag = false;
 bool cFlag = false;
 bool dFlag = false;
+bool DFlag = false;
 bool eFlag = false;
 bool fFlag = false;
 bool FFlag = false;
@@ -104,6 +105,7 @@ static const mbo_opt_struct OPTIONS[] =
        mbo_opt_struct('b', 0, "bit-vectors"),
        mbo_opt_struct('c', 0, "start-conditions"),
        mbo_opt_struct('d', 0, "debug-output"),
+       mbo_opt_struct('D', 0, "emit-dot"),
        mbo_opt_struct('e', 0, "ecb"),
        mbo_opt_struct('f', 0, "storable-state"),
        mbo_opt_struct('F', 0, "flex-syntax"),
@@ -116,7 +118,7 @@ static const mbo_opt_struct OPTIONS[] =
        mbo_opt_struct('u', 0, "unicode"),
        mbo_opt_struct('v', 0, "version"),
        mbo_opt_struct('V', 0, "vernum"),
-       mbo_opt_struct('w', 0, "wide-chars"),      
+       mbo_opt_struct('w', 0, "wide-chars"),
        mbo_opt_struct('1', 0, "single-pass"),
        mbo_opt_struct(10,  0, "no-generation-date"),
        mbo_opt_struct(11,  0, "case-insensitive"),
@@ -126,7 +128,7 @@ static const mbo_opt_struct OPTIONS[] =
 
 static void usage()
 {
-       cerr << "usage: re2c [-bdefghisvVw1] [-o file] file\n"
+       cerr << "usage: re2c [-bcdDefFghisvVw1] [-o file] file\n"
        "\n"
        "-? -h  --help           Display this info.\n"
        "\n"
@@ -141,6 +143,8 @@ static void usage()
        "                        about the current position and in which state the\n"
        "                        parser is.\n"
        "\n"
+       "-D     --emit-dot       Emit a Graphviz dot view of the DFA graph\n"
+       "\n"
        "-e     --ecb            Cross-compile from an ASCII platform to\n"
        "                        an EBCDIC one.\n"
        "\n"
@@ -227,6 +231,11 @@ int main(int argc, char *argv[])
                        dFlag = true;
                        break;
 
+                       case 'D':
+                       DFlag = true;
+                       iFlag = true;
+                       break;
+
                        case 'f':
                        fFlag = true;
                        break;
index bd7f162893bf1fb040d433bf57bffa939a887dad..3fff0feb96949b4d2d5c676aee9b1c76caa2dc92 100644 (file)
@@ -11,7 +11,7 @@
 \*(re \- convert \*(rxs to C/C++
 
 .SH SYNOPSIS
-\*(re [\fB-bdefFghisuvVw1\fP] [\fB-o output\fP] [\fB-c\fP [\fB-t header\fP]] \fBfile\fP
+\*(re [\fB-bdDefFghisuvVw1\fP] [\fB-o output\fP] [\fB-c\fP [\fB-t header\fP]] \fBfile\fP
 
 .SH DESCRIPTION
 \*(re is a preprocessor that generates C-based recognizers from regular
@@ -109,6 +109,11 @@ parser issues and states. If you use this switch you need to define a macro
 \fIvoid YYDEBUG(int state, char current)\fP. The first parameter receives the 
 state or -1 and the second parameter receives the input at the current cursor.
 .TP
+\fB-D\fP
+Emit Graphviz dot data. It can then be processed with e.g.
+"dot -Tpng input.dot > output.png". Please note that scanners with many states
+may crash dot.
+.TP
 \fB-e\fP
 Cross-compile from an ASCII platform to an EBCDIC one. 
 .TP
index d5e4c4bec7b0e6cd6c1b6aef8a86b721c64536c9..5c55b04cc6f257ab8f148862d51735fa95ef17cd 100644 (file)
@@ -116,7 +116,10 @@ echo:
                                        {
                                                fatal("found scanner block after YYMAXFILL declaration");
                                        }
-                                       out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
+                                       if (!DFlag)
+                                       {
+                                               out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
+                                       }
                                        tok = cursor;
                                        RETURN(1);
                                }
@@ -125,7 +128,10 @@ echo:
                                        {
                                                fatal("cannot generate YYMAXFILL twice");
                                        }
-                                       out << "#define YYMAXFILL " << maxFill << std::endl;
+                                       if (!DFlag)
+                                       {
+                                               out << "#define YYMAXFILL " << maxFill << std::endl;
+                                       }
                                        tok = pos = cursor;
                                        ignore_eoc = true;
                                        bUsedYYMaxFill = true;
@@ -149,7 +155,7 @@ echo:
                                        }
                                        tok = pos = cursor;
                                        ignore_eoc = true;
-                                       if (bLastPass)
+                                       if (bLastPass && !DFlag)
                                        {
                                                out << outputFileInfo;
                                                out << "\n";
@@ -170,7 +176,7 @@ echo:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else
+                                       else if (!DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
                                        }
@@ -187,7 +193,7 @@ echo:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else
+                                       else if (!DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
                                        }
@@ -199,7 +205,7 @@ echo:
                                        {
                                                ignore_cnt++;
                                        }
-                                       else
+                                       else if (!DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
                                        }
@@ -208,7 +214,7 @@ echo:
                                        goto echo;
                                }
        zero            {
-                                       if (!ignore_eoc)
+                                       if (!ignore_eoc && !DFlag)
                                        {
                                                out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok) - 1);
                                                // -1 so we don't write out the \0
diff --git a/re2c/test/dot.D.c b/re2c/test/dot.D.c
new file mode 100644 (file)
index 0000000..9d5bc3d
--- /dev/null
@@ -0,0 +1,24 @@
+/* Generated by re2c */
+
+digraph re2c {
+
+
+1 -> 2 [label="a"]
+1 -> 4 [label="e"]
+1 -> 5 [label=default]
+2 -> 10 [label="b"]
+2 -> 3 [label=default]
+3 [label="dot.D.re:8"];
+4 -> 6 [label="f"]
+4 -> 3 [label=default]
+5 -> 3
+6 -> 8 [label="g"]
+6 -> 7 [label=default]
+7 -> 3
+8 -> 9
+9 [label="dot.D.re:7"];
+10 -> 11 [label="c"]
+10 -> 7 [label=default]
+11 -> 12
+12 [label="dot.D.re:6"];
+}
diff --git a/re2c/test/dot.D.re b/re2c/test/dot.D.re
new file mode 100644 (file)
index 0000000..1de5f06
--- /dev/null
@@ -0,0 +1,13 @@
+int main(){
+       printf("some code that will be stripped");
+
+/*!re2c
+
+"abc"  { return 1; }
+"efg"  { return 2; }
+[^]    { return 3; }
+
+*/
+
+       printf("here too");
+}
diff --git a/re2c/test/dot_conditions.Dc.c b/re2c/test/dot_conditions.Dc.c
new file mode 100644 (file)
index 0000000..ac95120
--- /dev/null
@@ -0,0 +1,35 @@
+/* Generated by re2c */
+
+digraph re2c {
+
+0 -> state1 [label="state=state1"]
+0 -> state2 [label="state=state2"]
+/* *********************************** */
+state1 -> 1
+
+1 -> 3 [label="a"]
+1 -> 4 [label="f"]
+1 -> 2 [label=default]
+3 -> 8 [label="b"]
+3 -> 2 [label=default]
+4 -> 5 [label="o"]
+4 -> 2 [label=default]
+5 -> 6 [label="o"]
+5 -> 2 [label=default]
+6 -> 7
+7 [label="dot_conditions.Dc.re:8"];
+8 -> 9 [label="c"]
+8 -> 2 [label=default]
+9 -> 10
+10 [label="dot_conditions.Dc.re:6"];
+/* *********************************** */
+state2 -> 12
+12 -> 14 [label="a"]
+12 -> 13 [label=default]
+14 -> 15 [label="b"]
+14 -> 13 [label=default]
+15 -> 16 [label="c"]
+15 -> 13 [label=default]
+16 -> 17
+17 [label="dot_conditions.Dc.re:7"];
+}
diff --git a/re2c/test/dot_conditions.Dc.re b/re2c/test/dot_conditions.Dc.re
new file mode 100644 (file)
index 0000000..7e3f18a
--- /dev/null
@@ -0,0 +1,13 @@
+int main() {
+       printf("some code that will be stripped");
+
+/*!re2c
+
+<state1>"abc"  { return 1; }
+<state2>"abc"  { return 2; }
+<state1>"foo"  { return 3; }
+
+*/
+
+       printf("here too\n");
+}