src
Public Types | Public Member Functions | Public Attributes | List of all members
re2c::Scanner Class Reference

#include <scanner.h>

Inheritance diagram for re2c::Scanner:
Inheritance graph
[legend]
Collaboration diagram for re2c::Scanner:
Collaboration graph
[legend]

Public Types

enum  ParseMode { Stop, Parse, Reuse, Rules }
 

Public Member Functions

 Scanner (Input &, OutputFile &)
 
 ~Scanner ()
 
ParseMode echo ()
 
int scan ()
 
void reuse ()
 
void save_state (ScannerState &) const
 
void restore_state (const ScannerState &)
 
uint32_t get_cline () const
 
uint32_t get_line () const
 
const std::string & get_fname () const
 
void set_in_parse (bool new_in_parse)
 
void fatal_at (uint32_t line, ptrdiff_t ofs, const char *msg) const
 
void fatalf_at (uint32_t line, const char *,...) const RE2C_GXX_ATTRIBUTE((format(printf
 
void void fatalf (const char *,...) const RE2C_GXX_ATTRIBUTE((format(printf
 
void void void fatal (const char *) const
 
void fatal (ptrdiff_t, const char *) const
 
RegExpmkDiff (RegExp *e1, RegExp *e2) const
 
RegExpmkDot () const
 
RegExpmkDefault () const
 
 FORBID_COPY (Scanner)
 

Public Attributes

OutputFileout
 

Detailed Description

Definition at line 52 of file scanner.h.

Member Enumeration Documentation

Enumerator
Stop 
Parse 
Reuse 
Rules 

Definition at line 83 of file scanner.h.

Constructor & Destructor Documentation

re2c::Scanner::Scanner ( Input i,
OutputFile o 
)

Definition at line 65 of file scanner.cc.

66  : ScannerState ()
67  , in (i)
68  , out (o)
69 {}
OutputFile & out
Definition: scanner.h:58
re2c::Scanner::~Scanner ( )

Definition at line 175 of file scanner.cc.

176 {
177  delete [] bot;
178 }

Member Function Documentation

ParseMode re2c::Scanner::echo ( )
void re2c::Scanner::fatal ( const char *  msg) const
inline

Definition at line 140 of file scanner.h.

141 {
142  fatal(0, msg);
143 }
void void void fatal(const char *) const
Definition: scanner.h:140

Here is the caller graph for this function:

void re2c::Scanner::fatal ( ptrdiff_t  ofs,
const char *  msg 
) const

Definition at line 140 of file scanner.cc.

141 {
142  fatal_at(in_parse ? tline : cline, ofs, msg);
143 }
uint32_t cline
Definition: scanner.h:42
uint32_t tline
Definition: scanner.h:41
void fatal_at(uint32_t line, ptrdiff_t ofs, const char *msg) const
Definition: scanner.cc:132

Here is the call graph for this function:

void re2c::Scanner::fatal_at ( uint32_t  line,
ptrdiff_t  ofs,
const char *  msg 
) const

Definition at line 132 of file scanner.cc.

133 {
134  std::cerr << "re2c: error: "
135  << "line " << line << ", column " << (tchar + ofs + 1) << ": "
136  << msg << std::endl;
137  exit(1);
138 }
ptrdiff_t tchar
Definition: scanner.h:40

Here is the caller graph for this function:

void re2c::Scanner::fatalf ( const char *  fmt,
  ... 
) const

Definition at line 160 of file scanner.cc.

161 {
162  char szBuf[4096];
163 
164  va_list args;
165 
166  va_start(args, fmt);
167  vsnprintf(szBuf, sizeof(szBuf), fmt, args);
168  va_end(args);
169 
170  szBuf[sizeof(szBuf)-1] = '0';
171 
172  fatal(szBuf);
173 }
void void void fatal(const char *) const
Definition: scanner.h:140

Here is the call graph for this function:

Here is the caller graph for this function:

void re2c::Scanner::fatalf_at ( uint32_t  line,
const char *  fmt,
  ... 
) const

Definition at line 145 of file scanner.cc.

146 {
147  char szBuf[4096];
148 
149  va_list args;
150 
151  va_start(args, fmt);
152  vsnprintf(szBuf, sizeof(szBuf), fmt, args);
153  va_end(args);
154 
155  szBuf[sizeof(szBuf)-1] = '0';
156 
157  fatal_at(line, 0, szBuf);
158 }
void fatal_at(uint32_t line, ptrdiff_t ofs, const char *msg) const
Definition: scanner.cc:132

Here is the call graph for this function:

re2c::Scanner::FORBID_COPY ( Scanner  )
uint32_t re2c::Scanner::get_cline ( ) const
inline

Definition at line 125 of file scanner.h.

126 {
127  return cline;
128 }
uint32_t cline
Definition: scanner.h:42
const std::string & re2c::Scanner::get_fname ( ) const
inline

Definition at line 120 of file scanner.h.

121 {
122  return in.file_name;
123 }
std::string file_name
Definition: input.h:14
uint32_t re2c::Scanner::get_line ( ) const
inline

Definition at line 130 of file scanner.h.

131 {
132  return in_parse ? tline : cline;
133 }
uint32_t cline
Definition: scanner.h:42
uint32_t tline
Definition: scanner.h:41
RegExp * re2c::Scanner::mkDefault ( ) const

Definition at line 195 of file regexp.cc.

196 {
197  Range * def = Range::ran (0, opts->encoding.nCodeUnits());
198  return new MatchOp(def);
199 }
static Range * ran(uint32_t l, uint32_t u)
Definition: range.h:31
Enc encoding
Definition: opt.h:118
uint32_t nCodeUnits() const
Definition: enc.h:123
Opt opts
Definition: opt.cc:7

Here is the call graph for this function:

RegExp * re2c::Scanner::mkDiff ( RegExp e1,
RegExp e2 
) const

Definition at line 160 of file regexp.cc.

161 {
162  MatchOp * m1 = dynamic_cast<MatchOp *> (e1);
163  MatchOp * m2 = dynamic_cast<MatchOp *> (e2);
164  if (m1 == NULL || m2 == NULL)
165  {
166  fatal("can only difference char sets");
167  }
168  Range * r = Range::sub (m1->match, m2->match);
169 
170  return cls(r);
171 }
static Range * sub(const Range *r1, const Range *r2)
Definition: range.cc:61
void void void fatal(const char *) const
Definition: scanner.h:140

Here is the call graph for this function:

RegExp * re2c::Scanner::mkDot ( ) const

Definition at line 173 of file regexp.cc.

174 {
175  Range * full = opts->encoding.fullRange();
176  uint32_t c = '\n';
177  if (!opts->encoding.encode(c))
178  fatalf("Bad code point: '0x%X'", c);
179  Range * ran = Range::sym (c);
180  Range * inv = Range::sub (full, ran);
181 
182  return cls(inv);
183 }
static Range * sub(const Range *r1, const Range *r2)
Definition: range.cc:61
Range * fullRange() const
Definition: enc.cc:195
void void fatalf(const char *,...) const RE2C_GXX_ATTRIBUTE((format(printf
Definition: scanner.cc:160
bool encode(uint32_t &c) const
Definition: enc.cc:62
Enc encoding
Definition: opt.h:118
static Range * sym(uint32_t c)
Definition: range.h:27
Opt opts
Definition: opt.cc:7

Here is the call graph for this function:

void re2c::Scanner::restore_state ( const ScannerState state)

Definition at line 189 of file scanner.cc.

190 {
191  ptrdiff_t diff = bot - state.bot;
192  char *old_bot = bot;
193  char *old_lim = lim;
194  char *old_top = top;
195  char *old_eof = eof;
196  *(ScannerState*)this = state;
197  if (diff)
198  {
199  tok -= diff;
200  ptr -= diff;
201  cur -= diff;
202  pos -= diff;
203  ctx -= diff;
204  bot = old_bot;
205  lim = old_lim;
206  top = old_top;
207  eof = old_eof;
208  }
209 }
static int32_t diff(const re2c::Range *r1, const re2c::Range *r2, const re2c::Range *op1, const re2c::Range *op2, const char *op)
Definition: test.cc:43

Here is the call graph for this function:

void re2c::Scanner::reuse ( )

Definition at line 180 of file scanner.cc.

181 {
182  out.label_counter.reset ();
183  last_fill_index = 0;
184  bWroteGetState = false;
185  bWroteCondCheck = false;
187 }
bool bWroteGetState
Definition: main.cc:17
void reset_mapCodeName()
Definition: opt.cc:299
bool bWroteCondCheck
Definition: main.cc:18
Opt opts
Definition: opt.cc:7
uint32_t last_fill_index
Definition: main.cc:19
counter_t< label_t > label_counter
Definition: output.h:65
OutputFile & out
Definition: scanner.h:58

Here is the call graph for this function:

void re2c::Scanner::save_state ( ScannerState state) const
inline

Definition at line 135 of file scanner.h.

136 {
137  state = *this;
138 }
int re2c::Scanner::scan ( )
void re2c::Scanner::set_in_parse ( bool  new_in_parse)

Definition at line 127 of file scanner.cc.

128 {
129  in_parse = new_in_parse;
130 }

Member Data Documentation

OutputFile& re2c::Scanner::out

Definition at line 58 of file scanner.h.


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