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 mod‐
23       ule aims to visualise a grammar as a graph in order to make the struc‐
24       ture 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 Con‐
35       way for the idea.
36
37       Note that the Parse::RecDescent module should be installed.
38

METHODS

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

BUGS

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

AUTHOR

83       Leon Brocard <acme@astray.com>
84
86       Copyright (C) 2001, Leon Brocard
87
88       This module is free software; you can redistribute it or modify it
89       under the same terms as Perl itself.
90
91
92
93perl v5.8.8                       2004-12-02    GraphViz::Parse::RecDescent(3)
Impressum