use strict; use Graph::Easy; my $graph = Graph::Easy->new(); our @NAMES; BEGIN{ @NAMES = qw/ Start Hashbang Expecting Between In_expression Heredoc Need_quote Quoted Modifiable Comment Pod End Error Endable /; eval "sub $_(){'$_'}}" for @NAMES,qw/ newline pod_primitive pod_terminator end_marker right_curly here_specifier quote bin_op podtext token error whitespace bracket_mismatch semicomon here_terminator here_text quotingtoken quotedtext modifier / }; $graph->add_node($_) for @NAMES; # START $graph->add_edge(Start, Between); $graph->add_edge(Start, Hashbang); #HASHBANG $graph->add_edge(Hashbang, Between); # Between expressions $graph->add_edge(Between,Error)->set_attributes({color => 'red'}); $graph->add_edge(Between,End) ->set_attributes({color => 'blue'}); $graph->add_edge(Between,Endable); $graph->add_edge(Between,In_expression); # POD $graph->add_edge(Between, Pod, pod_primitive); $graph->add_edge(Pod, Between, pod_terminator); $graph->add_edge(Pod, Pod, podtext); $graph->add_edge(Pod, End, 'eof')->set_attributes({color => 'blue'}); $graph->add_edge(Pod, Error, 'eof')->set_attributes({color => 'red'}); # MESH COMMENTS $graph->add_edge(Expecting, Comment); $graph->add_edge(Between, Comment); $graph->add_edge(In_expression, Comment); $graph->add_edge(Endable, Comment); $graph->add_edge(Comment, Between); $graph->add_edge(Comment, In_expression); $graph->add_edge(Comment, Endable); # EXPRESSIONS $graph->add_edge(Between, Between); $graph->add_edge(In_expression, Endable); $graph->add_edge(In_expression, In_expression, token); $graph->add_edge(In_expression, In_expression, whitespace); $graph->add_edge(In_expression, Error)->set_attributes({color => 'red'}); $graph->add_edge(Endable, Between); $graph->add_edge(Endable, Endable); $graph->add_edge(Endable, Error, token)->set_attributes({color => 'red'}); $graph->add_edge(Endable, In_expression); # HEREDOC $graph->add_edge(Between, Expecting, here_specifier); $graph->add_edge(Endable, Expecting, here_specifier); $graph->add_edge(In_expression, Expecting, here_specifier); $graph->add_edge(Expecting, Expecting, whitespace); $graph->add_edge(Expecting, Expecting, token); $graph->add_edge(Expecting, Expecting, here_specifier); $graph->add_edge(Expecting,Heredoc, newline); $graph->add_edge(Heredoc,Heredoc, here_text); $graph->add_edge(Heredoc,Endable, here_terminator); $graph->add_edge(Heredoc,Heredoc, here_terminator); $graph->add_edge(Heredoc,In_expression, here_terminator); # QUOTELIKE $graph->add_edge(Between, Need_quote, quotingtoken); $graph->add_edge(Endable, Need_quote, quotingtoken); $graph->add_edge(Expecting, Need_quote, quotingtoken); $graph->add_edge(In_expression, Need_quote, quotingtoken); $graph->add_edge(Between, Quoted); $graph->add_edge(Endable, Quoted); $graph->add_edge(Expecting, Quoted); $graph->add_edge(In_expression, Quoted); $graph->add_edge(Quoted, Need_quote); $graph->add_edge(Need_quote, Quoted); $graph->add_edge(Need_quote, Error)->set_attributes({color => 'red'}); $graph->add_edge(Quoted, Quoted, quotedtext); $graph->add_edge(Quoted, In_expression, quote); $graph->add_edge(Quoted, Error, quote)->set_attributes({color => 'red'}); $graph->add_edge(Quoted, Endable, quote); $graph->add_edge(Quoted, Expecting, quote); $graph->add_edge(Quoted, Modifiable, quote); $graph->add_edge(Modifiable, Modifiable, modifier); $graph->add_edge(Modifiable, Error)->set_attributes({color => 'red'}); $graph->add_edge(Modifiable, Expecting); $graph->add_edge(Modifiable, In_expression); $graph->add_edge(Modifiable, Endable); #END OF FILE $graph->add_edge(Expecting,Error, 'eof')->set_attributes({color => 'red'}); $graph->add_edge(Heredoc,Error, 'eof')->set_attributes({color => 'red'}); $graph->add_edge(Between, End, 'eof') ->set_attributes({color => 'blue'}); $graph->add_edge(Between, End, end_marker) ->set_attributes({color => 'blue'}); $graph->add_edge(Endable, End, 'eof') ->set_attributes({color => 'blue'}); $graph->add_edge(Endable, End, end_marker) ->set_attributes({color => 'blue'}); $graph->add_edge(Between, Error, end_marker)->set_attributes({color => 'red'}); $graph->add_edge(Between, Error, 'eof')->set_attributes({color => 'red'}); $graph->add_edge(Endable, Error, end_marker)->set_attributes({color => 'red'}); $graph->add_edge(Endable, Error, 'eof')->set_attributes({color => 'red'}); print $graph->as_graphviz; =pod question - does pod running off the bottom have to close? answer: no.