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

#include <output.h>

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

Public Member Functions

 OutputFile (const char *fn)
 
 ~OutputFile ()
 
bool open ()
 
void new_block ()
 
OutputFilewraw (const char *s, size_t n)
 
OutputFilewc (char c)
 
OutputFilewc_hex (uint32_t n)
 
OutputFilewu32 (uint32_t n)
 
OutputFilewu32_hex (uint32_t n)
 
OutputFilewu32_width (uint32_t n, int w)
 
OutputFilewu64 (uint64_t n)
 
OutputFilewstring (const std::string &s)
 
OutputFilews (const char *s)
 
OutputFilewlabel (label_t l)
 
OutputFilewrank (rule_rank_t l)
 
OutputFilewrange (uint32_t u, uint32_t l)
 
OutputFilewline_info (uint32_t l, const char *fn)
 
OutputFilewversion_time ()
 
OutputFilewuser_start_label ()
 
OutputFilewind (uint32_t ind)
 
OutputFilewdelay_line_info ()
 
OutputFilewdelay_state_goto (uint32_t ind)
 
OutputFilewdelay_types ()
 
OutputFilewdelay_warn_condition_order ()
 
OutputFilewdelay_yyaccept_init (uint32_t ind)
 
OutputFilewdelay_yymaxfill ()
 
void set_used_yyaccept ()
 
bool get_used_yyaccept () const
 
void set_force_start_label (bool force)
 
void set_user_start_label (const std::string &label)
 
bool get_force_start_label () const
 
void set_block_line (uint32_t l)
 
uint32_t get_block_line () const
 
void emit (const std::vector< std::string > &types, size_t max_fill)
 
 FORBID_COPY (OutputFile)
 

Public Attributes

const char * file_name
 
counter_t< label_tlabel_counter
 
bool warn_condition_order
 

Detailed Description

Definition at line 55 of file output.h.

Constructor & Destructor Documentation

re2c::OutputFile::OutputFile ( const char *  fn)

Definition at line 55 of file output.cc.

56  : file_name (fn)
57  , file (NULL)
58  , blocks ()
59  , label_counter ()
60  , warn_condition_order (!opts->tFlag) // see note [condition order]
61 {
62  new_block ();
63 }
bool tFlag
Definition: opt.h:118
void new_block()
Definition: output.cc:284
bool warn_condition_order
Definition: output.h:66
Opt opts
Definition: opt.cc:7
const char * file_name
Definition: output.h:58
counter_t< label_t > label_counter
Definition: output.h:65

Here is the call graph for this function:

re2c::OutputFile::~OutputFile ( )

Definition at line 79 of file output.cc.

80 {
81  if (file != NULL && file != stdout)
82  {
83  fclose (file);
84  }
85  for (unsigned int i = 0; i < blocks.size (); ++i)
86  {
87  delete blocks[i];
88  }
89 }

Member Function Documentation

void re2c::OutputFile::emit ( const std::vector< std::string > &  types,
size_t  max_fill 
)

Definition at line 291 of file output.cc.

294 {
295  if (file != NULL)
296  {
297  unsigned int line_count = 1;
298  for (unsigned int j = 0; j < blocks.size (); ++j)
299  {
300  OutputBlock & b = * blocks[j];
301  for (unsigned int i = 0; i < b.fragments.size (); ++i)
302  {
303  OutputFragment & f = * b.fragments[i];
304  switch (f.type)
305  {
307  break;
309  output_line_info (f.stream, line_count + 1, file_name);
310  break;
312  output_state_goto (f.stream, f.indent, 0);
313  break;
315  output_types (f.stream, f.indent, types);
316  break;
318  if (warn_condition_order) // see note [condition order]
319  {
320  warn.condition_order (b.line);
321  }
322  break;
324  output_yyaccept_init (f.stream, f.indent, b.used_yyaccept);
325  break;
327  output_yymaxfill (f.stream, max_fill);
328  break;
329  }
330  std::string content = f.stream.str ();
331  fwrite (content.c_str (), 1, content.size (), file);
332  line_count += f.count_lines ();
333  }
334  }
335  }
336 }
void output_line_info(std::ostream &o, uint32_t line_number, const char *file_name)
Definition: output.cc:424
Warn warn
Definition: warn.cc:11
void output_state_goto(std::ostream &o, uint32_t ind, uint32_t start_label)
Definition: output.cc:388
void output_types(std::ostream &o, uint32_t ind, const std::vector< std::string > &types)
Definition: output.cc:432
bool warn_condition_order
Definition: output.h:66
const char * file_name
Definition: output.h:58
void condition_order(uint32_t line)
Definition: warn.cc:86
void output_yymaxfill(std::ostream &o, size_t max_fill)
Definition: output.cc:419
void output_yyaccept_init(std::ostream &o, uint32_t ind, bool used_yyaccept)
Definition: output.cc:411

