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
31 Conway for the original idea.
32
34 new
35 This is the constructor. It takes one mandatory argument, which is a
36 filename of the output file generated by running "yapp -v " on the
37 grammar file. For example, if your Parse::Yapp grammar file is called
38 "calc.yp", you would run "yapp -v calc.yp" and pass in "calc.output" as
39 an argument here. A GraphViz object is returned.
40
41 # Pass in a file generated via yapp -v
42 my $graph = GraphViz::Parse::Yapp->new('Yapp.output');
43 print $g->as_png;
44
45 as_*
46 The grammar can be visualised in a number of different graphical
47 formats. Methods include as_ps, as_hpgl, as_pcl, as_mif, as_pic, as_gd,
48 as_gd2, as_gif, as_jpeg, as_png, as_wbmp, as_ismap, as_imap, as_vrml,
49 as_vtx, as_mp, as_fig, as_svg. See the GraphViz documentation for more
50 information. The two most common methods are:
51
52 # Print out a PNG-format file
53 print $g->as_png;
54
55 # Print out a PostScript-format file
56 print $g->as_ps;
57
59 Leon Brocard <acme@astray.com>
60
62 Copyright (C) 2001, Leon Brocard
63
64 This module is free software; you can redistribute it or modify it
65 under the Perl License, a copy of which is available at
66 <http://dev.perl.org/licenses/>.
67
68
69
70perl v5.32.0 2020-07-28 GraphViz::Parse::Yapp(3)