Class GroupBoundaries

java.lang.Object
com.oracle.truffle.regex.tregex.parser.ast.GroupBoundaries
All Implemented Interfaces:
JsonConvertible

public class GroupBoundaries extends Object implements JsonConvertible
Objects of this class represent the capture group boundaries traversed in a single NFAStateTransition or ASTTransition. The boundaries of one capture group correspond to its opening and closing brackets. All capture group boundaries are mapped to indices according to Group.getBoundaryIndexStart() and Group.getBoundaryIndexEnd(). A transition may update or clear any boundary when traversed.
To save space, instances of this class are deduplicated in RegexAST. Due to the deduplication, every instance must be treated as immutable!
See Also:
  • Method Details

    • createCachedGroupBoundaries

      public static GroupBoundaries[] createCachedGroupBoundaries()
    • getStaticInstance

      public static GroupBoundaries getStaticInstance(RegexLanguage language, TBitSet updateIndices, TBitSet clearIndices)
      Used for deduplication of very common instances of this class.
    • getEmptyInstance

      public static GroupBoundaries getEmptyInstance(RegexLanguage language)
    • isEmpty

      public boolean isEmpty()
    • updatesToByteArray

      public byte[] updatesToByteArray()
    • clearsToByteArray

      public byte[] clearsToByteArray()
    • materializeArrays

      public void materializeArrays()
    • getUpdateIndices

      public TBitSet getUpdateIndices()
      Directly returns the TBitSet used to store the indices of all capture group boundaries that should be updated when traversed.
      CAUTION: Do not alter the returned object!
    • getClearIndices

      public TBitSet getClearIndices()
      Directly returns the TBitSet used to store the indices of all capture group boundaries that should be cleared when traversed.
      CAUTION: Do not alter the returned object!
    • hasIndexUpdates

      public boolean hasIndexUpdates()
    • hasIndexClears

      public boolean hasIndexClears()
    • hasLastGroup

      public boolean hasLastGroup()
    • updateBitSets

      public void updateBitSets(TBitSet foreignUpdateIndices, TBitSet foreignClearIndices)
      Updates the given TBitSets with the values contained in this GroupBoundaries object.
    • getLastGroup

      public int getLastGroup()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • applyToResultFactory

      public void applyToResultFactory(PreCalculatedResultFactory resultFactory, int index, boolean trackLastGroup)
      Updates a resultFactory in respect to a single transition and index.
      Parameters:
      resultFactory - the resultFactory to update.
      index - current index. All group boundaries contained in this object will be set to this value in the resultFactory.
    • applyExploded

      public void applyExploded(int[] array, int cgOffset, int lgOffset, int index, boolean trackLastGroup, boolean dontOverwriteLastGroup)
    • apply

      public void apply(int[] array, int cgOffset, int lgOffset, int index, boolean trackLastGroup)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toJson

      public JsonValue toJson()
      Specified by:
      toJson in interface JsonConvertible
    • indexUpdateSourceSectionsToJson

      public JsonArray indexUpdateSourceSectionsToJson(RegexAST ast)