rns / kollos-luif-doc

Reference documentation for LUIF (Lua Interface) of Kollos (Libmarpa + Lua) project
MIT License
2 stars 2 forks source link

Parse Events: adverbs + handlers? #32

Open rns opened 9 years ago

rns commented 9 years ago

LUIF manual currently specifies completion and prediction events via completed and predicted adverbs.

Their values are event handler functions, which can call context accessors to get location data and rule data.

Below is an idea on how to use that approach for other event types defined for Marpa::R2.

Nulling events can be set by modifying a nulling rule with nulled adverb.

Pre- and post-lexeme events can be set using predicted and completed adverbs of a lexeme rule (having action = lexeme or lexeme = true adverb). Their handlers will be able to use luif.recognizer.lexeme_read() to read lexemes and context accessors in luif.context.*.

Discard events can be set via discarded adverb on a lexeme rule.

discard = true on a lexeme rule will discard a lexeme, on a structural rule it will be a synonym for hiding ([]).

Exhaustion and rejection event handlers can be set in luif.recognizer.new(), and, if so set, will be synonymos to rejection = event in Marpa::R2.

All events are off (deactivated) by default that can be changed by luif.event.activate(rule_id, event_name) and luif.event.deactivate(rule_id, event_name), where event_name is the same as the adverb name. Alternatively, activate = on/off can be used in conjunction with the event handler adverbs.

jeffreykegler commented 9 years ago

Sounds basically good.

Note the distinction between nulling rules, which always derive the zero-length string, and nullable rules, which may derive the zero-length string. I think you say one in the above when you mean the other.

The idea of making hiding analogous to discarding is nice.

The event-adverb for discard needs another name, I think -- the name is analogous to other event names, but otherwise unsuggestive. Perhaps an event adverb, which is a discarded event for a discarded lexeme, a post-lexeme event for other lexemes and a completion event for structural rules.

Multiple event adverbs may occur with the same rule, so an activate adverb would be ambiguous.

On Thu, May 14, 2015 at 3:39 AM, rns notifications@github.com wrote:

LUIF manual currently specifies completion and prediction events via completed and predicted adverbs.

Their values are event handler functions, which can call context accessors https://github.com/rns/kollos-luif-doc/blob/master/manual.md#context_accessors to get location data and rule data.

Below is an idea on how to use that approach for other event types defined for Marpa::R2 https://metacpan.org/pod/distribution/Marpa-R2/pod/Event.pod.

Nulling events can be set by modifying a nulling rule with nulled adverb.

Pre- and post-lexeme events can be set using predicted and completed adverbs of a lexeme rule (having action = lexeme or lexeme = true adverb https://github.com/rns/kollos-luif-doc/issues/31). Their handlers will be able to use luif.recognizer.lexeme_read() to read lexemes and context accessors in luif.context.*.

Discard events can be set via discarded adverb on a lexeme rule.

discard = true on a lexeme rule will discard a lexeme, on a structural rule it will be a synonym for hiding ([]).

Exhaustion and rejection event handlers can be set in luif.recognizer.new(), and, if so set, will be synonymos to rejection = event in Marpa::R2.

All events are off (deactivated) by default that can be changed by luif.event.activate(rule_id, event_name) and luif.event.deactivate(rule_id, event_name), where event_name is the same as the adverb name. Alternatively, activate = on/off can be used in conjunction with the event handler adverbs.

— Reply to this email directly or view it on GitHub https://github.com/rns/kollos-luif-doc/issues/32.