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


23.3 Completion events

Libmarpa can be set up to generate a MARPA_EVENT_SYMBOL_COMPLETED event whenever the symbol is completed. A symbol is said to be completed when a non-nulling rule with that symbol on its LHS is completed.

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

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

To activate or deactivate a completion symbol event use the marpa_r_completion_symbol_activate() method.

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

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

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

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

Hard fails if the sym_id is not marked as a completion 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_completion_symbol_activate ( Marpa_Recognizer r, Marpa_Symbol_ID sym_id, int reactivate )

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

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

Hard fails if sym_id was not marked for completion 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_completion_event ( Marpa_Grammar g, Marpa_Symbol_ID sym_id)

On success, returns a boolean which is 1 iff sym_id is marked as a completion event symbol in g. For more about completion events, see marpa_g_symbol_is_completion_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_completion_event_set ( Marpa_Grammar g, Marpa_Symbol_ID sym_id, int value)

Libmarpa can be set up to generate an MARPA_EVENT_SYMBOL_COMPLETED event whenever the symbol is completed. A symbol is said to be completed when a non-nulling rule with that symbol on its LHS is completed.

For completion events for sym_id to occur, sym_id must be marked as a completion event symbol, and the completion 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_completion_symbol_activate(), and see marpa_r_completion_symbol_activate().

On success, if value is 1,

On success, if value is 0,

Nulled rules and symbols will never cause completion events. Nullable symbols may be marked as completion event symbols, but this will have an effect only when the symbol is not nulled. Nulling symbols may be marked as completion event symbols, but no completion events will ever be generated for a nulling symbol. Note that this implies that no completion event will ever be generated at earleme 0, the start of parsing.

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]