source: icGREP/icgrep-devel/icgrep/re/re_simplifier.cpp @ 4249

Last change on this file since 4249 was 4249, checked in by nmedfort, 5 years ago

Big update to use CC_NameMap; removed CharClass? and RE_Reducer.

File size: 921 bytes
Line 
1#include "re_simplifier.h"
2#include "re_cc.h"
3#include "re_name.h"
4#include "re_start.h"
5#include "re_end.h"
6#include "re_seq.h"
7#include "re_alt.h"
8#include "re_rep.h"
9#include <algorithm>
10#include <memory>
11#include <queue>
12
13namespace re {
14
15RE * RE_Simplifier::simplify(RE * re) {
16    if (Alt * alt = dyn_cast<Alt>(re)) {
17        std::vector<RE*> list;
18        list.reserve(alt->size());
19        for (RE * re : *alt) {
20            list.push_back(simplify(re));
21        }
22        re = makeAlt(list.begin(), list.end());
23    }
24    else if (Seq * seq = dyn_cast<Seq>(re)) {
25        std::vector<RE*> list;
26        list.reserve(seq->size());
27        for (RE * re : *seq) {
28            list.push_back(simplify(re));
29        }
30        re = makeSeq(list.begin(), list.end());
31    }
32    else if (Rep * rep = dyn_cast<Rep>(re)) {
33        re = makeRep(simplify(rep->getRE()), rep->getLB(), rep->getUB());
34    }
35    return re;
36}
37
38}
Note: See TracBrowser for help on using the repository browser.