Next: , Previous: , Up: Events   [Contents][Index]


23.5 Prediction events

Libmarpa can be set up to generate a MARPA_EVENT_SYMBOL_PREDICTED event when a non-nulled symbol is predicted. A non-nulled symbol is said to be predicted when a instance of it is acceptable at the current earleme according to the grammar. Nulled symbols do not generate predictions.

For a prediction event to be generated, the symbol must be marked, and the event must be activated.

To mark a symbol as a prediction event symbol use the marpa_g_symbol_is_prediction_event_set() method. The event will be activated by default.

To activate or deactivate a prediction symbol event use the marpa_r_prediction_symbol_activate() method.

Mutator function: int marpa_g_prediction_symbol_activate ( Marpa_Grammar g, Marpa_Symbol_ID sym_id, int reactivate )

Allows the user to deactivate and reactivate symbol prediction events in the grammar. On success, does the following:

The activation status of a prediction event in the grammar becomes the initial activation status of a prediction event in all of its child recognizers.

This method is seldom needed. When a symbol is marked as a prediction event symbol in the grammar, it is activated by default. See marpa_g_symbol_is_prediction_event_set(). And a prediction event can be deactivated and reactivated in the recognizer using the marpa_r_prediction_symbol_activate method. See marpa_r_prediction_symbol_activate().

Hard fails if the sym_id is not marked as a prediction event symbol in the grammar, or if the grammar has not been precomputed.

Return value: On success, the value of reactivate, which is a boolean. On hard failure, -2.

Mutator function: int marpa_r_prediction_symbol_activate ( Marpa_Recognizer r, Marpa_Symbol_ID sym_id, int boolean )

Allows the user to deactivate and reactivate symbol prediction events in the recognizer. On success, does the following:

When a recognizer is created, the activation status of its symbol prediction event for sym_id is initialized to the activation status of the symbol prediction event for sym_id in the base grammar.

Hard fails if sym_id was not marked for prediction events in the base grammar.

Return value: On success, the value of reactivate, which is a boolean. On hard failure, -2.

Accessor function: int marpa_g_symbol_is_prediction_event ( Marpa_Grammar g, Marpa_Symbol_ID sym_id)

On success, returns a boolean which is 1 iff sym_id is marked as a prediction event symbol in g. For more about prediction events, see marpa_g_symbol_is_prediction_event_set().

On soft failure, sym_id is well-formed, but there is no such symbol.

Hard fails if g is precomputed.

Return value: On success, a boolean . On soft failure, -1. On hard failure, -2.

Mutator function: int marpa_g_symbol_is_prediction_event_set ( Marpa_Grammar g, Marpa_Symbol_ID sym_id, int value)

Libmarpa can be set up to generate a MARPA_EVENT_SYMBOL_PREDICTED event when a non-nulled symbol is predicted. A non-nulled symbol is said to be predicted when a instance of it is acceptable at the current earleme according to the grammar. Nulled symbols do not generate predictions.

For prediction events for sym_id to occur, sym_id must be marked as a prediction event symbol, and the prediction event for sym_id must be activated in the recognizer. Event activation also occurs in the grammar, and the recognizer event activation status for sym_id is initialized from the grammar event activation status for sym_id. See marpa_g_prediction_symbol_activate(), and see marpa_r_prediction_symbol_activate().

On success, if value is 1,

On success, if value is 0,

If sym_id is well-formed, but there is no such symbol, soft fails.

Hards fails if the grammar is precomputed.

Return value: On success, value, which is a boolean. On soft failure, -1. On hard failure, -2.


Next: , Previous: , Up: Events   [Contents][Index]