1GraphViz2::Parse::RecDeUssceerntC(o3n)tributed Perl DocuGmreanpthaVtiizo2n::Parse::RecDescent(3)
2
3
4

NAME

6       GraphViz2::Parse::RecDescent - Visualize a Parse::RecDescent grammar as
7       a graph
8

Synopsis

10               #!/usr/bin/env perl
11
12               use strict;
13               use warnings;
14
15               use File::Spec;
16
17               use GraphViz2;
18               use GraphViz2::Parse::RecDescent;
19
20               use Log::Handler;
21
22               use Parse::RecDescent;
23
24               use File::Slurp; # For read_file().
25
26               # ------------------------------------------------
27
28               my($logger) = Log::Handler -> new;
29
30               $logger -> add
31                       (
32                        screen =>
33                        {
34                                maxlevel       => 'debug',
35                                message_layout => '%m',
36                                minlevel       => 'error',
37                        }
38                       );
39
40               my($graph) = GraphViz2 -> new
41                       (
42                        edge   => {color => 'grey'},
43                        global => {directed => 1},
44                        graph  => {rankdir => 'TB'},
45                        logger => $logger,
46                        node   => {color => 'blue', shape => 'oval'},
47                       );
48               my($g)      = GraphViz2::Parse::RecDescent -> new(graph => $graph);
49               my $grammar = read_file(File::Spec -> catfile('t', 'sample.recdescent.1.dat') );
50               my($parser) = Parse::RecDescent -> new($grammar);
51
52               $g -> create(name => 'Grammar', grammar => $parser);
53
54               my($format)      = shift || 'svg';
55               my($output_file) = shift || File::Spec -> catfile('html', "parse.recdescent.$format");
56
57               $graph -> run(format => $format, output_file => $output_file);
58
59       See scripts/parse.recdescent.pl ("Scripts Shipped with this Module" in
60       GraphViz2).
61

Description

63       Takes a Parse::RecDescent grammar and converts it into a graph.
64
65       You can write the result in any format supported by Graphviz
66       <http://www.graphviz.org/>.
67
68       Here is the list of output formats
69       <http://www.graphviz.org/content/output-formats>.
70

Distributions

72       This module is available as a Unix-style distro (*.tgz).
73
74       See <http://savage.net.au/Perl-modules/html/installing-a-module.html>
75       for help on unpacking and installing distros.
76

Installation

78       Install GraphViz2 as you would for any "Perl" module:
79
80       Run:
81
82               cpanm GraphViz2
83
84       or run:
85
86               sudo cpan GraphViz2
87
88       or unpack the distro, and then either:
89
90               perl Build.PL
91               ./Build
92               ./Build test
93               sudo ./Build install
94
95       or:
96
97               perl Makefile.PL
98               make (or dmake or nmake)
99               make test
100               make install
101

Constructor and Initialization

103   Calling new()
104       "new()" is called as "my($obj) = GraphViz2::Parse::RecDescent -> new(k1
105       => v1, k2 => v2, ...)".
106
107       It returns a new object of type "GraphViz2::Parse::RecDescent".
108
109       Key-value pairs accepted in the parameter list:
110
111       o graph => $graphviz_object
112           This option specifies the GraphViz2 object to use. This allows you
113           to configure it as desired.
114
115           The default is GraphViz2 -> new. The default attributes are the
116           same as in the synopsis, above, except for the logger of course,
117           which defaults to ''.
118
119           This key is optional.
120

Methods

122   create(name => $name, grammar => $grammar)
123       Creates the graph, which is accessible via the graph() method, or via
124       the graph object you passed to new().
125
126       Returns $self for method chaining.
127
128       $name is the string which will be placed in the root node of the tree.
129
130       $grammar is either a Parse::RecDescent object or a grammar. If it's a
131       grammar, the code will fabricate an object of type Parse::RecDescent.
132
133   graph()
134       Returns the graph object, either the one supplied to new() or the one
135       created during the call to new().
136

FAQ

138       See "FAQ" in GraphViz2 and "Scripts Shipped with this Module" in
139       GraphViz2.
140

Thanks

142       Many thanks are due to the people who chose to make Graphviz
143       <http://www.graphviz.org/> Open Source.
144
145       And thanks to Leon Brocard <http://search.cpan.org/~lbrocard/>, who
146       wrote GraphViz, and kindly gave me co-maint of the module.
147

Version Numbers

149       Version numbers < 1.00 represent development versions. From 1.00 up,
150       they are production versions.
151

Machine-Readable Change Log

153       The file Changes was converted into Changelog.ini by
154       Module::Metadata::Changes.
155

Support

157       Email the author, or log a bug on RT:
158
159       <https://rt.cpan.org/Public/Dist/Display.html?Name=GraphViz2>.
160

Author

162       GraphViz2 was written by Ron Savage <ron@savage.net.au> in 2011.
163
164       Home page: <http://savage.net.au/index.html>.
165
167       Australian copyright (c) 2011, Ron Savage.
168
169               All Programs of mine are 'OSI Certified Open Source Software';
170               you can redistribute them and/or modify them under the terms of
171               The Perl License, a copy of which is available at:
172               http://dev.perl.org/licenses/
173
174
175
176perl v5.28.1                      2018-02-23   GraphViz2::Parse::RecDescent(3)
Impressum