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

Last change on this file was 5887, checked in by cameron, 4 months ago

Separate compilation of Unicode property kernels

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