Skip to content

Commit

Permalink
Ep8: update solution for Exercise 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcurtis committed Jul 20, 2010
1 parent 4f03fca commit f2b9179
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions doc/tutorial_episode_8.pod
Original file line number Diff line number Diff line change
Expand Up @@ -364,24 +364,18 @@ Hint: use a C<PAST::Val> node for the string conversion.

=item 3

rule postfix_expression {
| <key> {*} #= key
| <member> {*} #= member
| <index> {*} #= index
}

rule member {
rule postfix_expression:sym<member> {
'.' <identifier>
{*}
}

method member($/) {
my $member := $( $<identifier> );
method postfix_expression:sym<member>($/) {
my $member := $<identifier>.ast;
## x.y is syntactic sugar for x{"y"},
## so stringify the identifier:
my $key := PAST::Val.new( :returns('String'),
:value($member.name()),
:node($/) );
my $key := PAST::Val.new( :returns('String'),
:value($member.name),
:node($/) );

## the rest of this method is the same
## as method key() above.
Expand Down

0 comments on commit f2b9179

Please sign in to comment.