Lines Matching refs:ctx

350         ctx->lastmark = state->lastmark; \
351 ctx->lastindex = state->lastindex; \
355 state->lastmark = ctx->lastmark; \
356 state->lastindex = ctx->lastindex; \
380 DATA_STACK_LOOKUP_AT(state, SRE(match_context), ctx, ctx_pos); \
401 DATA_STACK_LOOKUP_AT(state, SRE(match_context), ctx, ctx_pos); \
438 i = lastmark; /* ctx->lastmark may change if reallocated */ \
476 ctx = nextctx; \
482 DO_JUMPX(jumpvalue, jumplabel, nextpattern, ctx->match_all)
513 SRE(match_context)* ctx;
518 DATA_ALLOC(SRE(match_context), ctx);
519 ctx->last_ctx_pos = -1;
520 ctx->jump = JUMP_NONE;
521 ctx->pattern = pattern;
522 ctx->match_all = match_all;
527 ctx->ptr = (SRE_CHAR *)state->ptr;
529 if (ctx->pattern[0] == SRE_OP_INFO) {
532 if (ctx->pattern[3] && (uintptr_t)(end - ctx->ptr) < ctx->pattern[3]) {
535 end - ctx->ptr, (Py_ssize_t) ctx->pattern[3]));
538 ctx->pattern += ctx->pattern[1] + 1;
546 switch (*ctx->pattern++) {
551 TRACE(("|%p|%p|MARK %d\n", ctx->pattern,
552 ctx->ptr, ctx->pattern[0]));
553 i = ctx->pattern[0];
566 state->mark[i] = ctx->ptr;
567 ctx->pattern++;
573 TRACE(("|%p|%p|LITERAL %d\n", ctx->pattern,
574 ctx->ptr, *ctx->pattern));
575 if (ctx->ptr >= end || (SRE_CODE) ctx->ptr[0] != ctx->pattern[0])
577 ctx->pattern++;
578 ctx->ptr++;
584 TRACE(("|%p|%p|NOT_LITERAL %d\n", ctx->pattern,
585 ctx->ptr, *ctx->pattern));
586 if (ctx->ptr >= end || (SRE_CODE) ctx->ptr[0] == ctx->pattern[0])
588 ctx->pattern++;
589 ctx->ptr++;
594 TRACE(("|%p|%p|SUCCESS\n", ctx->pattern, ctx->ptr));
595 if (!ctx->match_all || ctx->ptr == state->end) {
596 state->ptr = ctx->ptr;
604 TRACE(("|%p|%p|AT %d\n", ctx->pattern, ctx->ptr, *ctx->pattern));
605 if (!SRE(at)(state, ctx->ptr, *ctx->pattern))
607 ctx->pattern++;
613 TRACE(("|%p|%p|CATEGORY %d\n", ctx->pattern,
614 ctx->ptr, *ctx->pattern));
615 if (ctx->ptr >= end || !sre_category(ctx->pattern[0], ctx->ptr[0]))
617 ctx->pattern++;
618 ctx->ptr++;
624 TRACE(("|%p|%p|ANY\n", ctx->pattern, ctx->ptr));
625 if (ctx->ptr >= end || SRE_IS_LINEBREAK(ctx->ptr[0]))
627 ctx->ptr++;
633 TRACE(("|%p|%p|ANY_ALL\n", ctx->pattern, ctx->ptr));
634 if (ctx->ptr >= end)
636 ctx->ptr++;
642 TRACE(("|%p|%p|IN\n", ctx->pattern, ctx->ptr));
643 if (ctx->ptr >= end ||
644 !SRE(charset)(state, ctx->pattern + 1, *ctx->ptr))
646 ctx->pattern += ctx->pattern[0];
647 ctx->ptr++;
652 ctx->pattern, ctx->ptr, ctx->pattern[0]));
653 if (ctx->ptr >= end ||
654 state->lower(*ctx->ptr) != state->lower(*ctx->pattern))
656 ctx->pattern++;
657 ctx->ptr++;
662 ctx->pattern, ctx->ptr, *ctx->pattern));
663 if (ctx->ptr >= end ||
664 state->lower(*ctx->ptr) == state->lower(*ctx->pattern))
666 ctx->pattern++;
667 ctx->ptr++;
671 TRACE(("|%p|%p|IN_IGNORE\n", ctx->pattern, ctx->ptr));
672 if (ctx->ptr >= end
673 || !SRE(charset)(state, ctx->pattern+1,
674 (SRE_CODE)state->lower(*ctx->ptr)))
676 ctx->pattern += ctx->pattern[0];
677 ctx->ptr++;
684 TRACE(("|%p|%p|JUMP %d\n", ctx->pattern,
685 ctx->ptr, ctx->pattern[0]));
686 ctx->pattern += ctx->pattern[0];
692 TRACE(("|%p|%p|BRANCH\n", ctx->pattern, ctx->ptr));
694 ctx->u.rep = state->repeat;
695 if (ctx->u.rep)
696 MARK_PUSH(ctx->lastmark);
697 for (; ctx->pattern[0]; ctx->pattern += ctx->pattern[0]) {
698 if (ctx->pattern[1] == SRE_OP_LITERAL &&
699 (ctx->ptr >= end ||
700 (SRE_CODE) *ctx->ptr != ctx->pattern[2]))
702 if (ctx->pattern[1] == SRE_OP_IN &&
703 (ctx->ptr >= end ||
704 !SRE(charset)(state, ctx->pattern + 3,
705 (SRE_CODE) *ctx->ptr)))
707 state->ptr = ctx->ptr;
708 DO_JUMP(JUMP_BRANCH, jump_branch, ctx->pattern+1);
710 if (ctx->u.rep)
711 MARK_POP_DISCARD(ctx->lastmark);
715 if (ctx->u.rep)
716 MARK_POP_KEEP(ctx->lastmark);
719 if (ctx->u.rep)
720 MARK_POP_DISCARD(ctx->lastmark);
733 TRACE(("|%p|%p|REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr,
734 ctx->pattern[1], ctx->pattern[2]));
736 if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr)
739 state->ptr = ctx->ptr;
741 ret = SRE(count)(state, ctx->pattern+3, ctx->pattern[2]);
743 DATA_LOOKUP_AT(SRE(match_context), ctx, ctx_pos);
744 ctx->count = ret;
745 ctx->ptr += ctx->count;
748 matches, and ctx->ptr points to the tail of the target
752 if (ctx->count < (Py_ssize_t) ctx->pattern[1])
755 if (ctx->pattern[ctx->pattern[0]] == SRE_OP_SUCCESS &&
756 ctx->ptr == state->end) {
758 state->ptr = ctx->ptr;
764 if (ctx->pattern[ctx->pattern[0]] == SRE_OP_LITERAL) {
767 ctx->u.chr = ctx->pattern[ctx->pattern[0]+1];
769 while (ctx->count >= (Py_ssize_t) ctx->pattern[1] &&
770 (ctx->ptr >= end || *ctx->ptr != ctx->u.chr)) {
771 ctx->ptr--;
772 ctx->count--;
774 if (ctx->count < (Py_ssize_t) ctx->pattern[1])
776 state->ptr = ctx->ptr;
778 ctx->pattern+ctx->pattern[0]);
786 ctx->ptr--;
787 ctx->count--;
792 while (ctx->count >= (Py_ssize_t) ctx->pattern[1]) {
793 state->ptr = ctx->ptr;
795 ctx->pattern+ctx->pattern[0]);
800 ctx->ptr--;
801 ctx->count--;
817 TRACE(("|%p|%p|MIN_REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr,
818 ctx->pattern[1], ctx->pattern[2]));
820 if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr)
823 state->ptr = ctx->ptr;
825 if (ctx->pattern[1] == 0)
826 ctx->count = 0;
829 ret = SRE(count)(state, ctx->pattern+3, ctx->pattern[1]);
831 DATA_LOOKUP_AT(SRE(match_context), ctx, ctx_pos);
832 if (ret < (Py_ssize_t) ctx->pattern[1])
836 ctx->count = ret;
837 ctx->ptr += ctx->count;
840 if (ctx->pattern[ctx->pattern[0]] == SRE_OP_SUCCESS &&
841 (!match_all || ctx->ptr == state->end)) {
843 state->ptr = ctx->ptr;
849 while ((Py_ssize_t)ctx->pattern[2] == SRE_MAXREPEAT
850 || ctx->count <= (Py_ssize_t)ctx->pattern[2]) {
851 state->ptr = ctx->ptr;
853 ctx->pattern+ctx->pattern[0]);
858 state->ptr = ctx->ptr;
859 ret = SRE(count)(state, ctx->pattern+3, 1);
861 DATA_LOOKUP_AT(SRE(match_context), ctx, ctx_pos);
865 ctx->ptr++;
866 ctx->count++;
876 TRACE(("|%p|%p|REPEAT %d %d\n", ctx->pattern, ctx->ptr,
877 ctx->pattern[1], ctx->pattern[2]));
880 ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep));
881 if (!ctx->u.rep) {
885 ctx->u.rep->count = -1;
886 ctx->u.rep->pattern = ctx->pattern;
887 ctx->u.rep->prev = state->repeat;
888 ctx->u.rep->last_ptr = NULL;
889 state->repeat = ctx->u.rep;
891 state->ptr = ctx->ptr;
892 DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]);
893 state->repeat = ctx->u.rep->prev;
894 PyObject_FREE(ctx->u.rep);
909 ctx->u.rep = state->repeat;
910 if (!ctx->u.rep)
913 state->ptr = ctx->ptr;
915 ctx->count = ctx->u.rep->count+1;
917 TRACE(("|%p|%p|MAX_UNTIL %" PY_FORMAT_SIZE_T "d\n", ctx->pattern,
918 ctx->ptr, ctx->count));
920 if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
922 ctx->u.rep->count = ctx->count;
924 ctx->u.rep->pattern+3);
929 ctx->u.rep->count = ctx->count-1;
930 state->ptr = ctx->ptr;
934 if ((ctx->count < (Py_ssize_t) ctx->u.rep->pattern[2] ||
935 ctx->u.rep->pattern[2] == SRE_MAXREPEAT) &&
936 state->ptr != ctx->u.rep->last_ptr) {
939 ctx->u.rep->count = ctx->count;
941 MARK_PUSH(ctx->lastmark);
943 DATA_PUSH(&ctx->u.rep->last_ptr);
944 ctx->u.rep->last_ptr = state->ptr;
946 ctx->u.rep->pattern+3);
947 DATA_POP(&ctx->u.rep->last_ptr);
949 MARK_POP_DISCARD(ctx->lastmark);
953 MARK_POP(ctx->lastmark);
955 ctx->u.rep->count = ctx->count-1;
956 state->ptr = ctx->ptr;
961 state->repeat = ctx->u.rep->prev;
962 DO_JUMP(JUMP_MAX_UNTIL_3, jump_max_until_3, ctx->pattern);
964 state->repeat = ctx->u.rep;
965 state->ptr = ctx->ptr;
972 ctx->u.rep = state->repeat;
973 if (!ctx->u.rep)
976 state->ptr = ctx->ptr;
978 ctx->count = ctx->u.rep->count+1;
980 TRACE(("|%p|%p|MIN_UNTIL %" PY_FORMAT_SIZE_T "d %p\n", ctx->pattern,
981 ctx->ptr, ctx->count, ctx->u.rep->pattern));
983 if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
985 ctx->u.rep->count = ctx->count;
987 ctx->u.rep->pattern+3);
992 ctx->u.rep->count = ctx->count-1;
993 state->ptr = ctx->ptr;
1000 state->repeat = ctx->u.rep->prev;
1001 DO_JUMP(JUMP_MIN_UNTIL_2, jump_min_until_2, ctx->pattern);
1007 state->repeat = ctx->u.rep;
1008 state->ptr = ctx->ptr;
1012 if ((ctx->count >= (Py_ssize_t) ctx->u.rep->pattern[2]
1013 && ctx->u.rep->pattern[2] != SRE_MAXREPEAT) ||
1014 state->ptr == ctx->u.rep->last_ptr)
1017 ctx->u.rep->count = ctx->count;
1019 DATA_PUSH(&ctx->u.rep->last_ptr);
1020 ctx->u.rep->last_ptr = state->ptr;
1022 ctx->u.rep->pattern+3);
1023 DATA_POP(&ctx->u.rep->last_ptr);
1028 ctx->u.rep->count = ctx->count-1;
1029 state->ptr = ctx->ptr;
1034 TRACE(("|%p|%p|GROUPREF %d\n", ctx->pattern,
1035 ctx->ptr, ctx->pattern[0]));
1036 i = ctx->pattern[0];
1047 if (ctx->ptr >= end || *ctx->ptr != *p)
1050 ctx->ptr++;
1054 ctx->pattern++;
1059 TRACE(("|%p|%p|GROUPREF_IGNORE %d\n", ctx->pattern,
1060 ctx->ptr, ctx->pattern[0]));
1061 i = ctx->pattern[0];
1072 if (ctx->ptr >= end ||
1073 state->lower(*ctx->ptr) != state->lower(*p))
1076 ctx->ptr++;
1080 ctx->pattern++;
1084 TRACE(("|%p|%p|GROUPREF_EXISTS %d\n", ctx->pattern,
1085 ctx->ptr, ctx->pattern[0]));
1087 i = ctx->pattern[0];
1091 ctx->pattern += ctx->pattern[1];
1097 ctx->pattern += ctx->pattern[1];
1102 ctx->pattern += 2;
1108 TRACE(("|%p|%p|ASSERT %d\n", ctx->pattern,
1109 ctx->ptr, ctx->pattern[1]));
1110 if (ctx->ptr - (SRE_CHAR *)state->beginning < (Py_ssize_t)ctx->pattern[1])
1112 state->ptr = ctx->ptr - ctx->pattern[1];
1113 DO_JUMP0(JUMP_ASSERT, jump_assert, ctx->pattern+2);
1115 ctx->pattern += ctx->pattern[0];
1121 TRACE(("|%p|%p|ASSERT_NOT %d\n", ctx->pattern,
1122 ctx->ptr, ctx->pattern[1]));
1123 if (ctx->ptr - (SRE_CHAR *)state->beginning >= (Py_ssize_t)ctx->pattern[1]) {
1124 state->ptr = ctx->ptr - ctx->pattern[1];
1125 DO_JUMP0(JUMP_ASSERT_NOT, jump_assert_not, ctx->pattern+2);
1131 ctx->pattern += ctx->pattern[0];
1136 TRACE(("|%p|%p|FAILURE\n", ctx->pattern, ctx->ptr));
1140 TRACE(("|%p|%p|UNKNOWN %d\n", ctx->pattern, ctx->ptr,
1141 ctx->pattern[-1]));
1147 ctx_pos = ctx->last_ctx_pos;
1148 jump = ctx->jump;
1149 DATA_POP_DISCARD(ctx);
1152 DATA_LOOKUP_AT(SRE(match_context), ctx, ctx_pos);
1156 TRACE(("|%p|%p|JUMP_MAX_UNTIL_2\n", ctx->pattern, ctx->ptr));
1159 TRACE(("|%p|%p|JUMP_MAX_UNTIL_3\n", ctx->pattern, ctx->ptr));
1162 TRACE(("|%p|%p|JUMP_MIN_UNTIL_2\n", ctx->pattern, ctx->ptr));
1165 TRACE(("|%p|%p|JUMP_MIN_UNTIL_3\n", ctx->pattern, ctx->ptr));
1168 TRACE(("|%p|%p|JUMP_BRANCH\n", ctx->pattern, ctx->ptr));
1171 TRACE(("|%p|%p|JUMP_MAX_UNTIL_1\n", ctx->pattern, ctx->ptr));
1174 TRACE(("|%p|%p|JUMP_MIN_UNTIL_1\n", ctx->pattern, ctx->ptr));
1177 TRACE(("|%p|%p|JUMP_REPEAT\n", ctx->pattern, ctx->ptr));
1180 TRACE(("|%p|%p|JUMP_REPEAT_ONE_1\n", ctx->pattern, ctx->ptr));
1183 TRACE(("|%p|%p|JUMP_REPEAT_ONE_2\n", ctx->pattern, ctx->ptr));
1186 TRACE(("|%p|%p|JUMP_MIN_REPEAT_ONE\n", ctx->pattern, ctx->ptr));
1189 TRACE(("|%p|%p|JUMP_ASSERT\n", ctx->pattern, ctx->ptr));
1192 TRACE(("|%p|%p|JUMP_ASSERT_NOT\n", ctx->pattern, ctx->ptr));
1195 TRACE(("|%p|%p|RETURN %" PY_FORMAT_SIZE_T "d\n", ctx->pattern,
1196 ctx->ptr, ret));