Curtailment

Return to Contents

CAUTION: This is implementation information and should not be relied upon in any way when using the library.

A curtailment is information attached to a result denoting one or more combinator/depth pairs.

Curtailment in general means that the result for a given combinator at a given position is only valid when that combinator is next encountered at that position for left recursion depth counts equal or greater than the curtailment.

If the left recursion count of a combinator at a particular position exceeds the number of remaining input tokens plus one, the combinator is curtailed at that count depth and fails.

When results are folded upwards, any curtailments are retained.

When two results are merged as in Sequence and Choice, if the results share curtailments then the curtailment of greater depth is retained.

If a result has to be recalculated due to the previous result for a given combinator at a given position not being valid due to being curtailed at a greater left recursion depth, then the recalculated result has the previous result's curtailments applied to it, except with the count depths replaced with the current left recursion depths.

When a result is recalculated and the depth of a curtailment plus the number of remaining tokens after the furthest finish of a result is less than the remaining tokens at the start of a result, then the curtail can be deleted from the result, since then it is no longer possible for curtailment to happen due to excessive left recursion count depth. This is algebraically equivalent to checking if the furthest finish of a result minus the left recursion depth is greater than the start position of the result.