src
Public Member Functions | Public Attributes | List of all members
re2c::Cases Struct Reference

#include <go.h>

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

Public Member Functions

void add (uint32_t lb, uint32_t ub, State *to)
 
 Cases (const Span *s, uint32_t n)
 
 ~Cases ()
 
void emit (OutputFile &o, uint32_t ind, bool &readCh)
 
void used_labels (std::set< label_t > &used)
 
 FORBID_COPY (Cases)
 

Public Attributes

const Statedef
 
Casecases
 
uint32_t cases_size
 

Detailed Description

Definition at line 41 of file go.h.

Constructor & Destructor Documentation

re2c::Cases::Cases ( const Span s,
uint32_t  n 
)

Definition at line 19 of file go_construct.cc.

20  : def (span_size == 0 ? NULL : span[span_size - 1].to)
21  , cases (new Case[span_size])
22  , cases_size (0)
23 {
24  for (uint32_t i = 0, lb = 0; i < span_size; ++ i)
25  {
26  add (lb, span[i].ub, span[i].to);
27  lb = span[i].ub;
28  }
29 }
const State * def
Definition: go.h:43
uint32_t cases_size
Definition: go.h:45
Case * cases
Definition: go.h:44
void add(uint32_t lb, uint32_t ub, State *to)
Definition: go_construct.cc:31

Here is the call graph for this function:

re2c::Cases::~Cases ( )

Definition at line 10 of file go_destruct.cc.

11 {
12  delete [] cases;
13 }
Case * cases
Definition: go.h:44

Member Function Documentation

void re2c::Cases::add ( uint32_t  lb,
uint32_t  ub,
State to 
)

Definition at line 31 of file go_construct.cc.

32 {
33  for (uint32_t i = 0; i < cases_size; ++i)
34  {
35  if (cases[i].to == to)
36  {
37  cases[i].ranges.push_back (std::make_pair (lb, ub));
38  return;
39  }
40  }
41  cases[cases_size].ranges.push_back (std::make_pair (lb, ub));
42  cases[cases_size].to = to;
43  ++cases_size;
44 }
uint32_t cases_size
Definition: go.h:45
Case * cases
Definition: go.h:44
const State * to
Definition: go.h:30
std::vector< std::pair< uint32_t, uint32_t > > ranges
Definition: go.h:29

Here is the caller graph for this function:

void re2c::Cases::emit ( OutputFile o,
uint32_t  ind,
bool &  readCh 
)

Definition at line 93 of file go_emit.cc.

94 {
95  o.wind(ind).ws("switch (").wstring(output_yych (readCh)).ws(") {\n");
96  for (uint32_t i = 0; i < cases_size; ++i)
97  {
98  if (cases[i].to != def)
99  {
100  cases[i].emit (o, ind);
101  output_goto (o, 1, readCh, cases[i].to->label);
102  }
103  }
104  o.wind(ind).ws("default:");
105  output_goto (o, 1, readCh, def->label);
106  o.wind(ind).ws("}\n");
107 }
const State * def
Definition: go.h:43
uint32_t cases_size
Definition: go.h:45
static std::string output_yych(bool &readCh)
Definition: go_emit.cc:26
void emit(OutputFile &o, uint32_t ind)
Definition: go_emit.cc:71
Case * cases
Definition: go.h:44
label_t label
Definition: adfa.h:25
static void output_goto(OutputFile &o, uint32_t ind, bool &readCh, label_t to)
Definition: go_emit.cc:44

Here is the call graph for this function:

re2c::Cases::FORBID_COPY ( Cases  )
void re2c::Cases::used_labels ( std::set< label_t > &  used)

Definition at line 14 of file go_used_labels.cc.

15 {
16  for (uint32_t i = 0; i < cases_size; ++i)
17  {
18  used.insert (cases[i].to->label);
19  }
20 }
uint32_t cases_size
Definition: go.h:45
Case * cases
Definition: go.h:44

Member Data Documentation

Case* re2c::Cases::cases

Definition at line 44 of file go.h.

uint32_t re2c::Cases::cases_size

Definition at line 45 of file go.h.

const State* re2c::Cases::def

Definition at line 43 of file go.h.


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