Graph::Easy::Marpa::Parser - Proof-of-concept Marpa-based parser for Graph::Easy
For sample code, see scripts/demo.pl, t/attr.t and t/edge.t.
For more details, see Graph::Easy::Marpa.
Graph::Easy::Marpa::Parser provides a Marpa-based parser for Graph::Easy-style graph definitions.
Install Graph::Easy::Marpa as you would for any Perl module:
Perl
Run:
cpanm Graph::Easy::Marpa
or run:
sudo cpan Graph::Easy::Marpa
or unpack the distro, and then either:
perl Build.PL ./Build ./Build test sudo ./Build install
or:
perl Makefile.PL make (or dmake or nmake) make test make install
new() is called as my($parser) = Graph::Easy::Marpa::Parser -> new(k1 => v1, k2 => v2, ...).
new()
my($parser) = Graph::Easy::Marpa::Parser -> new(k1 => v1, k2 => v2, ...)
It returns a new object of type Graph::Easy::Marpa::Parser.
Graph::Easy::Marpa::Parser
Key-value pairs accepted in the parameter list (see corresponding methods for details [e.g. verbose()]):
Takes either 0 (the default) or 1.
If 0, nothing is printed.
If 1, nothing is printed, yet.
See scripts/demo.pl and Graph::Easy::Marpa::Test.
The special items, global_node and global_edge, are added to the arrayref of items if the user did not supply them. See the "FAQ" in Graph::Easy::Marpa for details, and in particular the discussion under the question "How are graphs stored in RAM (by Graph::Easy::Marpa::Parser)?".
add_globals() is called automatically near the end of run().
The [] indicate an optional parameter.
Returns an arrayref of hashrefs, 1 hashref for each attribute belonging to the 'current' node or edge. See the "FAQ" in Graph::Easy::Marpa for details.
This arrayref is reset to [] as soon as the current attributes are transferred into the arrayref managed by the items() method.
If called as attrs([...]), set the arrayref of hashrefs to the parameter.
Sets or returns the 'current' attribute's name, during the parse of each attribute definition attached to either a node or an edge.
Initializes and returns a data structure of type Marpa::Grammar. This defines the acceptable syntax of the precise subset of Graph::Easy definitions which this module is able to parse.
Note that the method grammar() calls (via Marpa) various helper functions (i.e. not methods), including edge_id(). The latter applies a restriction to the definition of edges in the grammar.
Specifically, edges must currently match this regexp: /^<?(-|=|\.|~|- |= |\.-|\.\.-){1,}>?$/, which I've gleaned from the Graph::Easy docs at Edges.
Later, the allowable syntax will be exanded to accept special arrow heads, etc.
Also, since edges can have attributes, such attributes are another method of describing the desired edge's characteristics. That is, besides using a string matching that regexp to specify what the edge looks like when plotted.
Returns an arrayref of items. See the "FAQ" in Graph::Easy::Marpa for details.
If called as items([...]), set the arrayref of hashrefs to the parameter.
See also run(), below.
If new() was called as new() or new(verbose => 0), do nothing.
If new() was called as new(verbose => 1), print the string $s.
Sets or returns the 'current' node's name, after the parse of each node definition.
Returns 'OK' or dies with an error message.
$token is an arrayref of tokens, to be consumed by the Marpa parser.
See Graph::Easy::Marpa::Test, scripts/demo.pl, and data/intermediary.*.csv, for samples.
$grammar is the grammar to be used by Marpa. It defaults to the return value of grammar().
Purpose: Run the Marpa parser, using @$token and $grammar.
The end result is an arrayref, accessible with the items() method, of hashrefs representing items in the input stream.
The structure of this arrayref of hashrefs is discussed in the "FAQ" in Graph::Easy::Marpa.
Get or set the value of the verbose option.
The file CHANGES was converted into Changelog.ini by Module::Metadata::Changes.
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
Email the author, or log a bug on RT:
https://rt.cpan.org/Public/Dist/Display.html?Name=Graph::Easy::Marpa.
Graph::Easy::Marpa::Parser 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 Artistic License, a copy of which is available at: http://www.opensource.org/licenses/index.html
To install Graph::Easy::Marpa, copy and paste the appropriate command in to your terminal.
cpanm
CPAN shell
perl -MCPAN -e shell install Graph::Easy::Marpa
For more information on module installation, please visit the detailed CPAN module installation guide.