source: icGREP/icgrep-devel/icgrep/re/re_re.h @ 4206

Last change on this file since 4206 was 4206, checked in by nmedfort, 5 years ago

Minor clean-up

File size: 2.2 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef RE_H
8#define RE_H
9
10#include <vector>
11#include <assert.h>
12#include <llvm/Support/Casting.h>
13
14using namespace llvm;
15
16namespace re {
17
18class Vector;
19class Pair;
20
21class Alt;
22class CC;
23class Diff;
24class End;
25class Intersect;
26class Name;
27class Permute;
28class Rep;
29class Seq;
30class Start;
31class SymDiff;
32class Union;
33
34class RE {
35public:
36    enum class ClassTypeId : unsigned {
37        Alt
38        , CC
39        , Diff
40        , End
41        , Intersect
42        , Name
43        , Permute
44        , Rep
45        , Seq
46        , Start
47        , SymDiff
48        , Union
49    };
50    inline ClassTypeId getClassTypeId() const {
51        return mClassTypeId;
52    }
53    typedef std::initializer_list<RE *> InitializerList;
54    virtual ~RE() = 0;
55protected:
56    inline RE(const ClassTypeId id)
57    : mClassTypeId(id) {
58
59    }
60    const ClassTypeId mClassTypeId;
61};
62
63class Vector : public RE, public std::vector<RE*> {
64public:
65    virtual ~Vector() {
66        for (RE * re : *this) {
67            delete re;
68        }
69    }
70protected:
71    inline Vector(const ClassTypeId id)
72    : RE(id)
73    , std::vector<RE*>()
74    {
75
76    }
77    inline Vector(const ClassTypeId id, const iterator begin, const iterator end)
78    : RE(id)
79    , std::vector<RE*>(begin, end) {
80
81    }
82};
83
84//class Pair : public RE {
85//protected:
86//    inline Pair(const ClassTypeId id)
87//    : RE(id)
88//    , _lh(nullptr)
89//    , _rh(nullptr)
90//    {
91
92//    }
93//    inline Pair(const ClassTypeId id, const RE * lh, const RE * rh)
94//    : RE(id)
95//    , _lh(lh)
96//    , _rh(rh)
97//    {
98
99//    }
100//    virtual ~Pair() {
101//        delete _lh;
102//        delete _rh;
103//    }
104//protected:
105//    const RE * _lh;
106//    const RE * _rh;
107//};
108
109//static Diff * makeDiff(const RE * lh, const RE * rh);
110
111//static Intersect * makeIntersect(const RE * lh, const RE * rh);
112
113//static Permute * makePermute();
114//static Permute * makePermute(Vector::iterator begin, Vector::iterator end);
115
116//static SymDiff * makeSymDiff(const RE * lh, const RE * rh);
117
118//static Union * makeUnion(const RE * lh, const RE * rh);
119
120}
121
122#endif // RE_H
123
124
Note: See TracBrowser for help on using the repository browser.