Previous: , Up: Recognizer methods   [Contents][Index]


19.6 Other parse status methods

Accessor function: int marpa_r_earley_item_warning_threshold (Marpa_Recognizer r)

Details about the “earley item warning threshold” are in the description of the marpa_r_earley_item_warning_threshold_set() method. See marpa_r_earley_item_warning_threshold_set().

Return value: The Earley item warning threshold. Always succeeds.

Mutator function: int marpa_r_earley_item_warning_threshold_set (Marpa_Recognizer r, int threshold)

On success, sets the Earley item warning threshold. The Earley item warning threshold is a number that is compared with the count of Earley items in each Earley set. When it is matched or exceeded, a MARPA_EVENT_EARLEY_ITEM_THRESHOLD event is created. See MARPA_EVENT_EARLEY_ITEM_THRESHOLD.

If threshold is zero or less, an unlimited number of Earley items will be allowed without warning. This will rarely be what the user wants.

By default, Libmarpa calculates a value based on the grammar. The formula Libmarpa uses is the result of some experience, and most applications will be happy with it.

What should be done when the threshold is exceeded, depends on the application, but exceeding the threshold means that it is very likely that the time and space resources consumed by the parse will prove excessive. This is often a sign of a bug in the grammar. Applications often will want to smoothly shut down the parse, in effect treating the MARPA_EVENT_EARLEY_ITEM_THRESHOLD event as equivalent to library-recoverable hard failure.

Return value: The value that the Earley item warning threshold has after the method call is finished. Always succeeds.

Accessor function: int marpa_r_is_exhausted (Marpa_Recognizer r)

A parser is “exhausted” if it cannot accept any more input. See Exhaustion.

Return value: 1 if the parser is exhausted, 0 otherwise. Always succeeds.

Accessor function: int marpa_r_terminals_expected ( Marpa_Recognizer r, Marpa_Symbol_ID* buffer)

Returns a list of the ID’s of the symbols that are acceptable as tokens at the current earleme. buffer is expected to be large enough to hold the result. This is guaranteed to be the case if the buffer is large enough to hold an array of Marpa_Symbol_ID’s whose length is greater than or equal to the number of symbols in the grammar.

Return value: On success, the number of Marpa_Symbol_ID’s in buffer, which is always non-negative. On hard failure, -2.

Accessor function: int marpa_r_terminal_is_expected ( Marpa_Recognizer r, Marpa_Symbol_ID symbol_id)

On success, does the folloing:

Hard fails if the symbol with ID symbol_id does not exist.

Return value: On success, 0 or 1. On hard failure, -2.


Previous: , Up: Recognizer methods   [Contents][Index]