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

Last change on this file since 4405 was 4405, checked in by cameron, 5 years ago

AST support for Lookahead/Lookbehind? assertions

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