From b75521a8c0d9654133e49272d474d3de89fc9bd7 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Wed, 4 Mar 2015 17:15:38 +0000 Subject: [PATCH] Continued separating .dot case from other cases in codegen. Added test. --- re2c/code.cc | 15 ++++++++------- re2c/dfa.h | 2 +- re2c/test/dot2.D.c | 12 ++++++++++++ re2c/test/dot2.D.re | 6 ++++++ 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 re2c/test/dot2.D.c create mode 100644 re2c/test/dot2.D.re diff --git a/re2c/code.cc b/re2c/code.cc index 612a5581..018eb909 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -929,13 +929,17 @@ static bool genCases(OutputFile & o, uint ind, uint lb, Span *s, bool &newLine, return used; } -void Go::genSwitchD (OutputFile & o, uint ind, const State *from, const State *next, bool &readCh) const +void Go::genSwitchD (OutputFile & o, const State *from) const { bool newLine = true; - if (nSpans <= 2) + if (nSpans == 0) { - genLinear(o, ind, from, next, readCh, 0); + return; + } + else if (nSpans == 1) + { + o << from->label << " -> " << span[0].to->label << "\n"; } else { @@ -1234,10 +1238,7 @@ void Go::genGoto(OutputFile & o, uint ind, const State *from, const State *next, { if (DFlag) { - if (nSpans != 0) - { - genSwitchD (o, ind, from, next, readCh); - } + genSwitchD (o, from); return; } diff --git a/re2c/dfa.h b/re2c/dfa.h index 07395857..e3fdb450 100644 --- a/re2c/dfa.h +++ b/re2c/dfa.h @@ -189,7 +189,7 @@ public: void genBase(OutputFile &, uint ind, const State *from, const State *next, bool &readCh, uint mask) const; void genLinear(OutputFile &, uint ind, const State *from, const State *next, bool &readCh, uint mask) const; void genBinary(OutputFile &, uint ind, const State *from, const State *next, bool &readCh, uint mask) const; - void genSwitchD(OutputFile &, uint ind, const State *from, const State *next, bool &readCh) const; + void genSwitchD(OutputFile &, const State *from) const; void genSwitch(OutputFile &, uint ind, const State *from, const State *next, bool &readCh, uint mask) const; void genCpGoto(OutputFile &, uint ind, const State *from, const State *next, bool &readCh) const; void compact(); diff --git a/re2c/test/dot2.D.c b/re2c/test/dot2.D.c new file mode 100644 index 00000000..7ea5b34e --- /dev/null +++ b/re2c/test/dot2.D.c @@ -0,0 +1,12 @@ +/* Generated by re2c */ + +digraph re2c { + + +1 -> 2 [label="0x00"] +1 -> 4 [label=default] +2 -> 3 +3 [label="dot2.D.re:3"] +4 -> 5 +5 [label="dot2.D.re:4"] +} diff --git a/re2c/test/dot2.D.re b/re2c/test/dot2.D.re new file mode 100644 index 00000000..0fea50e7 --- /dev/null +++ b/re2c/test/dot2.D.re @@ -0,0 +1,6 @@ +/*!re2c + +"\x00" { return 1; } +[^] { return 3; } + +*/ -- 2.40.0