Previous: , Up: Progress reports   [Contents][Index]


20.2 Progress report methods

Mutator function: int marpa_r_progress_report_reset ( Marpa_Recognizer r)

On success, sets the current node of the report traverser to the start sentinel. See Progress report traverser.

This method is not usually needed. Its effect is to leave the traverser in the same state as it is immediately after the marpa_r_progress_report_start() method. Loosely speaking, it allows the traversal to “start over”.

Hard fails if the recognizer is not started, or if no progress report traverser is active.

Return value: On success, a non-negative value. On failure, -2.

Mutator function: int marpa_r_progress_report_start ( Marpa_Recognizer r, Marpa_Earley_Set_ID set_id)

Creates a progress report traverser in recognizer r for the Earley set with ID set_id.

On success, does the following:

Hard fails if no Earley set with ID set_id exists. The error code is MARPA_ERR_INVALID_LOCATION if set_id is negative. The error code is MARPA_ERR_NO_EARLEY_SET_AT_LOCATION if set_id is greater than the ID of the latest Earley set.

Return value: On success, the number of Earley items, which will always be non-negative. On hard failure, -2.

Mutator function: int marpa_r_progress_report_finish ( Marpa_Recognizer r )

On success, destroys the progress report traverser for recognizer r, freeing its memory. For details about the report traverser, see marpa_r_progress_report_start().

It is often not necessary to call this method. marpa_r_progress_report_start() destroys any previously existing progress report. And, when a recognizer is destroyed, its progress report is destroyed as a side effect.

Hard fails if no progress report is active.

Return value: On success, a non-negative value. On hard failure, -2.

Mutator function: Marpa_Rule_ID marpa_r_progress_item ( Marpa_Recognizer r, int* position, Marpa_Earley_Set_ID* origin )

This method allows access to the data for the next progress report item of a progress report. See Progress report traverser.

Let oldCurrent be the current node of the progress report traverser in r when this method was called. Let oldNext be the next link of oldCurrent. If oldCurrent is the end sentinel, oldNext is not defined, and this method soft fails.

In the event of success:

The “cooked dot position” is

In the event of soft failure:

In addition to watching for soft failure, the application can use the item count returned by marpa_r_progress_report_start() to determine when the last item has been seen.

Return value: On success, the rule ID of the progress report item, which is always non-negative. On soft failure, -1. If either the position or the origin argument is NULL, or on other hard failure, -2.


Previous: , Up: Progress reports   [Contents][Index]