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