Here is the call graph for this function:

Here is the caller graph for this function:

re2c::OutputFile::FORBID_COPY ( OutputFile  )
uint32_t re2c::OutputFile::get_block_line ( ) const

Definition at line 279 of file output.cc.

280 {
281  return blocks.back ()->line;
282 }

Here is the caller graph for this function:

bool re2c::OutputFile::get_force_start_label ( ) const

Definition at line 269 of file output.cc.

270 {
271  return blocks.back ()->force_start_label;
272 }

Here is the caller graph for this function:

bool re2c::OutputFile::get_used_yyaccept ( ) const

Definition at line 254 of file output.cc.

255 {
256  return blocks.back ()->used_yyaccept;
257 }

Here is the caller graph for this function:

void re2c::OutputFile::new_block ( )

Definition at line 284 of file output.cc.

285 {
286  blocks.push_back (new OutputBlock ());
287  insert_code ();
288 }

Here is the caller graph for this function:

bool re2c::OutputFile::open ( )

Definition at line 65 of file output.cc.

66 {
67  if (file_name == NULL)
68  {
69  file_name = "<stdout>";
70  file = stdout;
71  }
72  else
73  {
74  file = fopen (file_name, "wb");
75  }
76  return file != NULL;
77 }
const char * file_name
Definition: output.h:58

Here is the caller graph for this function:

void re2c::OutputFile::set_block_line ( uint32_t  l)

Definition at line 274 of file output.cc.

275 {
276  blocks.back ()->line = l;
277 }
void re2c::OutputFile::set_force_start_label ( bool  force)

Definition at line 259 of file output.cc.

260 {
261  blocks.back ()->force_start_label = force;
262 }
void re2c::OutputFile::set_used_yyaccept ( )

Definition at line 249 of file output.cc.

250 {
251  blocks.back ()->used_yyaccept = true;
252 }

Here is the caller graph for this function:

void re2c::OutputFile::set_user_start_label ( const std::string &  label)

Definition at line 264 of file output.cc.

265 {
266  blocks.back ()->user_start_label = label;
267 }
OutputFile & re2c::OutputFile::wc ( char  c)

Definition at line 149 of file output.cc.

150 {
151  stream () << c;
152  return *this;
153 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wc_hex ( uint32_t  n)

Definition at line 108 of file output.cc.

109 {
110  prtChOrHex (stream (), n);
111  return *this;
112 }
void prtChOrHex(std::ostream &o, uint32_t c)
Definition: print.cc:38

Here is the call graph for this function:

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wdelay_line_info ( )

Definition at line 202 of file output.cc.

203 {
204  blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::LINE_INFO, 0));
205  insert_code ();
206  return *this;
207 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wdelay_state_goto ( uint32_t  ind)

Definition at line 209 of file output.cc.

210 {
211  if (opts->fFlag && !bWroteGetState)
212  {
213  blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::STATE_GOTO, ind));
214  insert_code ();
215  bWroteGetState = true;
216  }
217  return *this;
218 }
bool bWroteGetState
Definition: main.cc:17
bool fFlag
Definition: opt.h:118
Opt opts
Definition: opt.cc:7

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wdelay_types ( )

Definition at line 220 of file output.cc.

221 {
222  warn_condition_order = false; // see note [condition order]
223  blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::TYPES, 0));
224  insert_code ();
225  return *this;
226 }
bool warn_condition_order
Definition: output.h:66
OutputFile & re2c::OutputFile::wdelay_warn_condition_order ( )

