1GraphViz2::Parse::Yacc(U3s)er Contributed Perl DocumentatGiroanphViz2::Parse::Yacc(3)
2
3
4

NAME

6       GraphViz2::Parse::Yacc - Visualize a yacc grammar as a graph
7

SYNOPSIS

9           use GraphViz2::Parse::Yacc;
10           # no objects - quicker
11           my $gd = GraphViz2::Parse::Yacc::to_graph('t/calc3.output');
12
13           # populate a GraphViz2 object with a Graph::Directed of a parser
14           my $gv = GraphViz2->from_graph(GraphViz2::Parse::Yacc::graphvizify($gd));
15
16           # OO interface, using lazy-built attributes
17           my $gvp = GraphViz2::Parse::Yacc->new(file_name => $file_name);
18           my $gd = $gvp->as_graph; # Graph::Directed object
19           # or supply a suitable Graph::Directed object
20           my $gvp = GraphViz2::Parse::Yacc->new(as_graph => $gd);
21           # then get the GraphViz2 object
22           my $gv = $gvp->graph;
23
24           # DEPRECATED ways to get $gvp with populated $gv
25           my $gvp = GraphViz2::Parse::Yacc->new;
26           $gvp->create(file_name => 't/calc3.output');
27           my $gv = $gvp->graph;
28           # or give it a pre-set-up GraphViz2 object
29           my $gv = GraphViz2->new(...);
30           my $gvp = GraphViz2::Parse::Yacc->new(graph => $gv);
31           # call ->create as above
32
33           # produce a visualisation
34           my $format = shift || 'svg';
35           my $output_file = shift || "output.$format";
36           $gv->run(format => $format, output_file => $output_file);
37
38       See t/gen.parse.yacc.pl.
39

DESCRIPTION

41       Takes a yacc grammar and converts it into a Graph::Directed object, or
42       directly into a GraphViz2 object.
43

FUNCTIONS

45       This is the recommended interface.
46
47   to_graph
48           my $gd = GraphViz2::Parse::Yacc::to_graph('t/calc3.output');
49
50       Given a yacc grammar, returns a Graph::Directed object describing the
51       finite state machine for it.
52
53   graphvizify
54           my $gv = GraphViz2->from_graph(GraphViz2::Parse::Yacc::graphvizify($gd));
55
56       Mutates the given graph object to add to it the "graphviz" attributes
57       visualisation "hints" that will make the "from_graph" in GraphViz2
58       method visualise this regular expression in the most meaningful way,
59       including labels and groupings.
60
61       It is idempotent as it simply sets the "graphviz" attribute of the
62       relevant graph entities.
63
64       Returns the graph object for convenience.
65

METHODS

67       This is a Moo class, but with a recommended functional interface.
68
69   Constructor attributes
70       file_name
71
72       The name of a yacc output file. See t/calc3.output.
73
74       This key is optional. You need to provide it by the time you access
75       either the "as_graph" or "graph".
76
77       as_graph
78
79       The Graph::Directed object to use. If not given, will be lazily built
80       on access, from the "file_name".
81
82       graph
83
84       The GraphViz2 object to use. This allows you to configure it as
85       desired.
86
87       This key is optional. If provided, the "create" method will populate
88       it.  If not, it will have these defaults, lazy-built and populated from
89       the "as_graph".
90
91           my $gv = GraphViz2->new(
92                   edge   => {color => 'grey'},
93                   global => {directed => 1},
94                   graph  => {rankdir => 'TB'},
95                   node   => {color => 'blue', shape => 'oval'},
96           );
97
98   create(file_name => $file_name)
99       DEPRECATED. Mutates the object to set the "file_name" attribute, then
100       accesses the "as_graph" attribute (possibly lazy-building it), then
101       "graphvizify"s its "as_graph" attribute with that information, then
102       "from_graph"s its "graph".
103
104       Returns $self for method chaining.
105

THANKS

107       Many thanks are due to the people who chose to make Graphviz
108       <http://www.graphviz.org/> Open Source.
109
110       And thanks to Leon Brocard <http://search.cpan.org/~lbrocard/>, who
111       wrote GraphViz, and kindly gave me co-maint of the module.
112

AUTHOR

114       GraphViz2 was written by Ron Savage <ron@savage.net.au> in 2011.
115
116       Home page: <http://savage.net.au/index.html>.
117
119       Australian copyright (c) 2011, Ron Savage.
120
121       All Programs of mine are 'OSI Certified Open Source Software'; you can
122       redistribute them and/or modify them under the terms of The Perl
123       License, a copy of which is available at: http://dev.perl.org/licenses/
124
125
126
127perl v5.36.0                      2023-01-20         GraphViz2::Parse::Yacc(3)
Impressum