GraphV...::Yapp(3pm)
β¨ GraphViz2::Parse::Yapp β¨
okay bestie, gather round, because this is the GraphViz2::Parse::Yapp page from the 3pm manual section and it's literally about turning your yapp grammar into a whole visual graph ππ
πΈ NAME πΈ
GraphViz2::Parse::Yapp β visualize a yapp grammar as a graph π¦
β¨ SYNOPSIS β¨
use GraphViz2::Parse::Yapp;
# no objects - quicker
my $gd = GraphViz2::Parse::Yapp::to_graph('t/calc.output');
# populate a GraphViz2 object with a Graph::Directed of a parser
my $gv = GraphViz2->from_graph(GraphViz2::Parse::Yapp::graphvizify($gd));
# OO interface, using lazy-built attributes
my $gvp = GraphViz2::Parse::Yapp->new(file_name => $file_name);
my $gd = $gvp->as_graph; # Graph::Directed object
# or supply a suitable Graph::Directed object
my $gvp = GraphViz2::Parse::Yapp->new(as_graph => $gd);
# then get the GraphViz2 object
my $gv = $gvp->graph;
# DEPRECATED ways to get $gvp with populated $gv
my $gvp = GraphViz2::Parse::Yapp->new;
$gvp->create(file_name => 't/calc.output');
my $gv = $gvp->graph;
# or give it a pre-set-up GraphViz2 object
my $gv = GraphViz2->new(...);
my $gvp = GraphViz2::Parse::Yapp->new(graph => $gv);
# call ->create as above
# produce a visualisation
my $format = shift || 'svg';
my $output_file = shift || "output.$format";
$gv->run(format => $format, output_file => $output_file);
See t/gen.parse.yapp.pl π
π DESCRIPTION π
It takes a yapp grammar and converts it into a Graph::Directed object, or β if you're feeling direct β straight into a GraphViz2 object. no cap, that's the whole vibe π
π«Ά FUNCTIONS π«Ά
This is the recommended interface, bestie. use this one.
π to_graph
my $gd = GraphViz2::Parse::Yapp::to_graph('t/calc.output');
Give it a yapp grammar and it hands you back a Graph::Directed object that describes the finite state machine for it. iconic behavior honestly π
π graphvizify
my $gv = GraphViz2->from_graph(GraphViz2::Parse::Yapp::graphvizify($gd));
This one mutates the graph object you pass in π³ β it adds the "graphviz" attribute visualisation "hints" that make the "from_graph" in GraphViz2 method visualise this regular expression in the most meaningful way possible, labels and groupings included. slay.
It's idempotent, because it just sets the "graphviz" attribute of the relevant graph entities. so running it again? no drama π
Returns the graph object, for convenience π
π METHODS π
This is a Moo class, but with a recommended functional interface. yes, both. she contains multitudes.
πΈ Constructor attributes πΈ
file_nameβ the name of a yapp output file. Seet/calc.output. This key is optional, but you do need to provide it by the time you access either the"as_graph"or"graph". β°as_graphβ theGraph::Directedobject to use. If you don't give it one, it'll be lazily built on access, from the"regexp". π§graphβ theGraphViz2object to use. This is the one that lets you configure things exactly how you want them. π
This key is optional. If you provide it, the "create" method will populate it. If you don't, it'll have these defaults, lazy-built and populated from the "as_graph":
my $gv = GraphViz2->new(
edge => {color => 'grey'},
global => {directed => 1},
graph => {rankdir => 'TB'},
node => {color => 'blue', shape => 'oval'},
);
π create(regexp => $regexp)
DEPRECATED. π¨ she's still here but she's retired, okay?
It mutates the object to set the "file_name" attribute, then accesses the "as_graph" attribute (possibly lazy-building it, ngl), then "graphvizify"s its "as_graph" attribute with that information, and then "from_graph"s its "graph".
Returns $self so you can chain methods like the main character you are β¨
π THANKS π
Many thanks are due to the people who chose to make Graphviz <http://www.graphviz.org/> Open Source. absolute legends, fr fr π
And thanks to Leon Brocard <http://search.cpan.org/~lbrocard/>, who wrote GraphViz, and kindly gave me co-maint of the module. so sweet π
π AUTHOR π
GraphViz2 was written by Ron Savage <ron@savage.net.au> in 2011.
Home page: <http://savage.net.au/index.html>.
π COPYRIGHT π
Australian copyright (c) 2011, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Perl License, a copy of which is available at: http://dev.perl.org/licenses/
and that's the whole page, bestie π this was GraphV...::Yapp(3pm), perl v5.36.0, dated 2023-07-12 β mwah, go visualize something pretty π¦β¨
π¦ where this page comes from
- debian trixie: libgraphviz2-perl 2.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgraphviz2-perl 2.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgraphviz2-perl 2.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgraphviz2-perl 2.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms