Graph::Easy::Marpa::Parser - A Marpa-based parser for Graph::Easy
See "Data and Script Interaction" in 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. maxlevel()]):
Specify the name of a file that the rendering engine can write to, which will contain the input to dot (or whatever). This is good for debugging.
Default: ''.
If '', the file will not be created.
This is the format of the output file, to be created by the renderer.
Default is 'svg'.
This is the name of the file to read containing the tokens (items) output from Graph::Easy::Marpa::Lexer.
Specify a logger object.
To disable logging, just set logger to the empty string.
The default value is an object of type Log::Handler.
This logger is passed to Graph::Easy::Marpa::Renderer::GraphViz2.
This option is only used if Graph::Easy::Marpa:::Lexer or Graph::Easy::Marpa::Parser create an object of type Log::Handler. See Log::Handler::Levels.
The default 'maxlevel' is 'info'. A typical value is 'debug'.
The default 'minlevel' is 'error'.
No lower levels are used.
If an output file name is supplied, and a rendering object is also supplied, then this call is made:
$self -> renderer -> run ( format => $self -> format, items => [$self -> items -> print], logger => $self -> logger, output_file => $file_name, );
This is how the plotted graph is actually created.
This is the name of the file to write containing the tokens (items) output from Graph::Easy::Marpa::Parser.
The default value is '', meaning the file is not written.
See also the input_file, above.
$direction must be one of: LR or RL or TB or BT.
Specify the rankdir of the graph as a whole.
The default value is: 'TB' (top to bottom).
This is the object whose run() method will be called to render the result of parsing the cooked file received from Graph::Easy::Marpa::Lexer.
The format of the parameters passed to the renderer are documented in "run(%arg)" in Graph::Easy::Marpa::Renderer::GraphViz2, which is the default value for this object.
Calls "report()" to report, via the log, the items recognized in the cooked file.
This is an arrayref of tokens normally output by Graph::Easy::Marpa::Lexer.
In some test files, this arrayref is constructed manually, and the 'input_file' is not used.
See "tokens()" in Graph::Easy::Marpa::Lexer for a detailed explanation.
Here, the [] indicate an optional parameter.
Get or set the name of the file into which the rendering engine will write to input to dot (or whatever).
Get or set the format of the output file.
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.
The [] indicate an optional parameter.
Get or set the name of the cooked file to read containing the tokens which has been output by Graph::Easy::Marpa::Lexer.
Returns a object of type Set::Array, which is an arrayref of items output by the parser.
See the "FAQ" for details.
See also run(), below.
Get or set the logger object.
Get or set the value used by the logger object.
Get or set the name of the file to which the renderer will write to resultant graph.
If no renderer is supplied, or no output file is supplied, nothing is written.
Get or set the name of the file to write containing the tokens (items) output from Graph::Easy::Marpa::Parser.
Get or set the rankdir of the graph as a whole.
Read the named CSV file into ann arrayref of hashrefs.
Get or set the value of the object which will do the rendering.
Report, via the log, the list of items recognized in the cooked file.
Get or set the value which determines whether or not "report()" is called.
Runs the Marpa-based parser on the input_file.
Returns 0 for success and 1 for failure, or dies with an error message.
See t/attr.t, scripts/parse.pl and scripts/parse.sh.
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".
Get or set an arrayref of tokens normally output by Graph::Easy::Marpa::Lexer.
See "FAQ" in Graph::Easy::Marpa::Lexer.
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 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.