-/* Generated by re2c 1.1 on Mon Aug 27 22:43:09 2018 */
+/* Generated by re2c 1.1 on Thu Aug 30 23:07:35 2018 */
#line 1 "../src/ast/lex.re"
#include "src/util/c99_stdint.h"
#include <stddef.h>
extern YYSTYPE yylval;
-#define YYCTYPE unsigned char
-#define YYCURSOR cur
-#define YYLIMIT lim
-#define YYMARKER mar
-#define YYCTXMARKER ctx
-#define YYFILL(n) { fill (n); }
+#define YYCTYPE unsigned char
+#define YYCURSOR cur
+#define YYLIMIT lim
+#define YYMARKER mar
+#define YYCTXMARKER ctx
+#define YYFILL(n) { fill (n); }
namespace re2c
{
Scanner::ParseMode Scanner::echo(OutputFile &out)
{
- if (eof && cur == eof) // Catch EOF
- {
- return Stop;
- }
+ if (eof && cur == eof) // Catch EOF
+ {
+ return Stop;
+ }
- tok = cur;
+ tok = cur;
echo:
- ptr = cur;
+ ptr = cur;
#line 57 "src/ast/lex.cc"
++YYCURSOR;
#line 136 "../src/ast/lex.re"
{
- if (cur != eof) goto echo;
- out.wraw(tok, ptr);
- return Stop;
- }
+ if (cur != eof) goto echo;
+ out.wraw(tok, ptr);
+ return Stop;
+ }
#line 121 "src/ast/lex.cc"
yy4:
++YYCURSOR;
yy7:
#line 148 "../src/ast/lex.re"
{
- cline++;
- pos = cur;
- goto echo;
- }
+ cline++;
+ pos = cur;
+ goto echo;
+ }
#line 142 "src/ast/lex.cc"
yy8:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 73 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- return Parse;
- }
+ out.wraw(tok, ptr);
+ return Parse;
+ }
#line 190 "src/ast/lex.cc"
yy18:
yych = (YYCTYPE)*++YYCURSOR;
YYCURSOR = YYCTXMARKER;
#line 142 "../src/ast/lex.re"
{
- out.wraw(tok, ptr + 1);
- set_sourceline();
- goto echo;
- }
+ out.wraw(tok, ptr + 1);
+ set_sourceline();
+ goto echo;
+ }
#line 454 "src/ast/lex.cc"
yy75:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 94 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- out.wdelay_yymaxfill();
- lex_end_of_comment(out);
- goto echo;
- }
+ out.wraw(tok, ptr);
+ out.wdelay_yymaxfill();
+ lex_end_of_comment(out);
+ goto echo;
+ }
#line 569 "src/ast/lex.cc"
yy102:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 83 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- return Reuse;
- }
+ out.wraw(tok, ptr);
+ return Reuse;
+ }
#line 597 "src/ast/lex.cc"
yy109:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 130 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- lex_tags(out, true);
- goto echo;
- }
+ out.wraw(tok, ptr);
+ lex_tags(out, true);
+ goto echo;
+ }
#line 646 "src/ast/lex.cc"
yy121:
++YYCURSOR;
#line 78 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- return Rules;
- }
+ out.wraw(tok, ptr);
+ return Rules;
+ }
#line 654 "src/ast/lex.cc"
yy123:
++YYCURSOR;
#line 124 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- lex_tags(out, false);
- goto echo;
- }
+ out.wraw(tok, ptr);
+ lex_tags(out, false);
+ goto echo;
+ }
#line 663 "src/ast/lex.cc"
yy125:
++YYCURSOR;
#line 115 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- out.wdelay_line_info_output();
- out.wdelay_types();
- out.wdelay_line_info_input(cline, get_fname());
- lex_end_of_comment(out);
- goto echo;
- }
+ out.wraw(tok, ptr);
+ out.wdelay_line_info_output();
+ out.wdelay_types();
+ out.wdelay_line_info_input(cline, get_fname());
+ lex_end_of_comment(out);
+ goto echo;
+ }
#line 675 "src/ast/lex.cc"
yy127:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 88 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- lex_end_of_comment(out);
- goto echo;
- }
+ out.wraw(tok, ptr);
+ lex_end_of_comment(out);
+ goto echo;
+ }
#line 688 "src/ast/lex.cc"
yy130:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 108 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- out.wdelay_state_goto(0);
- lex_end_of_comment(out);
- goto echo;
- }
+ out.wraw(tok, ptr);
+ out.wdelay_state_goto(0);
+ lex_end_of_comment(out);
+ goto echo;
+ }
#line 710 "src/ast/lex.cc"
yy135:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 101 "../src/ast/lex.re"
{
- out.wraw(tok, ptr);
- out.wdelay_yymaxnmatch();
- lex_end_of_comment(out);
- goto echo;
- }
+ out.wraw(tok, ptr);
+ out.wdelay_yymaxnmatch();
+ lex_end_of_comment(out);
+ goto echo;
+ }
#line 722 "src/ast/lex.cc"
}
#line 155 "../src/ast/lex.re"
void Scanner::lex_end_of_comment(OutputFile &out)
{
- uint32_t ignored = 0;
- for (;;) {
+ uint32_t ignored = 0;
+ for (;;) {
#line 732 "src/ast/lex.cc"
{
YYCTYPE yych;
++YYCURSOR;
#line 166 "../src/ast/lex.re"
{
- if (ignored > 0) {
- cline += ignored;
- out.wdelay_line_info_input(cline, get_fname());
- }
- tok = pos = cur;
- return;
- }
+ if (ignored > 0) {
+ cline += ignored;
+ out.wdelay_line_info_input(cline, get_fname());
+ }
+ tok = pos = cur;
+ return;
+ }
#line 779 "src/ast/lex.cc"
}
#line 174 "../src/ast/lex.re"
void Scanner::lex_tags(OutputFile &out, bool mtags)
{
- std::string fmt, sep;
- for (;;) {
+ std::string fmt, sep;
+ for (;;) {
#line 789 "src/ast/lex.cc"
{
YYCTYPE yych;
++YYCURSOR;
#line 188 "../src/ast/lex.re"
{
- out.wdelay_tags(new ConfTags(fmt, sep), mtags);
- tok = pos = cur;
- return;
- }
+ out.wdelay_tags(new ConfTags(fmt, sep), mtags);
+ tok = pos = cur;
+ return;
+ }
#line 889 "src/ast/lex.cc"
yy165:
yych = (YYCTYPE)*++YYCURSOR;
int Scanner::scan(const conopt_t *globopts)
{
- uint32_t depth, code_line;
+ uint32_t depth, code_line;
scan:
- tchar = cur - pos;
- tok = cur;
+ tchar = cur - pos;
+ tok = cur;
#line 952 "src/ast/lex.cc"
{
yy184:
#line 353 "../src/ast/lex.re"
{
- fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok);
- goto scan;
- }
+ fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok);
+ goto scan;
+ }
#line 1057 "src/ast/lex.cc"
yy185:
++YYCURSOR;
}
#line 332 "../src/ast/lex.re"
{
- goto scan;
- }
+ goto scan;
+ }
#line 1069 "src/ast/lex.cc"
yy188:
yyaccept = 0;
yy189:
#line 341 "../src/ast/lex.re"
{
- if (cur == eof) return 0;
- pos = cur;
- cline++;
- if (lexer_state == LEX_FLEX_NAME) {
- lexer_state = LEX_NORMAL;
- return TOKEN_FID_END;
- } else {
- goto scan;
- }
- }
+ if (cur == eof) return 0;
+ pos = cur;
+ cline++;
+ if (lexer_state == LEX_FLEX_NAME) {
+ lexer_state = LEX_NORMAL;
+ return TOKEN_FID_END;
+ } else {
+ goto scan;
+ }
+ }
#line 1092 "src/ast/lex.cc"
yy190:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 327 "../src/ast/lex.re"
{
- yylval.regexp = ast_dot(cline, get_column());
- return TOKEN_REGEXP;
- }
+ yylval.regexp = ast_dot(cline, get_column());
+ return TOKEN_REGEXP;
+ }
#line 1139 "src/ast/lex.cc"
yy202:
yych = (YYCTYPE)*++YYCURSOR;
yy210:
#line 203 "../src/ast/lex.re"
{
- depth = 1;
- code_line = cline;
- goto code;
- }
+ depth = 1;
+ code_line = cline;
+ goto code;
+ }
#line 1213 "src/ast/lex.cc"
yy211:
++YYCURSOR;
yy218:
#line 239 "../src/ast/lex.re"
{
- const std::string *name = new std::string(tok + 1, tok_len() - 1);
- yylval.regexp = ast_tag(cline, get_column(), name, tok[0] == '#');
- return TOKEN_REGEXP;
- }
+ const std::string *name = new std::string(tok + 1, tok_len() - 1);
+ yylval.regexp = ast_tag(cline, get_column(), name, tok[0] == '#');
+ return TOKEN_REGEXP;
+ }
#line 1270 "src/ast/lex.cc"
yy219:
++YYCURSOR;
#line 229 "../src/ast/lex.re"
{
- tok = cur;
- return 0;
- }
+ tok = cur;
+ return 0;
+ }
#line 1278 "src/ast/lex.cc"
yy221:
++YYCURSOR;
#line 223 "../src/ast/lex.re"
{
- depth = 1;
- goto comment;
- }
+ depth = 1;
+ goto comment;
+ }
#line 1286 "src/ast/lex.cc"
yy223:
++YYCURSOR;
#line 220 "../src/ast/lex.re"
{
- goto nextLine;
- }
+ goto nextLine;
+ }
#line 1293 "src/ast/lex.cc"
yy225:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '>') goto yy243;
#line 213 "../src/ast/lex.re"
{
- tok += 2; /* skip ":=" */
- depth = 0;
- code_line = cline;
- goto code;
- }
+ tok += 2; /* skip ":=" */
+ depth = 0;
+ code_line = cline;
+ goto code;
+ }
#line 1304 "src/ast/lex.cc"
yy227:
++YYCURSOR;
YYCURSOR -= 1;
#line 310 "../src/ast/lex.re"
{
- if (!globopts->FFlag) {
- yylval.str = new std::string (tok, tok_len());
- return TOKEN_ID;
- } else {
- std::vector<ASTChar> *str = new std::vector<ASTChar>;
- for (char *s = tok; s < cur; ++s) {
- const uint32_t
- chr = static_cast<uint8_t>(*s),
- col = static_cast<uint32_t>(s - tok);
- str->push_back(ASTChar(chr, col));
- }
- yylval.regexp = ast_str(cline, get_column(), str, false);
- return TOKEN_REGEXP;
- }
- }
+ if (!globopts->FFlag) {
+ yylval.str = new std::string (tok, tok_len());
+ return TOKEN_ID;
+ } else {
+ std::vector<ASTChar> *str = new std::vector<ASTChar>;
+ for (char *s = tok; s < cur; ++s) {
+ const uint32_t
+ chr = static_cast<uint8_t>(*s),
+ col = static_cast<uint32_t>(s - tok);
+ str->push_back(ASTChar(chr, col));
+ }
+ yylval.regexp = ast_str(cline, get_column(), str, false);
+ return TOKEN_REGEXP;
+ }
+ }
#line 1325 "src/ast/lex.cc"
yy229:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
#line 305 "../src/ast/lex.re"
{
- yylval.str = new std::string (tok, tok_len ());
- return TOKEN_ID;
- }
+ yylval.str = new std::string (tok, tok_len ());
+ return TOKEN_ID;
+ }
#line 1350 "src/ast/lex.cc"
yy233:
++YYCURSOR;
yy237:
#line 278 "../src/ast/lex.re"
{
- fatal_lc(get_cline(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers");
- }
+ fatal_lc(get_cline(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers");
+ }
#line 1367 "src/ast/lex.cc"
yy238:
++YYCURSOR;
YYCURSOR -= 2;
#line 209 "../src/ast/lex.re"
{
- return *tok;
- }
+ return *tok;
+ }
#line 1411 "src/ast/lex.cc"
yy245:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
#line 292 "../src/ast/lex.re"
{
- yylval.str = new std::string (tok, tok_len ());
- if (globopts->FFlag)
- {
- lexer_state = LEX_FLEX_NAME;
- return TOKEN_FID;
- }
- else
- {
- return TOKEN_ID;
- }
- }
+ yylval.str = new std::string (tok, tok_len ());
+ if (globopts->FFlag)
+ {
+ lexer_state = LEX_FLEX_NAME;
+ return TOKEN_FID;
+ }
+ else
+ {
+ return TOKEN_ID;
+ }
+ }
#line 1428 "src/ast/lex.cc"
yy247:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 247 "../src/ast/lex.re"
{
- if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min))
- {
- fatal_lc(get_cline(), get_column(), "repetition count overflow");
- }
- yylval.bounds.max = yylval.bounds.min;
- return TOKEN_CLOSESIZE;
- }
+ if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition count overflow");
+ }
+ yylval.bounds.max = yylval.bounds.min;
+ return TOKEN_CLOSESIZE;
+ }
#line 1451 "src/ast/lex.cc"
yy251:
++YYCURSOR;
#line 282 "../src/ast/lex.re"
{
- if (!globopts->FFlag) {
- fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch");
- }
- yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
- return TOKEN_ID;
- }
+ if (!globopts->FFlag) {
+ fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch");
+ }
+ yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
+ return TOKEN_ID;
+ }
#line 1462 "src/ast/lex.cc"
yy253:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 269 "../src/ast/lex.re"
{
- if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min))
- {
- fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
- }
- yylval.bounds.max = std::numeric_limits<uint32_t>::max();
- return TOKEN_CLOSESIZE;
- }
+ if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
+ }
+ yylval.bounds.max = std::numeric_limits<uint32_t>::max();
+ return TOKEN_CLOSESIZE;
+ }
#line 1490 "src/ast/lex.cc"
yy259:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 256 "../src/ast/lex.re"
{
- const char * p = strchr (tok, ',');
- if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min))
- {
- fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
- }
- if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max))
- {
- fatal_lc(get_cline(), get_column(), "repetition upper bound overflow");
- }
- return TOKEN_CLOSESIZE;
- }
+ const char * p = strchr (tok, ',');
+ if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
+ }
+ if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition upper bound overflow");
+ }
+ return TOKEN_CLOSESIZE;
+ }
#line 1515 "src/ast/lex.cc"
yy264:
yych = (YYCTYPE)*++YYCURSOR;
YYCURSOR = YYCTXMARKER;
#line 336 "../src/ast/lex.re"
{
- set_sourceline ();
- return TOKEN_LINE_INFO;
- }
+ set_sourceline ();
+ return TOKEN_LINE_INFO;
+ }
#line 1576 "src/ast/lex.cc"
yy273:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 420 "../src/ast/lex.re"
{
- if (cur == eof)
- {
- if (depth)
- {
- fatal_l(get_cline(), "missing '}'");
- }
- return 0;
- }
- goto code;
- }
+ if (cur == eof)
+ {
+ if (depth)
+ {
+ fatal_l(get_cline(), "missing '}'");
+ }
+ return 0;
+ }
+ goto code;
+ }
#line 1679 "src/ast/lex.cc"
yy282:
++YYCURSOR;
yy283:
#line 434 "../src/ast/lex.re"
{
- goto code;
- }
+ goto code;
+ }
#line 1687 "src/ast/lex.cc"
yy284:
yyaccept = 0;
yy285:
#line 401 "../src/ast/lex.re"
{
- if (depth == 0)
- {
- tok += strspn(tok, " \t\r\n");
- while (cur > tok && strchr(" \t\r\n", cur[-1]))
- {
- --cur;
- }
- yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
- return TOKEN_CODE;
- }
- else if (cur == eof)
- {
- fatal_l(get_cline(), "missing '}'");
- }
- pos = cur;
- cline++;
- goto code;
- }
+ if (depth == 0)
+ {
+ tok += strspn(tok, " \t\r\n");
+ while (cur > tok && strchr(" \t\r\n", cur[-1]))
+ {
+ --cur;
+ }
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
+ return TOKEN_CODE;
+ }
+ else if (cur == eof)
+ {
+ fatal_l(get_cline(), "missing '}'");
+ }
+ pos = cur;
+ cline++;
+ goto code;
+ }
#line 1726 "src/ast/lex.cc"
yy286:
yyaccept = 1;
++YYCURSOR;
#line 373 "../src/ast/lex.re"
{
- if (depth == 0)
- {
- fatal_l(get_cline(), "Curly braces are not allowed after ':='");
- }
- else
- {
- ++depth;
- }
- goto code;
- }
+ if (depth == 0)
+ {
+ fatal_l(get_cline(), "Curly braces are not allowed after ':='");
+ }
+ else
+ {
+ ++depth;
+ }
+ goto code;
+ }
#line 1751 "src/ast/lex.cc"
yy290:
++YYCURSOR;
#line 361 "../src/ast/lex.re"
{
- if (depth == 0)
- {
- fatal_l(get_cline(), "Curly braces are not allowed after ':='");
- }
- else if (--depth == 0)
- {
- yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
- return TOKEN_CODE;
- }
- goto code;
- }
+ if (depth == 0)
+ {
+ fatal_l(get_cline(), "Curly braces are not allowed after ':='");
+ }
+ else if (--depth == 0)
+ {
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
+ return TOKEN_CODE;
+ }
+ goto code;
+ }
#line 1767 "src/ast/lex.cc"
yy292:
yyaccept = 2;
YYCURSOR -= 1;
#line 388 "../src/ast/lex.re"
{
- if (depth == 0)
- {
- goto code;
- }
- else if (cur == eof)
- {
- fatal_l(get_cline(), "missing '}'");
- }
- pos = cur;
- cline++;
- goto code;
- }
+ if (depth == 0)
+ {
+ goto code;
+ }
+ else if (cur == eof)
+ {
+ fatal_l(get_cline(), "missing '}'");
+ }
+ pos = cur;
+ cline++;
+ goto code;
+ }
#line 1793 "src/ast/lex.cc"
yy294:
++YYCURSOR;
++YYCURSOR;
#line 431 "../src/ast/lex.re"
{
- goto code;
- }
+ goto code;
+ }
#line 1832 "src/ast/lex.cc"
yy302:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
#line 384 "../src/ast/lex.re"
{
- set_sourceline ();
- goto code;
- }
+ set_sourceline ();
+ goto code;
+ }
#line 1927 "src/ast/lex.cc"
yy320:
yych = (YYCTYPE)*++YYCURSOR;
yy328:
#line 469 "../src/ast/lex.re"
{
- if (cur == eof)
- {
- return 0;
- }
- goto comment;
- }
+ if (cur == eof)
+ {
+ return 0;
+ }
+ goto comment;
+ }
#line 2016 "src/ast/lex.cc"
yy329:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
yy330:
#line 460 "../src/ast/lex.re"
{
- if (cur == eof)
- {
- return 0;
- }
- tok = pos = cur;
- cline++;
- goto comment;
- }
+ if (cur == eof)
+ {
+ return 0;
+ }
+ tok = pos = cur;
+ cline++;
+ goto comment;
+ }
#line 2034 "src/ast/lex.cc"
yy331:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 441 "../src/ast/lex.re"
{
- if (--depth == 0)
- {
- goto scan;
- }
- else
- {
- goto comment;
- }
- }
+ if (--depth == 0)
+ {
+ goto scan;
+ }
+ else
+ {
+ goto comment;
+ }
+ }
#line 2079 "src/ast/lex.cc"
yy340:
++YYCURSOR;
#line 451 "../src/ast/lex.re"
{
- ++depth;
- fatal_lc(get_cline(), get_column(), "ambiguous /* found");
- goto comment;
- }
+ ++depth;
+ fatal_lc(get_cline(), get_column(), "ambiguous /* found");
+ goto comment;
+ }
#line 2088 "src/ast/lex.cc"
yy342:
yych = (YYCTYPE)*++YYCURSOR;
YYCURSOR = YYCTXMARKER;
#line 456 "../src/ast/lex.re"
{
- set_sourceline ();
- goto comment;
- }
+ set_sourceline ();
+ goto comment;
+ }
#line 2150 "src/ast/lex.cc"
yy354:
yych = (YYCTYPE)*++YYCURSOR;
const AST *Scanner::lex_cls(bool neg)
{
- std::vector<ASTRange> *cls = new std::vector<ASTRange>;
- uint32_t u, l, c, c0 = get_column();
+ std::vector<ASTRange> *cls = new std::vector<ASTRange>;
+ uint32_t u, l, c, c0 = get_column();
fst:
- tok = cur;
- c = get_column();
-
+ tok = cur;
+ c = get_column();
+
#line 2218 "src/ast/lex.cc"
{
YYCTYPE yych;
#line 505 "../src/ast/lex.re"
snd:
-
+
#line 2237 "src/ast/lex.cc"
{
YYCTYPE yych;
YYCURSOR -= 1;
#line 509 "../src/ast/lex.re"
{
- u = lex_cls_chr();
- if (l > u) {
- warn.swapped_range(cline, l, u);
- std::swap(l, u);
- }
- goto add;
- }
+ u = lex_cls_chr();
+ if (l > u) {
+ warn.swapped_range(cline, l, u);
+ std::swap(l, u);
+ }
+ goto add;
+ }
#line 2264 "src/ast/lex.cc"
}
#line 517 "../src/ast/lex.re"
add:
- cls->push_back(ASTRange(l, u, c));
- goto fst;
+ cls->push_back(ASTRange(l, u, c));
+ goto fst;
}
uint32_t Scanner::lex_cls_chr()
{
- tok = cur;
- const uint32_t l = get_cline(), c = get_column();
-
+ tok = cur;
+ const uint32_t l = get_cline(), c = get_column();
+
#line 2278 "src/ast/lex.cc"
{
YYCTYPE yych;
yy386:
#line 547 "../src/ast/lex.re"
{
- warn.useless_escape(cline, get_column(), tok[1]);
- return static_cast<uint8_t>(tok[1]);
- }
+ warn.useless_escape(cline, get_column(), tok[1]);
+ return static_cast<uint8_t>(tok[1]);
+ }
#line 2356 "src/ast/lex.cc"
yy387:
yych = (YYCTYPE)*++YYCURSOR;
uint32_t Scanner::lex_str_chr(char quote, bool &end)
{
- end = false;
- tok = cur;
- const uint32_t l = get_cline(), c = get_column();
-
+ end = false;
+ tok = cur;
+ const uint32_t l = get_cline(), c = get_column();
+
#line 2578 "src/ast/lex.cc"
{
YYCTYPE yych;
yy431:
#line 566 "../src/ast/lex.re"
{
- end = tok[0] == quote;
- return static_cast<uint8_t>(tok[0]);
- }
+ end = tok[0] == quote;
+ return static_cast<uint8_t>(tok[0]);
+ }
#line 2597 "src/ast/lex.cc"
yy432:
++YYCURSOR;
yy437:
#line 580 "../src/ast/lex.re"
{
- if (tok[1] != quote) {
- warn.useless_escape(cline, get_column(), tok[1]);
- }
- return static_cast<uint8_t>(tok[1]);
- }
+ if (tok[1] != quote) {
+ warn.useless_escape(cline, get_column(), tok[1]);
+ }
+ return static_cast<uint8_t>(tok[1]);
+ }
#line 2658 "src/ast/lex.cc"
yy438:
yych = (YYCTYPE)*++YYCURSOR;
const AST *Scanner::lex_str(char quote)
{
- const uint32_t column = get_column();
- std::vector<ASTChar> *str = new std::vector<ASTChar>;
- for (bool end;;) {
- const uint32_t c = lex_str_chr(quote, end);
- if (end) return ast_str(cline, column, str, quote == '\'');
- str->push_back(ASTChar(c, get_column()));
- }
+ const uint32_t column = get_column();
+ std::vector<ASTChar> *str = new std::vector<ASTChar>;
+ for (bool end;;) {
+ const uint32_t c = lex_str_chr(quote, end);
+ if (end) return ast_str(cline, column, str, quote == '\'');
+ str->push_back(ASTChar(c, get_column()));
+ }
}
void Scanner::set_sourceline ()
{
sourceline:
- tok = cur;
+ tok = cur;
#line 2880 "src/ast/lex.cc"
{
++YYCURSOR;
#line 623 "../src/ast/lex.re"
{
- --cur;
- tok = cur;
- return;
- }
+ --cur;
+ tok = cur;
+ return;
+ }
#line 2944 "src/ast/lex.cc"
yy479:
++YYCURSOR;
++YYCURSOR;
#line 618 "../src/ast/lex.re"
{
- tok = cur;
- return;
- }
+ tok = cur;
+ return;
+ }
#line 2958 "src/ast/lex.cc"
yy483:
yych = (YYCTYPE)*++YYCURSOR;
}
#line 605 "../src/ast/lex.re"
{
- if (!s_to_u32_unsafe (tok, cur, cline)) {
- fatal_lc(get_cline(), get_column(), "line number overflow");
- }
- goto sourceline;
- }
+ if (!s_to_u32_unsafe (tok, cur, cline)) {
+ fatal_lc(get_cline(), get_column(), "line number overflow");
+ }
+ goto sourceline;
+ }
#line 2981 "src/ast/lex.cc"
yy488:
++YYCURSOR;
++YYCURSOR;
#line 612 "../src/ast/lex.re"
{
- in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // strip quotes
- strrreplace (in.escaped_file_name, "\\", "\\\\");
- goto sourceline;
- }
+ in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // strip quotes
+ strrreplace (in.escaped_file_name, "\\", "\\\\");
+ goto sourceline;
+ }
#line 3004 "src/ast/lex.cc"
yy493:
++YYCURSOR;
-/* Generated by re2c 1.1 on Mon Aug 27 22:43:09 2018 */
+/* Generated by re2c 1.1 on Thu Aug 30 23:07:01 2018 */
#line 1 "../src/ast/lex_conf.re"
#include "src/util/c99_stdint.h"
#include <string>
void Scanner::lex_conf(Opt &opts)
{
- tok = cur;
- const uint32_t l = get_cline(), c = get_column();
+ tok = cur;
+ const uint32_t l = get_cline(), c = get_column();
#line 25 "src/ast/lex_conf.cc"
{
yy2:
#line 161 "../src/ast/lex_conf.re"
{
- fatal_lc(l, c, "unrecognized configuration '%.*s'",
- static_cast<int>(cur - tok), tok);
- }
+ fatal_lc(l, c, "unrecognized configuration '%.*s'",
+ static_cast<int>(cur - tok), tok);
+ }
#line 111 "src/ast/lex_conf.cc"
yy3:
++cur;
}
#line 128 "../src/ast/lex_conf.re"
{
- const int32_t n = lex_conf_number ();
- if (n < 0)
- {
- fatal_lc(l, c, "configuration 'indent:top' must be nonnegative");
- }
- opts.set_topIndent (static_cast<uint32_t> (n));
- return;
- }
+ const int32_t n = lex_conf_number ();
+ if (n < 0)
+ {
+ fatal_lc(l, c, "configuration 'indent:top' must be nonnegative");
+ }
+ opts.set_topIndent (static_cast<uint32_t> (n));
+ return;
+ }
#line 1315 "src/ast/lex_conf.cc"
yy254:
yych = (unsigned char)*++cur;
}
#line 94 "../src/ast/lex_conf.re"
{
- const int32_t n = lex_conf_number ();
- if (n < 0)
- {
- fatal_lc(l, c, "configuration 'cgoto:threshold' must be nonnegative");
- }
- opts.set_cGotoThreshold (static_cast<uint32_t> (n));
- return;
- }
+ const int32_t n = lex_conf_number ();
+ if (n < 0)
+ {
+ fatal_lc(l, c, "configuration 'cgoto:threshold' must be nonnegative");
+ }
+ opts.set_cGotoThreshold (static_cast<uint32_t> (n));
+ return;
+ }
#line 2376 "src/ast/lex_conf.cc"
yy501:
yych = (unsigned char)*++cur;
void Scanner::lex_conf_encoding_policy(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
#line 3326 "src/ast/lex_conf.cc"
{
yy718:
#line 172 "../src/ast/lex_conf.re"
{ fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'ignore', 'substitute', 'fail')"); }
+ "bad configuration value (expected: 'ignore', 'substitute', 'fail')"); }
#line 3342 "src/ast/lex_conf.cc"
yy719:
yych = (unsigned char)*(mar = ++cur);
#line 177 "../src/ast/lex_conf.re"
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_input(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
#line 3431 "src/ast/lex_conf.cc"
{
yy746:
#line 186 "../src/ast/lex_conf.re"
{ fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'default', 'custom')"); }
+ "bad configuration value (expected: 'default', 'custom')"); }
#line 3445 "src/ast/lex_conf.cc"
yy747:
yych = (unsigned char)*(mar = ++cur);
#line 190 "../src/ast/lex_conf.re"
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_empty_class(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
#line 3511 "src/ast/lex_conf.cc"
{
yy766:
#line 199 "../src/ast/lex_conf.re"
{ fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'match-empty', 'match-none', 'error')"); }
+ "bad configuration value (expected: 'match-empty', 'match-none', 'error')"); }
#line 3523 "src/ast/lex_conf.cc"
yy767:
yych = (unsigned char)*(mar = ++cur);
#line 204 "../src/ast/lex_conf.re"
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_dfa_minimization(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
#line 3619 "src/ast/lex_conf.cc"
{
yy794:
#line 213 "../src/ast/lex_conf.re"
{ fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'table', 'moore')"); }
+ "bad configuration value (expected: 'table', 'moore')"); }
#line 3631 "src/ast/lex_conf.cc"
yy795:
yych = (unsigned char)*(mar = ++cur);
#line 217 "../src/ast/lex_conf.re"
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_enc(Enc::type_t enc, Opt &opts)
{
- if (lex_conf_bool()) {
- opts.set_encoding(enc);
- } else {
- opts.unset_encoding(enc);
- }
+ if (lex_conf_bool()) {
+ opts.set_encoding(enc);
+ } else {
+ opts.unset_encoding(enc);
+ }
}
void Scanner::lex_conf_assign ()
bool Scanner::lex_conf_bool()
{
- return lex_conf_number() != 0;
+ return lex_conf_number() != 0;
}
int32_t Scanner::lex_conf_number ()
{
- lex_conf_assign ();
- tok = cur;
+ lex_conf_assign ();
+ tok = cur;
#line 3870 "src/ast/lex_conf.cc"
{
yy834:
#line 257 "../src/ast/lex_conf.re"
{
- int32_t n = 0;
- if (!s_to_i32_unsafe (tok, cur, n)) {
- fatal_lc(get_cline(), get_column(), "configuration value overflow");
- }
- lex_conf_semicolon ();
- return n;
- }
+ int32_t n = 0;
+ if (!s_to_i32_unsafe (tok, cur, n)) {
+ fatal_lc(get_cline(), get_column(), "configuration value overflow");
+ }
+ lex_conf_semicolon ();
+ return n;
+ }
#line 3933 "src/ast/lex_conf.cc"
yy835:
++cur;
std::string Scanner::lex_conf_string ()
{
- lex_conf_assign ();
- std::string s;
- tok = cur;
+ lex_conf_assign ();
+ std::string s;
+ tok = cur;
#line 3953 "src/ast/lex_conf.cc"
{
}
#line 289 "../src/ast/lex_conf.re"
{
- s = std::string(tok, tok_len());
- goto end;
- }
+ s = std::string(tok, tok_len());
+ goto end;
+ }
#line 4022 "src/ast/lex_conf.cc"
yy843:
++cur;
#line 274 "../src/ast/lex_conf.re"
{
- const char quote = tok[0];
- for (bool end;;) {
- const uint32_t c = lex_str_chr(quote, end);
- if (end) {
- goto end;
- }
- if (c > 0xFF) {
- fatal_lc(get_cline(), get_column(),
- "multibyte character in configuration string: 0x%X", c);
- } else {
- s += static_cast<char>(c);
- }
- }
- }
+ const char quote = tok[0];
+ for (bool end;;) {
+ const uint32_t c = lex_str_chr(quote, end);
+ if (end) {
+ goto end;
+ }
+ if (c > 0xFF) {
+ fatal_lc(get_cline(), get_column(),
+ "multibyte character in configuration string: 0x%X", c);
+ } else {
+ s += static_cast<char>(c);
+ }
+ }
+ }
#line 4041 "src/ast/lex_conf.cc"
}
#line 294 "../src/ast/lex_conf.re"
end:
- lex_conf_semicolon ();
- return s;
+ lex_conf_semicolon ();
+ return s;
}
} // end namespace re2c
static spec_t &find(specs_t &specs, const std::string &name)
{
- for (specs_t::iterator i = specs.begin(); i != specs.end(); ++i) {
- if (i->name == name) return *i;
- }
- specs.push_back(spec_t(name));
- return specs.back();
+ for (specs_t::iterator i = specs.begin(); i != specs.end(); ++i) {
+ if (i->name == name) return *i;
+ }
+ specs.push_back(spec_t(name));
+ return specs.back();
}
{
- const re2c::AST * regexp;
- re2c::Code * code;
- char op;
- re2c::ASTBounds bounds;
- std::string * str;
- re2c::CondList * clist;
+ const re2c::AST * regexp;
+ re2c::Code * code;
+ char op;
+ re2c::ASTBounds bounds;
+ std::string * str;
+ re2c::CondList * clist;
};
case 7:
{
- if (!context.symtab.insert(std::make_pair(*(yyvsp[-2].str), (yyvsp[-1].regexp))).second) {
- fatal_l(context.input.get_cline(), "sym already defined");
- }
- delete (yyvsp[-2].str);
- }
+ if (!context.symtab.insert(std::make_pair(*(yyvsp[-2].str), (yyvsp[-1].regexp))).second) {
+ fatal_l(context.input.get_cline(), "sym already defined");
+ }
+ delete (yyvsp[-2].str);
+ }
break;
case 8:
{
- fatal_l(context.input.get_cline(),
- "trailing contexts are not allowed in named definitions");
- }
+ fatal_l(context.input.get_cline(),
+ "trailing contexts are not allowed in named definitions");
+ }
break;
case 9:
{
- (yyval.str) = (yyvsp[-1].str);
- }
+ (yyval.str) = (yyvsp[-1].str);
+ }
break;
case 10:
{
- (yyval.str) = (yyvsp[0].str);
- }
+ (yyval.str) = (yyvsp[0].str);
+ }
break;
case 13:
{
- find(context.specs, "").rules.push_back(ASTRule((yyvsp[-1].regexp), (yyvsp[0].code)));
- }
+ find(context.specs, "").rules.push_back(ASTRule((yyvsp[-1].regexp), (yyvsp[0].code)));
+ }
break;
case 14:
{
- find(context.specs, "").defs.push_back((yyvsp[0].code));
- }
+ find(context.specs, "").defs.push_back((yyvsp[0].code));
+ }
break;
case 15:
{
- for(CondList::const_iterator i = (yyvsp[-3].clist)->begin(); i != (yyvsp[-3].clist)->end(); ++i) {
- find(context.specs, *i).rules.push_back(ASTRule((yyvsp[-1].regexp), (yyvsp[0].code)));
- }
- delete (yyvsp[-3].clist);
- }
+ for(CondList::const_iterator i = (yyvsp[-3].clist)->begin(); i != (yyvsp[-3].clist)->end(); ++i) {
+ find(context.specs, *i).rules.push_back(ASTRule((yyvsp[-1].regexp), (yyvsp[0].code)));
+ }
+ delete (yyvsp[-3].clist);
+ }
break;
case 16:
{
- for(CondList::const_iterator i = (yyvsp[-3].clist)->begin(); i != (yyvsp[-3].clist)->end(); ++i) {
- find(context.specs, *i).defs.push_back((yyvsp[0].code));
- }
- delete (yyvsp[-3].clist);
- }
+ for(CondList::const_iterator i = (yyvsp[-3].clist)->begin(); i != (yyvsp[-3].clist)->end(); ++i) {
+ find(context.specs, *i).defs.push_back((yyvsp[0].code));
+ }
+ delete (yyvsp[-3].clist);
+ }
break;
case 17:
{
- for (CondList::const_iterator i = (yyvsp[-2].clist)->begin(); i != (yyvsp[-2].clist)->end(); ++i) {
- find(context.specs, *i).setup.push_back((yyvsp[0].code));
- }
- delete (yyvsp[-2].clist);
- }
+ for (CondList::const_iterator i = (yyvsp[-2].clist)->begin(); i != (yyvsp[-2].clist)->end(); ++i) {
+ find(context.specs, *i).setup.push_back((yyvsp[0].code));
+ }
+ delete (yyvsp[-2].clist);
+ }
break;
case 18:
{
- const AST *r = ast_nil(context.input.get_cline(), 0);
- find(context.specs, "0").rules.push_back(ASTRule(r, (yyvsp[0].code)));
- }
+ const AST *r = ast_nil(context.input.get_cline(), 0);
+ find(context.specs, "0").rules.push_back(ASTRule(r, (yyvsp[0].code)));
+ }
break;
case 20:
{
- (yyval.code) = (yyvsp[0].code);
- (yyval.code)->cond = *(yyvsp[-1].str);
- delete (yyvsp[-1].str);
- }
+ (yyval.code) = (yyvsp[0].code);
+ (yyval.code)->cond = *(yyvsp[-1].str);
+ delete (yyvsp[-1].str);
+ }
break;
case 21:
{
- (yyval.code) = new Code(context.input.get_fname(), context.input.get_cline());
- (yyval.code)->cond = *(yyvsp[0].str);
- delete (yyvsp[0].str);
- }
+ (yyval.code) = new Code(context.input.get_fname(), context.input.get_cline());
+ (yyval.code)->cond = *(yyvsp[0].str);
+ delete (yyvsp[0].str);
+ }
break;
case 23:
{
- (yyval.clist) = new CondList;
- (yyval.clist)->insert("*");
- }
+ (yyval.clist) = new CondList;
+ (yyval.clist)->insert("*");
+ }
break;
case 24:
{
- (yyval.clist) = new CondList;
- (yyval.clist)->insert(*(yyvsp[0].str));
- delete (yyvsp[0].str);
- }
+ (yyval.clist) = new CondList;
+ (yyval.clist)->insert(*(yyvsp[0].str));
+ delete (yyvsp[0].str);
+ }
break;
case 25:
{
- (yyvsp[-2].clist)->insert(*(yyvsp[0].str));
- delete (yyvsp[0].str);
- (yyval.clist) = (yyvsp[-2].clist);
- }
+ (yyvsp[-2].clist)->insert(*(yyvsp[0].str));
+ delete (yyvsp[0].str);
+ (yyval.clist) = (yyvsp[-2].clist);
+ }
break;
case 26:
{
- (yyval.regexp) = ast_cap((yyvsp[0].regexp));
- }
+ (yyval.regexp) = ast_cap((yyvsp[0].regexp));
+ }
break;
case 27:
{
- (yyval.regexp) = ast_cat(ast_cap((yyvsp[-2].regexp)),
- ast_cat(ast_tag(context.input.get_cline(), 0, NULL, false), (yyvsp[0].regexp)));
- }
+ (yyval.regexp) = ast_cat(ast_cap((yyvsp[-2].regexp)),
+ ast_cat(ast_tag(context.input.get_cline(), 0, NULL, false), (yyvsp[0].regexp)));
+ }
break;
case 28:
{
- (yyval.regexp) = (yyvsp[0].regexp);
- }
+ (yyval.regexp) = (yyvsp[0].regexp);
+ }
break;
case 29:
{
- (yyval.regexp) = ast_alt((yyvsp[-2].regexp), (yyvsp[0].regexp));
- }
+ (yyval.regexp) = ast_alt((yyvsp[-2].regexp), (yyvsp[0].regexp));
+ }
break;
case 30:
{
- (yyval.regexp) = (yyvsp[0].regexp);
- }
+ (yyval.regexp) = (yyvsp[0].regexp);
+ }
break;
case 31:
{
- (yyval.regexp) = ast_diff((yyvsp[-2].regexp), (yyvsp[0].regexp));
- }
+ (yyval.regexp) = ast_diff((yyvsp[-2].regexp), (yyvsp[0].regexp));
+ }
break;
case 32:
{
- (yyval.regexp) = (yyvsp[0].regexp);
- }
+ (yyval.regexp) = (yyvsp[0].regexp);
+ }
break;
case 33:
{
- (yyval.regexp) = ast_cat((yyvsp[-1].regexp), (yyvsp[0].regexp));
- }
+ (yyval.regexp) = ast_cat((yyvsp[-1].regexp), (yyvsp[0].regexp));
+ }
break;
case 35:
{
- switch((yyvsp[0].op)) {
- case '*': (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 0, AST::MANY); break;
- case '+': (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 1, AST::MANY); break;
- case '?': (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 0, 1); break;
- }
- }
+ switch((yyvsp[0].op)) {
+ case '*': (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 0, AST::MANY); break;
+ case '+': (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 1, AST::MANY); break;
+ case '?': (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 0, 1); break;
+ }
+ }
break;
case 36:
{
- (yyval.regexp) = ast_iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max);
- }
+ (yyval.regexp) = ast_iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max);
+ }
break;
case 43:
{
- symtab_t::iterator i = context.symtab.find(*(yyvsp[0].str));
- if (i == context.symtab.end()) {
- fatal_l(context.input.get_cline(),
- "undefined symbol '%s'", (yyvsp[0].str)->c_str());
- }
- (yyval.regexp) = i->second;
- if (ast_need_wrap((yyval.regexp))) {
- (yyval.regexp) = ast_ref((yyval.regexp), *(yyvsp[0].str));
- }
- delete (yyvsp[0].str);
- }
+ symtab_t::iterator i = context.symtab.find(*(yyvsp[0].str));
+ if (i == context.symtab.end()) {
+ fatal_l(context.input.get_cline(),
+ "undefined symbol '%s'", (yyvsp[0].str)->c_str());
+ }
+ (yyval.regexp) = i->second;
+ if (ast_need_wrap((yyval.regexp))) {
+ (yyval.regexp) = ast_ref((yyval.regexp), *(yyvsp[0].str));
+ }
+ delete (yyvsp[0].str);
+ }
break;
case 44:
{
- (yyval.regexp) = ast_cap((yyvsp[-1].regexp));
- }
+ (yyval.regexp) = ast_cap((yyvsp[-1].regexp));
+ }
break;
void yyerror(context_t &context, const char* s)
{
- fatal_l(context.input.get_cline(), "%s", s);
+ fatal_l(context.input.get_cline(), "%s", s);
}
int yylex(context_t &context)
{
- return context.input.scan(&context.opts.glob);
+ return context.input.scan(&context.opts.glob);
}
} // extern "C"
{
- const re2c::AST * regexp;
- re2c::Code * code;
- char op;
- re2c::ASTBounds bounds;
- std::string * str;
- re2c::CondList * clist;
+ const re2c::AST * regexp;
+ re2c::Code * code;
+ char op;
+ re2c::ASTBounds bounds;
+ std::string * str;
+ re2c::CondList * clist;
};
-/* Generated by re2c 1.1 on Mon Aug 27 22:43:09 2018 */
+/* Generated by re2c 1.1 on Thu Aug 30 23:07:01 2018 */
#line 1 "../src/conf/parse_opts.re"
#include "src/code/input_api.h"
#include "src/conf/msg.h"
static inline bool next (char * & arg, char ** & argv)
{
- arg = *++argv;
- return arg != NULL;
+ arg = *++argv;
+ return arg != NULL;
}
parse_opts_t parse_opts(char **argv, conopt_t &globopts, Opt &opts, Warn &warn)
{
#define YYCTYPE unsigned char
- char * YYCURSOR;
- char * YYMARKER;
- Warn::option_t option;
+ char * YYCURSOR;
+ char * YYMARKER;
+ Warn::option_t option;
#line 29 "../src/conf/parse_opts.re"
opt:
- if (!next (YYCURSOR, argv))
- {
- goto end;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ goto end;
+ }
#line 35 "src/conf/parse_opts.cc"
{
++YYCURSOR;
#line 38 "../src/conf/parse_opts.re"
{
- error ("bad option: %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad option: %s", *argv);
+ return EXIT_FAIL;
+ }
#line 84 "src/conf/parse_opts.cc"
yy4:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 44 "../src/conf/parse_opts.re"
{
- // all remaining arguments are non-options
- // so they must be input files
- // re2c expects exactly one input file
- for (char * f; next (f, argv);)
- {
- if (!opts.source (f))
- {
- return EXIT_FAIL;
- }
- }
- goto end;
- }
+ // all remaining arguments are non-options
+ // so they must be input files
+ // re2c expects exactly one input file
+ for (char * f; next (f, argv);)
+ {
+ if (!opts.source (f))
+ {
+ return EXIT_FAIL;
+ }
+ }
+ goto end;
+ }
#line 147 "src/conf/parse_opts.cc"
yy18:
++YYCURSOR;
yy44:
#line 75 "../src/conf/parse_opts.re"
{
- error ("bad warning: %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad warning: %s", *argv);
+ return EXIT_FAIL;
+ }
#line 252 "src/conf/parse_opts.cc"
yy45:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
++YYCURSOR;
#line 92 "../src/conf/parse_opts.re"
{
- error ("bad short option: %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad short option: %s", *argv);
+ return EXIT_FAIL;
+ }
#line 943 "src/conf/parse_opts.cc"
yy206:
++YYCURSOR;
yy261:
#line 130 "../src/conf/parse_opts.re"
{
- error ("bad long option: %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad long option: %s", *argv);
+ return EXIT_FAIL;
+ }
#line 1113 "src/conf/parse_opts.cc"
yy262:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
++YYCURSOR;
#line 183 "../src/conf/parse_opts.re"
{
- error ("bad argument to option -o, --output: %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad argument to option -o, --output: %s", *argv);
+ return EXIT_FAIL;
+ }
#line 2824 "src/conf/parse_opts.cc"
yy700:
yych = (YYCTYPE)*++YYCURSOR;
++YYCURSOR;
#line 193 "../src/conf/parse_opts.re"
{
- error ("bad argument to option -t, --type-header: %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad argument to option -t, --type-header: %s", *argv);
+ return EXIT_FAIL;
+ }
#line 2887 "src/conf/parse_opts.cc"
yy708:
yych = (YYCTYPE)*++YYCURSOR;
opt_encoding_policy:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--encoding-policy");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--encoding-policy");
+ return EXIT_FAIL;
+ }
#line 2908 "src/conf/parse_opts.cc"
{
yy715:
#line 208 "../src/conf/parse_opts.re"
{
- error ("bad argument to option --encoding-policy (expected: ignore | substitute | fail): %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad argument to option --encoding-policy (expected: ignore | substitute | fail): %s", *argv);
+ return EXIT_FAIL;
+ }
#line 2925 "src/conf/parse_opts.cc"
yy716:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
opt_input:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--input");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--input");
+ return EXIT_FAIL;
+ }
#line 3026 "src/conf/parse_opts.cc"
{
yy746:
#line 225 "../src/conf/parse_opts.re"
{
- error ("bad argument to option --input (expected: default | custom): %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad argument to option --input (expected: default | custom): %s", *argv);
+ return EXIT_FAIL;
+ }
#line 3041 "src/conf/parse_opts.cc"
yy747:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
opt_empty_class:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--empty-class");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--empty-class");
+ return EXIT_FAIL;
+ }
#line 3115 "src/conf/parse_opts.cc"
{
yy768:
#line 241 "../src/conf/parse_opts.re"
{
- error ("bad argument to option --empty-class (expected: match-empty | match-none | error): %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad argument to option --empty-class (expected: match-empty | match-none | error): %s", *argv);
+ return EXIT_FAIL;
+ }
#line 3128 "src/conf/parse_opts.cc"
yy769:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
opt_dfa_minimization:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--minimization");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--minimization");
+ return EXIT_FAIL;
+ }
#line 3238 "src/conf/parse_opts.cc"
{
yy799:
#line 258 "../src/conf/parse_opts.re"
{
- error ("bad argument to option --dfa-minimization (expected: table | moore): %s", *argv);
- return EXIT_FAIL;
- }
+ error ("bad argument to option --dfa-minimization (expected: table | moore): %s", *argv);
+ return EXIT_FAIL;
+ }
#line 3251 "src/conf/parse_opts.cc"
yy800:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
end:
- if (!opts.source_file)
- {
- error ("no source file");
- return EXIT_FAIL;
- }
- globopts.fix();
+ if (!opts.source_file)
+ {
+ error ("no source file");
+ return EXIT_FAIL;
+ }
+ globopts.fix();
- return OK;
+ return OK;
#undef YYCTYPE
}
-/* Generated by re2c 1.1 on Thu Aug 30 22:35:53 2018 */
+/* Generated by re2c 1.1 on Thu Aug 30 23:07:01 2018 */
#line 1 "../src/conf/ver_to_vernum.re"
#include "src/util/c99_stdint.h"
#include <string>
extern YYSTYPE yylval;
-#define YYCTYPE unsigned char
-#define YYCURSOR cur
-#define YYLIMIT lim
-#define YYMARKER mar
-#define YYCTXMARKER ctx
-#define YYFILL(n) { fill (n); }
+#define YYCTYPE unsigned char
+#define YYCURSOR cur
+#define YYLIMIT lim
+#define YYMARKER mar
+#define YYCTXMARKER ctx
+#define YYFILL(n) { fill (n); }
namespace re2c
{
// but re2c makes an implicit assumption that YYCTYPE is unsigned
// when it generates comparisons
/*!re2c
- re2c:yych:conversion = 1;
+ re2c:yych:conversion = 1;
*/
/*!re2c
eoc = "*" "/";
lineinf = lineno (space+ dstring)? eol;
- esc = "\\";
- hex_digit = [0-9a-fA-F];
- esc_hex = esc ("x" hex_digit{2} | [uX] hex_digit{4} | "U" hex_digit{8});
- esc_oct = esc [0-3] [0-7]{2}; // max 1-byte octal value is '\377'
- esc_simple = esc [abfnrtv\\];
+ esc = "\\";
+ hex_digit = [0-9a-fA-F];
+ esc_hex = esc ("x" hex_digit{2} | [uX] hex_digit{4} | "U" hex_digit{8});
+ esc_oct = esc [0-3] [0-7]{2}; // max 1-byte octal value is '\377'
+ esc_simple = esc [abfnrtv\\];
*/
Scanner::ParseMode Scanner::echo(OutputFile &out)
{
- if (eof && cur == eof) // Catch EOF
- {
- return Stop;
- }
+ if (eof && cur == eof) // Catch EOF
+ {
+ return Stop;
+ }
- tok = cur;
+ tok = cur;
echo:
- ptr = cur;
+ ptr = cur;
/*!re2c
- "%{" | "/*!re2c" {
- out.wraw(tok, ptr);
- return Parse;
- }
-
- "/*!rules:re2c" {
- out.wraw(tok, ptr);
- return Rules;
- }
-
- "/*!use:re2c" {
- out.wraw(tok, ptr);
- return Reuse;
- }
-
- "/*!ignore:re2c" {
- out.wraw(tok, ptr);
- lex_end_of_comment(out);
- goto echo;
- }
-
- "/*!max:re2c" {
- out.wraw(tok, ptr);
- out.wdelay_yymaxfill();
- lex_end_of_comment(out);
- goto echo;
- }
-
- "/*!maxnmatch:re2c" {
- out.wraw(tok, ptr);
- out.wdelay_yymaxnmatch();
- lex_end_of_comment(out);
- goto echo;
- }
-
- "/*!getstate:re2c" {
- out.wraw(tok, ptr);
- out.wdelay_state_goto(0);
- lex_end_of_comment(out);
- goto echo;
- }
-
- "/*!types:re2c" {
- out.wraw(tok, ptr);
- out.wdelay_line_info_output();
- out.wdelay_types();
- out.wdelay_line_info_input(cline, get_fname());
- lex_end_of_comment(out);
- goto echo;
- }
-
- "/*!stags:re2c" {
- out.wraw(tok, ptr);
- lex_tags(out, false);
- goto echo;
- }
-
- "/*!mtags:re2c" {
- out.wraw(tok, ptr);
- lex_tags(out, true);
- goto echo;
- }
-
- eof {
- if (cur != eof) goto echo;
- out.wraw(tok, ptr);
- return Stop;
- }
-
- eol space* "#" space* "line" space+ / lineinf {
- out.wraw(tok, ptr + 1);
- set_sourceline();
- goto echo;
- }
-
- eol {
- cline++;
- pos = cur;
- goto echo;
- }
-
- * { goto echo; }
+ "%{" | "/*!re2c" {
+ out.wraw(tok, ptr);
+ return Parse;
+ }
+
+ "/*!rules:re2c" {
+ out.wraw(tok, ptr);
+ return Rules;
+ }
+
+ "/*!use:re2c" {
+ out.wraw(tok, ptr);
+ return Reuse;
+ }
+
+ "/*!ignore:re2c" {
+ out.wraw(tok, ptr);
+ lex_end_of_comment(out);
+ goto echo;
+ }
+
+ "/*!max:re2c" {
+ out.wraw(tok, ptr);
+ out.wdelay_yymaxfill();
+ lex_end_of_comment(out);
+ goto echo;
+ }
+
+ "/*!maxnmatch:re2c" {
+ out.wraw(tok, ptr);
+ out.wdelay_yymaxnmatch();
+ lex_end_of_comment(out);
+ goto echo;
+ }
+
+ "/*!getstate:re2c" {
+ out.wraw(tok, ptr);
+ out.wdelay_state_goto(0);
+ lex_end_of_comment(out);
+ goto echo;
+ }
+
+ "/*!types:re2c" {
+ out.wraw(tok, ptr);
+ out.wdelay_line_info_output();
+ out.wdelay_types();
+ out.wdelay_line_info_input(cline, get_fname());
+ lex_end_of_comment(out);
+ goto echo;
+ }
+
+ "/*!stags:re2c" {
+ out.wraw(tok, ptr);
+ lex_tags(out, false);
+ goto echo;
+ }
+
+ "/*!mtags:re2c" {
+ out.wraw(tok, ptr);
+ lex_tags(out, true);
+ goto echo;
+ }
+
+ eof {
+ if (cur != eof) goto echo;
+ out.wraw(tok, ptr);
+ return Stop;
+ }
+
+ eol space* "#" space* "line" space+ / lineinf {
+ out.wraw(tok, ptr + 1);
+ set_sourceline();
+ goto echo;
+ }
+
+ eol {
+ cline++;
+ pos = cur;
+ goto echo;
+ }
+
+ * { goto echo; }
*/
}
void Scanner::lex_end_of_comment(OutputFile &out)
{
- uint32_t ignored = 0;
- for (;;) {/*!re2c
- eof { fatal_lc(get_cline(), get_column(), "expected end of block"); }
-
- * { continue; }
- eol { ++ignored; continue; }
- eoc {
- if (ignored > 0) {
- cline += ignored;
- out.wdelay_line_info_input(cline, get_fname());
- }
- tok = pos = cur;
- return;
- }
- */}
+ uint32_t ignored = 0;
+ for (;;) {/*!re2c
+ eof { fatal_lc(get_cline(), get_column(), "expected end of block"); }
+
+ * { continue; }
+ eol { ++ignored; continue; }
+ eoc {
+ if (ignored > 0) {
+ cline += ignored;
+ out.wdelay_line_info_input(cline, get_fname());
+ }
+ tok = pos = cur;
+ return;
+ }
+ */}
}
void Scanner::lex_tags(OutputFile &out, bool mtags)
{
- std::string fmt, sep;
- for (;;) {/*!re2c
- * { fatal_lc(get_cline(), get_column(), "unrecognized configuration"); }
-
- "format" { fmt = lex_conf_string(); continue; }
- "separator" { sep = lex_conf_string(); continue; }
-
- space+ { continue; }
- eol { ++cline; continue; }
- eoc {
- out.wdelay_tags(new ConfTags(fmt, sep), mtags);
- tok = pos = cur;
- return;
- }
- */}
+ std::string fmt, sep;
+ for (;;) {/*!re2c
+ * { fatal_lc(get_cline(), get_column(), "unrecognized configuration"); }
+
+ "format" { fmt = lex_conf_string(); continue; }
+ "separator" { sep = lex_conf_string(); continue; }
+
+ space+ { continue; }
+ eol { ++cline; continue; }
+ eoc {
+ out.wdelay_tags(new ConfTags(fmt, sep), mtags);
+ tok = pos = cur;
+ return;
+ }
+ */}
}
int Scanner::scan(const conopt_t *globopts)
{
- uint32_t depth, code_line;
+ uint32_t depth, code_line;
scan:
- tchar = cur - pos;
- tok = cur;
+ tchar = cur - pos;
+ tok = cur;
/*!re2c
- "{" {
- depth = 1;
- code_line = cline;
- goto code;
- }
-
- ":" / "=>" {
- return *tok;
- }
-
- ":=" {
- tok += 2; /* skip ":=" */
- depth = 0;
- code_line = cline;
- goto code;
- }
+ "{" {
+ depth = 1;
+ code_line = cline;
+ goto code;
+ }
+
+ ":" / "=>" {
+ return *tok;
+ }
+
+ ":=" {
+ tok += 2; /* skip ":=" */
+ depth = 0;
+ code_line = cline;
+ goto code;
+ }
"//" {
- goto nextLine;
- }
- "/*" {
- depth = 1;
- goto comment;
- }
+ goto nextLine;
+ }
+ "/*" {
+ depth = 1;
+ goto comment;
+ }
endRE = "%}" | "*/";
endRE {
- tok = cur;
- return 0;
- }
-
- "'" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; }
- "\"" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; }
- "[" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; }
- "[^" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; }
-
- [@#] name {
- const std::string *name = new std::string(tok + 1, tok_len() - 1);
- yylval.regexp = ast_tag(cline, get_column(), name, tok[0] == '#');
- return TOKEN_REGEXP;
- }
-
- [*+?<>!,()|=;/\\] { return *tok; }
-
- "{" [0-9]+ "}" {
- if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min))
- {
- fatal_lc(get_cline(), get_column(), "repetition count overflow");
- }
- yylval.bounds.max = yylval.bounds.min;
- return TOKEN_CLOSESIZE;
- }
-
- "{" [0-9]+ "," [0-9]+ "}" {
- const char * p = strchr (tok, ',');
- if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min))
- {
- fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
- }
- if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max))
- {
- fatal_lc(get_cline(), get_column(), "repetition upper bound overflow");
- }
- return TOKEN_CLOSESIZE;
- }
-
- "{" [0-9]+ ",}" {
- if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min))
- {
- fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
- }
- yylval.bounds.max = std::numeric_limits<uint32_t>::max();
- return TOKEN_CLOSESIZE;
- }
-
- "{" [0-9]* "," {
- fatal_lc(get_cline(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers");
- }
-
- "{" name "}" {
- if (!globopts->FFlag) {
- fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch");
- }
- yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
- return TOKEN_ID;
- }
-
- "re2c:" { return TOKEN_CONF; }
-
- name / (space+ [^=>,]) {
- yylval.str = new std::string (tok, tok_len ());
- if (globopts->FFlag)
- {
- lexer_state = LEX_FLEX_NAME;
- return TOKEN_FID;
- }
- else
- {
- return TOKEN_ID;
- }
- }
-
- name / (space* [=>,]) {
- yylval.str = new std::string (tok, tok_len ());
- return TOKEN_ID;
- }
-
- name / [^] {
- if (!globopts->FFlag) {
- yylval.str = new std::string (tok, tok_len());
- return TOKEN_ID;
- } else {
- std::vector<ASTChar> *str = new std::vector<ASTChar>;
- for (char *s = tok; s < cur; ++s) {
- const uint32_t
- chr = static_cast<uint8_t>(*s),
- col = static_cast<uint32_t>(s - tok);
- str->push_back(ASTChar(chr, col));
- }
- yylval.regexp = ast_str(cline, get_column(), str, false);
- return TOKEN_REGEXP;
- }
- }
-
- "." {
- yylval.regexp = ast_dot(cline, get_column());
- return TOKEN_REGEXP;
- }
-
- space+ {
- goto scan;
- }
-
- eol space* "#" space* "line" space+ / lineinf {
- set_sourceline ();
- return TOKEN_LINE_INFO;
- }
-
- eol {
- if (cur == eof) return 0;
- pos = cur;
- cline++;
- if (lexer_state == LEX_FLEX_NAME) {
- lexer_state = LEX_NORMAL;
- return TOKEN_FID_END;
- } else {
- goto scan;
- }
- }
-
- * {
- fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok);
- goto scan;
- }
+ tok = cur;
+ return 0;
+ }
+
+ "'" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; }
+ "\"" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; }
+ "[" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; }
+ "[^" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; }
+
+ [@#] name {
+ const std::string *name = new std::string(tok + 1, tok_len() - 1);
+ yylval.regexp = ast_tag(cline, get_column(), name, tok[0] == '#');
+ return TOKEN_REGEXP;
+ }
+
+ [*+?<>!,()|=;/\\] { return *tok; }
+
+ "{" [0-9]+ "}" {
+ if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition count overflow");
+ }
+ yylval.bounds.max = yylval.bounds.min;
+ return TOKEN_CLOSESIZE;
+ }
+
+ "{" [0-9]+ "," [0-9]+ "}" {
+ const char * p = strchr (tok, ',');
+ if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
+ }
+ if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition upper bound overflow");
+ }
+ return TOKEN_CLOSESIZE;
+ }
+
+ "{" [0-9]+ ",}" {
+ if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min))
+ {
+ fatal_lc(get_cline(), get_column(), "repetition lower bound overflow");
+ }
+ yylval.bounds.max = std::numeric_limits<uint32_t>::max();
+ return TOKEN_CLOSESIZE;
+ }
+
+ "{" [0-9]* "," {
+ fatal_lc(get_cline(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers");
+ }
+
+ "{" name "}" {
+ if (!globopts->FFlag) {
+ fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch");
+ }
+ yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
+ return TOKEN_ID;
+ }
+
+ "re2c:" { return TOKEN_CONF; }
+
+ name / (space+ [^=>,]) {
+ yylval.str = new std::string (tok, tok_len ());
+ if (globopts->FFlag)
+ {
+ lexer_state = LEX_FLEX_NAME;
+ return TOKEN_FID;
+ }
+ else
+ {
+ return TOKEN_ID;
+ }
+ }
+
+ name / (space* [=>,]) {
+ yylval.str = new std::string (tok, tok_len ());
+ return TOKEN_ID;
+ }
+
+ name / [^] {
+ if (!globopts->FFlag) {
+ yylval.str = new std::string (tok, tok_len());
+ return TOKEN_ID;
+ } else {
+ std::vector<ASTChar> *str = new std::vector<ASTChar>;
+ for (char *s = tok; s < cur; ++s) {
+ const uint32_t
+ chr = static_cast<uint8_t>(*s),
+ col = static_cast<uint32_t>(s - tok);
+ str->push_back(ASTChar(chr, col));
+ }
+ yylval.regexp = ast_str(cline, get_column(), str, false);
+ return TOKEN_REGEXP;
+ }
+ }
+
+ "." {
+ yylval.regexp = ast_dot(cline, get_column());
+ return TOKEN_REGEXP;
+ }
+
+ space+ {
+ goto scan;
+ }
+
+ eol space* "#" space* "line" space+ / lineinf {
+ set_sourceline ();
+ return TOKEN_LINE_INFO;
+ }
+
+ eol {
+ if (cur == eof) return 0;
+ pos = cur;
+ cline++;
+ if (lexer_state == LEX_FLEX_NAME) {
+ lexer_state = LEX_NORMAL;
+ return TOKEN_FID_END;
+ } else {
+ goto scan;
+ }
+ }
+
+ * {
+ fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok);
+ goto scan;
+ }
*/
code:
/*!re2c
- "}" {
- if (depth == 0)
- {
- fatal_l(get_cline(), "Curly braces are not allowed after ':='");
- }
- else if (--depth == 0)
- {
- yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
- return TOKEN_CODE;
- }
- goto code;
- }
- "{" {
- if (depth == 0)
- {
- fatal_l(get_cline(), "Curly braces are not allowed after ':='");
- }
- else
- {
- ++depth;
- }
- goto code;
- }
- "\n" space* "#" space* "line" space+ / lineinf {
- set_sourceline ();
- goto code;
- }
- "\n" / ws {
- if (depth == 0)
- {
- goto code;
- }
- else if (cur == eof)
- {
- fatal_l(get_cline(), "missing '}'");
- }
- pos = cur;
- cline++;
- goto code;
- }
- "\n" {
- if (depth == 0)
- {
- tok += strspn(tok, " \t\r\n");
- while (cur > tok && strchr(" \t\r\n", cur[-1]))
- {
- --cur;
- }
- yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
- return TOKEN_CODE;
- }
- else if (cur == eof)
- {
- fatal_l(get_cline(), "missing '}'");
- }
- pos = cur;
- cline++;
- goto code;
- }
- eof {
- if (cur == eof)
- {
- if (depth)
- {
- fatal_l(get_cline(), "missing '}'");
- }
- return 0;
- }
- goto code;
- }
- dstring | sstring {
- goto code;
- }
- * {
- goto code;
- }
+ "}" {
+ if (depth == 0)
+ {
+ fatal_l(get_cline(), "Curly braces are not allowed after ':='");
+ }
+ else if (--depth == 0)
+ {
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
+ return TOKEN_CODE;
+ }
+ goto code;
+ }
+ "{" {
+ if (depth == 0)
+ {
+ fatal_l(get_cline(), "Curly braces are not allowed after ':='");
+ }
+ else
+ {
+ ++depth;
+ }
+ goto code;
+ }
+ "\n" space* "#" space* "line" space+ / lineinf {
+ set_sourceline ();
+ goto code;
+ }
+ "\n" / ws {
+ if (depth == 0)
+ {
+ goto code;
+ }
+ else if (cur == eof)
+ {
+ fatal_l(get_cline(), "missing '}'");
+ }
+ pos = cur;
+ cline++;
+ goto code;
+ }
+ "\n" {
+ if (depth == 0)
+ {
+ tok += strspn(tok, " \t\r\n");
+ while (cur > tok && strchr(" \t\r\n", cur[-1]))
+ {
+ --cur;
+ }
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
+ return TOKEN_CODE;
+ }
+ else if (cur == eof)
+ {
+ fatal_l(get_cline(), "missing '}'");
+ }
+ pos = cur;
+ cline++;
+ goto code;
+ }
+ eof {
+ if (cur == eof)
+ {
+ if (depth)
+ {
+ fatal_l(get_cline(), "missing '}'");
+ }
+ return 0;
+ }
+ goto code;
+ }
+ dstring | sstring {
+ goto code;
+ }
+ * {
+ goto code;
+ }
*/
comment:
/*!re2c
- "*" "/" {
- if (--depth == 0)
- {
- goto scan;
- }
- else
- {
- goto comment;
- }
- }
- "/" "*" {
- ++depth;
- fatal_lc(get_cline(), get_column(), "ambiguous /* found");
- goto comment;
- }
- "\n" space* "#" space* "line" space+ / lineinf {
- set_sourceline ();
- goto comment;
- }
- "\n" {
- if (cur == eof)
- {
- return 0;
- }
- tok = pos = cur;
- cline++;
- goto comment;
- }
- * {
- if (cur == eof)
- {
- return 0;
- }
- goto comment;
- }
+ "*" "/" {
+ if (--depth == 0)
+ {
+ goto scan;
+ }
+ else
+ {
+ goto comment;
+ }
+ }
+ "/" "*" {
+ ++depth;
+ fatal_lc(get_cline(), get_column(), "ambiguous /* found");
+ goto comment;
+ }
+ "\n" space* "#" space* "line" space+ / lineinf {
+ set_sourceline ();
+ goto comment;
+ }
+ "\n" {
+ if (cur == eof)
+ {
+ return 0;
+ }
+ tok = pos = cur;
+ cline++;
+ goto comment;
+ }
+ * {
+ if (cur == eof)
+ {
+ return 0;
+ }
+ goto comment;
+ }
*/
nextLine:
const AST *Scanner::lex_cls(bool neg)
{
- std::vector<ASTRange> *cls = new std::vector<ASTRange>;
- uint32_t u, l, c, c0 = get_column();
+ std::vector<ASTRange> *cls = new std::vector<ASTRange>;
+ uint32_t u, l, c, c0 = get_column();
fst:
- tok = cur;
- c = get_column();
- /*!re2c
- "]" { return ast_cls(cline, c0, cls, neg); }
- "" { l = lex_cls_chr(); goto snd; }
- */
+ tok = cur;
+ c = get_column();
+ /*!re2c
+ "]" { return ast_cls(cline, c0, cls, neg); }
+ "" { l = lex_cls_chr(); goto snd; }
+ */
snd:
- /*!re2c
- "" { u = l; goto add; }
- "-" / [^\]] {
- u = lex_cls_chr();
- if (l > u) {
- warn.swapped_range(cline, l, u);
- std::swap(l, u);
- }
- goto add;
- }
- */
+ /*!re2c
+ "" { u = l; goto add; }
+ "-" / [^\]] {
+ u = lex_cls_chr();
+ if (l > u) {
+ warn.swapped_range(cline, l, u);
+ std::swap(l, u);
+ }
+ goto add;
+ }
+ */
add:
- cls->push_back(ASTRange(l, u, c));
- goto fst;
+ cls->push_back(ASTRange(l, u, c));
+ goto fst;
}
uint32_t Scanner::lex_cls_chr()
{
- tok = cur;
- const uint32_t l = get_cline(), c = get_column();
- /*!re2c
- * { fatal_lc(l, c, "syntax error"); }
- esc? eol { fatal_lc(l, c, "newline in character class"); }
- esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); }
- esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); }
- esc { fatal_lc(l, c, "syntax error in escape sequence"); }
-
- . \ esc { return static_cast<uint8_t>(tok[0]); }
- esc_hex { return unesc_hex(tok, cur); }
- esc_oct { return unesc_oct(tok, cur); }
- esc "a" { return static_cast<uint8_t>('\a'); }
- esc "b" { return static_cast<uint8_t>('\b'); }
- esc "f" { return static_cast<uint8_t>('\f'); }
- esc "n" { return static_cast<uint8_t>('\n'); }
- esc "r" { return static_cast<uint8_t>('\r'); }
- esc "t" { return static_cast<uint8_t>('\t'); }
- esc "v" { return static_cast<uint8_t>('\v'); }
- esc "\\" { return static_cast<uint8_t>('\\'); }
- esc "-" { return static_cast<uint8_t>('-'); }
- esc "]" { return static_cast<uint8_t>(']'); }
- esc . {
- warn.useless_escape(cline, get_column(), tok[1]);
- return static_cast<uint8_t>(tok[1]);
- }
- */
+ tok = cur;
+ const uint32_t l = get_cline(), c = get_column();
+ /*!re2c
+ * { fatal_lc(l, c, "syntax error"); }
+ esc? eol { fatal_lc(l, c, "newline in character class"); }
+ esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); }
+ esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); }
+ esc { fatal_lc(l, c, "syntax error in escape sequence"); }
+
+ . \ esc { return static_cast<uint8_t>(tok[0]); }
+ esc_hex { return unesc_hex(tok, cur); }
+ esc_oct { return unesc_oct(tok, cur); }
+ esc "a" { return static_cast<uint8_t>('\a'); }
+ esc "b" { return static_cast<uint8_t>('\b'); }
+ esc "f" { return static_cast<uint8_t>('\f'); }
+ esc "n" { return static_cast<uint8_t>('\n'); }
+ esc "r" { return static_cast<uint8_t>('\r'); }
+ esc "t" { return static_cast<uint8_t>('\t'); }
+ esc "v" { return static_cast<uint8_t>('\v'); }
+ esc "\\" { return static_cast<uint8_t>('\\'); }
+ esc "-" { return static_cast<uint8_t>('-'); }
+ esc "]" { return static_cast<uint8_t>(']'); }
+ esc . {
+ warn.useless_escape(cline, get_column(), tok[1]);
+ return static_cast<uint8_t>(tok[1]);
+ }
+ */
}
uint32_t Scanner::lex_str_chr(char quote, bool &end)
{
- end = false;
- tok = cur;
- const uint32_t l = get_cline(), c = get_column();
- /*!re2c
- * { fatal_lc(l, c, "syntax error"); }
- esc? eol { fatal_lc(l, c, "newline in character string"); }
- esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); }
- esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); }
- esc { fatal_lc(l, c, "syntax error in escape sequence"); }
-
- . \ esc {
- end = tok[0] == quote;
- return static_cast<uint8_t>(tok[0]);
- }
- esc_hex { return unesc_hex(tok, cur); }
- esc_oct { return unesc_oct(tok, cur); }
- esc "a" { return static_cast<uint8_t>('\a'); }
- esc "b" { return static_cast<uint8_t>('\b'); }
- esc "f" { return static_cast<uint8_t>('\f'); }
- esc "n" { return static_cast<uint8_t>('\n'); }
- esc "r" { return static_cast<uint8_t>('\r'); }
- esc "t" { return static_cast<uint8_t>('\t'); }
- esc "v" { return static_cast<uint8_t>('\v'); }
- esc "\\" { return static_cast<uint8_t>('\\'); }
- esc . {
- if (tok[1] != quote) {
- warn.useless_escape(cline, get_column(), tok[1]);
- }
- return static_cast<uint8_t>(tok[1]);
- }
- */
+ end = false;
+ tok = cur;
+ const uint32_t l = get_cline(), c = get_column();
+ /*!re2c
+ * { fatal_lc(l, c, "syntax error"); }
+ esc? eol { fatal_lc(l, c, "newline in character string"); }
+ esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); }
+ esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); }
+ esc { fatal_lc(l, c, "syntax error in escape sequence"); }
+
+ . \ esc {
+ end = tok[0] == quote;
+ return static_cast<uint8_t>(tok[0]);
+ }
+ esc_hex { return unesc_hex(tok, cur); }
+ esc_oct { return unesc_oct(tok, cur); }
+ esc "a" { return static_cast<uint8_t>('\a'); }
+ esc "b" { return static_cast<uint8_t>('\b'); }
+ esc "f" { return static_cast<uint8_t>('\f'); }
+ esc "n" { return static_cast<uint8_t>('\n'); }
+ esc "r" { return static_cast<uint8_t>('\r'); }
+ esc "t" { return static_cast<uint8_t>('\t'); }
+ esc "v" { return static_cast<uint8_t>('\v'); }
+ esc "\\" { return static_cast<uint8_t>('\\'); }
+ esc . {
+ if (tok[1] != quote) {
+ warn.useless_escape(cline, get_column(), tok[1]);
+ }
+ return static_cast<uint8_t>(tok[1]);
+ }
+ */
}
const AST *Scanner::lex_str(char quote)
{
- const uint32_t column = get_column();
- std::vector<ASTChar> *str = new std::vector<ASTChar>;
- for (bool end;;) {
- const uint32_t c = lex_str_chr(quote, end);
- if (end) return ast_str(cline, column, str, quote == '\'');
- str->push_back(ASTChar(c, get_column()));
- }
+ const uint32_t column = get_column();
+ std::vector<ASTChar> *str = new std::vector<ASTChar>;
+ for (bool end;;) {
+ const uint32_t c = lex_str_chr(quote, end);
+ if (end) return ast_str(cline, column, str, quote == '\'');
+ str->push_back(ASTChar(c, get_column()));
+ }
}
void Scanner::set_sourceline ()
{
sourceline:
- tok = cur;
-/*!re2c
- lineno {
- if (!s_to_u32_unsafe (tok, cur, cline)) {
- fatal_lc(get_cline(), get_column(), "line number overflow");
- }
- goto sourceline;
- }
-
- dstring {
- in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // strip quotes
- strrreplace (in.escaped_file_name, "\\", "\\\\");
- goto sourceline;
- }
-
- eol {
- tok = cur;
- return;
- }
-
- eof {
- --cur;
- tok = cur;
- return;
- }
-
- * { goto sourceline; }
+ tok = cur;
+/*!re2c
+ lineno {
+ if (!s_to_u32_unsafe (tok, cur, cline)) {
+ fatal_lc(get_cline(), get_column(), "line number overflow");
+ }
+ goto sourceline;
+ }
+
+ dstring {
+ in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // strip quotes
+ strrreplace (in.escaped_file_name, "\\", "\\\\");
+ goto sourceline;
+ }
+
+ eol {
+ tok = cur;
+ return;
+ }
+
+ eof {
+ --cur;
+ tok = cur;
+ return;
+ }
+
+ * { goto sourceline; }
*/
}
// global re2c config (affects the whole file)
/*!re2c
- re2c:define:YYCTYPE = "unsigned char";
- re2c:define:YYCURSOR = cur;
- re2c:define:YYLIMIT = lim;
- re2c:define:YYMARKER = mar;
- re2c:define:YYCTXMARKER = ctx;
- re2c:define:YYFILL = fill;
+ re2c:define:YYCTYPE = "unsigned char";
+ re2c:define:YYCURSOR = cur;
+ re2c:define:YYLIMIT = lim;
+ re2c:define:YYMARKER = mar;
+ re2c:define:YYCTXMARKER = ctx;
+ re2c:define:YYFILL = fill;
- // source code is in ASCII: pointers have type 'char *'
- // but re2c makes an implicit assumption that YYCTYPE is unsigned
- // when it generates comparisons
- re2c:yych:conversion = 1;
+ // source code is in ASCII: pointers have type 'char *'
+ // but re2c makes an implicit assumption that YYCTYPE is unsigned
+ // when it generates comparisons
+ re2c:yych:conversion = 1;
- space = [ \t];
+ space = [ \t];
- conf_assign = space* "=" space*;
+ conf_assign = space* "=" space*;
- naked_char = . \ (space | [;]);
- naked = (naked_char \ ['"]) naked_char*;
+ naked_char = . \ (space | [;]);
+ naked = (naked_char \ ['"]) naked_char*;
- number = "0" | ("-"? [1-9] [0-9]*);
+ number = "0" | ("-"? [1-9] [0-9]*);
*/
void Scanner::lex_conf(Opt &opts)
{
- tok = cur;
- const uint32_t l = get_cline(), c = get_column();
+ tok = cur;
+ const uint32_t l = get_cline(), c = get_column();
/*!re2c
- "flags:" ("b" | "bit-vectors") { opts.set_bFlag(lex_conf_bool()); return; }
- "flags:" ("d" | "debug-output") { opts.set_dFlag(lex_conf_bool()); return; }
- "flags:" ("g" | "computed-gotos") { opts.set_gFlag(lex_conf_bool()); return; }
- "flags:" ("i" | "no-debug-info") { opts.set_iFlag(lex_conf_bool()); return; }
- "flags:" ("s" | "nested-ifs") { opts.set_sFlag(lex_conf_bool()); return; }
- "flags:" ("T" | "tags") { opts.set_tags(lex_conf_bool()); return; }
- "flags:" ("P" | "posix-captures") { opts.set_posix_captures(lex_conf_bool()); return; }
- "flags:case-insensitive" { opts.set_bCaseInsensitive(lex_conf_bool()); return; }
- "flags:case-inverted" { opts.set_bCaseInverted(lex_conf_bool()); return; }
- "flags:lookahead" { opts.set_lookahead(lex_conf_bool()); return; }
- "flags:optimize-tags" { opts.set_optimize_tags(lex_conf_bool()); return; }
- "flags:eager-skip" { opts.set_eager_skip(lex_conf_bool()); return; }
-
- "flags:" ("e" | "ecb") { lex_conf_enc(Enc::EBCDIC, opts); return; }
- "flags:" ("u" | "unicode") { lex_conf_enc(Enc::UTF32, opts); return; }
- "flags:" ("w" | "wide-chars") { lex_conf_enc(Enc::UCS2, opts); return; }
- "flags:" ("x" | "utf-16") { lex_conf_enc(Enc::UTF16, opts); return; }
- "flags:" ("8" | "utf-8") { lex_conf_enc(Enc::UTF8, opts); return; }
-
- "flags:encoding-policy" { lex_conf_encoding_policy(opts); return; }
- "flags:input" { lex_conf_input(opts); return; }
- "flags:empty-class" { lex_conf_empty_class(opts); return; }
- "flags:dfa-minimization" { lex_conf_dfa_minimization(opts); return; }
-
- "define:YYCONDTYPE" { opts.set_yycondtype (lex_conf_string ()); return; }
- "define:YYGETCONDITION" { opts.set_cond_get (lex_conf_string ()); return; }
- "define:YYGETCONDITION:naked" { opts.set_cond_get_naked (lex_conf_bool()); return; }
- "define:YYSETCONDITION" { opts.set_cond_set (lex_conf_string ()); return; }
- "define:YYSETCONDITION@cond" { opts.set_cond_set_arg (lex_conf_string ()); return; }
- "define:YYSETCONDITION:naked" { opts.set_cond_set_naked (lex_conf_bool()); return; }
- "condprefix" { opts.set_condPrefix (lex_conf_string ()); return; }
- "condenumprefix" { opts.set_condEnumPrefix (lex_conf_string ()); return; }
- "cond:divider" { opts.set_condDivider (lex_conf_string ()); return; }
- "cond:divider@cond" { opts.set_condDividerParam (lex_conf_string ()); return; }
- "cond:goto" { opts.set_condGoto (lex_conf_string ()); return; }
- "cond:goto@cond" { opts.set_condGotoParam (lex_conf_string ()); return; }
- "variable:yyctable" { opts.set_yyctable (lex_conf_string ()); return; }
-
- "define:YYGETSTATE" { opts.set_state_get (lex_conf_string ()); return; }
- "define:YYGETSTATE:naked" { opts.set_state_get_naked (lex_conf_bool()); return; }
- "define:YYSETSTATE" { opts.set_state_set (lex_conf_string ()); return; }
- "define:YYSETSTATE:naked" { opts.set_state_set_naked (lex_conf_bool()); return; }
- "define:YYSETSTATE@state" { opts.set_state_set_arg (lex_conf_string ()); return; }
- "label:yyFillLabel" { opts.set_yyfilllabel (lex_conf_string ()); return; }
- "label:yyNext" { opts.set_yynext (lex_conf_string ()); return; }
- "state:abort" { opts.set_bUseStateAbort (lex_conf_bool()); return; }
- "state:nextlabel" { opts.set_bUseStateNext (lex_conf_bool()); return; }
- "variable:yyaccept" { opts.set_yyaccept (lex_conf_string ()); return; }
-
- "variable:yybm" { opts.set_yybm (lex_conf_string ()); return; }
- "yybm:hex" { opts.set_yybmHexTable (lex_conf_bool()); return; }
- "cgoto:threshold"
- {
- const int32_t n = lex_conf_number ();
- if (n < 0)
- {
- fatal_lc(l, c, "configuration 'cgoto:threshold' must be nonnegative");
- }
- opts.set_cGotoThreshold (static_cast<uint32_t> (n));
- return;
- }
- "variable:yytarget" { opts.set_yytarget (lex_conf_string ()); return; }
-
- "define:YYCURSOR" { opts.set_yycursor (lex_conf_string ()); return; }
- "define:YYMARKER" { opts.set_yymarker (lex_conf_string ()); return; }
- "define:YYCTXMARKER" { opts.set_yyctxmarker (lex_conf_string ()); return; }
- "define:YYLIMIT" { opts.set_yylimit (lex_conf_string ()); return; }
-
- "define:YYPEEK" { opts.set_yypeek (lex_conf_string ()); return; }
- "define:YYSKIP" { opts.set_yyskip (lex_conf_string ()); return; }
- "define:YYBACKUP" { opts.set_yybackup (lex_conf_string ()); return; }
- "define:YYBACKUPCTX" { opts.set_yybackupctx (lex_conf_string ()); return; }
- "define:YYRESTORE" { opts.set_yyrestore (lex_conf_string ()); return; }
- "define:YYRESTORECTX" { opts.set_yyrestorectx (lex_conf_string ()); return; }
- "define:YYRESTORETAG" { opts.set_yyrestoretag (lex_conf_string ()); return; }
- "define:YYLESSTHAN" { opts.set_yylessthan (lex_conf_string ()); return; }
- "define:YYSTAGN" { opts.set_yystagn (lex_conf_string ()); return; }
- "define:YYSTAGP" { opts.set_yystagp (lex_conf_string ()); return; }
- "define:YYMTAGN" { opts.set_yymtagn (lex_conf_string ()); return; }
- "define:YYMTAGP" { opts.set_yymtagp (lex_conf_string ()); return; }
-
- "tags:prefix" { opts.set_tags_prefix (lex_conf_string ()); return; }
- "tags:expression" { opts.set_tags_expression(lex_conf_string ()); return; }
-
- "indent:string" { opts.set_indString (lex_conf_string ()); return; }
- "indent:top"
- {
- const int32_t n = lex_conf_number ();
- if (n < 0)
- {
- fatal_lc(l, c, "configuration 'indent:top' must be nonnegative");
- }
- opts.set_topIndent (static_cast<uint32_t> (n));
- return;
- }
-
- "define:YYDEBUG" { opts.set_yydebug (lex_conf_string ()); return; }
-
- "define:YYCTYPE" { opts.set_yyctype (lex_conf_string ()); return; }
- "variable:yych" { opts.set_yych (lex_conf_string ()); return; }
- "yych:conversion" { opts.set_yychConversion (lex_conf_bool()); return; }
- "yych:emit" { opts.set_bEmitYYCh (lex_conf_bool()); return; }
-
- "define:YYFILL" { opts.set_fill (lex_conf_string ()); return; }
- "yyfill:enable" { opts.set_fill_use (lex_conf_bool()); return; }
- "define:YYFILL@len" { opts.set_fill_arg (lex_conf_string ()); return; }
- "yyfill:parameter" { opts.set_fill_arg_use (lex_conf_bool()); return; }
- "define:YYFILL:naked" { opts.set_fill_naked (lex_conf_bool()); return; }
- "yyfill:check" { opts.set_fill_check (lex_conf_bool()); return; }
-
- "labelprefix" { opts.set_labelPrefix (lex_conf_string ()); return; }
-
- // try to lex number first, otherwize it would be lexed as a naked string
- "startlabel" / conf_assign number { opts.set_startlabel_force (lex_conf_bool()); return; }
- "startlabel" { opts.set_startlabel (lex_conf_string()); return; }
-
- // deprecated
- "variable:yystable" { lex_conf_string (); return; }
-
- [a-zA-Z0-9_:-]* {
- fatal_lc(l, c, "unrecognized configuration '%.*s'",
- static_cast<int>(cur - tok), tok);
- }
+ "flags:" ("b" | "bit-vectors") { opts.set_bFlag(lex_conf_bool()); return; }
+ "flags:" ("d" | "debug-output") { opts.set_dFlag(lex_conf_bool()); return; }
+ "flags:" ("g" | "computed-gotos") { opts.set_gFlag(lex_conf_bool()); return; }
+ "flags:" ("i" | "no-debug-info") { opts.set_iFlag(lex_conf_bool()); return; }
+ "flags:" ("s" | "nested-ifs") { opts.set_sFlag(lex_conf_bool()); return; }
+ "flags:" ("T" | "tags") { opts.set_tags(lex_conf_bool()); return; }
+ "flags:" ("P" | "posix-captures") { opts.set_posix_captures(lex_conf_bool()); return; }
+ "flags:case-insensitive" { opts.set_bCaseInsensitive(lex_conf_bool()); return; }
+ "flags:case-inverted" { opts.set_bCaseInverted(lex_conf_bool()); return; }
+ "flags:lookahead" { opts.set_lookahead(lex_conf_bool()); return; }
+ "flags:optimize-tags" { opts.set_optimize_tags(lex_conf_bool()); return; }
+ "flags:eager-skip" { opts.set_eager_skip(lex_conf_bool()); return; }
+
+ "flags:" ("e" | "ecb") { lex_conf_enc(Enc::EBCDIC, opts); return; }
+ "flags:" ("u" | "unicode") { lex_conf_enc(Enc::UTF32, opts); return; }
+ "flags:" ("w" | "wide-chars") { lex_conf_enc(Enc::UCS2, opts); return; }
+ "flags:" ("x" | "utf-16") { lex_conf_enc(Enc::UTF16, opts); return; }
+ "flags:" ("8" | "utf-8") { lex_conf_enc(Enc::UTF8, opts); return; }
+
+ "flags:encoding-policy" { lex_conf_encoding_policy(opts); return; }
+ "flags:input" { lex_conf_input(opts); return; }
+ "flags:empty-class" { lex_conf_empty_class(opts); return; }
+ "flags:dfa-minimization" { lex_conf_dfa_minimization(opts); return; }
+
+ "define:YYCONDTYPE" { opts.set_yycondtype (lex_conf_string ()); return; }
+ "define:YYGETCONDITION" { opts.set_cond_get (lex_conf_string ()); return; }
+ "define:YYGETCONDITION:naked" { opts.set_cond_get_naked (lex_conf_bool()); return; }
+ "define:YYSETCONDITION" { opts.set_cond_set (lex_conf_string ()); return; }
+ "define:YYSETCONDITION@cond" { opts.set_cond_set_arg (lex_conf_string ()); return; }
+ "define:YYSETCONDITION:naked" { opts.set_cond_set_naked (lex_conf_bool()); return; }
+ "condprefix" { opts.set_condPrefix (lex_conf_string ()); return; }
+ "condenumprefix" { opts.set_condEnumPrefix (lex_conf_string ()); return; }
+ "cond:divider" { opts.set_condDivider (lex_conf_string ()); return; }
+ "cond:divider@cond" { opts.set_condDividerParam (lex_conf_string ()); return; }
+ "cond:goto" { opts.set_condGoto (lex_conf_string ()); return; }
+ "cond:goto@cond" { opts.set_condGotoParam (lex_conf_string ()); return; }
+ "variable:yyctable" { opts.set_yyctable (lex_conf_string ()); return; }
+
+ "define:YYGETSTATE" { opts.set_state_get (lex_conf_string ()); return; }
+ "define:YYGETSTATE:naked" { opts.set_state_get_naked (lex_conf_bool()); return; }
+ "define:YYSETSTATE" { opts.set_state_set (lex_conf_string ()); return; }
+ "define:YYSETSTATE:naked" { opts.set_state_set_naked (lex_conf_bool()); return; }
+ "define:YYSETSTATE@state" { opts.set_state_set_arg (lex_conf_string ()); return; }
+ "label:yyFillLabel" { opts.set_yyfilllabel (lex_conf_string ()); return; }
+ "label:yyNext" { opts.set_yynext (lex_conf_string ()); return; }
+ "state:abort" { opts.set_bUseStateAbort (lex_conf_bool()); return; }
+ "state:nextlabel" { opts.set_bUseStateNext (lex_conf_bool()); return; }
+ "variable:yyaccept" { opts.set_yyaccept (lex_conf_string ()); return; }
+
+ "variable:yybm" { opts.set_yybm (lex_conf_string ()); return; }
+ "yybm:hex" { opts.set_yybmHexTable (lex_conf_bool()); return; }
+ "cgoto:threshold"
+ {
+ const int32_t n = lex_conf_number ();
+ if (n < 0)
+ {
+ fatal_lc(l, c, "configuration 'cgoto:threshold' must be nonnegative");
+ }
+ opts.set_cGotoThreshold (static_cast<uint32_t> (n));
+ return;
+ }
+ "variable:yytarget" { opts.set_yytarget (lex_conf_string ()); return; }
+
+ "define:YYCURSOR" { opts.set_yycursor (lex_conf_string ()); return; }
+ "define:YYMARKER" { opts.set_yymarker (lex_conf_string ()); return; }
+ "define:YYCTXMARKER" { opts.set_yyctxmarker (lex_conf_string ()); return; }
+ "define:YYLIMIT" { opts.set_yylimit (lex_conf_string ()); return; }
+
+ "define:YYPEEK" { opts.set_yypeek (lex_conf_string ()); return; }
+ "define:YYSKIP" { opts.set_yyskip (lex_conf_string ()); return; }
+ "define:YYBACKUP" { opts.set_yybackup (lex_conf_string ()); return; }
+ "define:YYBACKUPCTX" { opts.set_yybackupctx (lex_conf_string ()); return; }
+ "define:YYRESTORE" { opts.set_yyrestore (lex_conf_string ()); return; }
+ "define:YYRESTORECTX" { opts.set_yyrestorectx (lex_conf_string ()); return; }
+ "define:YYRESTORETAG" { opts.set_yyrestoretag (lex_conf_string ()); return; }
+ "define:YYLESSTHAN" { opts.set_yylessthan (lex_conf_string ()); return; }
+ "define:YYSTAGN" { opts.set_yystagn (lex_conf_string ()); return; }
+ "define:YYSTAGP" { opts.set_yystagp (lex_conf_string ()); return; }
+ "define:YYMTAGN" { opts.set_yymtagn (lex_conf_string ()); return; }
+ "define:YYMTAGP" { opts.set_yymtagp (lex_conf_string ()); return; }
+
+ "tags:prefix" { opts.set_tags_prefix (lex_conf_string ()); return; }
+ "tags:expression" { opts.set_tags_expression(lex_conf_string ()); return; }
+
+ "indent:string" { opts.set_indString (lex_conf_string ()); return; }
+ "indent:top"
+ {
+ const int32_t n = lex_conf_number ();
+ if (n < 0)
+ {
+ fatal_lc(l, c, "configuration 'indent:top' must be nonnegative");
+ }
+ opts.set_topIndent (static_cast<uint32_t> (n));
+ return;
+ }
+
+ "define:YYDEBUG" { opts.set_yydebug (lex_conf_string ()); return; }
+
+ "define:YYCTYPE" { opts.set_yyctype (lex_conf_string ()); return; }
+ "variable:yych" { opts.set_yych (lex_conf_string ()); return; }
+ "yych:conversion" { opts.set_yychConversion (lex_conf_bool()); return; }
+ "yych:emit" { opts.set_bEmitYYCh (lex_conf_bool()); return; }
+
+ "define:YYFILL" { opts.set_fill (lex_conf_string ()); return; }
+ "yyfill:enable" { opts.set_fill_use (lex_conf_bool()); return; }
+ "define:YYFILL@len" { opts.set_fill_arg (lex_conf_string ()); return; }
+ "yyfill:parameter" { opts.set_fill_arg_use (lex_conf_bool()); return; }
+ "define:YYFILL:naked" { opts.set_fill_naked (lex_conf_bool()); return; }
+ "yyfill:check" { opts.set_fill_check (lex_conf_bool()); return; }
+
+ "labelprefix" { opts.set_labelPrefix (lex_conf_string ()); return; }
+
+ // try to lex number first, otherwize it would be lexed as a naked string
+ "startlabel" / conf_assign number { opts.set_startlabel_force (lex_conf_bool()); return; }
+ "startlabel" { opts.set_startlabel (lex_conf_string()); return; }
+
+ // deprecated
+ "variable:yystable" { lex_conf_string (); return; }
+
+ [a-zA-Z0-9_:-]* {
+ fatal_lc(l, c, "unrecognized configuration '%.*s'",
+ static_cast<int>(cur - tok), tok);
+ }
*/
}
void Scanner::lex_conf_encoding_policy(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
/*!re2c
- * { fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'ignore', 'substitute', 'fail')"); }
- "ignore" { opts.set_encoding_policy(Enc::POLICY_IGNORE); goto end; }
- "substitute" { opts.set_encoding_policy(Enc::POLICY_SUBSTITUTE); goto end; }
- "fail" { opts.set_encoding_policy(Enc::POLICY_FAIL); goto end; }
+ * { fatal_lc(get_cline(), get_column(),
+ "bad configuration value (expected: 'ignore', 'substitute', 'fail')"); }
+ "ignore" { opts.set_encoding_policy(Enc::POLICY_IGNORE); goto end; }
+ "substitute" { opts.set_encoding_policy(Enc::POLICY_SUBSTITUTE); goto end; }
+ "fail" { opts.set_encoding_policy(Enc::POLICY_FAIL); goto end; }
*/
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_input(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
/*!re2c
- * { fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'default', 'custom')"); }
- "default" { opts.set_input_api(INPUT_DEFAULT); goto end; }
- "custom" { opts.set_input_api(INPUT_CUSTOM); goto end; }
+ * { fatal_lc(get_cline(), get_column(),
+ "bad configuration value (expected: 'default', 'custom')"); }
+ "default" { opts.set_input_api(INPUT_DEFAULT); goto end; }
+ "custom" { opts.set_input_api(INPUT_CUSTOM); goto end; }
*/
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_empty_class(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
/*!re2c
- * { fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'match-empty', 'match-none', 'error')"); }
- "match-empty" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_EMPTY); goto end; }
- "match-none" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_NONE); goto end; }
- "error" { opts.set_empty_class_policy(EMPTY_CLASS_ERROR); goto end; }
+ * { fatal_lc(get_cline(), get_column(),
+ "bad configuration value (expected: 'match-empty', 'match-none', 'error')"); }
+ "match-empty" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_EMPTY); goto end; }
+ "match-none" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_NONE); goto end; }
+ "error" { opts.set_empty_class_policy(EMPTY_CLASS_ERROR); goto end; }
*/
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_dfa_minimization(Opt &opts)
{
- lex_conf_assign ();
+ lex_conf_assign ();
/*!re2c
- * { fatal_lc(get_cline(), get_column(),
- "bad configuration value (expected: 'table', 'moore')"); }
- "table" { opts.set_dfa_minimization(DFA_MINIMIZATION_TABLE); goto end; }
- "moore" { opts.set_dfa_minimization(DFA_MINIMIZATION_MOORE); goto end; }
+ * { fatal_lc(get_cline(), get_column(),
+ "bad configuration value (expected: 'table', 'moore')"); }
+ "table" { opts.set_dfa_minimization(DFA_MINIMIZATION_TABLE); goto end; }
+ "moore" { opts.set_dfa_minimization(DFA_MINIMIZATION_MOORE); goto end; }
*/
end:
- lex_conf_semicolon();
+ lex_conf_semicolon();
}
void Scanner::lex_conf_enc(Enc::type_t enc, Opt &opts)
{
- if (lex_conf_bool()) {
- opts.set_encoding(enc);
- } else {
- opts.unset_encoding(enc);
- }
+ if (lex_conf_bool()) {
+ opts.set_encoding(enc);
+ } else {
+ opts.unset_encoding(enc);
+ }
}
void Scanner::lex_conf_assign ()
{
/*!re2c
- * { fatal_lc(get_cline(), get_column(), "missing '=' in configuration"); }
- conf_assign { return; }
+ * { fatal_lc(get_cline(), get_column(), "missing '=' in configuration"); }
+ conf_assign { return; }
*/
}
void Scanner::lex_conf_semicolon ()
{
/*!re2c
- * { fatal_lc(get_cline(), get_column(), "missing ending ';' in configuration"); }
- space* ";" { return; }
+ * { fatal_lc(get_cline(), get_column(), "missing ending ';' in configuration"); }
+ space* ";" { return; }
*/
}
bool Scanner::lex_conf_bool()
{
- return lex_conf_number() != 0;
+ return lex_conf_number() != 0;
}
int32_t Scanner::lex_conf_number ()
{
- lex_conf_assign ();
- tok = cur;
+ lex_conf_assign ();
+ tok = cur;
/*!re2c
- number {
- int32_t n = 0;
- if (!s_to_i32_unsafe (tok, cur, n)) {
- fatal_lc(get_cline(), get_column(), "configuration value overflow");
- }
- lex_conf_semicolon ();
- return n;
- }
+ number {
+ int32_t n = 0;
+ if (!s_to_i32_unsafe (tok, cur, n)) {
+ fatal_lc(get_cline(), get_column(), "configuration value overflow");
+ }
+ lex_conf_semicolon ();
+ return n;
+ }
*/
}
std::string Scanner::lex_conf_string ()
{
- lex_conf_assign ();
- std::string s;
- tok = cur;
+ lex_conf_assign ();
+ std::string s;
+ tok = cur;
/*!re2c
- ['"] {
- const char quote = tok[0];
- for (bool end;;) {
- const uint32_t c = lex_str_chr(quote, end);
- if (end) {
- goto end;
- }
- if (c > 0xFF) {
- fatal_lc(get_cline(), get_column(),
- "multibyte character in configuration string: 0x%X", c);
- } else {
- s += static_cast<char>(c);
- }
- }
- }
- naked {
- s = std::string(tok, tok_len());
- goto end;
- }
- "" { goto end; }
+ ['"] {
+ const char quote = tok[0];
+ for (bool end;;) {
+ const uint32_t c = lex_str_chr(quote, end);
+ if (end) {
+ goto end;
+ }
+ if (c > 0xFF) {
+ fatal_lc(get_cline(), get_column(),
+ "multibyte character in configuration string: 0x%X", c);
+ } else {
+ s += static_cast<char>(c);
+ }
+ }
+ }
+ naked {
+ s = std::string(tok, tok_len());
+ goto end;
+ }
+ "" { goto end; }
*/
end:
- lex_conf_semicolon ();
- return s;
+ lex_conf_semicolon ();
+ return s;
}
} // end namespace re2c
static spec_t &find(specs_t &specs, const std::string &name)
{
- for (specs_t::iterator i = specs.begin(); i != specs.end(); ++i) {
- if (i->name == name) return *i;
- }
- specs.push_back(spec_t(name));
- return specs.back();
+ for (specs_t::iterator i = specs.begin(); i != specs.end(); ++i) {
+ if (i->name == name) return *i;
+ }
+ specs.push_back(spec_t(name));
+ return specs.back();
}
%}
-%start spec
+%start spec
%lex-param {re2c::context_t &context}
%parse-param {re2c::context_t &context}
%union {
- const re2c::AST * regexp;
- re2c::Code * code;
- char op;
- re2c::ASTBounds bounds;
- std::string * str;
- re2c::CondList * clist;
+ const re2c::AST * regexp;
+ re2c::Code * code;
+ char op;
+ re2c::ASTBounds bounds;
+ std::string * str;
+ re2c::CondList * clist;
};
%token TOKEN_CLOSESIZE
%%
spec
- : /* empty */
- | spec TOKEN_CONF { context.input.lex_conf(context.opts); }
- | spec def
- | spec rule
- | spec TOKEN_LINE_INFO
- ;
+ : /* empty */
+ | spec TOKEN_CONF { context.input.lex_conf(context.opts); }
+ | spec def
+ | spec rule
+ | spec TOKEN_LINE_INFO
+ ;
def
- : name expr enddef {
- if (!context.symtab.insert(std::make_pair(*$1, $2)).second) {
- fatal_l(context.input.get_cline(), "sym already defined");
- }
- delete $1;
- }
- /* errors */
- | name expr '/' {
- fatal_l(context.input.get_cline(),
- "trailing contexts are not allowed in named definitions");
- };
+ : name expr enddef {
+ if (!context.symtab.insert(std::make_pair(*$1, $2)).second) {
+ fatal_l(context.input.get_cline(), "sym already defined");
+ }
+ delete $1;
+ }
+ /* errors */
+ | name expr '/' {
+ fatal_l(context.input.get_cline(),
+ "trailing contexts are not allowed in named definitions");
+ };
name
- : TOKEN_ID '=' {
- $$ = $1;
- }
- | TOKEN_FID {
- $$ = $1;
- };
+ : TOKEN_ID '=' {
+ $$ = $1;
+ }
+ | TOKEN_FID {
+ $$ = $1;
+ };
enddef: ';' | TOKEN_FID_END;
rule
- : trailexpr TOKEN_CODE {
- find(context.specs, "").rules.push_back(ASTRule($1, $2));
- }
-
- | '*' TOKEN_CODE {
- find(context.specs, "").defs.push_back($2);
- }
-
- | '<' clist '>' trailexpr ccode {
- for(CondList::const_iterator i = $2->begin(); i != $2->end(); ++i) {
- find(context.specs, *i).rules.push_back(ASTRule($4, $5));
- }
- delete $2;
- }
-
- | '<' clist '>' '*' ccode {
- for(CondList::const_iterator i = $2->begin(); i != $2->end(); ++i) {
- find(context.specs, *i).defs.push_back($5);
- }
- delete $2;
- }
-
- | '<' '!' clist '>' TOKEN_CODE {
- for (CondList::const_iterator i = $3->begin(); i != $3->end(); ++i) {
- find(context.specs, *i).setup.push_back($5);
- }
- delete $3;
- }
-
- | '<' '>' ccode {
- const AST *r = ast_nil(context.input.get_cline(), 0);
- find(context.specs, "0").rules.push_back(ASTRule(r, $3));
- };
+ : trailexpr TOKEN_CODE {
+ find(context.specs, "").rules.push_back(ASTRule($1, $2));
+ }
+
+ | '*' TOKEN_CODE {
+ find(context.specs, "").defs.push_back($2);
+ }
+
+ | '<' clist '>' trailexpr ccode {
+ for(CondList::const_iterator i = $2->begin(); i != $2->end(); ++i) {
+ find(context.specs, *i).rules.push_back(ASTRule($4, $5));
+ }
+ delete $2;
+ }
+
+ | '<' clist '>' '*' ccode {
+ for(CondList::const_iterator i = $2->begin(); i != $2->end(); ++i) {
+ find(context.specs, *i).defs.push_back($5);
+ }
+ delete $2;
+ }
+
+ | '<' '!' clist '>' TOKEN_CODE {
+ for (CondList::const_iterator i = $3->begin(); i != $3->end(); ++i) {
+ find(context.specs, *i).setup.push_back($5);
+ }
+ delete $3;
+ }
+
+ | '<' '>' ccode {
+ const AST *r = ast_nil(context.input.get_cline(), 0);
+ find(context.specs, "0").rules.push_back(ASTRule(r, $3));
+ };
ccode
- : TOKEN_CODE
+ : TOKEN_CODE
- | '=' '>' TOKEN_ID TOKEN_CODE {
- $$ = $4;
- $$->cond = *$3;
- delete $3;
- }
+ | '=' '>' TOKEN_ID TOKEN_CODE {
+ $$ = $4;
+ $$->cond = *$3;
+ delete $3;
+ }
- | ':' '=' '>' TOKEN_ID {
- $$ = new Code(context.input.get_fname(), context.input.get_cline());
- $$->cond = *$4;
- delete $4;
- };
+ | ':' '=' '>' TOKEN_ID {
+ $$ = new Code(context.input.get_fname(), context.input.get_cline());
+ $$->cond = *$4;
+ delete $4;
+ };
clist
- : conds
- | '*' {
- $$ = new CondList;
- $$->insert("*");
- };
+ : conds
+ | '*' {
+ $$ = new CondList;
+ $$->insert("*");
+ };
conds
- : TOKEN_ID {
- $$ = new CondList;
- $$->insert(*$1);
- delete $1;
- }
-
- | conds ',' TOKEN_ID {
- $1->insert(*$3);
- delete $3;
- $$ = $1;
- };
+ : TOKEN_ID {
+ $$ = new CondList;
+ $$->insert(*$1);
+ delete $1;
+ }
+
+ | conds ',' TOKEN_ID {
+ $1->insert(*$3);
+ delete $3;
+ $$ = $1;
+ };
trailexpr
- : expr {
- $$ = ast_cap($1);
- } | expr '/' expr {
- $$ = ast_cat(ast_cap($1),
- ast_cat(ast_tag(context.input.get_cline(), 0, NULL, false), $3));
- };
+ : expr {
+ $$ = ast_cap($1);
+ } | expr '/' expr {
+ $$ = ast_cat(ast_cap($1),
+ ast_cat(ast_tag(context.input.get_cline(), 0, NULL, false), $3));
+ };
expr:
- diff
- {
- $$ = $1;
- }
- | expr '|' diff
- {
- $$ = ast_alt($1, $3);
- }
+ diff
+ {
+ $$ = $1;
+ }
+ | expr '|' diff
+ {
+ $$ = ast_alt($1, $3);
+ }
;
diff:
- term
- {
- $$ = $1;
- }
- | diff '\\' term
- {
- $$ = ast_diff($1, $3);
- }
+ term
+ {
+ $$ = $1;
+ }
+ | diff '\\' term
+ {
+ $$ = ast_diff($1, $3);
+ }
;
term:
- factor
- {
- $$ = $1;
- }
- | factor term // in POSIX concatenation is right-associative
- {
- $$ = ast_cat($1, $2);
- }
+ factor
+ {
+ $$ = $1;
+ }
+ | factor term // in POSIX concatenation is right-associative
+ {
+ $$ = ast_cat($1, $2);
+ }
;
factor
- : primary
- | primary closes {
- switch($2) {
- case '*': $$ = ast_iter($1, 0, AST::MANY); break;
- case '+': $$ = ast_iter($1, 1, AST::MANY); break;
- case '?': $$ = ast_iter($1, 0, 1); break;
- }
- } | primary TOKEN_CLOSESIZE {
- $$ = ast_iter($1, $2.min, $2.max);
- };
+ : primary
+ | primary closes {
+ switch($2) {
+ case '*': $$ = ast_iter($1, 0, AST::MANY); break;
+ case '+': $$ = ast_iter($1, 1, AST::MANY); break;
+ case '?': $$ = ast_iter($1, 0, 1); break;
+ }
+ } | primary TOKEN_CLOSESIZE {
+ $$ = ast_iter($1, $2.min, $2.max);
+ };
closes
- : close
- | closes close { $$ = ($1 == $2) ? $1 : '*'; }
- ;
+ : close
+ | closes close { $$ = ($1 == $2) ? $1 : '*'; }
+ ;
close
- : '*' { $$ = '*'; }
- | '+' { $$ = '+'; }
- | '?' { $$ = '?'; }
- ;
+ : '*' { $$ = '*'; }
+ | '+' { $$ = '+'; }
+ | '?' { $$ = '?'; }
+ ;
primary
- : TOKEN_REGEXP
- | TOKEN_ID {
- symtab_t::iterator i = context.symtab.find(*$1);
- if (i == context.symtab.end()) {
- fatal_l(context.input.get_cline(),
- "undefined symbol '%s'", $1->c_str());
- }
- $$ = i->second;
- if (ast_need_wrap($$)) {
- $$ = ast_ref($$, *$1);
- }
- delete $1;
- } | '(' expr ')' {
- $$ = ast_cap($2);
- };
+ : TOKEN_REGEXP
+ | TOKEN_ID {
+ symtab_t::iterator i = context.symtab.find(*$1);
+ if (i == context.symtab.end()) {
+ fatal_l(context.input.get_cline(),
+ "undefined symbol '%s'", $1->c_str());
+ }
+ $$ = i->second;
+ if (ast_need_wrap($$)) {
+ $$ = ast_ref($$, *$1);
+ }
+ delete $1;
+ } | '(' expr ')' {
+ $$ = ast_cap($2);
+ };
%%
void yyerror(context_t &context, const char* s)
{
- fatal_l(context.input.get_cline(), "%s", s);
+ fatal_l(context.input.get_cline(), "%s", s);
}
int yylex(context_t &context)
{
- return context.input.scan(&context.opts.glob);
+ return context.input.scan(&context.opts.glob);
}
} // extern "C"
static inline bool next (char * & arg, char ** & argv)
{
- arg = *++argv;
- return arg != NULL;
+ arg = *++argv;
+ return arg != NULL;
}
parse_opts_t parse_opts(char **argv, conopt_t &globopts, Opt &opts, Warn &warn)
{
#define YYCTYPE unsigned char
- char * YYCURSOR;
- char * YYMARKER;
- Warn::option_t option;
+ char * YYCURSOR;
+ char * YYMARKER;
+ Warn::option_t option;
/*!re2c
- re2c:yyfill:enable = 0;
- re2c:yych:conversion = 1;
+ re2c:yyfill:enable = 0;
+ re2c:yych:conversion = 1;
- end = "\x00";
- filename = [^\x00-] [^\x00]*;
+ end = "\x00";
+ filename = [^\x00-] [^\x00]*;
*/
opt:
- if (!next (YYCURSOR, argv))
- {
- goto end;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ goto end;
+ }
/*!re2c
- *
- {
- error ("bad option: %s", *argv);
- return EXIT_FAIL;
- }
+ *
+ {
+ error ("bad option: %s", *argv);
+ return EXIT_FAIL;
+ }
- "--" end
- {
- // all remaining arguments are non-options
- // so they must be input files
- // re2c expects exactly one input file
- for (char * f; next (f, argv);)
- {
- if (!opts.source (f))
- {
- return EXIT_FAIL;
- }
- }
- goto end;
- }
+ "--" end
+ {
+ // all remaining arguments are non-options
+ // so they must be input files
+ // re2c expects exactly one input file
+ for (char * f; next (f, argv);)
+ {
+ if (!opts.source (f))
+ {
+ return EXIT_FAIL;
+ }
+ }
+ goto end;
+ }
- "-" end { if (!opts.source ("<stdin>")) return EXIT_FAIL; goto opt; }
- filename end { if (!opts.source (*argv)) return EXIT_FAIL; goto opt; }
+ "-" end { if (!opts.source ("<stdin>")) return EXIT_FAIL; goto opt; }
+ filename end { if (!opts.source (*argv)) return EXIT_FAIL; goto opt; }
- "-" { goto opt_short; }
- "--" { goto opt_long; }
+ "-" { goto opt_short; }
+ "--" { goto opt_long; }
- "-W" end { warn.set_all (); goto opt; }
- "-Werror" end { warn.set_all_error (); goto opt; }
- "-W" { option = Warn::W; goto opt_warn; }
- "-Wno-" { option = Warn::WNO; goto opt_warn; }
- "-Werror-" { option = Warn::WERROR; goto opt_warn; }
- "-Wno-error-" { option = Warn::WNOERROR; goto opt_warn; }
+ "-W" end { warn.set_all (); goto opt; }
+ "-Werror" end { warn.set_all_error (); goto opt; }
+ "-W" { option = Warn::W; goto opt_warn; }
+ "-Wno-" { option = Warn::WNO; goto opt_warn; }
+ "-Werror-" { option = Warn::WERROR; goto opt_warn; }
+ "-Wno-error-" { option = Warn::WNOERROR; goto opt_warn; }
*/
opt_warn:
/*!re2c
- *
- {
- error ("bad warning: %s", *argv);
- return EXIT_FAIL;
- }
- "condition-order" end { warn.set (Warn::CONDITION_ORDER, option); goto opt; }
- "empty-character-class" end { warn.set (Warn::EMPTY_CHARACTER_CLASS, option); goto opt; }
- "match-empty-string" end { warn.set (Warn::MATCH_EMPTY_STRING, option); goto opt; }
- "nondeterministic-tags" end { warn.set (Warn::NONDETERMINISTIC_TAGS, option); goto opt; }
- "swapped-range" end { warn.set (Warn::SWAPPED_RANGE, option); goto opt; }
- "undefined-control-flow" end { warn.set (Warn::UNDEFINED_CONTROL_FLOW, option); goto opt; }
- "unreachable-rules" end { warn.set (Warn::UNREACHABLE_RULES, option); goto opt; }
- "useless-escape" end { warn.set (Warn::USELESS_ESCAPE, option); goto opt; }
+ *
+ {
+ error ("bad warning: %s", *argv);
+ return EXIT_FAIL;
+ }
+ "condition-order" end { warn.set (Warn::CONDITION_ORDER, option); goto opt; }
+ "empty-character-class" end { warn.set (Warn::EMPTY_CHARACTER_CLASS, option); goto opt; }
+ "match-empty-string" end { warn.set (Warn::MATCH_EMPTY_STRING, option); goto opt; }
+ "nondeterministic-tags" end { warn.set (Warn::NONDETERMINISTIC_TAGS, option); goto opt; }
+ "swapped-range" end { warn.set (Warn::SWAPPED_RANGE, option); goto opt; }
+ "undefined-control-flow" end { warn.set (Warn::UNDEFINED_CONTROL_FLOW, option); goto opt; }
+ "unreachable-rules" end { warn.set (Warn::UNREACHABLE_RULES, option); goto opt; }
+ "useless-escape" end { warn.set (Warn::USELESS_ESCAPE, option); goto opt; }
*/
opt_short:
/*!re2c
- *
- {
- error ("bad short option: %s", *argv);
- return EXIT_FAIL;
- }
- end { goto opt; }
- [?h] { usage (); return EXIT_OK; }
- "v" { version (); return EXIT_OK; }
- "V" { vernum (); return EXIT_OK; }
+ *
+ {
+ error ("bad short option: %s", *argv);
+ return EXIT_FAIL;
+ }
+ end { goto opt; }
+ [?h] { usage (); return EXIT_OK; }
+ "v" { version (); return EXIT_OK; }
+ "V" { vernum (); return EXIT_OK; }
- "c" { globopts.cFlag = true; goto opt_short; }
- "D" { globopts.target = TARGET_DOT; goto opt_short; }
- "f" { globopts.fFlag = true; goto opt_short; }
- "F" { globopts.FFlag = true; goto opt_short; }
- "r" { globopts.rFlag = true; goto opt_short; }
- "S" { globopts.target = TARGET_SKELETON; goto opt_short; }
+ "c" { globopts.cFlag = true; goto opt_short; }
+ "D" { globopts.target = TARGET_DOT; goto opt_short; }
+ "f" { globopts.fFlag = true; goto opt_short; }
+ "F" { globopts.FFlag = true; goto opt_short; }
+ "r" { globopts.rFlag = true; goto opt_short; }
+ "S" { globopts.target = TARGET_SKELETON; goto opt_short; }
- "b" { opts.set_bFlag(true); goto opt_short; }
- "d" { opts.set_dFlag(true); goto opt_short; }
- "g" { opts.set_gFlag(true); goto opt_short; }
- "i" { opts.set_iFlag(true); goto opt_short; }
- "s" { opts.set_sFlag(true); goto opt_short; }
- "T" { opts.set_tags(true); goto opt_short; }
- "P" { opts.set_posix_captures(true); goto opt_short; }
- "e" { opts.set_encoding(Enc::EBCDIC); goto opt_short; }
- "u" { opts.set_encoding(Enc::UTF32); goto opt_short; }
- "w" { opts.set_encoding(Enc::UCS2); goto opt_short; }
- "x" { opts.set_encoding(Enc::UTF16); goto opt_short; }
- "8" { opts.set_encoding(Enc::UTF8); goto opt_short; }
- "o" end { if (!next (YYCURSOR, argv)) { error_arg ("-o, --output"); return EXIT_FAIL; } goto opt_output; }
- "o" { *argv = YYCURSOR; goto opt_output; }
- "t" end { if (!next (YYCURSOR, argv)) { error_arg ("-t, --type-header"); return EXIT_FAIL; } goto opt_header; }
- "t" { *argv = YYCURSOR; goto opt_header; }
- "1" { goto opt_short; } // deprecated
+ "b" { opts.set_bFlag(true); goto opt_short; }
+ "d" { opts.set_dFlag(true); goto opt_short; }
+ "g" { opts.set_gFlag(true); goto opt_short; }
+ "i" { opts.set_iFlag(true); goto opt_short; }
+ "s" { opts.set_sFlag(true); goto opt_short; }
+ "T" { opts.set_tags(true); goto opt_short; }
+ "P" { opts.set_posix_captures(true); goto opt_short; }
+ "e" { opts.set_encoding(Enc::EBCDIC); goto opt_short; }
+ "u" { opts.set_encoding(Enc::UTF32); goto opt_short; }
+ "w" { opts.set_encoding(Enc::UCS2); goto opt_short; }
+ "x" { opts.set_encoding(Enc::UTF16); goto opt_short; }
+ "8" { opts.set_encoding(Enc::UTF8); goto opt_short; }
+ "o" end { if (!next (YYCURSOR, argv)) { error_arg ("-o, --output"); return EXIT_FAIL; } goto opt_output; }
+ "o" { *argv = YYCURSOR; goto opt_output; }
+ "t" end { if (!next (YYCURSOR, argv)) { error_arg ("-t, --type-header"); return EXIT_FAIL; } goto opt_header; }
+ "t" { *argv = YYCURSOR; goto opt_header; }
+ "1" { goto opt_short; } // deprecated
*/
opt_long:
/*!re2c
- *
- {
- error ("bad long option: %s", *argv);
- return EXIT_FAIL;
- }
- "help" end { usage (); return EXIT_OK; }
- "version" end { version (); return EXIT_OK; }
- "vernum" end { vernum (); return EXIT_OK; }
+ *
+ {
+ error ("bad long option: %s", *argv);
+ return EXIT_FAIL;
+ }
+ "help" end { usage (); return EXIT_OK; }
+ "version" end { version (); return EXIT_OK; }
+ "vernum" end { vernum (); return EXIT_OK; }
- "start-"? "conditions" end { globopts.cFlag = true; goto opt; }
- "emit-dot" end { globopts.target = TARGET_DOT; goto opt; }
- "storable-state" end { globopts.fFlag = true; goto opt; }
- "flex-syntax" end { globopts.FFlag = true; goto opt; }
- "reusable" end { globopts.rFlag = true; goto opt; }
- "no-generation-date" end { globopts.bNoGenerationDate = true; goto opt; }
- "no-version" end { globopts.version = false; goto opt; }
- "skeleton" end { globopts.target = TARGET_SKELETON; goto opt; }
+ "start-"? "conditions" end { globopts.cFlag = true; goto opt; }
+ "emit-dot" end { globopts.target = TARGET_DOT; goto opt; }
+ "storable-state" end { globopts.fFlag = true; goto opt; }
+ "flex-syntax" end { globopts.FFlag = true; goto opt; }
+ "reusable" end { globopts.rFlag = true; goto opt; }
+ "no-generation-date" end { globopts.bNoGenerationDate = true; goto opt; }
+ "no-version" end { globopts.version = false; goto opt; }
+ "skeleton" end { globopts.target = TARGET_SKELETON; goto opt; }
- "bit-vectors" end { opts.set_bFlag (true); goto opt; }
- "debug-output" end { opts.set_dFlag (true); goto opt; }
- "computed-gotos" end { opts.set_gFlag (true); goto opt; }
- "no-debug-info" end { opts.set_iFlag (true); goto opt; }
- "nested-ifs" end { opts.set_sFlag (true); goto opt; }
- "case-insensitive" end { opts.set_bCaseInsensitive (true); goto opt; }
- "case-inverted" end { opts.set_bCaseInverted (true); goto opt; }
- "tags" end { opts.set_tags (true); goto opt; }
- "posix-captures" end { opts.set_posix_captures(true); goto opt; }
- "no-lookahead" end { opts.set_lookahead(false); goto opt; }
- "no-optimize-tags" end { opts.set_optimize_tags(false); goto opt; }
- "eager-skip" end { opts.set_eager_skip(true); goto opt; }
- "ecb" end { opts.set_encoding(Enc::EBCDIC); goto opt; }
- "unicode" end { opts.set_encoding(Enc::UTF32); goto opt; }
- "wide-chars" end { opts.set_encoding(Enc::UCS2); goto opt; }
- "utf-16" end { opts.set_encoding(Enc::UTF16); goto opt; }
- "utf-8" end { opts.set_encoding(Enc::UTF8); goto opt; }
- "output" end { if (!next (YYCURSOR, argv)) { error_arg ("-o, --output"); return EXIT_FAIL; } goto opt_output; }
- "type-header" end { if (!next (YYCURSOR, argv)) { error_arg ("-t, --type-header"); return EXIT_FAIL; } goto opt_header; }
- "encoding-policy" end { goto opt_encoding_policy; }
- "input" end { goto opt_input; }
- "empty-class" end { goto opt_empty_class; }
- "dfa-minimization" end { goto opt_dfa_minimization; }
- "single-pass" end { goto opt; } // deprecated
+ "bit-vectors" end { opts.set_bFlag (true); goto opt; }
+ "debug-output" end { opts.set_dFlag (true); goto opt; }
+ "computed-gotos" end { opts.set_gFlag (true); goto opt; }
+ "no-debug-info" end { opts.set_iFlag (true); goto opt; }
+ "nested-ifs" end { opts.set_sFlag (true); goto opt; }
+ "case-insensitive" end { opts.set_bCaseInsensitive (true); goto opt; }
+ "case-inverted" end { opts.set_bCaseInverted (true); goto opt; }
+ "tags" end { opts.set_tags (true); goto opt; }
+ "posix-captures" end { opts.set_posix_captures(true); goto opt; }
+ "no-lookahead" end { opts.set_lookahead(false); goto opt; }
+ "no-optimize-tags" end { opts.set_optimize_tags(false); goto opt; }
+ "eager-skip" end { opts.set_eager_skip(true); goto opt; }
+ "ecb" end { opts.set_encoding(Enc::EBCDIC); goto opt; }
+ "unicode" end { opts.set_encoding(Enc::UTF32); goto opt; }
+ "wide-chars" end { opts.set_encoding(Enc::UCS2); goto opt; }
+ "utf-16" end { opts.set_encoding(Enc::UTF16); goto opt; }
+ "utf-8" end { opts.set_encoding(Enc::UTF8); goto opt; }
+ "output" end { if (!next (YYCURSOR, argv)) { error_arg ("-o, --output"); return EXIT_FAIL; } goto opt_output; }
+ "type-header" end { if (!next (YYCURSOR, argv)) { error_arg ("-t, --type-header"); return EXIT_FAIL; } goto opt_header; }
+ "encoding-policy" end { goto opt_encoding_policy; }
+ "input" end { goto opt_input; }
+ "empty-class" end { goto opt_empty_class; }
+ "dfa-minimization" end { goto opt_dfa_minimization; }
+ "single-pass" end { goto opt; } // deprecated
- "dump-nfa" end { globopts.dump_nfa = true; goto opt; }
- "dump-dfa-raw" end { globopts.dump_dfa_raw = true; goto opt; }
- "dump-dfa-det" end { globopts.dump_dfa_det = true; goto opt; }
- "dump-dfa-tagopt" end { globopts.dump_dfa_tagopt = true; goto opt; }
- "dump-dfa-min" end { globopts.dump_dfa_min = true; goto opt; }
- "dump-adfa" end { globopts.dump_adfa = true; goto opt; }
+ "dump-nfa" end { globopts.dump_nfa = true; goto opt; }
+ "dump-dfa-raw" end { globopts.dump_dfa_raw = true; goto opt; }
+ "dump-dfa-det" end { globopts.dump_dfa_det = true; goto opt; }
+ "dump-dfa-tagopt" end { globopts.dump_dfa_tagopt = true; goto opt; }
+ "dump-dfa-min" end { globopts.dump_dfa_min = true; goto opt; }
+ "dump-adfa" end { globopts.dump_adfa = true; goto opt; }
*/
opt_output:
/*!re2c
- *
- {
- error ("bad argument to option -o, --output: %s", *argv);
- return EXIT_FAIL;
- }
- filename end { globopts.output_file = *argv; goto opt; }
+ *
+ {
+ error ("bad argument to option -o, --output: %s", *argv);
+ return EXIT_FAIL;
+ }
+ filename end { globopts.output_file = *argv; goto opt; }
*/
opt_header:
/*!re2c
- *
- {
- error ("bad argument to option -t, --type-header: %s", *argv);
- return EXIT_FAIL;
- }
- filename end { globopts.header_file = *argv; goto opt; }
+ *
+ {
+ error ("bad argument to option -t, --type-header: %s", *argv);
+ return EXIT_FAIL;
+ }
+ filename end { globopts.header_file = *argv; goto opt; }
*/
opt_encoding_policy:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--encoding-policy");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--encoding-policy");
+ return EXIT_FAIL;
+ }
/*!re2c
- *
- {
- error ("bad argument to option --encoding-policy (expected: ignore | substitute | fail): %s", *argv);
- return EXIT_FAIL;
- }
- "ignore" end { opts.set_encoding_policy (Enc::POLICY_IGNORE); goto opt; }
- "substitute" end { opts.set_encoding_policy (Enc::POLICY_SUBSTITUTE); goto opt; }
- "fail" end { opts.set_encoding_policy (Enc::POLICY_FAIL); goto opt; }
+ *
+ {
+ error ("bad argument to option --encoding-policy (expected: ignore | substitute | fail): %s", *argv);
+ return EXIT_FAIL;
+ }
+ "ignore" end { opts.set_encoding_policy (Enc::POLICY_IGNORE); goto opt; }
+ "substitute" end { opts.set_encoding_policy (Enc::POLICY_SUBSTITUTE); goto opt; }
+ "fail" end { opts.set_encoding_policy (Enc::POLICY_FAIL); goto opt; }
*/
opt_input:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--input");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--input");
+ return EXIT_FAIL;
+ }
/*!re2c
- *
- {
- error ("bad argument to option --input (expected: default | custom): %s", *argv);
- return EXIT_FAIL;
- }
- "default" end { opts.set_input_api(INPUT_DEFAULT); goto opt; }
- "custom" end { opts.set_input_api(INPUT_CUSTOM); goto opt; }
+ *
+ {
+ error ("bad argument to option --input (expected: default | custom): %s", *argv);
+ return EXIT_FAIL;
+ }
+ "default" end { opts.set_input_api(INPUT_DEFAULT); goto opt; }
+ "custom" end { opts.set_input_api(INPUT_CUSTOM); goto opt; }
*/
opt_empty_class:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--empty-class");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--empty-class");
+ return EXIT_FAIL;
+ }
/*!re2c
- *
- {
- error ("bad argument to option --empty-class (expected: match-empty | match-none | error): %s", *argv);
- return EXIT_FAIL;
- }
- "match-empty" end { opts.set_empty_class_policy (EMPTY_CLASS_MATCH_EMPTY); goto opt; }
- "match-none" end { opts.set_empty_class_policy (EMPTY_CLASS_MATCH_NONE); goto opt; }
- "error" end { opts.set_empty_class_policy (EMPTY_CLASS_ERROR); goto opt; }
+ *
+ {
+ error ("bad argument to option --empty-class (expected: match-empty | match-none | error): %s", *argv);
+ return EXIT_FAIL;
+ }
+ "match-empty" end { opts.set_empty_class_policy (EMPTY_CLASS_MATCH_EMPTY); goto opt; }
+ "match-none" end { opts.set_empty_class_policy (EMPTY_CLASS_MATCH_NONE); goto opt; }
+ "error" end { opts.set_empty_class_policy (EMPTY_CLASS_ERROR); goto opt; }
*/
opt_dfa_minimization:
- if (!next (YYCURSOR, argv))
- {
- error_arg ("--minimization");
- return EXIT_FAIL;
- }
+ if (!next (YYCURSOR, argv))
+ {
+ error_arg ("--minimization");
+ return EXIT_FAIL;
+ }
/*!re2c
- *
- {
- error ("bad argument to option --dfa-minimization (expected: table | moore): %s", *argv);
- return EXIT_FAIL;
- }
- "table" end { opts.set_dfa_minimization (DFA_MINIMIZATION_TABLE); goto opt; }
- "moore" end { opts.set_dfa_minimization (DFA_MINIMIZATION_MOORE); goto opt; }
+ *
+ {
+ error ("bad argument to option --dfa-minimization (expected: table | moore): %s", *argv);
+ return EXIT_FAIL;
+ }
+ "table" end { opts.set_dfa_minimization (DFA_MINIMIZATION_TABLE); goto opt; }
+ "moore" end { opts.set_dfa_minimization (DFA_MINIMIZATION_MOORE); goto opt; }
*/
end:
- if (!opts.source_file)
- {
- error ("no source file");
- return EXIT_FAIL;
- }
- globopts.fix();
+ if (!opts.source_file)
+ {
+ error ("no source file");
+ return EXIT_FAIL;
+ }
+ globopts.fix();
- return OK;
+ return OK;
#undef YYCTYPE
}