1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#ifndef _RE2C_ADFA_ADFA_
#define _RE2C_ADFA_ADFA_
#include <stddef.h>
#include "src/util/c99_stdint.h"
#include <set>
#include <string>
#include <valarray>
#include <vector>
#include "src/adfa/action.h"
#include "src/codegen/bitmap.h"
#include "src/codegen/go.h"
#include "src/codegen/label.h"
#include "src/dfa/tcmd.h"
#include "src/msg/location.h"
#include "src/regexp/rule.h"
#include "src/regexp/tag.h"
#include "src/util/forbid_copy.h"
namespace re2c {
class Msg;
struct opt_t;
class Output;
struct dfa_t;
struct State
{
label_t label;
State * next;
State * prev;
size_t fill;
bool fallback;
size_t rule;
tcid_t rule_tags;
tcid_t fall_tags;
bool isBase;
Go go;
Action action;
State ()
: label (label_t::first ())
, next (0)
, prev (0)
, fill (0)
, fallback (false)
, rule (Rule::NONE)
, rule_tags (TCID0)
, fall_tags (TCID0)
, isBase (false)
, go ()
, action ()
{}
~State ()
{
operator delete (go.span);
}
FORBID_COPY (State);
};
struct DFA
{
accept_t accepts;
const loc_t loc;
const std::string name;
const std::string cond;
uint32_t lbChar;
uint32_t ubChar;
uint32_t nStates;
State * head;
State *defstate;
std::vector<State*> finstates;
const tcid_t tags0;
std::vector<uint32_t> &charset;
std::valarray<Rule> &rules;
std::vector<Tag> &tags;
std::set<tagver_t> &mtagvers;
const tagver_t *finvers;
tcpool_t &tcpool;
size_t max_fill;
size_t max_nmatch;
bool need_backup;
bool need_accept;
bool oldstyle_ctxmarker;
tagver_t maxtagver;
const size_t def_rule;
const size_t key_size;
bitmaps_t bitmaps;
std::string setup;
const Code *eof_action;
Msg &msg;
DFA ( const dfa_t &dfa
, const std::vector<size_t> &fill
, size_t def
, size_t key
, const loc_t &loc
, const std::string &nm
, const std::string &cn
, const std::string &su
, const Code *eof
, const opt_t *opts
, Msg &msg
);
~DFA ();
void reorder();
void prepare(const opt_t *opts);
void calc_stats(bool explicit_tags);
void emit (Output &, uint32_t &, bool, bool &);
private:
void addState(State*, State *);
void split (State *);
void findBaseState(const opt_t *opts);
void hoist_tags(const opt_t *opts);
void hoist_tags_and_skip(const opt_t *opts);
void count_used_labels(std::set<label_t> &used, label_t start, label_t initial, const opt_t *opts) const;
void emit_body (Output &, uint32_t &, const std::set<label_t> & used_labels, label_t initial) const;
void emit_dot(Output &o, bool last_cond) const;
FORBID_COPY (DFA);
};
} // namespace re2c
#endif // _RE2C_ADFA_ADFA_
|