From: Ulya Trofimovich Date: Sun, 8 Jan 2017 10:34:04 +0000 (+0000) Subject: Reuse mode: always reparse rules and restore options of the rules block. X-Git-Tag: 1.0~39^2~152 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54e14cedea61d6ef709f6ba2db257a4e0d9bd87f;p=re2c Reuse mode: always reparse rules and restore options of the rules block. --- diff --git a/re2c/bootstrap/src/parse/lex.cc b/re2c/bootstrap/src/parse/lex.cc index 0580479f..a80a4f19 100644 --- a/re2c/bootstrap/src/parse/lex.cc +++ b/re2c/bootstrap/src/parse/lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Sun Jan 1 18:41:52 2017 */ +/* Generated by re2c 0.16 on Sun Jan 8 10:21:00 2017 */ #line 1 "../src/parse/lex.re" #include "src/util/c99_stdint.h" #include diff --git a/re2c/bootstrap/src/parse/parser.cc b/re2c/bootstrap/src/parse/parser.cc index 6cce158d..2894f182 100644 --- a/re2c/bootstrap/src/parse/parser.cc +++ b/re2c/bootstrap/src/parse/parser.cc @@ -2055,6 +2055,7 @@ void parse(Scanner &input, Output & o) dfas_t dfas; ScannerState rules_state, curr_state; Opt &opts = input.opts; + const opt_t *rules_opts = NULL; o.source.new_block(opts); @@ -2068,49 +2069,33 @@ void parse(Scanner &input, Output & o) Enc encodingOld = opts->encoding; for (Scanner::ParseMode mode; (mode = input.echo()) != Scanner::Stop;) { - input.save_state(curr_state); - if (opts->rFlag && mode == Scanner::Rules && !dfas.empty()) - { - input.fatal("cannot have a second 'rules:re2c' block"); - } - if (mode == Scanner::Reuse) - { - if (dfas.empty()) - { - input.fatal("got 'use:re2c' without 'rules:re2c'"); - } - } - else if (mode == Scanner::Rules) - { + if (mode == Scanner::Reuse) { + if (!rules_opts) input.fatal("got 'use:re2c' without 'rules:re2c'"); + } else if (mode == Scanner::Rules) { + if (rules_opts) input.fatal("cannot have a second 'rules:re2c' block"); input.save_state(rules_state); - } - else - { + rules_opts = opts.snapshot(); + } else { dfas.clear(); } // parse next re2c block context_t context = {input, specs, symtab}; specs.clear(); - yyparse(context); - if (opts->rFlag && mode == Scanner::Reuse) { - if (!specs.empty() || opts->encoding != encodingOld) { - // Re-parse rules - mode = Scanner::Parse; - input.restore_state(rules_state); - input.reuse(); - dfas.clear(); - specs.clear(); - symtab.clear(); - yyparse(context); - - // Now append potential new rules - input.restore_state(curr_state); - mode = Scanner::Parse; - yyparse(context); - } - encodingOld = opts->encoding; + if (mode == Scanner::Reuse) { + // re-parse rules block + input.save_state(curr_state); + mode = Scanner::Parse; + input.reuse(); + dfas.clear(); + symtab.clear(); + input.restore_state(rules_state); + opts.restore(rules_opts); + yyparse(context); + input.restore_state(curr_state); + mode = Scanner::Parse; } + yyparse(context); // start new output block with accumulated options o.source.new_block(opts); @@ -2144,6 +2129,7 @@ void parse(Scanner &input, Output & o) emit_epilog (o.source, o.skeletons); } + delete rules_opts; RegExp::flist.clear(); Code::flist.clear(); Range::vFreeList.clear(); diff --git a/re2c/src/conf/opt.h b/re2c/src/conf/opt.h index 40799208..b8c9628b 100644 --- a/re2c/src/conf/opt.h +++ b/re2c/src/conf/opt.h @@ -154,7 +154,7 @@ public: realopt_t (useropt_t & opt); const opt_t * operator -> (); void sync (); - const opt_t *snapshot() const { return new opt_t(real); } + friend struct Opt; }; class useropt_t @@ -165,6 +165,7 @@ public: useropt_t (); opt_t * operator -> (); friend void realopt_t::sync (); + friend struct Opt; }; struct Opt @@ -184,7 +185,17 @@ public: , realopt (useropt) {} - const opt_t *snapshot() const { return realopt.snapshot(); } + const opt_t *snapshot() + { + realopt.sync(); + return new opt_t(realopt.real); + } + + void restore(const opt_t *opts) + { + useropt.opt = *opts; + realopt.sync(); + } // read-only access, forces options syncronization const opt_t * operator -> () diff --git a/re2c/src/parse/parser.ypp b/re2c/src/parse/parser.ypp index f7e1134f..241dd085 100644 --- a/re2c/src/parse/parser.ypp +++ b/re2c/src/parse/parser.ypp @@ -430,6 +430,7 @@ void parse(Scanner &input, Output & o) dfas_t dfas; ScannerState rules_state, curr_state; Opt &opts = input.opts; + const opt_t *rules_opts = NULL; o.source.new_block(opts); @@ -443,49 +444,33 @@ void parse(Scanner &input, Output & o) Enc encodingOld = opts->encoding; for (Scanner::ParseMode mode; (mode = input.echo()) != Scanner::Stop;) { - input.save_state(curr_state); - if (opts->rFlag && mode == Scanner::Rules && !dfas.empty()) - { - input.fatal("cannot have a second 'rules:re2c' block"); - } - if (mode == Scanner::Reuse) - { - if (dfas.empty()) - { - input.fatal("got 'use:re2c' without 'rules:re2c'"); - } - } - else if (mode == Scanner::Rules) - { + if (mode == Scanner::Reuse) { + if (!rules_opts) input.fatal("got 'use:re2c' without 'rules:re2c'"); + } else if (mode == Scanner::Rules) { + if (rules_opts) input.fatal("cannot have a second 'rules:re2c' block"); input.save_state(rules_state); - } - else - { + rules_opts = opts.snapshot(); + } else { dfas.clear(); } // parse next re2c block context_t context = {input, specs, symtab}; specs.clear(); - yyparse(context); - if (opts->rFlag && mode == Scanner::Reuse) { - if (!specs.empty() || opts->encoding != encodingOld) { - // Re-parse rules - mode = Scanner::Parse; - input.restore_state(rules_state); - input.reuse(); - dfas.clear(); - specs.clear(); - symtab.clear(); - yyparse(context); - - // Now append potential new rules - input.restore_state(curr_state); - mode = Scanner::Parse; - yyparse(context); - } - encodingOld = opts->encoding; + if (mode == Scanner::Reuse) { + // re-parse rules block + input.save_state(curr_state); + mode = Scanner::Parse; + input.reuse(); + dfas.clear(); + symtab.clear(); + input.restore_state(rules_state); + opts.restore(rules_opts); + yyparse(context); + input.restore_state(curr_state); + mode = Scanner::Parse; } + yyparse(context); // start new output block with accumulated options o.source.new_block(opts); @@ -519,6 +504,7 @@ void parse(Scanner &input, Output & o) emit_epilog (o.source, o.skeletons); } + delete rules_opts; RegExp::flist.clear(); Code::flist.clear(); Range::vFreeList.clear(); diff --git a/re2c/test/repeat-01.cgir--skeleton.c b/re2c/test/repeat-01.cgir--skeleton.c index eb4178ee..11787d15 100644 --- a/re2c/test/repeat-01.cgir--skeleton.c +++ b/re2c/test/repeat-01.cgir--skeleton.c @@ -55,7 +55,7 @@ error: #define YYLESSTHAN(n) (limit - cursor) < n #define YYFILL(n) { break; } -static int action_line13_r1 +static int action_line22_r1 ( unsigned *pkix , const YYKEYTYPE *keys , const YYCTYPE *start @@ -73,7 +73,7 @@ static int action_line13_r1 if (rule_exp == 255) { fprintf ( stderr - , "warning: lex_line13_r1: control flow is undefined for input" + , "warning: lex_line22_r1: control flow is undefined for input" " at position %ld, rerun re2c with '-W'\n" , pos ); @@ -85,7 +85,7 @@ static int action_line13_r1 } else { fprintf ( stderr - , "error: lex_line13_r1: at position %ld (key %u):\n" + , "error: lex_line22_r1: at position %ld (key %u):\n" "\texpected: match length %ld, rule %u\n" "\tactual: match length %ld, rule %u\n" , pos @@ -99,14 +99,14 @@ static int action_line13_r1 } } -static int check_key_count_line13_r1(unsigned have, unsigned used, unsigned need) +static int check_key_count_line22_r1(unsigned have, unsigned used, unsigned need) { if (used + need <= have) return 0; - fprintf(stderr, "error: lex_line13_r1: not enough keys\n"); + fprintf(stderr, "error: lex_line22_r1: not enough keys\n"); return 1; } -int lex_line13_r1() +int lex_line22_r1() { const size_t padding = 1; /* YYMAXFILL */ int status = 0; @@ -121,7 +121,7 @@ int lex_line13_r1() unsigned int i = 0; input = (YYCTYPE *) read_file - ("repeat-01.cgir--skeleton.c.line13_r1.input" + ("repeat-01.cgir--skeleton.c.line22_r1.input" , sizeof (YYCTYPE) , padding , &input_len @@ -132,7 +132,7 @@ int lex_line13_r1() } keys = (YYKEYTYPE *) read_file - ("repeat-01.cgir--skeleton.c.line13_r1.keys" + ("repeat-01.cgir--skeleton.c.line22_r1.keys" , sizeof (YYKEYTYPE) , 0 , &keys_count @@ -164,23 +164,23 @@ int lex_line13_r1() yy3: yy4: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 2); + status = check_key_count_line22_r1(keys_count, i, 3) + || action_line22_r1(&i, keys, input, token, &cursor, 2); continue; yy6: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 3); + status = check_key_count_line22_r1(keys_count, i, 3) + || action_line22_r1(&i, keys, input, token, &cursor, 3); continue; yy8: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 0); + status = check_key_count_line22_r1(keys_count, i, 3) + || action_line22_r1(&i, keys, input, token, &cursor, 0); continue; yy10: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 1); + status = check_key_count_line22_r1(keys_count, i, 3) + || action_line22_r1(&i, keys, input, token, &cursor, 1); continue; } @@ -188,11 +188,11 @@ yy10: if (cursor != eof) { status = 1; const long pos = token - input; - fprintf(stderr, "error: lex_line13_r1: unused input strings left at position %ld\n", pos); + fprintf(stderr, "error: lex_line22_r1: unused input strings left at position %ld\n", pos); } if (i != keys_count) { status = 1; - fprintf(stderr, "error: lex_line13_r1: unused keys left after %u keys\n", i); + fprintf(stderr, "error: lex_line22_r1: unused keys left after %u keys\n", i); } } @@ -217,7 +217,7 @@ end: #define YYLESSTHAN(n) (limit - cursor) < n #define YYFILL(n) { break; } -static int action_line13_r2 +static int action_line22_r2 ( unsigned *pkix , const YYKEYTYPE *keys , const YYCTYPE *start @@ -235,7 +235,7 @@ static int action_line13_r2 if (rule_exp == 255) { fprintf ( stderr - , "warning: lex_line13_r2: control flow is undefined for input" + , "warning: lex_line22_r2: control flow is undefined for input" " at position %ld, rerun re2c with '-W'\n" , pos ); @@ -247,7 +247,7 @@ static int action_line13_r2 } else { fprintf ( stderr - , "error: lex_line13_r2: at position %ld (key %u):\n" + , "error: lex_line22_r2: at position %ld (key %u):\n" "\texpected: match length %ld, rule %u\n" "\tactual: match length %ld, rule %u\n" , pos @@ -261,14 +261,14 @@ static int action_line13_r2 } } -static int check_key_count_line13_r2(unsigned have, unsigned used, unsigned need) +static int check_key_count_line22_r2(unsigned have, unsigned used, unsigned need) { if (used + need <= have) return 0; - fprintf(stderr, "error: lex_line13_r2: not enough keys\n"); + fprintf(stderr, "error: lex_line22_r2: not enough keys\n"); return 1; } -int lex_line13_r2() +int lex_line22_r2() { const size_t padding = 1; /* YYMAXFILL */ int status = 0; @@ -283,7 +283,7 @@ int lex_line13_r2() unsigned int i = 0; input = (YYCTYPE *) read_file - ("repeat-01.cgir--skeleton.c.line13_r2.input" + ("repeat-01.cgir--skeleton.c.line22_r2.input" , sizeof (YYCTYPE) , padding , &input_len @@ -294,7 +294,7 @@ int lex_line13_r2() } keys = (YYKEYTYPE *) read_file - ("repeat-01.cgir--skeleton.c.line13_r2.keys" + ("repeat-01.cgir--skeleton.c.line22_r2.keys" , sizeof (YYKEYTYPE) , 0 , &keys_count @@ -324,18 +324,18 @@ int lex_line13_r2() yy15: yy16: YYSKIP (); - status = check_key_count_line13_r2(keys_count, i, 3) - || action_line13_r2(&i, keys, input, token, &cursor, 1); + status = check_key_count_line22_r2(keys_count, i, 3) + || action_line22_r2(&i, keys, input, token, &cursor, 1); continue; yy18: YYSKIP (); - status = check_key_count_line13_r2(keys_count, i, 3) - || action_line13_r2(&i, keys, input, token, &cursor, 2); + status = check_key_count_line22_r2(keys_count, i, 3) + || action_line22_r2(&i, keys, input, token, &cursor, 2); continue; yy20: YYSKIP (); - status = check_key_count_line13_r2(keys_count, i, 3) - || action_line13_r2(&i, keys, input, token, &cursor, 0); + status = check_key_count_line22_r2(keys_count, i, 3) + || action_line22_r2(&i, keys, input, token, &cursor, 0); continue; } @@ -343,11 +343,645 @@ yy20: if (cursor != eof) { status = 1; const long pos = token - input; - fprintf(stderr, "error: lex_line13_r2: unused input strings left at position %ld\n", pos); + fprintf(stderr, "error: lex_line22_r2: unused input strings left at position %ld\n", pos); } if (i != keys_count) { status = 1; - fprintf(stderr, "error: lex_line13_r2: unused keys left after %u keys\n", i); + fprintf(stderr, "error: lex_line22_r2: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line34_r1 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line34_r1: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line34_r1: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line34_r1(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line34_r1: not enough keys\n"); + return 1; +} + +int lex_line34_r1() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line34_r1.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line34_r1.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy3; + if (yych <= '1') goto yy4; + goto yy6; + } else { + if (yych <= '`') goto yy3; + if (yych <= 'a') goto yy8; + if (yych <= 'b') goto yy10; + } +yy3: +yy4: + YYSKIP (); + status = check_key_count_line34_r1(keys_count, i, 3) + || action_line34_r1(&i, keys, input, token, &cursor, 2); + continue; +yy6: + YYSKIP (); + status = check_key_count_line34_r1(keys_count, i, 3) + || action_line34_r1(&i, keys, input, token, &cursor, 3); + continue; +yy8: + YYSKIP (); + status = check_key_count_line34_r1(keys_count, i, 3) + || action_line34_r1(&i, keys, input, token, &cursor, 0); + continue; +yy10: + YYSKIP (); + status = check_key_count_line34_r1(keys_count, i, 3) + || action_line34_r1(&i, keys, input, token, &cursor, 1); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line34_r1: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line34_r1: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line34_r2 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line34_r2: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line34_r2: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line34_r2(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line34_r2: not enough keys\n"); + return 1; +} + +int lex_line34_r2() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line34_r2.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line34_r2.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy15; + if (yych <= '1') goto yy16; + goto yy18; + } else { + if (yych == 'b') goto yy20; + } +yy15: +yy16: + YYSKIP (); + status = check_key_count_line34_r2(keys_count, i, 3) + || action_line34_r2(&i, keys, input, token, &cursor, 1); + continue; +yy18: + YYSKIP (); + status = check_key_count_line34_r2(keys_count, i, 3) + || action_line34_r2(&i, keys, input, token, &cursor, 2); + continue; +yy20: + YYSKIP (); + status = check_key_count_line34_r2(keys_count, i, 3) + || action_line34_r2(&i, keys, input, token, &cursor, 0); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line34_r2: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line34_r2: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line46_r1 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line46_r1: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line46_r1: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line46_r1(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line46_r1: not enough keys\n"); + return 1; +} + +int lex_line46_r1() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line46_r1.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line46_r1.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy3; + if (yych <= '1') goto yy4; + goto yy6; + } else { + if (yych <= '`') goto yy3; + if (yych <= 'a') goto yy8; + if (yych <= 'b') goto yy10; + } +yy3: +yy4: + YYSKIP (); + status = check_key_count_line46_r1(keys_count, i, 3) + || action_line46_r1(&i, keys, input, token, &cursor, 2); + continue; +yy6: + YYSKIP (); + status = check_key_count_line46_r1(keys_count, i, 3) + || action_line46_r1(&i, keys, input, token, &cursor, 3); + continue; +yy8: + YYSKIP (); + status = check_key_count_line46_r1(keys_count, i, 3) + || action_line46_r1(&i, keys, input, token, &cursor, 0); + continue; +yy10: + YYSKIP (); + status = check_key_count_line46_r1(keys_count, i, 3) + || action_line46_r1(&i, keys, input, token, &cursor, 1); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line46_r1: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line46_r1: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line46_r2 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line46_r2: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line46_r2: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line46_r2(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line46_r2: not enough keys\n"); + return 1; +} + +int lex_line46_r2() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line46_r2.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-01.cgir--skeleton.c.line46_r2.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy15; + if (yych <= '1') goto yy16; + goto yy18; + } else { + if (yych == 'b') goto yy20; + } +yy15: +yy16: + YYSKIP (); + status = check_key_count_line46_r2(keys_count, i, 3) + || action_line46_r2(&i, keys, input, token, &cursor, 1); + continue; +yy18: + YYSKIP (); + status = check_key_count_line46_r2(keys_count, i, 3) + || action_line46_r2(&i, keys, input, token, &cursor, 2); + continue; +yy20: + YYSKIP (); + status = check_key_count_line46_r2(keys_count, i, 3) + || action_line46_r2(&i, keys, input, token, &cursor, 0); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line46_r2: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line46_r2: unused keys left after %u keys\n", i); } } @@ -367,15 +1001,39 @@ end: int main() { - if(lex_line13_r1() != 0) { + if(lex_line22_r1() != 0) { + return 1; + } + if(lex_line22_r2() != 0) { + return 1; + } + if(lex_line34_r1() != 0) { + return 1; + } + if(lex_line34_r2() != 0) { + return 1; + } + if(lex_line46_r1() != 0) { return 1; } - if(lex_line13_r2() != 0) { + if(lex_line46_r2() != 0) { return 1; } return 0; } 12ab  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12ab +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12ab +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12ab +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿre2c: warning: line 13: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] re2c: warning: line 13: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 22: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 22: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 34: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 34: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 46: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 46: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] diff --git a/re2c/test/repeat-01.cgir.c b/re2c/test/repeat-01.cgir.c index 5618c966..d726ab59 100644 --- a/re2c/test/repeat-01.cgir.c +++ b/re2c/test/repeat-01.cgir.c @@ -192,3 +192,9 @@ yy19: re2c: warning: line 13: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] re2c: warning: line 13: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 22: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 22: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 34: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 34: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 46: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 46: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] diff --git a/re2c/test/repeat-02.cgir--skeleton.c b/re2c/test/repeat-02.cgir--skeleton.c index 2159dbc7..52b12aa3 100644 --- a/re2c/test/repeat-02.cgir--skeleton.c +++ b/re2c/test/repeat-02.cgir--skeleton.c @@ -55,7 +55,7 @@ error: #define YYLESSTHAN(n) (limit - cursor) < n #define YYFILL(n) { break; } -static int action_line13_r1 +static int action_line20_r1 ( unsigned *pkix , const YYKEYTYPE *keys , const YYCTYPE *start @@ -73,7 +73,7 @@ static int action_line13_r1 if (rule_exp == 255) { fprintf ( stderr - , "warning: lex_line13_r1: control flow is undefined for input" + , "warning: lex_line20_r1: control flow is undefined for input" " at position %ld, rerun re2c with '-W'\n" , pos ); @@ -85,7 +85,7 @@ static int action_line13_r1 } else { fprintf ( stderr - , "error: lex_line13_r1: at position %ld (key %u):\n" + , "error: lex_line20_r1: at position %ld (key %u):\n" "\texpected: match length %ld, rule %u\n" "\tactual: match length %ld, rule %u\n" , pos @@ -99,14 +99,14 @@ static int action_line13_r1 } } -static int check_key_count_line13_r1(unsigned have, unsigned used, unsigned need) +static int check_key_count_line20_r1(unsigned have, unsigned used, unsigned need) { if (used + need <= have) return 0; - fprintf(stderr, "error: lex_line13_r1: not enough keys\n"); + fprintf(stderr, "error: lex_line20_r1: not enough keys\n"); return 1; } -int lex_line13_r1() +int lex_line20_r1() { const size_t padding = 1; /* YYMAXFILL */ int status = 0; @@ -121,7 +121,7 @@ int lex_line13_r1() unsigned int i = 0; input = (YYCTYPE *) read_file - ("repeat-02.cgir--skeleton.c.line13_r1.input" + ("repeat-02.cgir--skeleton.c.line20_r1.input" , sizeof (YYCTYPE) , padding , &input_len @@ -132,7 +132,7 @@ int lex_line13_r1() } keys = (YYKEYTYPE *) read_file - ("repeat-02.cgir--skeleton.c.line13_r1.keys" + ("repeat-02.cgir--skeleton.c.line20_r1.keys" , sizeof (YYKEYTYPE) , 0 , &keys_count @@ -164,23 +164,23 @@ int lex_line13_r1() yy3: yy4: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 2); + status = check_key_count_line20_r1(keys_count, i, 3) + || action_line20_r1(&i, keys, input, token, &cursor, 2); continue; yy6: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 3); + status = check_key_count_line20_r1(keys_count, i, 3) + || action_line20_r1(&i, keys, input, token, &cursor, 3); continue; yy8: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 0); + status = check_key_count_line20_r1(keys_count, i, 3) + || action_line20_r1(&i, keys, input, token, &cursor, 0); continue; yy10: YYSKIP (); - status = check_key_count_line13_r1(keys_count, i, 3) - || action_line13_r1(&i, keys, input, token, &cursor, 1); + status = check_key_count_line20_r1(keys_count, i, 3) + || action_line20_r1(&i, keys, input, token, &cursor, 1); continue; } @@ -188,11 +188,11 @@ yy10: if (cursor != eof) { status = 1; const long pos = token - input; - fprintf(stderr, "error: lex_line13_r1: unused input strings left at position %ld\n", pos); + fprintf(stderr, "error: lex_line20_r1: unused input strings left at position %ld\n", pos); } if (i != keys_count) { status = 1; - fprintf(stderr, "error: lex_line13_r1: unused keys left after %u keys\n", i); + fprintf(stderr, "error: lex_line20_r1: unused keys left after %u keys\n", i); } } @@ -217,7 +217,7 @@ end: #define YYLESSTHAN(n) (limit - cursor) < n #define YYFILL(n) { break; } -static int action_line13_r2 +static int action_line20_r2 ( unsigned *pkix , const YYKEYTYPE *keys , const YYCTYPE *start @@ -235,7 +235,7 @@ static int action_line13_r2 if (rule_exp == 255) { fprintf ( stderr - , "warning: lex_line13_r2: control flow is undefined for input" + , "warning: lex_line20_r2: control flow is undefined for input" " at position %ld, rerun re2c with '-W'\n" , pos ); @@ -247,7 +247,7 @@ static int action_line13_r2 } else { fprintf ( stderr - , "error: lex_line13_r2: at position %ld (key %u):\n" + , "error: lex_line20_r2: at position %ld (key %u):\n" "\texpected: match length %ld, rule %u\n" "\tactual: match length %ld, rule %u\n" , pos @@ -261,14 +261,14 @@ static int action_line13_r2 } } -static int check_key_count_line13_r2(unsigned have, unsigned used, unsigned need) +static int check_key_count_line20_r2(unsigned have, unsigned used, unsigned need) { if (used + need <= have) return 0; - fprintf(stderr, "error: lex_line13_r2: not enough keys\n"); + fprintf(stderr, "error: lex_line20_r2: not enough keys\n"); return 1; } -int lex_line13_r2() +int lex_line20_r2() { const size_t padding = 1; /* YYMAXFILL */ int status = 0; @@ -283,7 +283,7 @@ int lex_line13_r2() unsigned int i = 0; input = (YYCTYPE *) read_file - ("repeat-02.cgir--skeleton.c.line13_r2.input" + ("repeat-02.cgir--skeleton.c.line20_r2.input" , sizeof (YYCTYPE) , padding , &input_len @@ -294,7 +294,7 @@ int lex_line13_r2() } keys = (YYKEYTYPE *) read_file - ("repeat-02.cgir--skeleton.c.line13_r2.keys" + ("repeat-02.cgir--skeleton.c.line20_r2.keys" , sizeof (YYKEYTYPE) , 0 , &keys_count @@ -324,18 +324,18 @@ int lex_line13_r2() yy15: yy16: YYSKIP (); - status = check_key_count_line13_r2(keys_count, i, 3) - || action_line13_r2(&i, keys, input, token, &cursor, 1); + status = check_key_count_line20_r2(keys_count, i, 3) + || action_line20_r2(&i, keys, input, token, &cursor, 1); continue; yy18: YYSKIP (); - status = check_key_count_line13_r2(keys_count, i, 3) - || action_line13_r2(&i, keys, input, token, &cursor, 2); + status = check_key_count_line20_r2(keys_count, i, 3) + || action_line20_r2(&i, keys, input, token, &cursor, 2); continue; yy20: YYSKIP (); - status = check_key_count_line13_r2(keys_count, i, 3) - || action_line13_r2(&i, keys, input, token, &cursor, 0); + status = check_key_count_line20_r2(keys_count, i, 3) + || action_line20_r2(&i, keys, input, token, &cursor, 0); continue; } @@ -343,11 +343,645 @@ yy20: if (cursor != eof) { status = 1; const long pos = token - input; - fprintf(stderr, "error: lex_line13_r2: unused input strings left at position %ld\n", pos); + fprintf(stderr, "error: lex_line20_r2: unused input strings left at position %ld\n", pos); } if (i != keys_count) { status = 1; - fprintf(stderr, "error: lex_line13_r2: unused keys left after %u keys\n", i); + fprintf(stderr, "error: lex_line20_r2: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line32_r1 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line32_r1: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line32_r1: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line32_r1(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line32_r1: not enough keys\n"); + return 1; +} + +int lex_line32_r1() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line32_r1.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line32_r1.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy3; + if (yych <= '1') goto yy4; + goto yy6; + } else { + if (yych <= '`') goto yy3; + if (yych <= 'a') goto yy8; + if (yych <= 'b') goto yy10; + } +yy3: +yy4: + YYSKIP (); + status = check_key_count_line32_r1(keys_count, i, 3) + || action_line32_r1(&i, keys, input, token, &cursor, 2); + continue; +yy6: + YYSKIP (); + status = check_key_count_line32_r1(keys_count, i, 3) + || action_line32_r1(&i, keys, input, token, &cursor, 3); + continue; +yy8: + YYSKIP (); + status = check_key_count_line32_r1(keys_count, i, 3) + || action_line32_r1(&i, keys, input, token, &cursor, 0); + continue; +yy10: + YYSKIP (); + status = check_key_count_line32_r1(keys_count, i, 3) + || action_line32_r1(&i, keys, input, token, &cursor, 1); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line32_r1: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line32_r1: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line32_r2 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line32_r2: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line32_r2: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line32_r2(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line32_r2: not enough keys\n"); + return 1; +} + +int lex_line32_r2() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line32_r2.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line32_r2.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy15; + if (yych <= '1') goto yy16; + goto yy18; + } else { + if (yych == 'b') goto yy20; + } +yy15: +yy16: + YYSKIP (); + status = check_key_count_line32_r2(keys_count, i, 3) + || action_line32_r2(&i, keys, input, token, &cursor, 1); + continue; +yy18: + YYSKIP (); + status = check_key_count_line32_r2(keys_count, i, 3) + || action_line32_r2(&i, keys, input, token, &cursor, 2); + continue; +yy20: + YYSKIP (); + status = check_key_count_line32_r2(keys_count, i, 3) + || action_line32_r2(&i, keys, input, token, &cursor, 0); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line32_r2: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line32_r2: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line44_r1 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line44_r1: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line44_r1: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line44_r1(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line44_r1: not enough keys\n"); + return 1; +} + +int lex_line44_r1() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line44_r1.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line44_r1.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy3; + if (yych <= '1') goto yy4; + goto yy6; + } else { + if (yych <= '`') goto yy3; + if (yych <= 'a') goto yy8; + if (yych <= 'b') goto yy10; + } +yy3: +yy4: + YYSKIP (); + status = check_key_count_line44_r1(keys_count, i, 3) + || action_line44_r1(&i, keys, input, token, &cursor, 2); + continue; +yy6: + YYSKIP (); + status = check_key_count_line44_r1(keys_count, i, 3) + || action_line44_r1(&i, keys, input, token, &cursor, 3); + continue; +yy8: + YYSKIP (); + status = check_key_count_line44_r1(keys_count, i, 3) + || action_line44_r1(&i, keys, input, token, &cursor, 0); + continue; +yy10: + YYSKIP (); + status = check_key_count_line44_r1(keys_count, i, 3) + || action_line44_r1(&i, keys, input, token, &cursor, 1); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line44_r1: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line44_r1: unused keys left after %u keys\n", i); + } + } + +end: + free(input); + free(keys); + + return status; +} + +#undef YYCTYPE +#undef YYKEYTYPE +#undef YYPEEK +#undef YYSKIP +#undef YYLESSTHAN +#undef YYFILL + +#define YYCTYPE unsigned char +#define YYKEYTYPE unsigned char +#define YYPEEK() *cursor +#define YYSKIP() ++cursor +#define YYLESSTHAN(n) (limit - cursor) < n +#define YYFILL(n) { break; } + +static int action_line44_r2 + ( unsigned *pkix + , const YYKEYTYPE *keys + , const YYCTYPE *start + , const YYCTYPE *token + , const YYCTYPE **cursor + , YYKEYTYPE rule_act + ) +{ + const unsigned kix = *pkix; + const long pos = token - start; + const long len_act = *cursor - token; + const long len_exp = (long) keys[kix + 1]; + const YYKEYTYPE rule_exp = keys[kix + 2]; + *pkix = kix + 3; + if (rule_exp == 255) { + fprintf + ( stderr + , "warning: lex_line44_r2: control flow is undefined for input" + " at position %ld, rerun re2c with '-W'\n" + , pos + ); + } + if (len_act == len_exp && rule_act == rule_exp) { + const YYKEYTYPE offset = keys[kix]; + *cursor = token + offset; + return 0; + } else { + fprintf + ( stderr + , "error: lex_line44_r2: at position %ld (key %u):\n" + "\texpected: match length %ld, rule %u\n" + "\tactual: match length %ld, rule %u\n" + , pos + , kix + , len_exp + , rule_exp + , len_act + , rule_act + ); + return 1; + } +} + +static int check_key_count_line44_r2(unsigned have, unsigned used, unsigned need) +{ + if (used + need <= have) return 0; + fprintf(stderr, "error: lex_line44_r2: not enough keys\n"); + return 1; +} + +int lex_line44_r2() +{ + const size_t padding = 1; /* YYMAXFILL */ + int status = 0; + size_t input_len = 0; + size_t keys_count = 0; + YYCTYPE *input = NULL; + YYKEYTYPE *keys = NULL; + const YYCTYPE *cursor = NULL; + const YYCTYPE *limit = NULL; + const YYCTYPE *token = NULL; + const YYCTYPE *eof = NULL; + unsigned int i = 0; + + input = (YYCTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line44_r2.input" + , sizeof (YYCTYPE) + , padding + , &input_len + ); + if (input == NULL) { + status = 1; + goto end; + } + + keys = (YYKEYTYPE *) read_file + ("repeat-02.cgir--skeleton.c.line44_r2.keys" + , sizeof (YYKEYTYPE) + , 0 + , &keys_count + ); + if (keys == NULL) { + status = 1; + goto end; + } + + cursor = input; + limit = input + input_len + padding; + eof = input + input_len; + + for (i = 0; status == 0 && cursor < eof && i < keys_count;) { + token = cursor; + YYCTYPE yych; + + if (YYLESSTHAN (1)) YYFILL(1); + yych = YYPEEK (); + if (yych <= '2') { + if (yych <= '0') goto yy15; + if (yych <= '1') goto yy16; + goto yy18; + } else { + if (yych == 'b') goto yy20; + } +yy15: +yy16: + YYSKIP (); + status = check_key_count_line44_r2(keys_count, i, 3) + || action_line44_r2(&i, keys, input, token, &cursor, 1); + continue; +yy18: + YYSKIP (); + status = check_key_count_line44_r2(keys_count, i, 3) + || action_line44_r2(&i, keys, input, token, &cursor, 2); + continue; +yy20: + YYSKIP (); + status = check_key_count_line44_r2(keys_count, i, 3) + || action_line44_r2(&i, keys, input, token, &cursor, 0); + continue; + + } + if (status == 0) { + if (cursor != eof) { + status = 1; + const long pos = token - input; + fprintf(stderr, "error: lex_line44_r2: unused input strings left at position %ld\n", pos); + } + if (i != keys_count) { + status = 1; + fprintf(stderr, "error: lex_line44_r2: unused keys left after %u keys\n", i); } } @@ -367,15 +1001,39 @@ end: int main() { - if(lex_line13_r1() != 0) { + if(lex_line20_r1() != 0) { + return 1; + } + if(lex_line20_r2() != 0) { + return 1; + } + if(lex_line32_r1() != 0) { + return 1; + } + if(lex_line32_r2() != 0) { + return 1; + } + if(lex_line44_r1() != 0) { return 1; } - if(lex_line13_r2() != 0) { + if(lex_line44_r2() != 0) { return 1; } return 0; } 12ab  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12ab +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12ab +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12ab +  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`cdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ12b  !"#$%&'()*+,-./03456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿre2c: warning: line 13: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] re2c: warning: line 13: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 20: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 20: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 32: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 32: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 44: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 44: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] diff --git a/re2c/test/repeat-02.cgir.c b/re2c/test/repeat-02.cgir.c index d3fa94d8..601b0fab 100644 --- a/re2c/test/repeat-02.cgir.c +++ b/re2c/test/repeat-02.cgir.c @@ -192,3 +192,9 @@ yy19: re2c: warning: line 13: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] re2c: warning: line 13: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 20: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 20: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 32: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 32: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 44: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 44: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] diff --git a/re2c/test/repeat-04.cgir.c b/re2c/test/repeat-04.cgir.c index c4e18734..d1e9b6ff 100644 --- a/re2c/test/repeat-04.cgir.c +++ b/re2c/test/repeat-04.cgir.c @@ -1,3 +1,5 @@ re2c: warning: line 14: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] re2c: warning: line 14: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 18: control flow in condition 'r1' is undefined for strings that match '[\x0-\x30\x33-\x60\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] +re2c: warning: line 18: control flow in condition 'r2' is undefined for strings that match '[\x0-\x30\x33-\x61\x63-\xFF]', use default rule '*' [-Wundefined-control-flow] re2c: error: line 20, column 1: cannot have a second 'rules:re2c' block diff --git a/re2c/test/repeat-07_error.gir.c b/re2c/test/repeat-07_error.gir.c index 93f46cad..4a06b113 100644 --- a/re2c/test/repeat-07_error.gir.c +++ b/re2c/test/repeat-07_error.gir.c @@ -1,4 +1,4 @@ re2c: warning: line 14: control flow is undefined for strings that match '[\x0-\x60\x65-\xFF]', use default rule '*' [-Wundefined-control-flow] re2c: warning: line 27: control flow is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow] re2c: warning: line 45: control flow is undefined for strings that match '\xA', use default rule '*' [-Wundefined-control-flow] -re2c: error: line 52, column 1: Cannot set UTF32 encoding: please reset USC2 encoding first +re2c: error: line 53, column 1: Cannot set USC2 encoding: please reset UTF32 encoding first diff --git a/re2c/test/repeat-08.ir.c b/re2c/test/repeat-08.ir.c new file mode 100644 index 00000000..a4c25862 --- /dev/null +++ b/re2c/test/repeat-08.ir.c @@ -0,0 +1,5 @@ +/* Generated by re2c */ +// empty rules block should not trigger error + + + diff --git a/re2c/test/repeat-08.ir.re b/re2c/test/repeat-08.ir.re new file mode 100644 index 00000000..74930fc3 --- /dev/null +++ b/re2c/test/repeat-08.ir.re @@ -0,0 +1,4 @@ +// empty rules block should not trigger error + +/*!rules:re2c*/ +/*!use:re2c*/ diff --git a/re2c/test/repeat-09.ir.c b/re2c/test/repeat-09.ir.c new file mode 100644 index 00000000..1e17df47 --- /dev/null +++ b/re2c/test/repeat-09.ir.c @@ -0,0 +1,22 @@ +/* Generated by re2c */ +// 2nd use block must inherit options from rules block, not from the 1st use block + + + + + { + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR++; + {} + } + + + +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR++; + {} +} + diff --git a/re2c/test/repeat-09.ir.re b/re2c/test/repeat-09.ir.re new file mode 100644 index 00000000..a3c76772 --- /dev/null +++ b/re2c/test/repeat-09.ir.re @@ -0,0 +1,11 @@ +// 2nd use block must inherit options from rules block, not from the 1st use block + +/*!rules:re2c + * {} +*/ + +/*!use:re2c + re2c:indent:top = 3; +*/ + +/*!use:re2c*/