public final class DFACaptureGroupPartialTransition extends Object implements JsonConvertible
| Modifier and Type | Class and Description |
|---|---|
static class |
DFACaptureGroupPartialTransition.IndexOperation |
static class |
DFACaptureGroupPartialTransition.LastGroupUpdate |
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY |
static DFACaptureGroupPartialTransition.IndexOperation[] |
EMPTY_INDEX_OPS |
static DFACaptureGroupPartialTransition.LastGroupUpdate[] |
EMPTY_LAST_GROUP_UPDATES |
static int |
FINAL_STATE_RESULT_INDEX |
public static final int FINAL_STATE_RESULT_INDEX
public static final byte[] EMPTY
public static final DFACaptureGroupPartialTransition.IndexOperation[] EMPTY_INDEX_OPS
public static final DFACaptureGroupPartialTransition.LastGroupUpdate[] EMPTY_LAST_GROUP_UPDATES
public static DFACaptureGroupPartialTransition create(DFAGenerator dfaGen, byte[] reorderSwaps, byte[] arrayCopies, DFACaptureGroupPartialTransition.IndexOperation[] indexUpdates, DFACaptureGroupPartialTransition.IndexOperation[] indexClears, DFACaptureGroupPartialTransition.LastGroupUpdate[] lastGroupUpdates, byte preReorderFinalStateResultIndex)
DFACaptureGroupPartialTransition. All numeric values stored in this
class refer to indices of the first or second dimension of
DFACaptureGroupTrackingData.results and are stored as byte to save space.
This is OK since the dimensions of DFACaptureGroupTrackingData.results are capped by
TRegexOptions.TRegexMaxNumberOfNFAStatesInOneDFATransition
(1st dimension) and
TRegexOptions.TRegexMaxNumberOfCaptureGroupsForDFA
* 2 (2nd dimension, times two because we need two array slots per capture group, one
for the beginning and one for the end). DFACaptureGroupTrackingData.results as a 2D-array here, it is
actually flattened into one dimension for performance. For that reason, we additionally have
DFACaptureGroupTrackingData.currentResultOrder, which stores the offset of every
"row" in the 2D-array. We need to be able to reorder the rows of the 2D-array, and we do that
by simply reordering DFACaptureGroupTrackingData.currentResultOrder. DFACaptureGroupTrackingData.results is a 3x2 array, then
DFACaptureGroupTrackingData.currentResultOrder will initially contain [0, 2, 4]. If
we want to swap the first two rows of the 2D array,
DFACaptureGroupTrackingData.currentResultOrder becomes [2, 0, 4].reorderSwaps - reorder DFACaptureGroupTrackingData.currentResultOrder using a
sequence of swap operations described in this array. Every two elements in this
array denote one swap operation.
Example:
If currentResultOrder = DFACaptureGroupTrackingData#currentResultOrder and
reorderSwaps = [0, 1, 1, 2], then currentResultOrder[0] will be
swapped with currentResultOrder[1], and currentResultOrder[1] will
be swapped with currentResultOrder[2], in that order.
arrayCopies - copy rows of DFACaptureGroupTrackingData.results (1st dimension)
as described in this array. Every two elements in this array denote one copy
operation, where the first element is the source, and the second is the target.
The copy operations will be applied after the reordering of
DFACaptureGroupTrackingData.currentResultOrder with reorderSwaps.
Example:
If results = DFACaptureGroupTrackingData#results and
arrayCopies = [0, 1, 2, 3], then the contents of results[0] will
be copied into results[1], and the contents of results[2] will be
copied into results[3].
indexUpdates - denotes which index of which array in
DFACaptureGroupTrackingData.results shall be updated to
currentIndex in
DFACaptureGroupPartialTransition.apply(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int),
DFACaptureGroupPartialTransition.applyPreFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int, boolean)
and
DFACaptureGroupPartialTransition.applyFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int)
. In every row (1st dimension element) of this 2D array, the first value is the
index of one row in DFACaptureGroupTrackingData.results, all following
values are indices in that row that shall be set to currentIndex.
Example:
If results = DFACaptureGroupTrackingData#results and
indexUpdates = [[0, 1, 2], [3, 4]], then results[0][1],
results[0][2] and results[3][4] will be set to
currentIndex.
indexClears - denotes which index of which array in
DFACaptureGroupTrackingData.results shall be updated to 0 in
DFACaptureGroupPartialTransition.apply(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int),
DFACaptureGroupPartialTransition.applyPreFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int, boolean)
and
DFACaptureGroupPartialTransition.applyFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int)
, analogous to indexUpdates.preReorderFinalStateResultIndex - denotes the row (1st dimension element) of
DFACaptureGroupTrackingData.results that corresponds to the NFA final
state before the reordering given by reorderSwaps is applied.
This is needed in
DFACaptureGroupPartialTransition.applyPreFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int, boolean)
when TRegexDFAExecutorNode.isSearching() is true, because in that
case we need to be able to apply copy the current result corresponding to the NFA
final state without doing any reordering.DFACaptureGroupPartialTransition, or a static empty instance if all
arguments are empty or zero.public static DFACaptureGroupPartialTransition intersect(DFACaptureGroupPartialTransition[] transitions)
public DFACaptureGroupPartialTransition subtract(DFACaptureGroupPartialTransition other)
public static DFACaptureGroupPartialTransition getEmptyInstance()
public boolean isEmpty()
public int getId()
public boolean doesReorderResults()
public byte[] getReorderSwaps()
public byte[] getArrayCopies()
public DFACaptureGroupPartialTransition.IndexOperation[] getIndexUpdates()
public DFACaptureGroupPartialTransition.IndexOperation[] getIndexClears()
public DFACaptureGroupPartialTransition.LastGroupUpdate[] getLastGroupUpdates()
public int getCost()
public void apply(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex)
public void apply(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex, boolean preFinal, boolean export)
public void applyFinalStateTransition(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex)
public JsonValue toJson()
toJson in interface JsonConvertible