Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postpone position assignment #105

Merged
merged 2 commits into from
Jul 30, 2024
Merged

Commits on Jul 24, 2024

  1. Add a test case for bounded iterations.

    This test case exposes a bug which causes the upper limit of a finite
    bound to be ignored in certain cases.
    
    The regular expression used in the test case is a minimal reproducer;
    a more practical but less readable and less easily debugged example
    would be a regular expression that accepts fully-qualified domain
    names.
    dag-erling committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    fdb68b3 View commit details
    Browse the repository at this point in the history
  2. Postpone position assignment until the end.

    During AST expansion, it is possible for new literal nodes to be created
    and given the same position as existing literals.  The code attempts to
    reposition nodes when this happens but does not always succeed.  The
    result is a short-circuit in the TNFA which can manifest as an infinite
    loop, e.g. a bounded iteration being treated as an unbounded one.  This
    reshuffling can also leave positions unfilled, wasting memory.
    
    Instead of trying to assign positions to literal nodes on creation, and
    then having to renumber them on the fly during AST expansion, wait until
    the end and move position assignment into `tre_compute_nfl()`, which we
    rename to `tre_compute_npfl()`.
    dag-erling committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    2e5030a View commit details
    Browse the repository at this point in the history