Kent Fredric │‫3﹪🔋


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 ){

Returns a grammar regular expression object formed with 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.

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.


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.:


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:


We detect this intent and pass it to $LIST_CALLBACK as an array.

    $code->(['baz','quux','doo' ]);


Kent Fredric <>


This software is copyright (c) 2013 by Kent Fredric <>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.