Ignore:
Timestamp:
Feb 4, 2012, 3:49:37 PM (13 years ago)
Author:
[email protected]
Message:

Rubber stamped by Sam Weinig.

  • yarr/YarrPattern.cpp:

(JSC::Yarr::YarrPatternConstructor::quantifyAtom):

  • Fix comment.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/yarr/YarrPattern.cpp

    r103672 r106748  
    477477        ASSERT((term.quantityCount == 1) && (term.quantityType == QuantifierFixedCount));
    478478
    479         // For any assertion with a zero minimum, not matching is valid and has no effect,
    480         // remove it.  Otherwise, we need to match as least once, but there is no point
    481         // matching more than once, so remove the quantifier.  It is not entirely clear
    482         // from the spec whether or not this behavior is correct, but I believe this
    483         // matches Firefox. :-/
    484479        if (term.type == PatternTerm::TypeParentheticalAssertion) {
     480            // If an assertion is quantified with a minimum count of zero, it can simply be removed.
     481            // This arises from the RepeatMatcher behaviour in the spec. Matching an assertion never
     482            // results in any input being consumed, however the continuation passed to the assertion
     483            // (called in steps, 8c and 9 of the RepeatMatcher definition, ES5.1 15.10.2.5) will
     484            // reject all zero length matches (see step 2.1). A match from the continuation of the
     485            // expression will still be accepted regardless (via steps 8a and 11) - the upshot of all
     486            // this is that matches from the assertion are not required, and won't be accepted anyway,
     487            // so no need to ever run it.
    485488            if (!min)
    486489                m_alternative->removeLastTerm();
     490            // We never need to run an assertion more than once. Subsequent interations will be run
     491            // with the same start index (since assertions are non-capturing) and the same captures
     492            // (per step 4 of RepeatMatcher in ES5.1 15.10.2.5), and as such will always produce the
     493            // same result and captures. If the first match succeeds then the subsequent (min - 1)
     494            // matches will too. Any additional optional matches will fail (on the same basis as the
     495            // minimum zero quantified assertions, above), but this will still result in a match.
    487496            return;
    488497        }
Note: See TracChangeset for help on using the changeset viewer.