Definition at line 228 of file output.cc.

229 {
230  blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::WARN_CONDITION_ORDER, 0));
231  insert_code ();
232  return *this;
233 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wdelay_yyaccept_init ( uint32_t  ind)

Definition at line 235 of file output.cc.

236 {
237  blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::YYACCEPT_INIT, ind));
238  insert_code ();
239  return *this;
240 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wdelay_yymaxfill ( )

Definition at line 242 of file output.cc.

243 {
244  blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::YYMAXFILL, 0));
245  insert_code ();
246  return *this;
247 }
OutputFile & re2c::OutputFile::wind ( uint32_t  ind)

Definition at line 191 of file output.cc.

192 {
193  stream () << indent(ind);
194  return *this;
195 }
std::string indent(uint32_t ind)
Definition: indent.h:11

Here is the call graph for this function:

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wlabel ( label_t  l)

Definition at line 179 of file output.cc.

180 {
181  stream () << l;
182  return *this;
183 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wline_info ( uint32_t  l,
const char *  fn 
)

Definition at line 127 of file output.cc.

128 {
129  output_line_info (stream (), l, fn);
130  return *this;
131 }
void output_line_info(std::ostream &o, uint32_t line_number, const char *file_name)
Definition: output.cc:424

Here is the call graph for this function:

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wrange ( uint32_t  u,
uint32_t  l 
)

Definition at line 114 of file output.cc.

115 {
116  printSpan (stream (), l, u);
117  return *this;
118 }
void printSpan(std::ostream &o, uint32_t lb, uint32_t ub)
Definition: print.cc:139

Here is the call graph for this function:

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wrank ( rule_rank_t  l)

Definition at line 185 of file output.cc.

186 {
187  stream () << r;
188  return *this;
189 }
OutputFile & re2c::OutputFile::wraw ( const char *  s,
size_t  n 
)

Definition at line 96 of file output.cc.

97 {
98  stream ().write (s, static_cast<std::streamsize> (n));
99  return *this;
100 }
OutputFile & re2c::OutputFile::ws ( const char *  s)

Definition at line 173 of file output.cc.

174 {
175  stream () << s;
176  return *this;
177 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wstring ( const std::string &  s)

Definition at line 167 of file output.cc.

168 {
169  stream () << s;
170  return *this;
171 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wu32 ( uint32_t  n)

Definition at line 155 of file output.cc.

156 {
157  stream () << n;
158  return *this;
159 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wu32_hex ( uint32_t  n)

Definition at line 102 of file output.cc.

103 {
104  prtHex (stream (), n);
105  return *this;
106 }
void prtHex(std::ostream &o, uint32_t c)
Definition: print.cc:53

Here is the call graph for this function:

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wu32_width ( uint32_t  n,
int  w 
)

Definition at line 120 of file output.cc.

121 {
122  stream () << std::setw (w);
123  stream () << n;
124  return *this;
125 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wu64 ( uint64_t  n)

Definition at line 161 of file output.cc.

162 {
163  stream () << n;
164  return *this;
165 }

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wuser_start_label ( )

Definition at line 139 of file output.cc.

140 {
141  const std::string label = blocks.back ()->user_start_label;
142  if (!label.empty ())
143  {
144  wstring(label).ws(":\n");
145  }
146  return *this;
147 }
OutputFile & ws(const char *s)
Definition: output.cc:173
OutputFile & wstring(const std::string &s)
Definition: output.cc:167

Here is the call graph for this function:

Here is the caller graph for this function:

OutputFile & re2c::OutputFile::wversion_time ( )

Definition at line 133 of file output.cc.

134 {
135  output_version_time (stream ());
136  return *this;
137 }
void output_version_time(std::ostream &o)
Definition: output.cc:442

Here is the call graph for this function:

Member Data Documentation

const char* re2c::OutputFile::file_name

Definition at line 58 of file output.h.

counter_t<label_t> re2c::OutputFile::label_counter

Definition at line 65 of file output.h.

bool re2c::OutputFile::warn_condition_order

Definition at line 66 of file output.h.


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