bueller.ca

the digital workshop of Matt Ferris

‹ API

ontoken()

void ontoken ( str token, ref handler )

Handlers are registered via ontoken(). Typically, handlers are simply passed a closure as ontoken() expects a reference to the handler.

Example 1 - registering a closure as a handler

ontoken('T_ACTION_ACCEPT', sub {

    # the accept token
    my $token = shift;

    # the position of the token in the rule
    my $tpos = shift;

    # do stuff here

});

Example 2 - registering a referenced handler

sub myHandler {
    my $token = shift;
    my $tpos = shift;
    # do stuff here
}

ontoken('T_ACTION_ACCEPT', \&myHandler);

‹ API