File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -517,13 +517,33 @@ function PatternsParse(tokens) {
517
517
CheckQuantifier ( par , obj )
518
518
}
519
519
break
520
+ case TOK . LPAR :
521
+ {
522
+ print ( "(" )
523
+ if ( par . IsNextRPar ( ) ) {
524
+ par . captures . push ( new PatternObject ( PAT . POSITION , par , par . captures . length + 1 ) )
525
+ par . Next ( )
526
+ par . Next ( )
527
+ } else {
528
+ par . StartCapture ( )
529
+ }
530
+ par . Next ( )
531
+ }
532
+ break
533
+ case TOK . RPAR :
534
+ {
535
+ print ( ")" )
536
+ par . EndCapture ( )
537
+ par . Next ( )
538
+ }
539
+ break
520
540
case TOK . CAPTUREREF :
521
541
{
522
542
print ( "Captureref" )
523
543
let obj = new PatternObject ( PAT . CAPTUREREF , par , par . current . string )
524
544
if ( par . current . string === "0" ) {
525
545
new PatternObject ( PAT . NOTE , obj , "Reference for capture #0 is available only in string.gsub." )
526
- } else if ( par . captures . length < par . current . string - 1 ) {
546
+ } else if ( par . captures . length < par . current . string ) {
527
547
new PatternObject ( PAT . WARNING , obj , "Reference for capture #" + par . current . string + " is not found." )
528
548
} else if ( par . captures [ par . current . string - 1 ] . type === PAT . POSITION ) {
529
549
new PatternObject ( PAT . NOTE , obj , "References for position captures are available only in string.gsub." )
You can’t perform that action at this time.
0 commit comments