1GraphViz::Parse::RecDesUcseenrt(C3o)ntributed Perl DocumGernatpahtViiozn::Parse::RecDescent(3)
2
3
4

NAME

6       GraphViz::Parse::RecDescent - Visualise grammars
7

SYNOPSIS

9         use GraphViz::Parse::RecDescent;
10
11         # Either pass in the grammar
12         my $graph = GraphViz::Parse::RecDescent->new($grammar);
13         print $g->as_png;
14
15         # or a Parse::RecDescent parser object
16         my $graph = GraphViz::Parse::RecDescent->new($parser);
17         print $g->as_ps;
18

DESCRIPTION

20       This module makes it easy to visualise Parse::RecDescent grammars.
21       Writing Parse::RecDescent grammars is tricky at the best of times, and
22       grammars almost always evolve in ways unforseen at the start. This
23       module aims to visualise a grammar as a graph in order to make the
24       structure clear and aid in understanding the grammar.
25
26       Rules are represented as nodes, which have their name on the left of
27       the node and their productions on the right of the node. The subrules
28       present in the productions are represented by edges to the subrule
29       nodes.
30
31       Thus, every node (rule) should be connected to the graph - otherwise a
32       rule is not part of the grammar.
33
34       This uses the GraphViz module to draw the graph. Thanks to Damian
35       Conway for the idea.
36
37       Note that the Parse::RecDescent module should be installed.
38

METHODS

40   new
41       This is the constructor. It takes one mandatory argument, which can
42       either be the grammar text or a Parse::RecDescent parser object of the
43       grammar to be visualised. A GraphViz object is returned.
44
45         # Either pass in the grammar
46         my $graph = GraphViz::Parse::RecDescent->new($grammar);
47
48         # or a Parse::RecDescent parser object
49         my $graph = GraphViz::Parse::RecDescent->new($parser);
50
51   as_*
52       The grammar can be visualised in a number of different graphical
53       formats. Methods include as_ps, as_hpgl, as_pcl, as_mif, as_pic, as_gd,
54       as_gd2, as_gif, as_jpeg, as_png, as_wbmp, as_ismap, as_imap, as_vrml,
55       as_vtx, as_mp, as_fig, as_svg. See the GraphViz documentation for more
56       information. The two most common methods are:
57
58         # Print out a PNG-format file
59         print $g->as_png;
60
61         # Print out a PostScript-format file
62         print $g->as_ps;
63

BUGS

65       Translating the grammar to a graph is accomplished by peeking inside
66       the internals of a parser object, which is a tad scary. A new version
67       of Parse::RecDescent with different internals may break this module.
68
69       At the moment, almost all Parse::RecDescent directives are supported.
70       If you find one that has been missed - let me know!
71
72       Unfortunately, alternations (such as the following) do not produce very
73       pretty graphs, due to the fact that they are implicit (unamed) rules
74       and are implemented by new long-named subrules.
75
76         character: 'the' ( good | bad | ugly ) /dude/
77
78       Hopefully Parse::FastDescent will make this all much easier.
79

AUTHOR

81       Leon Brocard <acme@astray.com>
82
84       Copyright (C) 2001, Leon Brocard
85
86       This module is free software; you can redistribute it or modify it
87       under the Perl License, a copy of which is available at
88       <http://dev.perl.org/licenses/>.
89
90
91
92perl v5.30.1                      2020-01-30    GraphViz::Parse::RecDescent(3)
Impressum