@@ -267,6 +267,11 @@ enum Jump {
267267 RepeatOne2 ,
268268 MinRepeatOne1 ,
269269 MinRepeatOne2 ,
270+ AtomicGroup1 ,
271+ PossessiveRepeat1 ,
272+ PossessiveRepeat2 ,
273+ PossessiveRepeat3 ,
274+ PossessiveRepeat4 ,
270275}
271276
272277fn _match < S : StrDrive > ( req : & Request < S > , state : & mut State , ctx : MatchContext ) -> bool {
@@ -445,6 +450,73 @@ fn _match<S: StrDrive>(req: &Request<S>, state: &mut State, ctx: MatchContext) -
445450 ctx. jump = Jump :: MinRepeatOne1 ;
446451 continue ' context;
447452 }
453+ Jump :: AtomicGroup1 => {
454+ if popped_result {
455+ ctx. skip_code_from ( req, 1 ) ;
456+ ctx. string_position = state. string_position ;
457+ ctx. string_offset = req. string . offset ( 0 , state. string_position ) ;
458+ // dispatch opcode
459+ } else {
460+ state. string_position = ctx. string_position ;
461+ break ' result false ;
462+ }
463+ }
464+ Jump :: PossessiveRepeat1 => {
465+ let min_count = ctx. peek_code ( req, 2 ) as isize ;
466+ if ctx. count < min_count {
467+ break ' context ctx. next_offset ( 4 , Jump :: PossessiveRepeat2 ) ;
468+ }
469+ // zero match protection
470+ ctx. string_position = usize:: MAX ;
471+ ctx. jump = Jump :: PossessiveRepeat3 ;
472+ continue ' context;
473+ }
474+ Jump :: PossessiveRepeat2 => {
475+ if popped_result {
476+ ctx. count += 1 ;
477+ ctx. jump = Jump :: PossessiveRepeat1 ;
478+ continue ' context;
479+ } else {
480+ state. string_position = ctx. string_position ;
481+ break ' result false ;
482+ }
483+ }
484+ Jump :: PossessiveRepeat3 => {
485+ let max_count = ctx. peek_code ( req, 3 ) as usize ;
486+ if ( ( ctx. count as usize ) < max_count || max_count == MAXREPEAT )
487+ && ctx. string_position != state. string_position
488+ {
489+ state. marks . push ( ) ;
490+ ctx. string_position = state. string_position ;
491+ ctx. string_offset = req. string . offset ( 0 , state. string_position ) ;
492+ break ' context ctx. next_offset ( 4 , Jump :: PossessiveRepeat4 ) ;
493+ }
494+ ctx. string_position = state. string_position ;
495+ ctx. string_offset = req. string . offset ( 0 , state. string_position ) ;
496+ // popped_result = false;
497+ // ctx.jump = Jump::PossessiveRepeat4;
498+ // continue 'context;
499+ ctx. skip_code_from ( req, 1 ) ;
500+ ctx. skip_code ( 1 ) ;
501+ // if ctx.remaining_codes(req) > 1 && ctx.toplevel {
502+ // ctx.skip_code(1);
503+ // }
504+ }
505+ Jump :: PossessiveRepeat4 => {
506+ if popped_result {
507+ state. marks . pop_discard ( ) ;
508+ ctx. count += 1 ;
509+ ctx. jump = Jump :: PossessiveRepeat3 ;
510+ continue ' context;
511+ }
512+ state. marks . pop ( ) ;
513+ state. string_position = ctx. string_position ;
514+ ctx. skip_code_from ( req, 1 ) ;
515+ ctx. skip_code ( 1 ) ;
516+ // if ctx.remaining_codes(req) > 1 && ctx.toplevel {
517+ // ctx.skip_code(1);
518+ // }
519+ }
448520 }
449521 ctx. jump = Jump :: OpCode ;
450522
@@ -759,15 +831,43 @@ fn _match<S: StrDrive>(req: &Request<S>, state: &mut State, ctx: MatchContext) -
759831 ctx. skip_code_from ( req, 2 )
760832 }
761833 }
834+ /* <ATOMIC_GROUP> <skip> pattern <SUCCESS> tail */
835+ SreOpcode :: ATOMIC_GROUP => {
836+ state. string_position = ctx. string_position ;
837+ break ' context ctx. next_offset ( 2 , Jump :: AtomicGroup1 ) ;
838+ }
839+ /* <POSSESSIVE_REPEAT> <skip> <1=min> <2=max> pattern
840+ <SUCCESS> tail */
841+ SreOpcode :: POSSESSIVE_REPEAT => {
842+ state. string_position = ctx. string_position ;
843+ ctx. count = 0 ;
844+ ctx. jump = Jump :: PossessiveRepeat1 ;
845+ continue ' context;
846+ }
847+ /* <POSSESSIVE_REPEAT_ONE> <skip> <1=min> <2=max> item <SUCCESS>
848+ tail */
849+ SreOpcode :: POSSESSIVE_REPEAT_ONE => {
850+ let min_count = ctx. peek_code ( req, 2 ) as usize ;
851+ let max_count = ctx. peek_code ( req, 3 ) as usize ;
852+ if ctx. remaining_chars ( req) < min_count {
853+ break ' result false ;
854+ }
855+ state. string_position = ctx. string_position ;
856+ let mut count_ctx = ctx;
857+ count_ctx. skip_code ( 4 ) ;
858+ let count = _count ( req, state, count_ctx, max_count) ;
859+ if count < min_count {
860+ break ' result false ;
861+ }
862+ ctx. skip_char ( req, count) ;
863+ ctx. skip_code_from ( req, 1 ) ;
864+ }
762865 SreOpcode :: CHARSET => todo ! ( ) ,
763866 SreOpcode :: BIGCHARSET => todo ! ( ) ,
764867 SreOpcode :: NEGATE => todo ! ( ) ,
765868 SreOpcode :: RANGE => todo ! ( ) ,
766869 SreOpcode :: RANGE_UNI_IGNORE => todo ! ( ) ,
767870 SreOpcode :: SUBPATTERN => todo ! ( ) ,
768- SreOpcode :: ATOMIC_GROUP => todo ! ( ) ,
769- SreOpcode :: POSSESSIVE_REPEAT => todo ! ( ) ,
770- SreOpcode :: POSSESSIVE_REPEAT_ONE => todo ! ( ) ,
771871 }
772872 }
773873 } ;
@@ -1906,7 +2006,7 @@ fn _count<S: StrDrive>(
19062006
19072007 while count < max_count {
19082008 let sub_ctx = MatchContext {
1909- toplevel : true ,
2009+ toplevel : false ,
19102010 jump : Jump :: OpCode ,
19112011 repeat_ctx_id : usize:: MAX ,
19122012 count : -1 ,
0 commit comments