src
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
re2c::Node Struct Reference

#include <skeleton.h>

Collaboration diagram for re2c::Node:
Collaboration graph
[legend]

Public Types

typedef u32lim_t< 1024 *1024 *1024 > covers_t
 
typedef u32lim_t< 1024 > nakeds_t
 
typedef std::map< Node *, path_t::arc_tarcs_t
 
typedef std::map< Node *, way_arc_tarcsets_t
 
typedef local_increment_t< uint8_t > local_inc
 

Public Member Functions

 Node ()
 
void init (bool b, RuleOp *r, const std::vector< std::pair< Node *, uint32_t > > &arcs)
 
 ~Node ()
 
bool end () const
 
void calc_dist ()
 
void calc_reachable ()
 
template<typename cunit_t , typename key_t >
void cover (path_t &prefix, FILE *input, FILE *keys, covers_t &size)
 
void naked_ways (way_t &prefix, std::vector< way_t > &ways, nakeds_t &size)
 
 FORBID_COPY (Node)
 

Public Attributes

arcs_t arcs
 
arcsets_t arcsets
 
uint8_t loop
 
rule_t rule
 
bool ctx
 
uint32_t dist
 
std::set< rule_treachable
 
path_tsuffix
 

Static Public Attributes

static const uint32_t DIST_ERROR = std::numeric_limits<uint32_t>::max()
 
static const uint32_t DIST_MAX = DIST_ERROR - 1
 

Detailed Description

Definition at line 30 of file skeleton.h.

Member Typedef Documentation

typedef std::map<Node *, path_t::arc_t> re2c::Node::arcs_t

Definition at line 65 of file skeleton.h.

typedef std::map<Node *, way_arc_t> re2c::Node::arcsets_t

Definition at line 66 of file skeleton.h.

typedef u32lim_t<1024 * 1024 * 1024> re2c::Node::covers_t

Definition at line 57 of file skeleton.h.

Definition at line 67 of file skeleton.h.

Definition at line 63 of file skeleton.h.

Constructor & Destructor Documentation

re2c::Node::Node ( )

Definition at line 15 of file skeleton.cc.

16  : arcs ()
17  , arcsets ()
18  , loop (0)
19  , rule (rule_rank_t::none (), false)
20  , ctx (false)
21  , dist (DIST_ERROR)
22  , reachable ()
23  , suffix (NULL)
24 {}
rule_t rule
Definition: skeleton.h:78
uint32_t dist
Definition: skeleton.h:86
arcsets_t arcsets
Definition: skeleton.h:71
arcs_t arcs
Definition: skeleton.h:70
uint8_t loop
Definition: skeleton.h:75
std::set< rule_t > reachable
Definition: skeleton.h:89
static const uint32_t DIST_ERROR
Definition: skeleton.h:84
static rule_rank_t none()
Definition: rule_rank.cc:23
path_t * suffix
Definition: skeleton.h:92
bool ctx
Definition: skeleton.h:81
re2c::Node::~Node ( )

Definition at line 62 of file skeleton.cc.

63 {
64  delete suffix;
65 }
path_t * suffix
Definition: skeleton.h:92

Member Function Documentation

void re2c::Node::calc_dist ( )

Definition at line 18 of file maxlen.cc.

19 {
20  if (dist != DIST_ERROR)
21  {
22  return;
23  }
24  else if (end ())
25  {
26  dist = 0;
27  }
28  else if (loop < 2)
29  {
30  local_inc _ (loop);
31  for (arcs_t::iterator i = arcs.begin (); i != arcs.end (); ++i)
32  {
33  i->first->calc_dist ();
34  if (i->first->dist != DIST_ERROR)
35  {
36  if (dist == DIST_ERROR)
37  {
38  dist = i->first->dist;
39  }
40  else
41  {
42  dist = std::max (dist, i->first->dist);
43  }
44  }
45  }
46  dist = std::min (dist + 1, DIST_MAX);
47  }
48 }
uint32_t dist
Definition: skeleton.h:86
arcs_t arcs
Definition: skeleton.h:70
uint8_t loop
Definition: skeleton.h:75
static const uint32_t DIST_ERROR
Definition: skeleton.h:84
local_increment_t< uint8_t > local_inc
Definition: skeleton.h:67
bool end() const
Definition: skeleton.cc:67
static const uint32_t DIST_MAX
Definition: skeleton.h:85

Here is the call graph for this function:

void re2c::Node::calc_reachable ( )

Definition at line 16 of file unreachable.cc.

17 {
18  if (!reachable.empty ())
19  {
20  return;
21  }
22  else if (end ())
23  {
24  reachable.insert (rule);
25  }
26  else if (loop < 2)
27  {
28  local_inc _ (loop);
29  for (arcs_t::iterator i = arcs.begin (); i != arcs.end (); ++i)
30  {
31  i->first->calc_reachable ();
32  reachable.insert (i->first->reachable.begin (), i->first->reachable.end ());
33  }
34  }
35 }
rule_t rule
Definition: skeleton.h:78
arcs_t arcs
Definition: skeleton.h:70
uint8_t loop
Definition: skeleton.h:75
std::set< rule_t > reachable
Definition: skeleton.h:89
local_increment_t< uint8_t > local_inc
Definition: skeleton.h:67
bool end() const
Definition: skeleton.cc:67

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename cunit_t , typename key_t >
void re2c::Node::cover ( path_t prefix,
FILE *  input,
FILE *  keys,
covers_t size 
)

Definition at line 56 of file generate_data.cc.

