bueller.ca

the digital workshop of Matt Ferris

‹ API

newrule()

hashref newrule ()

Example 1 - calling newrule()

ontoken('T_ACTION_ACCEPT', sub {

    # the accept token
    my $token = shift;

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

    $rule = newrule();

});

When newrule() is called, a new rule structure is created within the current scope and set as the current rule being processed.

Example 2 - calling getrule() before and after newrule()

# get the current rule
$ruleA = getrule();

# create a new rule
newrule();

# get the current rule again
$ruleB = getrule();

if ($ruleA != $ruleB) {
    print "rules don't match";
}
else {
    print "rules match";
}

In the above example, the output would be rules don't match as the call to newrule() replaced the existing rule for the scope.

See also

getrule()

‹ API