What arguments are passed to the Marpa :: R2 action?

AT Marpa :: R2 page , I understand BNF (Backus-Naur form), but I completely lost the effect of callbacks.

In this example below, I understand that the two, left and right members are passed on do_multiply. I have no problem with this. The problem is that I can’t find the documentation about what these arguments are?

my $dsl = <<'END_OF_DSL';
:default ::= action => [name,values]
lexeme default = latm => 1    
Calculator ::= Expression action => ::first
...
    Term '*' Factor action => do_multiply
...
END_OF_DSL

my $grammar = Marpa::R2::Scanless::G->new( { source => \$dsl } );

sub do_multiply    { $_[1] * $_[2] }   

What is $_[0]or even $_[3]? Where is this documented? Even on the official marpa website I do not see any documentation.

In another example, here is the answer of chobora , we see what pairapplies to $_[2]and $_[3]:

Fragment of BNF:

Hash  ::= '(' Pairs ')'     action => hash
Pairs ::= Pair+             action => pairs
Pair  ::= '(' Key Value ')' action => pair
Key   ::= String

Kernel Code:

$recce->read(\$input);
print Dumper $recce->value;

sub hash   { $_[2] }
sub pairs  { shift; +{ map @$_, @_ } }
sub pair   { [ @_[2, 3] ] }               # What is 2 and 3?
sub itself { $_[1] }
+4
source share
1

Marpe:: R2 docs :

sub My_Actions::do_add {
    my ( undef, $t1, undef, $t2 ) = @_;
    return $t1 + $t2;
}

Perl - . node .

Perl . value per-parse-tree, . per-parse-tree object . node "children" - , RHS . , per-parse-tree.

, . , node . . .

, . $_[0].

, $_[1] $_[2] - , .


:

use Data::Printer;

sub My_Actions::do_add {
    my ( undef, $t1, undef, $t2 ) = @_;
say 'do_add';
p @_;

    return $t1 + $t2;
}

sub My_Actions::do_multiply {
    my ( undef, $t1, undef, $t2 ) = @_;
say 'do_multiply';
p @_;
   return $t1 * $t2;
}

__END__

do_multiply
[
    [0] {},
    [1] 42,
    [2] "*",
    [3] 1
]
do_add
[
    [0] {},
    [1] 42,
    [2] "+",
    [3] 7
]
+4

All Articles