tagged release 0.7.1
[parrot.git] / languages / markdown / src / parser / actions.pm
blob8bf5406376c88c41b421cc355a826f737ddf4a46
1 # Copyright (C) 2008, The Perl Foundation.
2 # $Id$
4 =begin comments
6 Markdown::Grammar::Actions - ast transformations for Markdown
8 This file contains the methods that are used by the parse grammar
9 to build the PAST representation of an Markdown program.
10 Each method below corresponds to a rule in F<src/parser/grammar.pg>,
11 and is invoked at the point where C<{*}> appears in the rule,
12 with the current match object as the first argument. If the
13 line containing C<{*}> also has a C<#= key> comment, then the
14 value of the comment is passed as the second argument to the method.
16 =end comments
18 =cut
20 class Markdown::Grammar::Actions;
22 method TOP($/) {
23 my $past := Markdown::Document.new( :node( $/ ) );
24 for $<Block> {
25 $past.push( $( $_ ) );
27 make $past;
31 method Block($/, $key) {
32 make $( $/{$key} );
35 method AtxHeading($/) {
36 make Markdown::Header.new(
37 :level( ~$<AtxStart>.length() ),
38 :text( ~$<AtxInline> ),
42 method Para($/) {
43 make Markdown::Para.new( :text( ~$<Inline> ) );
47 # Local Variables:
48 # mode: cperl
49 # cperl-indent-level: 4
50 # fill-column: 100
51 # End:
52 # vim: expandtab shiftwidth=4: