The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Parse::RecDescent::Deparse - Turn a Parse::RecDescent object back into its grammar


  use Parse::RecDescent::Deparse;

  my $foo = new Parse::RecDescent($grammar);
  print $foo->deparse;


This module adds the deparse method to the Parse::RecDescent class, which returns a textual description of the grammar.

Why? There are at least two equally unlikely reasons why this could be useful:

  • You're working on something which grovels around in the Parse::RecDescent object data structure and want to view the effects of your changes. For instance, a Parse::RecDescent optimizer. (This package does not contain a functional Parse::RecDescent optimizer.)

  • You want to understand how Parse::RecDescent does what it does, and fancy the source of this package is a bit more of a gentle introduction than the source of Parse::RecDescent itself.


Parse::RecDescent::Deparse can correctly deparse the metagrammar for Parse::RecDescent input, so that's a good thing. There are no bugs in the Parse::RecDescent optimizer as it clearly does not exist.


Simon Cozens,