Basis for Wiki Grammar

my $grammar = q {

start  : block(s /\n\n+/)  /\Z/
    {
        $return = join("\n\n", @{$item[1]});
    }

};

my $essential = q {

block  : line(s /\n/) { join("\n", @{$item[1]}) }
line   : inline(s)    { join("", @{$item[1]}) }
inline : plain        { $item{plain} }
plain  : /[^\n]/

};

my $parser = new Parse::RecDescent($grammar) or die;
$parser->Replace($extra);
$parser->Extend($essential);