1 #ifndef _RE2C_RE_RULE_
2 #define _RE2C_RE_RULE_
3 
4 #include <stddef.h>
5 #include "src/util/c99_stdint.h"
6 #include <set>
7 #include <string>
8 
9 #include "src/msg/location.h"
10 #include "src/util/free_list.h"
11 
12 
13 namespace re2c {
14 
15 // semantic action (user-defined code for rule)
16 struct SemAct {
17     static free_list<SemAct*> flist;
18 
19     const loc_t loc;
20     bool autogen;
21     const std::string text;
22     std::string cond;
23 
SemActSemAct24     explicit SemAct(const loc_t &loc)
25         : loc(loc), autogen(true), text(""), cond("") { flist.insert(this); }
SemActSemAct26     SemAct(const loc_t &loc, const std::string &t)
27         : loc(loc), autogen(false), text(t), cond("") { flist.insert(this); }
~SemActSemAct28     ~SemAct() { flist.erase(this); }
29 };
30 
31 struct Rule
32 {
33     static const size_t NONE;
34 
35     const SemAct *semact;
36     std::set<uint32_t> shadow;
37     size_t ltag; // first tag
38     size_t htag; // next to last tag
39     size_t ttag; // trailing context
40     size_t ncap; // number of POSIX captures
41 
RuleRule42     Rule(): semact(NULL), shadow(), ltag(0), htag(0), ttag(0), ncap(0) {}
43 
44     // copy ctor and assignment are required for containers on macOS
RuleRule45     Rule(const Rule &r)
46         : semact(r.semact)
47         , shadow(r.shadow)
48         , ltag(r.ltag)
49         , htag(r.htag)
50         , ttag(r.ttag)
51         , ncap(r.ncap)
52     {}
53     Rule& operator= (const Rule &r)
54     {
55         semact = r.semact;
56         shadow = r.shadow;
57         ltag = r.ltag;
58         htag = r.htag;
59         ttag = r.ttag;
60         ncap = r.ncap;
61         return *this;
62     }
63 };
64 
65 } // namespace re2c
66 
67 #endif // _RE2C_RE_RULE_
68