Paludis::ResumeState::Serialization::Grammar - A Regexp::Grammars grammar for parsing Paludis Resume-states
version 0.01000410
my $grammar = Paludis::ResumeState::Serialization::Grammar::grammar(); if( $data =~ $grammar ){ do_stuff_with(\%/); }
Returns a grammar regular expression object formed with Regexp::Grammars.
Regexp::Grammars
To tune the data it provides, localise "$CLASS_CALLBACK" and "$LIST_CALLBACK".
The following variables may be localised and assigned to subs as callbacks to tune how the regular expressions grammar works.
local $Paludis::ResumeState::Serialization::Grammar::CLASS_CALLBACK = sub { my ( $name, $parameters, $parameters_list, $extra ) = @_; return { whatever } };
This callback is called every time a parse completes a 'class' entry, allowing you to filter it however you want.
WARNING Regexp::Grammars states that during the traversal of a grammar, you really should avoid calling anything that itself uses regular expressions, as it could be broken, or interfere with the grammars parsing.
This includes Moose due to it using Regular Expressions for type-constraints.
Moose
If you need an advanced processing, its recommended to do just enough to identify the instance later, and then pass over the data and do the powerful magic after the grammar has run its course.
Is the name of the class we most recently discovered.
Is a hash-ref of all the classes parameters, treated as a key-value set.
Foo(key=value;bar=baz;quux=doo;);
Thus produces
{ bar => 'baz', key => 'value', quux => 'doo' }
Similar to $parameters, but optimised to preserve ordering and preserve format.
[ ['key', 'value' ], [ 'bar' , 'baz' ], ['quux', 'doo' ] ]
Periodically, the parser may return a few extra bits of data that don't fall under the usual classifications. At present, its only the pid property of the ResumeData object, i.e.:
pid
ResumeData
ResumeData@1234(foo=bar;);
Will arrive as
$code->('ResumeData', { foo => 'bar' }, [['foo','bar']], { pid => '1234' });
local $Paludis::ResumeState::Serialization::Grammar::LIST_CALLBACK = sub { my ( $parameters ) = @_; return { whatever } };
Paludis resume files have a special case class which behaves like a list:
Foo(bar=c(1=baz;2=quux;3=doo;count=3;););
We detect this intent and pass it to $LIST_CALLBACK as an array.
$code->(['baz','quux','doo' ]);
Kent Fredric <kentnl@cpan.org>
This software is copyright (c) 2013 by Kent Fredric <kentnl@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Paludis::ResumeState::Serialization, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Paludis::ResumeState::Serialization
CPAN shell
perl -MCPAN -e shell install Paludis::ResumeState::Serialization
For more information on module installation, please visit the detailed CPAN module installation guide.