source: icGREP/icgrep-devel/icgrep/re/re_multiplex.cpp @ 6167

Last change on this file since 6167 was 6167, checked in by cameron, 9 months ago

Multiplexing using RE_transformer

File size: 1.7 KB
Line 
1#include "re_multiplex.h"
2#include <re/re_name.h>
3#include <re/re_alt.h>
4#include <re/re_cc.h>
5#include <re/re_seq.h>
6#include <re/re_rep.h>
7#include <re/re_diff.h>
8#include <re/re_intersect.h>
9#include <re/re_assertion.h>
10#include <re/re_group.h>
11#include <re/re_analysis.h>
12#include <re/re_memoizer.hpp>
13#include <re/printer_re.h>
14#include <UCD/ucd_compiler.hpp>
15#include <UCD/resolve_properties.h>
16#include <boost/container/flat_set.hpp>
17#include <cc/alphabet.h>
18#include <cc/multiplex_CCs.h>
19#include <sstream>
20#include <iostream>
21#include <functional>
22#include <llvm/Support/raw_ostream.h>
23
24using namespace boost::container;
25using namespace llvm;
26
27namespace re {
28 
29
30class CC_multiplexer : public RE_Transformer {
31public:
32    CC_multiplexer(cc::MultiplexedAlphabet * mpx) : RE_Transformer(), mMultiplexedAlphabet(mpx) {}
33    RE * transformCC(CC *) override;
34    RE * transformName(Name *) override;
35private:
36    cc::MultiplexedAlphabet * mMultiplexedAlphabet;
37};
38
39RE * CC_multiplexer::transformCC(CC * cc) {
40    if (cc->getAlphabet() == mMultiplexedAlphabet->getSourceAlphabet()) {
41        return mMultiplexedAlphabet->transformCC(cc);
42    }
43    return cc;
44}
45
46RE * CC_multiplexer::transformName(Name * name) {
47    if (LLVM_LIKELY(name->getDefinition() != nullptr)) {
48        RE * xfrm = transform(name->getDefinition());
49        if (name->getType() == Name::Type::ZeroWidth)
50            return makeZeroWidth(name->getName(), xfrm);
51        else if (name->getType() == Name::Type::Capture)
52            return makeCapture(name->getName(), xfrm);
53        else
54            return makeName(name->getName(), xfrm);
55    }
56    return name;
57}
58
59RE * transformCCs(cc::MultiplexedAlphabet * mpx, RE * re) {
60    return CC_multiplexer(mpx).transform(re);
61} 
62
63}
Note: See TracBrowser for help on using the repository browser.