Skip to content

Commit 20030ff

Browse files
committed
Add option --invert-captures.
The new option inverts the meaning on capturing and non-capturing parentheses: `(! ...)` becomes capturing, and `( ... )` becomes non-capturing, including the implicit whole-regexp group, which also becomes non-capturing. The idea of the new option is to let the user decide which gropus should be capturing and which are purely structural, and explicitly mark only the capturing ones for submatch extraction.
1 parent 338806b commit 20030ff

9 files changed

Lines changed: 1395 additions & 1334 deletions

File tree

bootstrap/lib/parse.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,13 +1144,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
11441144

11451145
case 13: /* primary: '(' ')' */
11461146
#line 77 "../lib/parse.ypp"
1147-
{ (yyval.regexp) = ast.cap(ast.nil(NOWHERE)); }
1147+
{ (yyval.regexp) = ast.cap(ast.nil(NOWHERE), true); }
11481148
#line 1149 "lib/parse.cc"
11491149
break;
11501150

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

0 commit comments

Comments
 (0)