From 9b49cd3c4f7a4c4c5e35291583e6a33d4b1fb2a2 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Tue, 10 May 2016 16:48:29 +0100 Subject: [PATCH] Fixed parsing of some configurations (forgot to parse semicolon). Added test for various 're2c:flags:' configurations. --- re2c/bootstrap/src/parse/lex_conf.cc | 130 ++++++++++++++------------- re2c/src/parse/lex_conf.re | 28 +++--- re2c/test/config/flags.c | 7 ++ re2c/test/config/flags.re | 56 ++++++++++++ 4 files changed, 150 insertions(+), 71 deletions(-) create mode 100644 re2c/test/config/flags.c create mode 100644 re2c/test/config/flags.re diff --git a/re2c/bootstrap/src/parse/lex_conf.cc b/re2c/bootstrap/src/parse/lex_conf.cc index 51a6a6d4..1656edd3 100644 --- a/re2c/bootstrap/src/parse/lex_conf.cc +++ b/re2c/bootstrap/src/parse/lex_conf.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Tue May 10 13:05:36 2016 */ +/* Generated by re2c 0.16 on Tue May 10 16:46:34 2016 */ #line 1 "../src/parse/lex_conf.re" #include "src/util/c99_stdint.h" #include @@ -3205,7 +3205,7 @@ yy770: yy771: ++cur; #line 178 "../src/parse/lex_conf.re" - { opts.set_encoding_policy(Enc::POLICY_FAIL); return; } + { opts.set_encoding_policy(Enc::POLICY_FAIL); goto end; } #line 3210 "src/parse/lex_conf.cc" yy773: yych = (unsigned char)*++cur; @@ -3226,7 +3226,7 @@ yy776: yy777: ++cur; #line 176 "../src/parse/lex_conf.re" - { opts.set_encoding_policy(Enc::POLICY_IGNORE); return; } + { opts.set_encoding_policy(Enc::POLICY_IGNORE); goto end; } #line 3231 "src/parse/lex_conf.cc" yy779: yych = (unsigned char)*++cur; @@ -3239,18 +3239,20 @@ yy779: if (yych != 'e') goto yy765; ++cur; #line 177 "../src/parse/lex_conf.re" - { opts.set_encoding_policy(Enc::POLICY_SUBSTITUTE); return; } + { opts.set_encoding_policy(Enc::POLICY_SUBSTITUTE); goto end; } #line 3244 "src/parse/lex_conf.cc" } #line 179 "../src/parse/lex_conf.re" +end: + lex_conf_semicolon(); } void Scanner::lex_conf_input() { lex_conf_assign (); -#line 3254 "src/parse/lex_conf.cc" +#line 3256 "src/parse/lex_conf.cc" { unsigned char yych; if ((lim - cur) < 7) fill(7); @@ -3261,10 +3263,10 @@ void Scanner::lex_conf_input() yy787: ++cur; yy788: -#line 186 "../src/parse/lex_conf.re" +#line 188 "../src/parse/lex_conf.re" { fatal("bad configuration value" " (expected: 'default', 'custom')"); } -#line 3268 "src/parse/lex_conf.cc" +#line 3270 "src/parse/lex_conf.cc" yy789: yych = (unsigned char)*(ptr = ++cur); if (yych == 'u') goto yy791; @@ -3309,26 +3311,28 @@ yy799: goto yy792; yy800: ++cur; -#line 189 "../src/parse/lex_conf.re" - { opts.set_input_api(InputAPI::CUSTOM); return; } -#line 3315 "src/parse/lex_conf.cc" +#line 191 "../src/parse/lex_conf.re" + { opts.set_input_api(InputAPI::CUSTOM); goto end; } +#line 3317 "src/parse/lex_conf.cc" yy802: yych = (unsigned char)*++cur; if (yych != 't') goto yy792; ++cur; -#line 188 "../src/parse/lex_conf.re" - { opts.set_input_api(InputAPI::DEFAULT); return; } -#line 3322 "src/parse/lex_conf.cc" -} #line 190 "../src/parse/lex_conf.re" + { opts.set_input_api(InputAPI::DEFAULT); goto end; } +#line 3324 "src/parse/lex_conf.cc" +} +#line 192 "../src/parse/lex_conf.re" +end: + lex_conf_semicolon(); } void Scanner::lex_conf_empty_class() { lex_conf_assign (); -#line 3332 "src/parse/lex_conf.cc" +#line 3336 "src/parse/lex_conf.cc" { unsigned char yych; if ((lim - cur) < 11) fill(11); @@ -3337,10 +3341,10 @@ void Scanner::lex_conf_empty_class() if (yych == 'm') goto yy810; ++cur; yy808: -#line 197 "../src/parse/lex_conf.re" +#line 201 "../src/parse/lex_conf.re" { fatal("bad configuration value" " (expected: 'match-empty', 'match-none', 'error')"); } -#line 3344 "src/parse/lex_conf.cc" +#line 3348 "src/parse/lex_conf.cc" yy809: yych = (unsigned char)*(ptr = ++cur); if (yych == 'r') goto yy811; @@ -3377,9 +3381,9 @@ yy817: goto yy812; yy818: ++cur; -#line 201 "../src/parse/lex_conf.re" - { opts.set_empty_class_policy(EMPTY_CLASS_ERROR); return; } -#line 3383 "src/parse/lex_conf.cc" +#line 205 "../src/parse/lex_conf.re" + { opts.set_empty_class_policy(EMPTY_CLASS_ERROR); goto end; } +#line 3387 "src/parse/lex_conf.cc" yy820: yych = (unsigned char)*++cur; if (yych != '-') goto yy812; @@ -3417,24 +3421,26 @@ yy828: goto yy812; yy829: ++cur; -#line 200 "../src/parse/lex_conf.re" - { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_NONE); return; } -#line 3423 "src/parse/lex_conf.cc" +#line 204 "../src/parse/lex_conf.re" + { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_NONE); goto end; } +#line 3427 "src/parse/lex_conf.cc" yy831: ++cur; -#line 199 "../src/parse/lex_conf.re" - { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_EMPTY); return; } -#line 3428 "src/parse/lex_conf.cc" +#line 203 "../src/parse/lex_conf.re" + { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_EMPTY); goto end; } +#line 3432 "src/parse/lex_conf.cc" } -#line 202 "../src/parse/lex_conf.re" +#line 206 "../src/parse/lex_conf.re" +end: + lex_conf_semicolon(); } void Scanner::lex_conf_dfa_minimization() { lex_conf_assign (); -#line 3438 "src/parse/lex_conf.cc" +#line 3444 "src/parse/lex_conf.cc" { unsigned char yych; if ((lim - cur) < 5) fill(5); @@ -3443,10 +3449,10 @@ void Scanner::lex_conf_dfa_minimization() if (yych == 't') goto yy838; ++cur; yy836: -#line 209 "../src/parse/lex_conf.re" +#line 215 "../src/parse/lex_conf.re" { fatal("bad configuration value" " (expected: 'table', 'moore')"); } -#line 3450 "src/parse/lex_conf.cc" +#line 3456 "src/parse/lex_conf.cc" yy837: yych = (unsigned char)*(ptr = ++cur); if (yych == 'o') goto yy839; @@ -3483,17 +3489,19 @@ yy845: goto yy840; yy846: ++cur; -#line 212 "../src/parse/lex_conf.re" - { opts.set_dfa_minimization(DFA_MINIMIZATION_MOORE); return; } -#line 3489 "src/parse/lex_conf.cc" +#line 218 "../src/parse/lex_conf.re" + { opts.set_dfa_minimization(DFA_MINIMIZATION_MOORE); goto end; } +#line 3495 "src/parse/lex_conf.cc" yy848: ++cur; -#line 211 "../src/parse/lex_conf.re" - { opts.set_dfa_minimization(DFA_MINIMIZATION_TABLE); return; } -#line 3494 "src/parse/lex_conf.cc" +#line 217 "../src/parse/lex_conf.re" + { opts.set_dfa_minimization(DFA_MINIMIZATION_TABLE); goto end; } +#line 3500 "src/parse/lex_conf.cc" } -#line 213 "../src/parse/lex_conf.re" +#line 219 "../src/parse/lex_conf.re" +end: + lex_conf_semicolon(); } void Scanner::lex_conf_enc(Enc::type_t enc) @@ -3511,7 +3519,7 @@ void Scanner::lex_conf_enc(Enc::type_t enc) void Scanner::lex_conf_assign () { -#line 3515 "src/parse/lex_conf.cc" +#line 3523 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3558,9 +3566,9 @@ void Scanner::lex_conf_assign () } ++cur; yy853: -#line 231 "../src/parse/lex_conf.re" +#line 239 "../src/parse/lex_conf.re" { fatal ("missing '=' in configuration"); } -#line 3564 "src/parse/lex_conf.cc" +#line 3572 "src/parse/lex_conf.cc" yy854: yych = (unsigned char)*(ptr = ++cur); if (yych <= 0x1F) { @@ -3577,9 +3585,9 @@ yy855: if (yybm[0+yych] & 128) { goto yy855; } -#line 232 "../src/parse/lex_conf.re" +#line 240 "../src/parse/lex_conf.re" { return; } -#line 3583 "src/parse/lex_conf.cc" +#line 3591 "src/parse/lex_conf.cc" yy858: ++cur; if (lim <= cur) fill(1); @@ -3593,14 +3601,14 @@ yy858: cur = ptr; goto yy853; } -#line 233 "../src/parse/lex_conf.re" +#line 241 "../src/parse/lex_conf.re" } void Scanner::lex_conf_semicolon () { -#line 3604 "src/parse/lex_conf.cc" +#line 3612 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3647,9 +3655,9 @@ void Scanner::lex_conf_semicolon () } ++cur; yy864: -#line 239 "../src/parse/lex_conf.re" +#line 247 "../src/parse/lex_conf.re" { fatal ("missing ending ';' in configuration"); } -#line 3653 "src/parse/lex_conf.cc" +#line 3661 "src/parse/lex_conf.cc" yy865: yych = (unsigned char)*(ptr = ++cur); if (yybm[0+yych] & 128) { @@ -3658,9 +3666,9 @@ yy865: if (yych != ';') goto yy864; yy866: ++cur; -#line 240 "../src/parse/lex_conf.re" +#line 248 "../src/parse/lex_conf.re" { return; } -#line 3664 "src/parse/lex_conf.cc" +#line 3672 "src/parse/lex_conf.cc" yy868: ++cur; if (lim <= cur) fill(1); @@ -3672,7 +3680,7 @@ yy868: cur = ptr; goto yy864; } -#line 241 "../src/parse/lex_conf.re" +#line 249 "../src/parse/lex_conf.re" } @@ -3686,7 +3694,7 @@ int32_t Scanner::lex_conf_number () lex_conf_assign (); tok = cur; -#line 3690 "src/parse/lex_conf.cc" +#line 3698 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3740,7 +3748,7 @@ yy874: yy875: ++cur; yy876: -#line 255 "../src/parse/lex_conf.re" +#line 263 "../src/parse/lex_conf.re" { int32_t n = 0; if (!s_to_i32_unsafe (tok, cur, n)) @@ -3750,7 +3758,7 @@ yy876: lex_conf_semicolon (); return n; } -#line 3754 "src/parse/lex_conf.cc" +#line 3762 "src/parse/lex_conf.cc" yy877: ++cur; if (lim <= cur) fill(1); @@ -3760,7 +3768,7 @@ yy877: } goto yy876; } -#line 264 "../src/parse/lex_conf.re" +#line 272 "../src/parse/lex_conf.re" } @@ -3770,7 +3778,7 @@ std::string Scanner::lex_conf_string () std::string s; tok = cur; -#line 3774 "src/parse/lex_conf.cc" +#line 3782 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3824,9 +3832,9 @@ std::string Scanner::lex_conf_string () if (yych != ';') goto yy882; } } -#line 291 "../src/parse/lex_conf.re" +#line 299 "../src/parse/lex_conf.re" { goto end; } -#line 3830 "src/parse/lex_conf.cc" +#line 3838 "src/parse/lex_conf.cc" yy882: ++cur; if (lim <= cur) fill(1); @@ -3834,15 +3842,15 @@ yy882: if (yybm[0+yych] & 128) { goto yy882; } -#line 287 "../src/parse/lex_conf.re" +#line 295 "../src/parse/lex_conf.re" { s = std::string(tok, tok_len()); goto end; } -#line 3843 "src/parse/lex_conf.cc" +#line 3851 "src/parse/lex_conf.cc" yy885: ++cur; -#line 273 "../src/parse/lex_conf.re" +#line 281 "../src/parse/lex_conf.re" { const char quote = tok[0]; for (bool end;;) { @@ -3857,9 +3865,9 @@ yy885: } } } -#line 3861 "src/parse/lex_conf.cc" +#line 3869 "src/parse/lex_conf.cc" } -#line 292 "../src/parse/lex_conf.re" +#line 300 "../src/parse/lex_conf.re" end: lex_conf_semicolon (); diff --git a/re2c/src/parse/lex_conf.re b/re2c/src/parse/lex_conf.re index 08876d48..093e3e3a 100644 --- a/re2c/src/parse/lex_conf.re +++ b/re2c/src/parse/lex_conf.re @@ -173,10 +173,12 @@ void Scanner::lex_conf_encoding_policy() /*!re2c * { fatal("bad configuration value" " (expected: 'ignore', 'substitute', 'fail')"); } - "ignore" { opts.set_encoding_policy(Enc::POLICY_IGNORE); return; } - "substitute" { opts.set_encoding_policy(Enc::POLICY_SUBSTITUTE); return; } - "fail" { opts.set_encoding_policy(Enc::POLICY_FAIL); return; } + "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(); } void Scanner::lex_conf_input() @@ -185,9 +187,11 @@ void Scanner::lex_conf_input() /*!re2c * { fatal("bad configuration value" " (expected: 'default', 'custom')"); } - "default" { opts.set_input_api(InputAPI::DEFAULT); return; } - "custom" { opts.set_input_api(InputAPI::CUSTOM); return; } + "default" { opts.set_input_api(InputAPI::DEFAULT); goto end; } + "custom" { opts.set_input_api(InputAPI::CUSTOM); goto end; } */ +end: + lex_conf_semicolon(); } void Scanner::lex_conf_empty_class() @@ -196,10 +200,12 @@ void Scanner::lex_conf_empty_class() /*!re2c * { fatal("bad configuration value" " (expected: 'match-empty', 'match-none', 'error')"); } - "match-empty" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_EMPTY); return; } - "match-none" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_NONE); return; } - "error" { opts.set_empty_class_policy(EMPTY_CLASS_ERROR); return; } + "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(); } void Scanner::lex_conf_dfa_minimization() @@ -208,9 +214,11 @@ void Scanner::lex_conf_dfa_minimization() /*!re2c * { fatal("bad configuration value" " (expected: 'table', 'moore')"); } - "table" { opts.set_dfa_minimization(DFA_MINIMIZATION_TABLE); return; } - "moore" { opts.set_dfa_minimization(DFA_MINIMIZATION_MOORE); return; } + "table" { opts.set_dfa_minimization(DFA_MINIMIZATION_TABLE); goto end; } + "moore" { opts.set_dfa_minimization(DFA_MINIMIZATION_MOORE); goto end; } */ +end: + lex_conf_semicolon(); } void Scanner::lex_conf_enc(Enc::type_t enc) diff --git a/re2c/test/config/flags.c b/re2c/test/config/flags.c new file mode 100644 index 00000000..b0d0e9d5 --- /dev/null +++ b/re2c/test/config/flags.c @@ -0,0 +1,7 @@ +/* Generated by re2c */ +#line 1 "flags.re" + +int main() +{ + return 0; +} diff --git a/re2c/test/config/flags.re b/re2c/test/config/flags.re new file mode 100644 index 00000000..67aec08a --- /dev/null +++ b/re2c/test/config/flags.re @@ -0,0 +1,56 @@ +/*!re2c + re2c:flags:D; + re2c:flags:emit-dot; + re2c:flags:S; + re2c:flags:skeleton; + + re2c:flags:b = 0; + re2c:flags:bit-vectors = 1; + re2c:flags:c = 0; + re2c:flags:start-conditions = 1; + re2c:flags:d = 0; + re2c:flags:debug-output = 1; + re2c:flags:f = 0; + re2c:flags:storable-state = 1; + re2c:flags:F = 0; + re2c:flags:flex-syntax = 1; + re2c:flags:g = 0; + re2c:flags:computed-gotos = 1; + re2c:flags:i = 0; + re2c:flags:no-debug-info = 1; + re2c:flags:r = 0; + re2c:flags:reusable = 1; + re2c:flags:s = 0; + re2c:flags:nested-ifs = 1; + re2c:flags:T = 0; + re2c:flags:tags = 1; + re2c:flags:no-generation-date = 0; + re2c:flags:no-version = 1; + re2c:flags:case-insensitive = 0; + re2c:flags:case-inverted = 1; + + re2c:flags:e = 1; + re2c:flags:ecb = 0; + re2c:flags:u = 1; + re2c:flags:unicode = 0; + re2c:flags:w = 1; + re2c:flags:wide-chars = 0; + re2c:flags:x = 1; + re2c:flags:utf-16 = 0; + re2c:flags:8 = 1; + re2c:flags:utf-8 = 0; + + re2c:flags:encoding-policy = ignore; + re2c:flags:encoding-policy = substitute; + re2c:flags:encoding-policy = fail; + + re2c:flags:input = custom; + re2c:flags:input = default; + + re2c:flags:empty-class = match-empty; + re2c:flags:empty-class = match-none; + re2c:flags:empty-class = error; + + re2c:flags:dfa-minimization = table; + re2c:flags:dfa-minimization = moore; +*/ -- 2.40.0