src
adfa.h
Go to the documentation of this file.
1 #ifndef _RE2C_IR_ADFA_ADFA_
2 #define _RE2C_IR_ADFA_ADFA_
3 
4 #include <stddef.h>
5 #include "src/util/c99_stdint.h"
6 #include <set>
7 #include <string>
8 
9 #include "src/codegen/go.h"
10 #include "src/codegen/label.h"
11 #include "src/ir/adfa/action.h"
12 #include "src/ir/regexp/regexp.h"
13 #include "src/util/forbid_copy.h"
14 
15 namespace re2c
16 {
17 
18 struct Skeleton;
19 struct Output;
20 struct OutputFile;
21 struct dfa_t;
22 
23 struct State
24 {
28  size_t fill;
29 
30  bool isPreCtxt;
31  bool isBase;
32  Go go;
34 
35  State ()
36  : label (label_t::first ())
37  , rule (NULL)
38  , next (0)
39  , fill (0)
40  , isPreCtxt (false)
41  , isBase (false)
42  , go ()
43  , action ()
44  {}
45  ~State ()
46  {
47  operator delete (go.span);
48  }
49 
51 };
52 
53 class DFA
54 {
55  accept_t accepts;
56  Skeleton * skeleton;
57 
58 public:
59  const std::string name;
60  const std::string cond;
61  const uint32_t line;
62 
63  uint32_t lbChar;
64  uint32_t ubChar;
65  uint32_t nStates;
67 
68  // statistics
69  size_t max_fill;
73 
74 public:
75  DFA ( const dfa_t &dfa
76  , const std::vector<size_t> &fill
77  , Skeleton *skel
78  , const charset_t &charset
79  , const std::string &n
80  , const std::string &c
81  , uint32_t l
82  );
83  ~DFA ();
84  void reorder();
85  void prepare();
86  void calc_stats();
87  void emit (Output &, uint32_t &, bool, bool &);
88 
89 private:
90  void addState(State*, State *);
91  void split (State *);
92  void findBaseState ();
93  void count_used_labels (std::set<label_t> & used, label_t prolog, label_t start, bool force_start) const;
94  void emit_body (OutputFile &, uint32_t &, const std::set<label_t> & used_labels, label_t initial) const;
95 
96  FORBID_COPY (DFA);
97 };
98 
99 } // namespace re2c
100 
101 #endif // _RE2C_IR_ADFA_ADFA_
const uint32_t line
Definition: adfa.h:61
size_t max_fill
Definition: adfa.h:69
std::vector< uint32_t > charset_t
Definition: regexp.h:16
void calc_stats()
Definition: prepare.cc:240
bool isPreCtxt
Definition: adfa.h:30
State()
Definition: adfa.h:35
const std::string cond
Definition: adfa.h:60
size_t fill
Definition: adfa.h:28
RuleOp * rule
Definition: adfa.h:26
uint32_t lbChar
Definition: adfa.h:63
~DFA()
Definition: adfa.cc:79
FORBID_COPY(State)
void emit(Output &, uint32_t &, bool, bool &)
Definition: emit_dfa.cc:115
Action action
Definition: adfa.h:33
DFA(const dfa_t &dfa, const std::vector< size_t > &fill, Skeleton *skel, const charset_t &charset, const std::string &n, const std::string &c, uint32_t l)
Definition: adfa.cc:17
bool need_backup
Definition: adfa.h:70
bool need_backupctx
Definition: adfa.h:71
uint32_t ubChar
Definition: adfa.h:64
label_t label
Definition: adfa.h:25
State * head
Definition: adfa.h:66
void reorder()
Definition: adfa.cc:92
bool isBase
Definition: adfa.h:31
void prepare()
Definition: prepare.cc:140
Definition: adfa.h:53
~State()
Definition: adfa.h:45
Go go
Definition: adfa.h:32
Span * span
Definition: go.h:175
uint32_t nStates
Definition: adfa.h:65
Definition: bitmap.cc:10
bool need_accept
Definition: adfa.h:72
Definition: go.h:172
const std::string name
Definition: adfa.h:59
State * next
Definition: adfa.h:27