src
regexp.h
Go to the documentation of this file.
1 #ifndef _RE2C_IR_REGEXP_REGEXP_
2 #define _RE2C_IR_REGEXP_REGEXP_
3 
4 #include "src/util/c99_stdint.h"
5 #include <iosfwd>
6 #include <set>
7 #include <vector>
8 
9 #include "src/util/free_list.h"
10 #include "src/util/forbid_copy.h"
11 
12 namespace re2c
13 {
14 
15 struct nfa_state_t;
16 struct nfa_t;
17 
18 typedef std::vector<uint32_t> charset_t;
19 
20 class RegExp
21 {
22 public:
24 
25  inline RegExp ()
26  {
27  vFreeList.insert (this);
28  }
29  inline virtual ~RegExp ()
30  {
31  vFreeList.erase (this);
32  }
33  virtual void split (std::set<uint32_t> &) = 0;
34  virtual uint32_t calc_size() const = 0;
35  virtual uint32_t fixedLength ();
36  virtual nfa_state_t *compile(nfa_t &nfa, nfa_state_t *n) = 0;
37  virtual void display (std::ostream &) const = 0;
38  friend std::ostream & operator << (std::ostream & o, const RegExp & re);
39 
41 };
42 
43 RegExp * doAlt (RegExp * e1, RegExp * e2);
44 RegExp * mkAlt (RegExp * e1, RegExp * e2);
45 RegExp * doCat (RegExp * e1, RegExp * e2);
46 RegExp * repeat (RegExp * e, uint32_t n);
47 RegExp * repeat_from_to (RegExp * e, uint32_t n, uint32_t m);
48 RegExp * repeat_from (RegExp * e, uint32_t n);
49 
50 } // end namespace re2c
51 
52 #endif // _RE2C_IR_REGEXP_REGEXP_
size_type erase(const key_type &key)
Definition: free_list.h:23
std::vector< uint32_t > charset_t
Definition: regexp.h:16
RegExp * doAlt(RegExp *e1, RegExp *e2)
Definition: regexp.cc:27
RegExp * repeat_from(RegExp *e, uint32_t n)
Definition: regexp.cc:234
RegExp * repeat_from_to(RegExp *e, uint32_t n, uint32_t m)
Definition: regexp.cc:222
friend std::ostream & operator<<(std::ostream &o, const RegExp &re)
Definition: display.cc:14
static free_list< RegExp * > vFreeList
Definition: regexp.h:23
virtual nfa_state_t * compile(nfa_t &nfa, nfa_state_t *n)=0
virtual void split(std::set< uint32_t > &)=0
virtual uint32_t fixedLength()
Definition: fixed_length.cc:12
FORBID_COPY(RegExp)
virtual uint32_t calc_size() const =0
virtual void display(std::ostream &) const =0
RegExp * repeat(RegExp *e, uint32_t n)
Definition: regexp.cc:211
virtual ~RegExp()
Definition: regexp.h:29
Definition: bitmap.cc:10
RegExp * doCat(RegExp *e1, RegExp *e2)
Definition: regexp.cc:98
RegExp * mkAlt(RegExp *e1, RegExp *e2)
Definition: regexp.cc:40