Record Class LookbehindPos

java.lang.Object
java.lang.Record
com.orbit.prog.LookbehindPos
All Implemented Interfaces:
Instr

public record LookbehindPos(Prog body, int minLen, int maxLen, int next) extends Record implements Instr
Positive lookbehind assertion supporting bounded variable-length patterns.

At the current position pos, scans all start positions s in the range [max(lbFrom, pos - maxLen), pos - minLen] and executes body forward from each s. If any sub-match spans exactly [s, pos], execution continues at next; otherwise the current thread is killed. No input is consumed.

Both fixed-length (minLen == maxLen) and bounded variable-length lookbehind bodies are supported. Unbounded lookbehind (maxLen == Integer.MAX_VALUE) must be rejected by the parser before a LookbehindPos instruction is created.

Instances are immutable and safe for use by multiple concurrent threads.

  • Constructor Summary

    Constructors
    Constructor
    Description
    LookbehindPos(Prog body, int minLen, int maxLen, int next)
    Creates a new LookbehindPos, validating that minLen and maxLen are non-negative and that maxLen >= minLen.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the body record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxLen record component.
    int
    Returns the value of the minLen record component.
    int
    Returns the value of the next record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LookbehindPos

      public LookbehindPos(Prog body, int minLen, int maxLen, int next)
      Creates a new LookbehindPos, validating that minLen and maxLen are non-negative and that maxLen >= minLen.
      Throws:
      IllegalArgumentException - if minLen < 0 or maxLen < minLen
  • Method Details

    • next

      public int next()
      Returns the value of the next record component.
      Specified by:
      next in interface Instr
      Returns:
      the value of the next record component
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • body

      public Prog body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component
    • minLen

      public int minLen()
      Returns the value of the minLen record component.
      Returns:
      the value of the minLen record component
    • maxLen

      public int maxLen()
      Returns the value of the maxLen record component.
      Returns:
      the value of the maxLen record component