From 922bea338915eb3661def7cc090d5cf87dff6744 Mon Sep 17 00:00:00 2001 From: nuno-lopes Date: Thu, 8 Jan 2009 16:34:51 +0000 Subject: [PATCH] add code to dump a compiled regex --- re2c/actions.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/re2c/actions.cc b/re2c/actions.cc index 2621f653..8f7c2dc8 100644 --- a/re2c/actions.cc +++ b/re2c/actions.cc @@ -37,11 +37,13 @@ Symbol *Symbol::find(const SubStr &str) return (*it).second; } -void showIns(std::ostream &o, const Ins &i, const Ins &base) +const Ins* showIns(std::ostream &o, const Ins &i, const Ins &base) { o.width(3); o << &i - &base << ": "; + const Ins *ret = &(&i)[1]; + switch (i.i.tag) { @@ -49,8 +51,8 @@ void showIns(std::ostream &o, const Ins &i, const Ins &base) { o << "match "; - for (const Ins *j = &(&i)[1]; j < (Ins*) i.i.link; ++j) - prtCh(o, j->c.value); + for (; ret < (Ins*) i.i.link; ++ret) + prtCh(o, ret->c.value); break; } @@ -73,6 +75,7 @@ void showIns(std::ostream &o, const Ins &i, const Ins &base) } o << "\n"; + return ret; } uint RegExp::fixedLength() @@ -1048,6 +1051,12 @@ DFA* genCode(RegExp *re) optimize(ins); + /* + for (const Ins *inst = &ins[0]; inst < &ins[re->size]; ) { + inst = showIns(std::cout, *inst, ins[0]); + } + */ + for (j = 0; j < re->size;) { unmark(&ins[j]); -- 2.40.0