source: icGREP/icgrep-devel/icgrep/re/re_name_gather.cpp @ 6184

Last change on this file since 6184 was 6173, checked in by nmedfort, 9 months ago

Added RE_Inspector.

Migrated RE passes to RE_Transformer.

Incorporated Memoizer functionality into RE_Transformer/Inspector.

Removed Memoizer.

Bug fix for unicode_set.

File size: 1.8 KB
Line 
1#include "re_name_gather.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_range.h>
8#include <re/re_diff.h>
9#include <re/re_intersect.h>
10#include <re/re_assertion.h>
11#include <re/re_group.h>
12#include <re/re_analysis.h>
13#include <cc/alphabet.h>
14#include <UCD/ucd_compiler.hpp>
15#include <UCD/resolve_properties.h>
16#include <boost/container/flat_set.hpp>
17#include <llvm/Support/Casting.h>
18#include <llvm/Support/raw_ostream.h>
19
20using namespace llvm;
21namespace re {
22   
23   
24void gatherUnicodeProperties (RE * re, std::set<Name *> & nameSet) {
25    if (isa<Name>(re)) {
26        if (cast<Name>(re)->getType() == Name::Type::UnicodeProperty) {
27            nameSet.emplace(cast<Name>(re));
28        }
29    } else if (isa<Seq>(re)) {
30        for (RE * item : *cast<Seq>(re)) {
31            gatherUnicodeProperties(item, nameSet);
32        }
33    } else if (isa<Alt>(re)) {
34        for (RE * item : *cast<Alt>(re)) {
35            gatherUnicodeProperties(item, nameSet);
36        }
37    } else if (isa<Rep>(re)) {
38        gatherUnicodeProperties(cast<Rep>(re)->getRE(), nameSet);
39    } else if (isa<Assertion>(re)) {
40        gatherUnicodeProperties(cast<Assertion>(re)->getAsserted(), nameSet);
41    } else if (Range * rg = dyn_cast<Range>(re)) {
42        gatherUnicodeProperties(rg->getLo(), nameSet);
43        gatherUnicodeProperties(rg->getHi(), nameSet);
44    } else if (isa<Diff>(re)) {
45        gatherUnicodeProperties(cast<Diff>(re)->getLH(), nameSet);
46        gatherUnicodeProperties(cast<Diff>(re)->getRH(), nameSet);
47    } else if (isa<Intersect>(re)) {
48        gatherUnicodeProperties(cast<Intersect>(re)->getLH(), nameSet);
49        gatherUnicodeProperties(cast<Intersect>(re)->getRH(), nameSet);
50    } else if (isa<Group>(re)) {
51        gatherUnicodeProperties(cast<Group>(re)->getRE(), nameSet);
52    }
53}
54
55}
Note: See TracBrowser for help on using the repository browser.