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


25.15 Per-rule events

The event types are either global or per-symbol — there are no per-rule events. Nonetheless, the user can get the equivalent of per-rule events in two ways, both discussed previously (see Marker symbols). The competely general way is to use marker symbols.

The other way is to declare MARPA_EVENT_SYMBOL_PREDICTED and MARPA_EVENT_SYMBOL_COMPLETED events for the LHS of the rule. This has two limitations: First, it can only trigger events before the first RHS symbol of the rule, or after the rule’s last RHS symbol. Second, the MARPA_EVENT_SYMBOL_PREDICTED and MARPA_EVENT_SYMBOL_COMPLETED events will trigger events for all rules with the same LHS, which may not be what is wanted.

We illustrate the second limitation with an example, which we will call lim2Ex. In lim2Ex, we have the following:

Suppose we want an event to trigger at, and only at, the place when rule (R3) is fully recognized. In lim2Ex, the MARPA_EVENT_SYMBOL_COMPLETED event for symbol A triggers at the end of both rules (R3) and (R4). The triggering at the end of rule (R4) is problematic.