source: icGREP/icgrep-devel/icgrep/UCD/ucd_compiler.hpp @ 4617

Last change on this file since 4617 was 4617, checked in by nmedfort, 4 years ago

Upload of an untested (inactive) UCD compiler.

File size: 2.2 KB
Line 
1#ifndef UCDCOMPILER_HPP
2#define UCDCOMPILER_HPP
3
4#include <vector>
5#include <cc/cc_compiler.h>
6#include <re/re_cc.h>
7#include <UCD/unicode_set.h>
8#include <unordered_map>
9
10class Encoding;
11
12namespace UCD {
13
14class UCDCompiler {
15
16    using CC = re::CC;
17    using PabloBuilder = pablo::PabloBuilder;
18    using PabloAST = pablo::PabloAST;
19    using codepoint_t = re::codepoint_t;
20    using RangeList = std::vector<re::interval_t>;
21
22public:
23    UCDCompiler(pablo::PabloBlock & entry, const Encoding & encoding);
24
25    PabloAST * generateWithDefaultIfHierarchy(const UnicodeSet & set, PabloBuilder & entry);
26
27    PabloAST * generateWithIfHierarchy(const RangeList & ifRanges, const UnicodeSet & set, PabloBuilder & entry);
28
29protected:
30
31    PabloAST * generateWithIfHierarchy(const RangeList & ifRanges, const UnicodeSet & set, const codepoint_t lo, const codepoint_t hi, PabloBuilder & block);
32
33    PabloAST * generateSubRanges(const UnicodeSet & set, const codepoint_t lo, const codepoint_t hi, PabloBuilder & block, PabloAST * target);
34
35    PabloAST * sequenceGenerator(const RangeList && ranges, const unsigned byte_no, PabloBuilder & block, PabloAST * target, PabloAST * prefix);
36
37    PabloAST * sequenceGenerator(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & block, PabloAST * target, PabloAST * prefix);
38
39    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, PabloBuilder & block);
40    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & block, PabloAST * target);
41
42    PabloAST * makePrefix(const codepoint_t cp, const unsigned byte_no, PabloBuilder & pb);
43
44    static RangeList byteDefinitions(const RangeList & list, const unsigned byte_no);
45
46    template <typename RangeListOrUnicodeSet>
47    static RangeList rangeIntersect(const RangeListOrUnicodeSet & list, const codepoint_t lo, const codepoint_t hi);
48
49    static RangeList rangeGaps(const RangeList & list, const codepoint_t lo, const codepoint_t hi);
50
51    static RangeList outerRanges(const RangeList & list);
52
53    static RangeList innerRanges(const RangeList & list);
54
55private:
56    cc::CC_Compiler         mCharacterClassCompiler;
57    CC * const              mSuffix;
58};
59
60}
61
62#endif // UCDCOMPILER_HPP
Note: See TracBrowser for help on using the repository browser.