Lines Matching refs:term

90             : term(0)
99 int term;
117 ParenthesesDisjunctionContext(int* output, ByteTerm& term)
120 unsigned firstSubpatternId = term.atom.subpatternId;
121 unsigned numNestedSubpatterns = term.atom.parenthesesDisjunction->m_numSubpatterns;
128 new(getDisjunctionContext(term)) DisjunctionContext();
142 DisjunctionContext* getDisjunctionContext(ByteTerm& term)
144 return reinterpret_cast<DisjunctionContext*>(&(subpatternBackup[term.atom.parenthesesDisjunction->m_numSubpatterns << 1]));
151 ParenthesesDisjunctionContext* allocParenthesesDisjunctionContext(ByteDisjunction* disjunction, int* output, ByteTerm& term)
153 return new(malloc(sizeof(ParenthesesDisjunctionContext) + (((term.atom.parenthesesDisjunction->m_numSubpatterns << 1) - 1) * sizeof(int)) + sizeof(DisjunctionContext) + (disjunction->m_frameSize - 1) * sizeof(uintptr_t))) ParenthesesDisjunctionContext(output, term);
348 bool matchAssertionBOL(ByteTerm& term)
350 return (input.atStart(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition - 1)));
353 bool matchAssertionEOL(ByteTerm& term)
355 if (term.inputPosition)
356 return (input.atEnd(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition)));
361 bool matchAssertionWordBoundary(ByteTerm& term)
363 bool prevIsWordchar = !input.atStart(term.inputPosition) && testCharacterClass(pattern->wordcharCharacterClass, input.readChecked(term.inputPosition - 1));
365 if (term.inputPosition)
366 readIsWordchar = !input.atEnd(term.inputPosition) && testCharacterClass(pattern->wordcharCharacterClass, input.readChecked(term.inputPosition));
371 return term.invert() ? !wordBoundary : wordBoundary;
374 bool backtrackPatternCharacter(ByteTerm& term, DisjunctionContext* context)
376 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);
378 switch (term.atom.quantityType) {
391 if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
393 if (checkCharacter(term.atom.patternCharacter, term.inputPosition - 1))
403 bool backtrackPatternCasedCharacter(ByteTerm& term, DisjunctionContext* context)
405 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);
407 switch (term.atom.quantityType) {
420 if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
422 if (checkCasedCharacter(term.atom.casedCharacter.lo, term.atom.casedCharacter.hi, term.inputPosition - 1))
432 bool matchCharacterClass(ByteTerm& term, DisjunctionContext* context)
434 ASSERT(term.type == ByteTerm::TypeCharacterClass);
435 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);
437 switch (term.atom.quantityType) {
439 for (unsigned matchAmount = 0; matchAmount < term.atom.quantityCount; ++matchAmount) {
440 if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition + matchAmount))
448 while ((matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
449 if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition - 1)) {
469 bool backtrackCharacterClass(ByteTerm& term, DisjunctionContext* context)
471 ASSERT(term.type == ByteTerm::TypeCharacterClass);
472 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);
474 switch (term.atom.quantityType) {
487 if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
489 if (checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition - 1))
499 bool matchBackReference(ByteTerm& term, DisjunctionContext* context)
501 ASSERT(term.type == ByteTerm::TypeBackReference);
502 BackTrackInfoBackReference* backTrack = reinterpret_cast<BackTrackInfoBackReference*>(context->frame + term.frameLocation);
504 int matchBegin = output[(term.atom.subpatternId << 1)];
505 int matchEnd = output[(term.atom.subpatternId << 1) + 1];
512 switch (term.atom.quantityType) {
515 for (unsigned matchAmount = 0; matchAmount < term.atom.quantityCount; ++matchAmount) {
516 if (!tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition)) {
526 while ((matchAmount < term.atom.quantityCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition))
542 bool backtrackBackReference(ByteTerm& term, DisjunctionContext* context)
544 ASSERT(term.type == ByteTerm::TypeBackReference);
545 BackTrackInfoBackReference* backTrack = reinterpret_cast<BackTrackInfoBackReference*>(context->frame + term.frameLocation);
547 int matchBegin = output[(term.atom.subpatternId << 1)];
548 int matchEnd = output[(term.atom.subpatternId << 1) + 1];
555 switch (term.atom.quantityType) {
570 if ((backTrack->matchAmount < term.atom.quantityCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition)) {
581 void recordParenthesesMatch(ByteTerm& term, ParenthesesDisjunctionContext* context)
583 if (term.capture()) {
584 unsigned subpatternId = term.atom.subpatternId;
585 output[(subpatternId << 1)] = context->getDisjunctionContext(term)->matchBegin + term.inputPosition;
586 output[(subpatternId << 1) + 1] = context->getDisjunctionContext(term)->matchEnd + term.inputPosition;
589 void resetMatches(ByteTerm& term, ParenthesesDisjunctionContext* context)
591 unsigned firstSubpatternId = term.atom.subpatternId;
592 unsigned count = term.atom.parenthesesDisjunction->m_numSubpatterns;
595 void resetAssertionMatches(ByteTerm& term)
597 unsigned firstSubpatternId = term.atom.subpatternId;
598 unsigned count = term.atom.parenthesesDisjunction->m_numSubpatterns;
602 bool parenthesesDoBacktrack(ByteTerm& term, BackTrackInfoParentheses* backTrack)
607 if (matchDisjunction(term.atom.parenthesesDisjunction, context->getDisjunctionContext(term), true))
610 resetMatches(term, context);
618 bool matchParenthesesOnceBegin(ByteTerm& term, DisjunctionContext* context)
620 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
621 ASSERT(term.atom.quantityCount == 1);
623 BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);
625 switch (term.atom.quantityType) {
633 context->term += term.atom.parenthesesWidth;
640 if (term.capture()) {
641 unsigned subpatternId = term.atom.subpatternId;
642 output[(subpatternId << 1)] = input.getPos() + term.inputPosition;
648 bool matchParenthesesOnceEnd(ByteTerm& term, DisjunctionContext*)
650 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceEnd);
651 ASSERT(term.atom.quantityCount == 1);
653 if (term.capture()) {
654 unsigned subpatternId = term.atom.subpatternId;
655 output[(subpatternId << 1) + 1] = input.getPos() + term.inputPosition;
660 bool backtrackParenthesesOnceBegin(ByteTerm& term, DisjunctionContext* context)
662 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
663 ASSERT(term.atom.quantityCount == 1);
665 BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);
667 if (term.capture()) {
668 unsigned subpatternId = term.atom.subpatternId;
673 switch (term.atom.quantityType) {
678 context->term += term.atom.parenthesesWidth;
689 bool backtrackParenthesesOnceEnd(ByteTerm& term, DisjunctionContext* context)
691 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceEnd);
692 ASSERT(term.atom.quantityCount == 1);
694 BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);
696 switch (term.atom.quantityType) {
699 context->term -= term.atom.parenthesesWidth;
706 if (term.capture()) {
707 unsigned subpatternId = term.atom.subpatternId;
708 output[(subpatternId << 1) + 1] = input.getPos() + term.inputPosition;
710 context->term -= term.atom.parenthesesWidth;
720 bool matchParentheticalAssertionBegin(ByteTerm& term, DisjunctionContext* context)
722 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionBegin);
723 ASSERT(term.atom.quantityCount == 1);
725 BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);
731 bool matchParentheticalAssertionEnd(ByteTerm& term, DisjunctionContext* context)
733 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionEnd);
734 ASSERT(term.atom.quantityCount == 1);
736 BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);
741 if (term.invert()) {
742 context->term -= term.atom.parenthesesWidth;
749 bool backtrackParentheticalAssertionBegin(ByteTerm& term, DisjunctionContext* context)
751 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionBegin);
752 ASSERT(term.atom.quantityCount == 1);
755 if (term.invert()) {
756 context->term += term.atom.parenthesesWidth;
763 bool backtrackParentheticalAssertionEnd(ByteTerm& term, DisjunctionContext* context)
765 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionEnd);
766 ASSERT(term.atom.quantityCount == 1);
768 BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);
772 context->term -= term.atom.parenthesesWidth;
776 bool matchParentheses(ByteTerm& term, DisjunctionContext* context)
778 ASSERT(term.type == ByteTerm::TypeParenthesesSubpattern);
780 BackTrackInfoParentheses* backTrack = reinterpret_cast<BackTrackInfoParentheses*>(context->frame + term.frameLocation);
782 unsigned subpatternId = term.atom.subpatternId;
783 ByteDisjunction* disjunctionBody = term.atom.parenthesesDisjunction;
791 switch (term.atom.quantityType) {
794 while (backTrack->matchAmount < term.atom.quantityCount) {
796 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
797 if (matchDisjunction(disjunctionBody, context->getDisjunctionContext(term)))
801 resetMatches(term, context);
803 if (!parenthesesDoBacktrack(term, backTrack))
808 ASSERT(backTrack->matchAmount == term.atom.quantityCount);
810 recordParenthesesMatch(term, context);
815 while (backTrack->matchAmount < term.atom.quantityCount) {
816 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
817 if (matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term)))
820 resetMatches(term, context);
828 recordParenthesesMatch(term, context);
851 bool backtrackParentheses(ByteTerm& term, DisjunctionContext* context)
853 ASSERT(term.type == ByteTerm::TypeParenthesesSubpattern);
855 BackTrackInfoParentheses* backTrack = reinterpret_cast<BackTrackInfoParentheses*>(context->frame + term.frameLocation);
857 if (term.capture()) {
858 unsigned subpatternId = term.atom.subpatternId;
863 ByteDisjunction* disjunctionBody = term.atom.parenthesesDisjunction;
865 switch (term.atom.quantityType) {
867 ASSERT(backTrack->matchAmount == term.atom.quantityCount);
871 if (!parenthesesDoBacktrack(term, backTrack))
875 while (backTrack->matchAmount < term.atom.quantityCount) {
877 context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
878 if (matchDisjunction(disjunctionBody, context->getDisjunctionContext(term)))
882 resetMatches(term, context);
884 if (!parenthesesDoBacktrack(term, backTrack))
889 ASSERT(backTrack->matchAmount == term.atom.quantityCount);
891 recordParenthesesMatch(term, context);
900 if (matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term), true)) {
901 while (backTrack->matchAmount < term.atom.quantityCount) {
902 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
903 if (matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term)))
906 resetMatches(term, context);
912 resetMatches(term, context);
919 recordParenthesesMatch(term, context);
926 if (backTrack->matchAmount < term.atom.quantityCount) {
927 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
928 if (matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term))) {
930 recordParenthesesMatch(term, context);
933 resetMatches(term, context);
941 if (matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term), true)) {
945 recordParenthesesMatch(term, context);
951 resetMatches(term, context);
964 #define MATCH_NEXT() { ++context->term; goto matchAgain; }
965 #define BACKTRACK() { --context->term; goto backtrack; }
966 #define currentTerm() (disjunction->terms[context->term])
973 context->term = 0;
976 ASSERT(context->term < static_cast<int>(disjunction->terms.size()));
999 context->term += offset;
1111 ASSERT(context->term < static_cast<int>(disjunction->terms.size()));
1122 context->term += offset;
1139 context->term += offset;
1148 context->term -= offset;
1533 PatternTerm& term = alternative->m_terms[i];
1535 switch (term.type) {
1537 assertionBOL(term.inputPosition - currentCountAlreadyChecked);
1541 assertionEOL(term.inputPosition - currentCountAlreadyChecked);
1545 assertionWordBoundary(term.invertOrCapture, term.inputPosition - currentCountAlreadyChecked);
1549 atomPatternCharacter(term.patternCharacter, term.inputPosition - currentCountAlreadyChecked, term.frameLocation, term.quantityCount, term.quantityType);
1553 atomCharacterClass(term.characterClass, term.invertOrCapture, term.inputPosition - currentCountAlreadyChecked, term.frameLocation, term.quantityCount, term.quantityType);
1557 atomBackReference(term.subpatternId, term.inputPosition - currentCountAlreadyChecked, term.frameLocation, term.quantityCount, term.quantityType);
1565 if ((term.quantityCount == 1) && !term.parentheses.isCopy) {
1566 if (term.quantityType == QuantifierFixedCount) {
1567 disjunctionAlreadyCheckedCount = term.parentheses.disjunction->m_minimumSize;
1568 unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;
1569 atomParenthesesSubpatternBegin(term.parentheses.subpatternId, term.invertOrCapture, delegateEndInputOffset - disjunctionAlreadyCheckedCount, term.frameLocation, term.frameLocation);
1570 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, term.parentheses.disjunction->m_minimumSize);
1571 atomParenthesesEnd(true, term.parentheses.lastSubpatternId, delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType, term.parentheses.disjunction->m_callFrameSize);
1573 unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;
1574 atomParenthesesSubpatternBegin(term.parentheses.subpatternId, term.invertOrCapture, delegateEndInputOffset - disjunctionAlreadyCheckedCount, term.frameLocation, term.frameLocation + RegexStackSpaceForBackTrackInfoParenthesesOnce);
1575 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, 0);
1576 atomParenthesesEnd(true, term.parentheses.lastSubpatternId, delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType, term.parentheses.disjunction->m_callFrameSize);
1579 unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;
1580 atomParenthesesSubpatternBegin(term.parentheses.subpatternId, term.invertOrCapture, delegateEndInputOffset - disjunctionAlreadyCheckedCount, term.frameLocation, 0);
1581 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, 0);
1582 atomParenthesesEnd(false, term.parentheses.lastSubpatternId, delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType, term.parentheses.disjunction->m_callFrameSize);
1588 unsigned alternativeFrameLocation = term.inputPosition + RegexStackSpaceForBackTrackInfoParentheticalAssertion;
1590 atomParentheticalAssertionBegin(term.parentheses.subpatternId, term.invertOrCapture, term.frameLocation, alternativeFrameLocation);
1591 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, 0);
1592 atomParenthesesEnd(true, term.parentheses.lastSubpatternId, 0, term.frameLocation, term.quantityCount, term.quantityType);