src
spec.h
Go to the documentation of this file.
1 #ifndef _RE2C_PARSE_SPEC_
2 #define _RE2C_PARSE_SPEC_
3 
5 #include "src/parse/rules.h"
6 
7 namespace re2c
8 {
9 
10 struct Spec
11 {
14 
15  Spec ()
16  : re (NULL)
17  , rules ()
18  {}
19  Spec (const Spec & spec)
20  : re (spec.re)
21  , rules (spec.rules)
22  {}
23  Spec & operator = (const Spec & spec)
24  {
25  re = spec.re;
26  rules = spec.rules;
27  return *this;
28  }
29  bool add_def (RuleOp * r)
30  {
31  if (rules.find (rule_rank_t::def ()) != rules.end ())
32  {
33  return false;
34  }
35  else
36  {
37  add (r);
38  return true;
39  }
40  }
41  void add (RuleOp * r)
42  {
43  rules[r->rank].line = r->loc.line;
44  re = mkAlt (re, r);
45  }
46  void clear ()
47  {
48  re = NULL;
49  rules.clear ();
50  }
51 };
52 
53 } // namespace re2c
54 
55 #endif // _RE2C_PARSE_SPEC_
uint32_t line
Definition: loc.h:14
Spec()
Definition: spec.h:15
void add(RuleOp *r)
Definition: spec.h:41
std::map< rule_rank_t, rule_info_t > rules_t
Definition: rules.h:25
Spec(const Spec &spec)
Definition: spec.h:19
Spec & operator=(const Spec &spec)
Definition: spec.h:23
rules_t rules
Definition: spec.h:13
void clear()
Definition: spec.h:46
rule_rank_t rank
Definition: regexp_rule.h:23
bool add_def(RuleOp *r)
Definition: spec.h:29
const Loc loc
Definition: regexp_rule.h:16
RegExp * re
Definition: spec.h:12
static rule_rank_t def()
Definition: rule_rank.cc:30
Definition: bitmap.cc:10
RegExp * mkAlt(RegExp *e1, RegExp *e2)
Definition: regexp.cc:40