Skip to content

Commit

Permalink
Add option --invert-captures.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skvadrik committed Apr 21, 2023
1 parent 338806b commit 20030ff
Show file tree
Hide file tree
Showing 9 changed files with 1,395 additions and 1,334 deletions.
4 changes: 2 additions & 2 deletions bootstrap/lib/parse.cc
Original file line number Diff line number Diff line change
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)); }
{ (yyval.regexp) = ast.cap(ast.nil(NOWHERE), true); }
#line 1149 "lib/parse.cc"
break;

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

Expand Down
Loading

0 comments on commit 20030ff

Please sign in to comment.