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

Last change on this file since 5208 was 5160, checked in by nmedfort, 3 years ago

Initial work for incorporating Types into Pablo AST.

File size: 3.0 KB
RevLine 
[4617]1#ifndef UCDCOMPILER_HPP
2#define UCDCOMPILER_HPP
3
[4797]4#include <re/re_cc.h>
[4617]5#include <vector>
[4797]6#include <boost/container/flat_map.hpp>
[4617]7
[4623]8namespace cc {
9    class CC_Compiler;
10}
[4617]11
[4814]12namespace re {
13    class Name;
14}
15
[4623]16namespace pablo {
17    class PabloBuilder;
18    class PabloAST;
19}
20
[4617]21namespace UCD {
22
[4623]23class UnicodeSet;
24
[4617]25class UCDCompiler {
26
27    using CC = re::CC;
28    using PabloBuilder = pablo::PabloBuilder;
29    using PabloAST = pablo::PabloAST;
30    using codepoint_t = re::codepoint_t;
31    using RangeList = std::vector<re::interval_t>;
[4797]32    using TargetMap = boost::container::flat_map<const UnicodeSet *, PabloAST *>;
[4804]33    using Target = std::pair<const UnicodeSet *, PabloAST *>;
[4797]34    using TargetVector = std::vector<Target>;
[4617]35
[4814]36    static const RangeList defaultIfHierachy;
37    static const RangeList noIfHierachy;
38
[4617]39public:
[4814]40
41    using NameMap = boost::container::flat_map<re::Name *, PabloAST *>;
42
[4622]43    UCDCompiler(cc::CC_Compiler & ccCompiler);
[4617]44
[4814]45    void generateWithDefaultIfHierarchy(NameMap & names, PabloBuilder & entry);
[4617]46
[4814]47    void generateWithoutIfHierarchy(NameMap & names, PabloBuilder & entry);
[4736]48
[4814]49    PabloAST * generateWithDefaultIfHierarchy(const UnicodeSet * set, PabloBuilder & entry);
50
51    PabloAST * generateWithoutIfHierarchy(const UnicodeSet * set, PabloBuilder & entry);
52
[4617]53protected:
54
[4797]55    void generateRange(const RangeList & ifRanges, PabloBuilder & entry);
[4617]56
[4797]57    void generateRange(const RangeList & ifRanges, const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder);
[4617]58
[4797]59    void generateSubRanges(const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder);
60
[4661]61    PabloAST * sequenceGenerator(const RangeList && ranges, const unsigned byte_no, PabloBuilder & builder, PabloAST * target, PabloAST * prefix);
[4617]62
[4661]63    PabloAST * sequenceGenerator(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & builder, PabloAST * target, PabloAST * prefix);
[4617]64
[4661]65    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder);
[4623]66
[4661]67    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & builder, PabloAST * target);
[4617]68
[4661]69    PabloAST * makePrefix(const codepoint_t cp, const unsigned byte_no, PabloBuilder & builder, PabloAST * prefix);
[4617]70
[5045]71    static RangeList byteDefinitions(const RangeList & list, const unsigned byte_no, bool isUTF_16);
[4617]72
73    template <typename RangeListOrUnicodeSet>
74    static RangeList rangeIntersect(const RangeListOrUnicodeSet & list, const codepoint_t lo, const codepoint_t hi);
75
76    static RangeList rangeGaps(const RangeList & list, const codepoint_t lo, const codepoint_t hi);
77
78    static RangeList outerRanges(const RangeList & list);
79
80    static RangeList innerRanges(const RangeList & list);
81
[5160]82    void addTargets(PabloBuilder & entry, const NameMap & names);
[4808]83
[4841]84    void updateNames(NameMap & names, PabloBuilder & entry);
[4808]85
[4617]86private:
[4622]87    cc::CC_Compiler &       mCharacterClassCompiler;
[4631]88    PabloAST *              mSuffixVar;
[4797]89    TargetMap               mTargetMap;
[4617]90};
91
92}
93
94#endif // UCDCOMPILER_HPP
Note: See TracBrowser for help on using the repository browser.