-/* Generated by re2c 0.14.3 on Wed Aug 12 22:30:20 2015 */
+/* Generated by re2c 0.14.3 on Fri Aug 14 12:58:19 2015 */
#line 1 "../src/parse/scanner_lex.re"
#include <stdlib.h>
#include <string.h>
{
if (!(ignore_eoc || DFlag || flag_skeleton))
{
- out.write(tok, cur - tok - 1);
+ out.write(tok, tok_len () - 1);
// -1 so we don't write out the \0
}
if(cur == eof)
}
else if (!(DFlag || flag_skeleton))
{
- out.write(tok, cur - tok);
+ out.write(tok, tok_len ());
}
tok = pos = cur;
cline++;
const size_t lexeme_len = cur[-1] == '{'
? sizeof ("%{") - 1
: sizeof ("/*!re2c") - 1;
- out.write(tok, cur - tok - lexeme_len);
+ out.write(tok, tok_len () - lexeme_len);
}
tok = cur;
return Parse;
if (!(DFlag || flag_skeleton))
{
const size_t lexeme_len = sizeof ("/*!use:re2c") - 1;
- out.write(tok, cur - tok - lexeme_len);
+ out.write(tok, tok_len () - lexeme_len);
}
tok = cur;
return Reuse;
}
else if (!(DFlag || flag_skeleton))
{
- out.write(tok, cur - tok);
+ out.write(tok, tok_len ());
}
tok = pos = cur;
goto echo;
}
else if (!(DFlag || flag_skeleton))
{
- out.write(tok, cur - tok);
+ out.write(tok, tok_len ());
}
tok = pos = cur;
goto echo;
if (!FFlag) {
fatal("curly braces for names only allowed with -F switch");
}
- yylval.str = new std::string (tok + 1, cur - tok - 2);
+ yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
return ID;
}
#line 959 "src/parse/scanner_lex.cc"
#line 391 "../src/parse/scanner_lex.re"
{
if (!FFlag) {
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
return ID;
} else {
/* Add one char in front and one behind instead of 's or "s */
- SubStr s (tok, cur - tok);
+ SubStr s (tok, tok_len ());
if (bCaseInsensitive || bCaseInverted)
{
yylval.regexp = strToCaseInsensitiveRE (s);
YYCURSOR = YYCTXMARKER;
#line 386 "../src/parse/scanner_lex.re"
{
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
return ID;
}
#line 1047 "src/parse/scanner_lex.cc"
{
tok += 5; /* skip "re2c:" */
lexer_state = LEX_CONFIG;
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
return CONFIG;
}
#line 1133 "src/parse/scanner_lex.cc"
YYCURSOR = YYCTXMARKER;
#line 373 "../src/parse/scanner_lex.re"
{
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
if (FFlag)
{
lexer_state = LEX_FLEX_NAME;
++YYCURSOR;
#line 302 "../src/parse/scanner_lex.re"
{
- SubStr s (tok, cur - tok);
+ SubStr s (tok, tok_len ());
yylval.regexp = ranToRE (s);
return RANGE;
}
++YYCURSOR;
#line 296 "../src/parse/scanner_lex.re"
{
- SubStr s (tok, cur - tok);
+ SubStr s (tok, tok_len ());
yylval.regexp = invToRE (s);
return RANGE;
}
++YYCURSOR;
#line 276 "../src/parse/scanner_lex.re"
{
- SubStr s (tok + 1, cur - tok - 2);
+ SubStr s (tok + 1, tok_len () - 2); // -2 to omit quotes
if (bCaseInverted)
{
yylval.regexp = strToRE (s);
++YYCURSOR;
#line 263 "../src/parse/scanner_lex.re"
{
- SubStr s (tok + 1, cur - tok - 2);
+ SubStr s (tok + 1, tok_len () - 2); // -2 to omit quotes
if (bCaseInsensitive || bCaseInverted)
{
yylval.regexp = strToCaseInsensitiveRE (s);
{
--cur;
}
- yylval.code = new Code (tok, cur - tok, get_fname (), tline);
+ yylval.code = new Code (tok, tok_len (), get_fname (), tline);
return CODE;
}
else if (cur == eof)
}
else if (--depth == 0)
{
- yylval.code = new Code (tok, cur - tok, get_fname (), tline);
+ yylval.code = new Code (tok, tok_len (), get_fname (), tline);
return CODE;
}
goto code;
yy358:
#line 608 "../src/parse/scanner_lex.re"
{
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
lexer_state = LEX_NORMAL;
return VALUE;
}
yy360:
#line 603 "../src/parse/scanner_lex.re"
{
- yylval.number = atoi(std::string (tok, cur - tok).c_str());
+ yylval.number = atoi(std::string (tok, tok_len ()).c_str());
lexer_state = LEX_NORMAL;
return NUMBER;
}
yy388:
#line 635 "../src/parse/scanner_lex.re"
{
- cline = atoi(std::string (tok, cur - tok).c_str());
+ cline = atoi(std::string (tok, tok_len ()).c_str());
goto sourceline;
}
#line 2630 "src/parse/scanner_lex.cc"
++YYCURSOR;
#line 639 "../src/parse/scanner_lex.re"
{
- escape (in.file_name, std::string (tok + 1, cur - tok - 2));
+ escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes
goto sourceline;
}
#line 2667 "src/parse/scanner_lex.cc"
return blocks.back ()->fragments.back ()->stream;
}
-void OutputFile::write (const char * s, std::streamsize n)
+void OutputFile::write (const char * s, size_t n)
{
- stream ().write (s, n);
+ stream ().write (s, static_cast<std::streamsize> (n));
}
void OutputFile::write_hex (uint32_t n)
void new_block ();
- void write (const char * s, std::streamsize n);
+ void write (const char * s, size_t n);
void write_hex (uint32_t n);
void write_char_hex (uint32_t n);
void write_range (uint32_t u, uint32_t l);
private:
void fill (uint32_t);
void set_sourceline ();
+ size_t tok_len () const;
public:
Scanner(Input &, OutputFile &);
FORBID_COPY (Scanner);
};
+inline size_t Scanner::tok_len () const
+{
+ // lexing and fill procedures must maintain: token pointer <= cursor pointer
+ return static_cast<size_t> (cur - tok);
+}
+
inline size_t Scanner::get_pos() const
{
- return cur - bot;
+ // lexing and fill procedures must maintain: buffer bottom <= cursor pointer
+ return static_cast<size_t> (cur - bot);
}
inline const std::string & Scanner::get_fname () const
const size_t lexeme_len = cur[-1] == '{'
? sizeof ("%{") - 1
: sizeof ("/*!re2c") - 1;
- out.write(tok, cur - tok - lexeme_len);
+ out.write(tok, tok_len () - lexeme_len);
}
tok = cur;
return Parse;
if (!(DFlag || flag_skeleton))
{
const size_t lexeme_len = sizeof ("/*!use:re2c") - 1;
- out.write(tok, cur - tok - lexeme_len);
+ out.write(tok, tok_len () - lexeme_len);
}
tok = cur;
return Reuse;
}
else if (!(DFlag || flag_skeleton))
{
- out.write(tok, cur - tok);
+ out.write(tok, tok_len ());
}
tok = pos = cur;
goto echo;
}
else if (!(DFlag || flag_skeleton))
{
- out.write(tok, cur - tok);
+ out.write(tok, tok_len ());
}
tok = pos = cur;
goto echo;
}
else if (!(DFlag || flag_skeleton))
{
- out.write(tok, cur - tok);
+ out.write(tok, tok_len ());
}
tok = pos = cur;
cline++;
zero {
if (!(ignore_eoc || DFlag || flag_skeleton))
{
- out.write(tok, cur - tok - 1);
+ out.write(tok, tok_len () - 1);
// -1 so we don't write out the \0
}
if(cur == eof)
}
dstring {
- SubStr s (tok + 1, cur - tok - 2);
+ SubStr s (tok + 1, tok_len () - 2); // -2 to omit quotes
if (bCaseInsensitive || bCaseInverted)
{
yylval.regexp = strToCaseInsensitiveRE (s);
}
sstring {
- SubStr s (tok + 1, cur - tok - 2);
+ SubStr s (tok + 1, tok_len () - 2); // -2 to omit quotes
if (bCaseInverted)
{
yylval.regexp = strToRE (s);
}
istring {
- SubStr s (tok, cur - tok);
+ SubStr s (tok, tok_len ());
yylval.regexp = invToRE (s);
return RANGE;
}
cstring {
- SubStr s (tok, cur - tok);
+ SubStr s (tok, tok_len ());
yylval.regexp = ranToRE (s);
return RANGE;
}
if (!FFlag) {
fatal("curly braces for names only allowed with -F switch");
}
- yylval.str = new std::string (tok + 1, cur - tok - 2);
+ yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
return ID;
}
config {
tok += 5; /* skip "re2c:" */
lexer_state = LEX_CONFIG;
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
return CONFIG;
}
name / (space+ [^=>,]) {
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
if (FFlag)
{
lexer_state = LEX_FLEX_NAME;
}
name / (space* [=>,]) {
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
return ID;
}
name / [^] {
if (!FFlag) {
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
return ID;
} else {
/* Add one char in front and one behind instead of 's or "s */
- SubStr s (tok, cur - tok);
+ SubStr s (tok, tok_len ());
if (bCaseInsensitive || bCaseInverted)
{
yylval.regexp = strToCaseInsensitiveRE (s);
}
else if (--depth == 0)
{
- yylval.code = new Code (tok, cur - tok, get_fname (), tline);
+ yylval.code = new Code (tok, tok_len (), get_fname (), tline);
return CODE;
}
goto code;
{
--cur;
}
- yylval.code = new Code (tok, cur - tok, get_fname (), tline);
+ yylval.code = new Code (tok, tok_len (), get_fname (), tline);
return CODE;
}
else if (cur == eof)
value:
/*!re2c
number {
- yylval.number = atoi(std::string (tok, cur - tok).c_str());
+ yylval.number = atoi(std::string (tok, tok_len ()).c_str());
lexer_state = LEX_NORMAL;
return NUMBER;
}
value {
- yylval.str = new std::string (tok, cur - tok);
+ yylval.str = new std::string (tok, tok_len ());
lexer_state = LEX_NORMAL;
return VALUE;
}
tok = cur;
/*!re2c
lineno {
- cline = atoi(std::string (tok, cur - tok).c_str());
+ cline = atoi(std::string (tok, tok_len ()).c_str());
goto sourceline;
}
dstring {
- escape (in.file_name, std::string (tok + 1, cur - tok - 2));
+ escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes
goto sourceline;
}
"\n" {