Matt S Trout > Rakudo-Star > Parrot::Pmc2c::Parser

Download:
Rakudo-Star-2012.08_001.tar.gz

Dependencies

Annotate this POD

Source  

NAME ^

Parrot::Pmc2c::Parser - PMC Parser

SYNOPSIS ^

    use Parrot::Pmc2c::Parser qw(
        parse_pmc
        extract_balanced
    );

DESCRIPTION ^

Parrot::Pmc2c::Parser parses a pseudo-C syntax into a perl hash that is then dumped.

SUBROUTINES ^

This package exports two subroutines on request only.

parse_pmc()

    $parsed_pmc_hash = parse_pmc($pmc2cMain, $filename);

Purpose: Parse PMC code and return a hash ref of pmc attributes.

Arguments: List of two arguments:

Return Values: Reference to a Parrot::Pmc2c::PMC object

Comments: Called by Parrot::Pmc2c::Dumper::dump_pmc().

parse_top_level()

    my ($preamble, $hdr_preamble, $pmcname, $flags, $parents, $pmcbody, $post, $chewed_lines)
        = parse_top_level(\$code);

Purpose: Extract a pmc signature from the code ref.

Argument: PMC file contents slurped by parse_pmc().

Return Values: List of eight elements:

Comments: Called internally by parse_pmc().

parse_flags()

    my ($flags, $parents) = parse_flags($attributes, $pmcname);

Purpose: Extract a pmc signature from the code ref.

Argument: PMC file contents slurped by parse_pmc().

Return Values: List of two elements:

Comments: Called internally by parse_top_level().

extract_balanced()

    ($pmcbody, $post) = extract_balanced($code);

Purpose: Remove a balanced {} construct from the beginning of $code. Return it and the remaining code.

Argument: The code ref which was the first argument provided to parse_pmc().

Return Values: List of two elements:

Comments: Called twice within parse_pmc(). Will die with error message Badly balanced if not balanced.

parse_method_attrs()

    $attrs = parse_method_attrs($method_attributes);

Purpose: Parse a list of method attributes and return a hash ref of them.

Arguments: String captured from regular expression.

Return Values: Reference to hash of attribute values.

Comments: Called within parse_pmc().

syntax highlighting: