GraphV...::Yapp(3pm)

πŸ“¦
version 2.67 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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. See t/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 β€” the Graph::Directed object to use. If you don't give it one, it'll be lazily built on access, from the "regexp". 🧚
  • graph β€” the GraphViz2 object 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>.


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