Changeset 86547 in webkit for trunk/Source/JavaScriptCore/yarr/YarrPattern.cpp
- Timestamp:
- May 16, 2011, 2:08:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/yarr/YarrPattern.cpp
r80217 r86547 492 492 unsigned numParenAlternatives = parenthesesDisjunction->m_alternatives.size(); 493 493 unsigned numBOLAnchoredAlts = 0; 494 bool containsEmptyAlternative = false;495 494 496 495 for (unsigned i = 0; i < numParenAlternatives; i++) { 497 if (!parenthesesDisjunction->m_alternatives[i]->m_terms.size() && numParenAlternatives > 1) {498 PatternAlternative* altToRemove = parenthesesDisjunction->m_alternatives[i];499 parenthesesDisjunction->m_alternatives.remove(i);500 delete altToRemove;501 --numParenAlternatives;502 503 containsEmptyAlternative = true;504 continue;505 }506 507 496 // Bubble up BOL flags 508 497 if (parenthesesDisjunction->m_alternatives[i]->m_startsWithBOL) … … 519 508 lastTerm.parentheses.lastSubpatternId = m_pattern.m_numSubpatterns; 520 509 m_invertParentheticalAssertion = false; 521 522 if (containsEmptyAlternative) {523 // Backup and remove the current disjunction's alternatives.524 Vector<PatternAlternative*> alternatives;525 alternatives.append(parenthesesDisjunction->m_alternatives);526 parenthesesDisjunction->m_alternatives.clear();527 PatternAlternative* alternative = parenthesesDisjunction->addNewAlternative();528 529 // Insert a new non-capturing parentheses.530 unsigned subpatternId = m_pattern.m_numSubpatterns + 1;531 PatternDisjunction* newDisjunction = new PatternDisjunction(alternative);532 m_pattern.m_disjunctions.append(newDisjunction);533 alternative->m_terms.append(PatternTerm(PatternTerm::TypeParenthesesSubpattern, subpatternId, newDisjunction, false, false));534 newDisjunction->m_alternatives.append(alternatives);535 536 // Set the quantifier of the new parentheses to '?' and set the inherited properties.537 PatternTerm& disjunctionTerm = alternative->lastTerm();538 disjunctionTerm.quantify(1, QuantifierGreedy);539 disjunctionTerm.parentheses.lastSubpatternId = m_pattern.m_numSubpatterns;540 alternative->m_containsBOL = m_alternative->m_containsBOL;541 alternative->m_startsWithBOL = m_alternative->m_startsWithBOL;542 }543 510 } 544 511
Note:
See TracChangeset
for help on using the changeset viewer.