++ed by:

2 PAUSE users
2 non-PAUSE users.

Ron Savage


GraphViz2::Parse::RecDescent - Visualize a Parse::RecDescent grammar as a graph


        #!/usr/bin/env perl
        use strict;
        use warnings;
        use File::Spec;
        use GraphViz2;
        use GraphViz2::Parse::RecDescent;
        use Log::Handler;
        use Parse::RecDescent;
        use Perl6::Slurp;
        $logger -> add
                 screen =>
                         maxlevel       => 'debug',
                         message_layout => '%m',
                         minlevel       => 'error',
        my($graph) = GraphViz2 -> new
                 edge   => {color => 'grey'},
                 global => {directed => 1},
                 graph  => {rankdir => 'TB'},
                 logger => $logger,
        my($g)      = GraphViz2::Parse::RecDescent -> new(graph => $graph);
        my $grammar = slurp(File::Spec -> catfile('t', 'sample.recdescent.1.dat') );
        my($parser) = Parse::RecDescent -> new($grammar);
        $g -> create(name => 'Grammar', grammar => $parser);
        my($output_file) = shift || File::Spec -> catfile('html', "parse.recdescent.$format");

See scripts/parse.recdescent.pl ("Scripts Shipped with this Module" in GraphViz2).


Takes a Parse::RecDescent grammar and converts it into a graph.

You can write the result in any format supported by Graphviz.

Here is the list of output formats.



See http://savage.net.au/Perl-modules/html/installing-a-module.html for help on unpacking and installing distros.


Install GraphViz2 as you would for any Perl module:


        cpanm GraphViz2

or run:

        sudo cpan GraphViz2

or unpack the distro, and then either:

        perl Build.PL
        ./Build test
        sudo ./Build install


        perl Makefile.PL
        make (or dmake or nmake)
        make test
        make install

Constructor and Initialization

Calling new()

new() is called as my($obj) = GraphViz2::Parse::RecDescent -> new(k1 => v1, k2 => v2, ...).

It returns a new object of type GraphViz2::Parse::RecDescent.

Key-value pairs accepted in the parameter list:

o graph => $graphviz_object



This key is optional.


create(name => $name, grammar => $grammar)


Returns $self for method chaining.

$name is the string which will be placed in the root node of the tree.

$grammar is either a Parse::RecDescent object or a grammar. If it's a grammar, the code will fabricate an object of type Parse::RecDescent.








Version Numbers


Machine-Readable Change Log



Email the author, or log a bug on RT:



GraphViz2 was written by Ron Savage <ron@savage.net.au> in 2011.

Home page: http://savage.net.au/index.html.


Australian copyright (c) 2011, Ron Savage.

        The Artistic License, a copy of which is available at: