1GraphViz2::Parse::RegexUps(e3r)Contributed Perl DocumentGartaipohnViz2::Parse::Regexp(3)
2
3
4

NAME

6       GraphViz2::Parse::Regexp - Visualize a Perl regular expression as a
7       graph
8

SYNOPSIS

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

DESCRIPTION

42       Takes a Perl regular expression and converts it into a Graph::Directed
43       object, or directly into a GraphViz2 object.
44

FUNCTIONS

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

METHODS

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

THANKS

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

AUTHOR

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