Skip to content

Commit

Permalink
Add configuration re2c:invert_captures.
Browse files Browse the repository at this point in the history
Make option --invert-captures configurable. This requires postponing the
decision whether a group is capturing or not to the after-parsing stage
when the configurations for a block are known and the immutable AST is
converted to a regexp.

Add a test for the new configuration.
  • Loading branch information
skvadrik committed Apr 24, 2023
1 parent dedd72d commit ce75619
Show file tree
Hide file tree
Showing 15 changed files with 1,919 additions and 1,741 deletions.
4 changes: 2 additions & 2 deletions bootstrap/lib/parse.cc
Expand Up @@ -1144,13 +1144,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);

case 13: /* primary: '(' ')' */
#line 77 "../lib/parse.ypp"
{ (yyval.regexp) = ast.cap(ast.nil(NOWHERE), true); }
{ (yyval.regexp) = ast.cap(ast.nil(NOWHERE), CAPTURE); }
#line 1149 "lib/parse.cc"
break;

case 14: /* primary: '(' expr ')' */
#line 78 "../lib/parse.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp), true); }
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp), CAPTURE); }
#line 1155 "lib/parse.cc"
break;

Expand Down
22 changes: 11 additions & 11 deletions bootstrap/src/options/parse_opts.cc
Expand Up @@ -2016,7 +2016,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy410:
++YYCURSOR;
#line 162 "../src/options/parse_opts.re"
#line 161 "../src/options/parse_opts.re"
{ opts.set_tags(true); goto opt; }
#line 2022 "src/options/parse_opts.cc"
yy411:
Expand Down Expand Up @@ -2922,7 +2922,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy630:
++YYCURSOR;
#line 163 "../src/options/parse_opts.re"
#line 162 "../src/options/parse_opts.re"
{ opts.set_unsafe(false); goto opt; }
#line 2928 "src/options/parse_opts.cc"
yy631:
Expand Down Expand Up @@ -3058,7 +3058,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy663:
++YYCURSOR;
#line 159 "../src/options/parse_opts.re"
#line 158 "../src/options/parse_opts.re"
{ opts.set_nested_ifs(true); goto opt; }
#line 3064 "src/options/parse_opts.cc"
yy664:
Expand Down Expand Up @@ -3104,7 +3104,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy674:
++YYCURSOR;
#line 155 "../src/options/parse_opts.re"
#line 154 "../src/options/parse_opts.re"
{ opts.set_bitmaps(true); goto opt; }
#line 3110 "src/options/parse_opts.cc"
yy675:
Expand All @@ -3117,7 +3117,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy677:
++YYCURSOR;
#line 157 "../src/options/parse_opts.re"
#line 156 "../src/options/parse_opts.re"
{ opts.set_case_ranges(true); goto opt; }
#line 3123 "src/options/parse_opts.cc"
yy678:
Expand Down Expand Up @@ -3247,7 +3247,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy708:
++YYCURSOR;
#line 156 "../src/options/parse_opts.re"
#line 155 "../src/options/parse_opts.re"
{ opts.set_debug(true); goto opt; }
#line 3253 "src/options/parse_opts.cc"
yy709:
Expand Down Expand Up @@ -3340,7 +3340,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy730:
++YYCURSOR;
#line 161 "../src/options/parse_opts.re"
#line 160 "../src/options/parse_opts.re"
{ opts.set_case_inverted(true); goto opt; }
#line 3346 "src/options/parse_opts.cc"
yy731:
Expand Down Expand Up @@ -3420,7 +3420,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
goto yy246;
yy749:
++YYCURSOR;
#line 158 "../src/options/parse_opts.re"
#line 157 "../src/options/parse_opts.re"
{ opts.set_cgoto(true); goto opt; }
#line 3426 "src/options/parse_opts.cc"
yy750:
Expand Down Expand Up @@ -3506,8 +3506,8 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
#line 3507 "src/options/parse_opts.cc"
yy768:
++YYCURSOR;
#line 153 "../src/options/parse_opts.re"
{ globopts.invert_captures = true; goto opt; }
#line 163 "../src/options/parse_opts.re"
{ opts.set_invert_captures(true); goto opt; }
#line 3512 "src/options/parse_opts.cc"
yy769:
yych = *++YYCURSOR;
Expand All @@ -3533,7 +3533,7 @@ Ret parse_opts(char** argv, conopt_t& globopts, Opt& opts, Msg& msg) {
#line 3534 "src/options/parse_opts.cc"
yy774:
++YYCURSOR;
#line 160 "../src/options/parse_opts.re"
#line 159 "../src/options/parse_opts.re"
{ opts.set_case_insensitive(true); goto opt; }
#line 3539 "src/options/parse_opts.cc"
yy775:
Expand Down

0 comments on commit ce75619

Please sign in to comment.