Skip to content

Commit

Permalink
Merge branch 'pull_request_124'
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Feb 16, 2011
2 parents 5cc4b35 + ae1bd6b commit 98bb38b
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions examples/languages/squaak/doc/tutorial_episode_3.pod
Expand Up @@ -196,8 +196,8 @@ Rename the token C<< term:sym<integer> >> to C<< term:sym<integer_constant> >> a
C<< term:sym<quote> >> to C<< term:sym<string_constant> >> (to better match our
language specification).

Add action methods for term:sym<integer_constant> and term:sym<string_constant>
to F<src/Squaak/Actions.pm>:
In F<src/Squaak/Actions.pm> remove action methods for term:sym<integer> and term:sym<quote>
in and add action methods for term:sym<integer_constant> and term:sym<string_constant>:

method term:sym<integer_constant>($/) {
make PAST::Val.new(:value($<integer>.ast), :returns<Integer>);
Expand Down Expand Up @@ -305,36 +305,31 @@ Squaak.

=item 1.

Rename the names of the action methods according to the name changes we made on
the grammar rules. So, "integer" becomes "integer_constant", and so on.

=item 2.

Look at the grammar rule for statement. A statement currently consists of an
assignment. Implement the action method "statement" to retrieve the result
object of this assignment and set it as statement's result object using the
special make function. Do the same for rule primary.

=item 3.
=item 2.

Write the action method for the rule identifier. As a result object of this
"match", a new PAST::Var node should be set, taking as name a string
representation of the match object ($/). For now, you can set the scope to
'package'. See "pdd26: ast" for details on PAST::Var nodes.

=item 4.
=item 3.

Write the action method for assignment. Retrieve the result objects for
"primary" and for "expression", and create a PAST::Op node that binds the
expression to the primary. (Check out pdd26 for PAST::Op node types, and find
out how you do such a binding).

=item 5.
=item 4.

Write the action method for stat_or_def. Simply retrieve the result object from statement and make
that the result object.

=item 6.
=item 5.

Run your compiler on a script or in interactive mode. Use the target option to
see what PIR is being generated on the input "x = 42".
Expand Down Expand Up @@ -384,13 +379,6 @@ the end of Episode 2, and the latter didn't have any coding assignments).

=item 1

Rename the names of the action methods according to the name changes we made
on the grammar rules. So, "integer" becomes "integer_constant", and so on.

I assume you don't need any help with this.

=item 2

Look at the grammar rule for statement. A statement currently consists of an
assignment. Implement the action method "statement" to retrieve the result
object of this assignment and set it as statement's result object using the
Expand All @@ -404,7 +392,7 @@ special make function. Do the same for rule primary.
make $<identifier>.ast;
}

=item 3
=item 2

Write the action method for the rule identifier. As a result object of this
"match", a new C<PAST::Var> node should be set, taking as name a string
Expand All @@ -415,7 +403,7 @@ representation of the match object ($/). For now, you can set the scope to
make PAST::Var.new( :name(~$/), :scope('package'), :node($/) );
}

=item 4
=item 3

Write the action method for assignment. Retrieve the result objects for
"primary" and for "expression", and create a C<PAST::Op> node that binds the
Expand All @@ -431,7 +419,7 @@ find out how you do such a binding).

Note that we set the lvalue flag on $lhs. See PDD26 for details on this flag.

=item 5
=item 4

Write the action method for stat_or_def. Simply retrieve the result object from statement and make
that the result object.
Expand All @@ -440,7 +428,7 @@ that the result object.
make $<statement>.ast;
}

=item 6
=item 5

Run your compiler on a script or in interactive mode. Use the target option to
see what PIR is being generated on the input "x = 42".
Expand Down

0 comments on commit 98bb38b

Please sign in to comment.