1GraphViz::Parse::Yapp(3U)ser Contributed Perl DocumentatiGornaphViz::Parse::Yapp(3)
2
3
4
6 GraphViz::Parse::Yapp - Visualise grammars
7
9 use GraphViz::Parse::Yapp;
10
11 # Pass in a file generated via yapp -v
12 my $g = GraphViz::Parse::Yapp->new('Yapp.output');
13 print $g->as_png;
14
16 This module makes it easy to visualise Parse::Yapp grammars. Writing
17 Parse::Yapp grammars is tricky at the best of times, and grammars
18 almost always evolve in ways unforseen at the start. This module aims
19 to visualise a grammar as a graph in order to make the structure clear
20 and aid in understanding the grammar.
21
22 Rules are represented as nodes, which have their name on the left of
23 the node and their productions on the right of the node. The subrules
24 present in the productions are represented by edges to the subrule
25 nodes.
26
27 Thus, every node (rule) should be connected to the graph - otherwise a
28 rule is not part of the grammar.
29
30 This uses the GraphViz module to draw the graph. Thanks to Damian Con‐
31 way for the original idea.
32
34 new
35
36 This is the constructor. It takes one mandatory argument, which is a
37 filename of the output file generated by running "yapp -v " on the
38 grammar file. For example, if your Parse::Yapp grammar file is called
39 "calc.yp", you would run "yapp -v calc.yp" and pass in "calc.output" as
40 an argument here. A GraphViz object is returned.
41
42 # Pass in a file generated via yapp -v
43 my $graph = GraphViz::Parse::Yapp->new('Yapp.output');
44 print $g->as_png;
45
46 as_*
47
48 The grammar can be visualised in a number of different graphical for‐
49 mats. Methods include as_ps, as_hpgl, as_pcl, as_mif, as_pic, as_gd,
50 as_gd2, as_gif, as_jpeg, as_png, as_wbmp, as_ismap, as_imap, as_vrml,
51 as_vtx, as_mp, as_fig, as_svg. See the GraphViz documentation for more
52 information. The two most common methods are:
53
54 # Print out a PNG-format file
55 print $g->as_png;
56
57 # Print out a PostScript-format file
58 print $g->as_ps;
59
61 Leon Brocard <acme@astray.com>
62
64 Copyright (C) 2001, Leon Brocard
65
66 This module is free software; you can redistribute it or modify it
67 under the same terms as Perl itself.
68
69
70
71perl v5.8.8 2004-12-02 GraphViz::Parse::Yapp(3)