src
action.h
Go to the documentation of this file.
1 #ifndef _RE2C_IR_ADFA_ACTION_
2 #define _RE2C_IR_ADFA_ACTION_
3 
4 #include <vector>
5 
6 #include "src/codegen/label.h"
7 #include "src/util/c99_stdint.h"
8 #include "src/util/uniq_vector.h"
9 
10 namespace re2c
11 {
12 
13 struct OutputFile;
14 class RuleOp;
15 class State;
16 
17 struct Initial
18 {
20  bool setMarker;
21 
22  inline Initial (label_t l, bool b)
23  : label (l)
24  , setMarker (b)
25  {}
26 };
27 
29 
30 class Action
31 {
32 public:
33  enum type_t
34  {
41  } type;
42  union
43  {
45  uint32_t save;
46  const accept_t * accepts;
47  const RuleOp * rule;
48  } info;
49 
50 public:
51  inline Action ()
52  : type (MATCH)
53  , info ()
54  {}
56  {
57  clear ();
58  }
59  void set_initial (label_t label, bool used_marker)
60  {
61  clear ();
62  type = INITIAL;
63  info.initial = new Initial (label, used_marker);
64  }
65  void set_save (uint32_t save)
66  {
67  clear ();
68  type = SAVE;
69  info.save = save;
70  }
71  void set_move ()
72  {
73  clear ();
74  type = MOVE;
75  }
76  void set_accept (const accept_t * accepts)
77  {
78  clear ();
79  type = ACCEPT;
80  info.accepts = accepts;
81  }
82  void set_rule (const RuleOp * const rule)
83  {
84  clear ();
85  type = RULE;
86  info.rule = rule;
87  }
88 
89 private:
90  void clear ()
91  {
92  switch (type)
93  {
94  case INITIAL:
95  delete info.initial;
96  break;
97  case MATCH:
98  case SAVE:
99  case MOVE:
100  case ACCEPT:
101  case RULE:
102  break;
103  }
104  }
105 };
106 
107 } // namespace re2c
108 
109 #endif // _RE2C_IR_ADFA_ACTION_
Initial(label_t l, bool b)
Definition: action.h:22
void set_rule(const RuleOp *const rule)
Definition: action.h:82
bool setMarker
Definition: action.h:20
const accept_t * accepts
Definition: action.h:46
void set_save(uint32_t save)
Definition: action.h:65
void set_move()
Definition: action.h:71
union re2c::Action::@5 info
const RuleOp * rule
Definition: action.h:47
label_t label
Definition: action.h:19
uniq_vector_t< const State * > accept_t
Definition: action.h:28
void set_accept(const accept_t *accepts)
Definition: action.h:76
uint32_t save
Definition: action.h:45
Definition: bitmap.cc:10
void set_initial(label_t label, bool used_marker)
Definition: action.h:59
enum re2c::Action::type_t type
Initial * initial
Definition: action.h:44