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


14.6 Other parse status methods

Function: int marpa_r_earley_item_warning_threshold (Marpa_Recognizer r)

Returns the Earley item warning threshold. See marpa_r_earley_item_warning_threshold_set().

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

Function: int marpa_r_earley_item_warning_threshold_set (Marpa_Recognizer r, int threshold)

[Mutator] 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.

Function: int marpa_r_is_exhausted (Marpa_Recognizer r)

A parser is “exhausted” if it cannot accept any more input. Both successful and failed parses can be exhausted. In many grammars, the parse is always exhausted as soon as it succeeds. Good parses may also exist at earlemes prior to the current one.

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

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 a number of Marpa_Symbol_ID’s that 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. On failure, -2.

Function: int marpa_r_terminal_is_expected ( Marpa_Recognizer r, Marpa_Symbol_ID symbol_id)

Return values on success: If symbol_id is the ID of a valid terminal symbol that is expected at the current earleme, a number greater than zero. If symbol_id is the ID of a valid terminal symbol that is not expected at the current earleme, or if symbol_id is the ID of a valid symbol that is not a terminal, zero.

Failure cases: Returns -2 on failure. It is a failure if symbol_id is not the ID of a valid symbol.


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