57 {
58  if (end () && suffix == NULL)
59  {
60  suffix = new path_t (rule, ctx);
61  }
62  if (suffix != NULL)
63  {
64  prefix.append (suffix);
65  size = size + cover_one<cunit_t, key_t> (input, keys, prefix);
66  }
67  else if (loop < 2)
68  {
69  local_inc _ (loop);
70  for (arcs_t::iterator i = arcs.begin ();
71  i != arcs.end () && !size.overflow(); ++i)
72  {
73  path_t new_prefix = prefix;
74  new_prefix.extend (i->first->rule, i->first->ctx, &i->second);
75  i->first->cover<cunit_t, key_t> (new_prefix, input, keys, size);
76  if (i->first->suffix != NULL && suffix == NULL)
77  {
78  suffix = new path_t (rule, ctx);
79  suffix->extend (i->first->rule, i->first->ctx, &i->second);
80  suffix->append (i->first->suffix);
81  }
82  }
83  }
84 }
void append(const path_t *p)
Definition: path.h:85
rule_t rule
Definition: skeleton.h:78
arcs_t arcs
Definition: skeleton.h:70
uint8_t loop
Definition: skeleton.h:75
void extend(rule_t r, bool c, const arc_t *a)
Definition: path.h:71
local_increment_t< uint8_t > local_inc
Definition: skeleton.h:67
bool end() const
Definition: skeleton.cc:67
path_t * suffix
Definition: skeleton.h:92
bool ctx
Definition: skeleton.h:81

Here is the call graph for this function:

bool re2c::Node::end ( ) const

Definition at line 67 of file skeleton.cc.

68 {
69  return arcs.size () == 0;
70 }
arcs_t arcs
Definition: skeleton.h:70

Here is the caller graph for this function:

re2c::Node::FORBID_COPY ( Node  )
void re2c::Node::init ( bool  b,
RuleOp r,
const std::vector< std::pair< Node *, uint32_t > > &  arcs 
)

Definition at line 26 of file skeleton.cc.

27 {
28  if (r)
29  {
30  rule.rank = r->rank;
31  rule.restorectx = r->ctx->fixedLength () != 0;
32  }
33 
34  ctx = c;
35 
36  uint32_t lb = 0;
37  std::vector<std::pair<Node*, uint32_t> >::const_iterator
38  i = a.begin(),
39  e = a.end();
40  for (; i != e; ++i)
41  {
42  Node *n = i->first;
43  const uint32_t ub = i->second - 1;
44 
45  // pick at most 0x100 unique edges from this range
46  // (for 1-byte code units this covers the whole range: [0 - 0xFF])
47  // - range bounds must be included
48  // - values should be evenly distributed
49  // - values should be deterministic
50  const uint32_t step = 1 + (ub - lb) / 0x100;
51  for (uint32_t c = lb; c < ub; c += step)
52  {
53  arcs[n].push_back (c);
54  }
55  arcs[n].push_back (ub);
56 
57  arcsets[n].push_back (std::make_pair (lb, ub));
58  lb = ub + 1;
59  }
60 }
rule_t rule
Definition: skeleton.h:78
bool restorectx
Definition: path.h:15
arcsets_t arcsets
Definition: skeleton.h:71
arcs_t arcs
Definition: skeleton.h:70
rule_rank_t rank
Definition: path.h:14
bool ctx
Definition: skeleton.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

void re2c::Node::naked_ways ( way_t prefix,
std::vector< way_t > &  ways,
nakeds_t size 
)

Definition at line 19 of file control_flow.cc.

20 {
21  if (!rule.rank.is_none ())
22  {
23  return;
24  }
25  else if (end ())
26  {
27  ways.push_back (prefix);
28  size = size + nakeds_t::from64(prefix.size ());
29  }
30  else if (loop < 2)
31  {
32  local_inc _ (loop);
33  for (arcsets_t::iterator i = arcsets.begin ();
34  i != arcsets.end () && !size.overflow (); ++i)
35  {
36  prefix.push_back (&i->second);
37  i->first->naked_ways (prefix, ways, size);
38  prefix.pop_back ();
39  }
40  }
41 }
rule_t rule
Definition: skeleton.h:78
arcsets_t arcsets
Definition: skeleton.h:71
static u32lim_t from64(uint64_t x)
Definition: u32lim.h:29
uint8_t loop
Definition: skeleton.h:75
local_increment_t< uint8_t > local_inc
Definition: skeleton.h:67
bool end() const
Definition: skeleton.cc:67
bool is_none() const
Definition: rule_rank.cc:37
rule_rank_t rank
Definition: path.h:14

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

arcs_t re2c::Node::arcs

Definition at line 70 of file skeleton.h.

arcsets_t re2c::Node::arcsets

Definition at line 71 of file skeleton.h.

bool re2c::Node::ctx

Definition at line 81 of file skeleton.h.

uint32_t re2c::Node::dist

Definition at line 86 of file skeleton.h.

const uint32_t re2c::Node::DIST_ERROR = std::numeric_limits<uint32_t>::max()
static

Definition at line 84 of file skeleton.h.

const uint32_t re2c::Node::DIST_MAX = DIST_ERROR - 1
static

Definition at line 85 of file skeleton.h.

uint8_t re2c::Node::loop

Definition at line 75 of file skeleton.h.

std::set<rule_t> re2c::Node::reachable

Definition at line 89 of file skeleton.h.

rule_t re2c::Node::rule

Definition at line 78 of file skeleton.h.

path_t* re2c::Node::suffix

Definition at line 92 of file skeleton.h.


The documentation for this struct was generated from the following files: