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

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

Implemented slab allocator based on the original Parabix StringPool?; intergrated it with RE and Pablo AST nodes.

File size: 2.3 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#include <slab_allocator.h>
14
15using namespace llvm;
16
17namespace re {
18
19class Vector;
20class Pair;
21
22class Alt;
23class Any;
24class CC;
25class Diff;
26class End;
27class Intersect;
28class Name;
29class Permute;
30class Rep;
31class Seq;
32class Start;
33class SymDiff;
34class Union;
35
36class RE {
37public:
38    typedef SlabAllocator<1024> Allocator;
39    enum class ClassTypeId : unsigned {
40        Alt
41        , Any
42        , CC
43        , Diff
44        , End
45        , Intersect
46        , Name
47        , Permute
48        , Rep
49        , Seq
50        , Start
51        , SymDiff
52        , Union
53    };
54    inline ClassTypeId getClassTypeId() const {
55        return mClassTypeId;
56    }
57    inline static void release_memory() {
58        mAllocator.release_memory();
59    }
60    typedef std::initializer_list<RE *> InitializerList;
61protected:
62    inline RE(const ClassTypeId id)
63    : mClassTypeId(id) {
64
65    }
66    const ClassTypeId mClassTypeId;
67
68    static Allocator mAllocator;
69};
70
71class Vector : public RE, public std::vector<RE*> {
72public:
73    virtual ~Vector() {
74    }
75protected:
76    inline Vector(const ClassTypeId id)
77    : RE(id)
78    , std::vector<RE*>()
79    {
80
81    }
82    inline Vector(const ClassTypeId id, const iterator begin, const iterator end)
83    : RE(id)
84    , std::vector<RE*>(begin, end) {
85
86    }
87};
88
89//class Pair : public RE {
90//protected:
91//    inline Pair(const ClassTypeId id)
92//    : RE(id)
93//    , _lh(nullptr)
94//    , _rh(nullptr)
95//    {
96
97//    }
98//    inline Pair(const ClassTypeId id, const RE * lh, const RE * rh)
99//    : RE(id)
100//    , _lh(lh)
101//    , _rh(rh)
102//    {
103
104//    }
105//    virtual ~Pair() {
106//    }
107//protected:
108//    const RE * _lh;
109//    const RE * _rh;
110//};
111
112//static Diff * makeDiff(const RE * lh, const RE * rh);
113
114//static Intersect * makeIntersect(const RE * lh, const RE * rh);
115
116//static Permute * makePermute();
117//static Permute * makePermute(Vector::iterator begin, Vector::iterator end);
118
119//static SymDiff * makeSymDiff(const RE * lh, const RE * rh);
120
121//static Union * makeUnion(const RE * lh, const RE * rh);
122
123}
124
125#endif // RE_H
126
127
Note: See TracBrowser for help on using the repository browser.