Interface TradeReport

This report indicates super-linear runtime caused by polynomial backtracking between two distinct quantifiers.

Examples

/a+a+/, /\d*\w+/, /a*(?:a{2}d?|cd?)b?a+/, /(?:a+ba+){2}/, (?:a|ba+)+

Description

This type of super-linear runtime is caused by the polynomial backtracking between two unbounded quantifiers.

Start and end quantifiers

While the start and end quantifiers are guaranteed to be distinct unbounded quantifiers, one may be parent (or ancestor) of the other (e.g. /(?:a|ba+)+/). The matching direction of the quantifiers may also be different (e.g. /a+(?<!a*b)/).

Notes

This type is called "trade" because polynomial backtracking between two quantifiers looks like the two quantifiers are exchanging characters, a trade of sorts.

Hierarchy

Properties

character: {
    literal: Literal;
    pick: string;
    set: CharSet;
}

The character to be repeated in order to create an input for which the analysed literal will have super-linear runtime behavior.

Type declaration

  • literal: Literal

    A literal that represents set.

    E.g. if set only contained the character "a" (lower case A), then the literal may be /a/.

  • pick: string

    A single character that can be repeated to cause super-linear runtime.

    The implementation is allowed to pick any character in set but makes a best effort to pick a "humanly readable" character.

  • set: CharSet

    A non-empty set of characters that can be repeated to cause super-linear runtime.

    CharSet is a class from the refa library.

endQuant: Quantifier
exponential: boolean

Whether the polynomial backtracking of this report causes exponential backtracking.

startQuant: Quantifier
type: "Trade"

Methods

  • Returns a new literal with this cause of super-linear runtime being fixed. If the cause of this report could not be automatically fixed, undefined will be returned.

    A fixed literal is guaranteed to behave exactly the same as the analysed literal.

    Returns undefined | Literal