- Actions look like standard Perl blocks.
- Inside the actions, Parse::RecDescent will supply
several variables for us:
This is a list with the return values of all the matched
items in the current production. $item is
the name of the current rule.
Compare the use of $1, $2 in a
This provides named access to the items that are already
matched in the current production. Items are named after the
subrules they match; other items have a number as key, the
number that corresponds with the number in the
- $return. If an assignment to
$return is made in a production and
the production succeeds, $return is returned
instead of the value of the last item.
Compare the use of $$ in a yacc grammar.
- $text. The remaining of the unparsed text.
You may assign to this - if the production fails, any changes
to $text don't propagate out - but they do if the
- $thisline, $prevline, $thiscolumn, $prevcolumn,
these variables give information on where in the text the
parser is. This can be useful for error messages.
- $thisparser. A reference to the
current parser object. For deep magic, assign to this
variable and switch to a different parser for the remainer
of the current rule...
- $thisrule, $thisprod.
References to objects representing the current rule and
If you need scribble space in these variables, use
- And more...
- Startup actions are performed before attempting to match the
first rule. Startup actions are found in the grammar before
the definition of the first rule. Typical usuage is to initialize