diff options
Diffstat (limited to 'JavaScriptCore/yarr/RegexCompiler.cpp')
-rw-r--r-- | JavaScriptCore/yarr/RegexCompiler.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/JavaScriptCore/yarr/RegexCompiler.cpp b/JavaScriptCore/yarr/RegexCompiler.cpp index 06ecbad..9063359 100644 --- a/JavaScriptCore/yarr/RegexCompiler.cpp +++ b/JavaScriptCore/yarr/RegexCompiler.cpp @@ -459,7 +459,7 @@ public: PatternDisjunction* parenthesesDisjunction = new PatternDisjunction(m_alternative); m_pattern.m_disjunctions.append(parenthesesDisjunction); - m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction, capture)); + m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction, capture, false)); m_alternative = parenthesesDisjunction->addNewAlternative(); } @@ -467,7 +467,7 @@ public: { PatternDisjunction* parenthesesDisjunction = new PatternDisjunction(m_alternative); m_pattern.m_disjunctions.append(parenthesesDisjunction); - m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParentheticalAssertion, m_pattern.m_numSubpatterns + 1, parenthesesDisjunction, invert)); + m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParentheticalAssertion, m_pattern.m_numSubpatterns + 1, parenthesesDisjunction, false, invert)); m_alternative = parenthesesDisjunction->addNewAlternative(); m_invertParentheticalAssertion = invert; } @@ -477,16 +477,16 @@ public: ASSERT(m_alternative->m_parent); ASSERT(m_alternative->m_parent->m_parent); - PatternDisjunction* parenthesisDisjunction = m_alternative->m_parent; + PatternDisjunction* parenthesesDisjunction = m_alternative->m_parent; m_alternative = m_alternative->m_parent->m_parent; PatternTerm& lastTerm = m_alternative->lastTerm(); - unsigned numParenAlternatives = parenthesisDisjunction->m_alternatives.size(); + unsigned numParenAlternatives = parenthesesDisjunction->m_alternatives.size(); unsigned numBOLAnchoredAlts = 0; // Bubble up BOL flags for (unsigned i = 0; i < numParenAlternatives; i++) { - if (parenthesisDisjunction->m_alternatives[i]->m_startsWithBOL) + if (parenthesesDisjunction->m_alternatives[i]->m_startsWithBOL) numBOLAnchoredAlts++; } @@ -520,7 +520,7 @@ public: PatternTerm& term = currentAlternative->lastTerm(); ASSERT((term.type == PatternTerm::TypeParenthesesSubpattern) || (term.type == PatternTerm::TypeParentheticalAssertion)); - if ((term.type == PatternTerm::TypeParenthesesSubpattern) && term.invertOrCapture && (subpatternId == term.subpatternId)) { + if ((term.type == PatternTerm::TypeParenthesesSubpattern) && term.capture() && (subpatternId == term.parentheses.subpatternId)) { m_alternative->m_terms.append(PatternTerm::ForwardReference()); return; } @@ -595,7 +595,7 @@ public: term.quantify(min, QuantifierFixedCount); m_alternative->m_terms.append(copyTerm(term)); // NOTE: this term is interesting from an analysis perspective, in that it can be ignored..... - m_alternative->lastTerm().quantify((max == UINT_MAX) ? max : max - min, greedy ? QuantifierGreedy : QuantifierNonGreedy); + m_alternative->lastTerm().quantify((max == quantifyInfinite) ? max : max - min, greedy ? QuantifierGreedy : QuantifierNonGreedy); if (m_alternative->lastTerm().type == PatternTerm::TypeParenthesesSubpattern) m_alternative->lastTerm().parentheses.isCopy = true; } @@ -734,7 +734,8 @@ public: // This optimization identifies sets of parentheses that we will never need to backtrack. // In these cases we do not need to store state from prior iterations. // We can presently avoid backtracking for: - // * a set of parens at the end of the regular expression (last term in any of the alternatives of the main body disjunction). + // * where the parens are at the end of the regular expression (last term in any of the + // alternatives of the main body disjunction). // * where the parens are non-capturing, and quantified unbounded greedy (*). // * where the parens do not contain any capturing subpatterns. void checkForTerminalParentheses() @@ -745,13 +746,13 @@ public: return; Vector<PatternAlternative*>& alternatives = m_pattern.m_body->m_alternatives; - for (unsigned i =0; i < alternatives.size(); ++i) { + for (size_t i = 0; i < alternatives.size(); ++i) { Vector<PatternTerm>& terms = alternatives[i]->m_terms; if (terms.size()) { PatternTerm& term = terms.last(); if (term.type == PatternTerm::TypeParenthesesSubpattern && term.quantityType == QuantifierGreedy - && term.quantityCount == UINT_MAX + && term.quantityCount == quantifyInfinite && !term.capture()) term.parentheses.isTerminal = true; } @@ -844,7 +845,7 @@ public: return false; case PatternTerm::TypeParentheticalAssertion: - if (term.invertOrCapture) + if (term.invert()) return false; case PatternTerm::TypeParenthesesSubpattern: |