Interface SelfReport

This report indicates super-linear runtime cause by polynomial backtracking of a quantifier with itself.

Examples

(?:a+){2}, (?:a+)+

Description

This type of super-linear runtime is the special case of the trade type ([[TradeReport]]) where a quantifier trades characters with itself. As this requires some form of repetition of the quantifier, the self quantifier is always nested within a parent quantifier. The maximum of the parent quantifier determines the degree of polynomial backtracking (e.g. /(a+){0,3}/ backtracks in O(n^3) and /(a+)+/ backtracks in O(2^n)).

Fixing

To fix these reports, quantifier must be prevent from reaching itself. This can be accomplished by e.g. removing the quantifier (e.g. /(?:a+)+/ => /(?:a)+/), using assertions (e.g. /(a+|b){0,3}/ => /(a+(?!a)|b){0,3}/), or rewriting the affected parts of the pattern. Reports of simple cases usually have a fix for you.

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.

exponential: boolean

Whether the polynomial backtracking of this report causes exponential backtracking.

parentQuant: Quantifier

A parent quantifier of [[quant]].

The maximum of this quantifier is at least 2.

This is guaranteed to be not the same quantifier as [[quant]].

quant: Quantifier

An unbounded quantifier that can reach itself.

type: "Self"

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