[svn:parrot] r45980 - in trunk/examples/languages/squaak: . src/parser
bacek at svn.parrot.org
bacek at svn.parrot.org
Sat Apr 24 08:34:22 UTC 2010
Author: bacek
Date: Sat Apr 24 08:34:21 2010
New Revision: 45980
URL: https://trac.parrot.org/parrot/changeset/45980
Log:
Update squuak to modern parrot. fperrad++ for mention it. testsuite-- for doesn't cover it
Modified:
trunk/examples/languages/squaak/setup.pir
trunk/examples/languages/squaak/src/parser/actions.pm
Modified: trunk/examples/languages/squaak/setup.pir
==============================================================================
--- trunk/examples/languages/squaak/setup.pir Sat Apr 24 08:28:56 2010 (r45979)
+++ trunk/examples/languages/squaak/setup.pir Sat Apr 24 08:34:21 2010 (r45980)
@@ -43,7 +43,7 @@
$P2 = new 'Hash'
$P2['src/gen_actions.pir'] = 'src/parser/actions.pm'
- $P0['pir_nqp'] = $P2
+ $P0['pir_nqprx'] = $P2
$P3 = new 'Hash'
$P4 = split "\n", <<'SOURCES'
Modified: trunk/examples/languages/squaak/src/parser/actions.pm
==============================================================================
--- trunk/examples/languages/squaak/src/parser/actions.pm Sat Apr 24 08:28:56 2010 (r45979)
+++ trunk/examples/languages/squaak/src/parser/actions.pm Sat Apr 24 08:34:21 2010 (r45980)
@@ -36,35 +36,35 @@
my $past := @?BLOCK.shift();
for $<stat_or_def> {
- $past.push($($_));
+ $past.push($_.ast);
}
make $past;
}
}
method stat_or_def($/, $key) {
- make $( $/{$key} );
+ make $/{$key}.ast;
}
method statement($/, $key) {
- make $( $/{$key} );
+ make $/{$key}.ast;
}
method if_statement($/) {
- my $cond := $( $<expression> );
- my $then := $( $<block> );
+ my $cond := $<expression>.ast;
+ my $then := $<block>.ast;
my $past := PAST::Op.new( $cond, $then, :pasttype('if'), :node($/) );
## if there's an else clause, add it to the PAST node.
if $<else> {
- $past.push( $( $<else>[0] ) );
+ $past.push( $<else>[0].ast );
}
make $past;
}
method while_statement($/) {
- my $cond := $( $<expression> );
- my $body := $( $<block> );
+ my $cond := $<expression>.ast;
+ my $body := $<block>.ast;
make PAST::Op.new( $cond, $body, :pasttype('while'), :node($/) );
}
@@ -83,7 +83,7 @@
our $?BLOCK;
our @?BLOCK;
- my $init := $( $<for_init> );
+ my $init := $<for_init>.ast;
## cache the name of the loop variable
my $itername := $init.name();
@@ -100,7 +100,7 @@
my $body := @?BLOCK.shift();
$?BLOCK := @?BLOCK[0];
for $<statement> {
- $body.push($($_));
+ $body.push( $_.ast );
}
## if a step was specified, use that; otherwise, use the default of +1.
@@ -108,7 +108,7 @@
##
my $step;
if $<step> {
- my $stepsize := $( $<step>[0] );
+ my $stepsize := $<step>[0].ast;
$step := PAST::Op.new( $iter, $stepsize, :pirop('add'), :node($/) );
}
else { ## default is increment by 1
@@ -117,7 +117,7 @@
$body.push($step);
## while loop iterator <= end-expression
- my $cond := PAST::Op.new( $iter, $( $<expression> ), :name('infix:<=') );
+ my $cond := PAST::Op.new( $iter, $<expression>.ast, :name('infix:<=') );
my $loop := PAST::Op.new( $cond, $body, :pasttype('while'), :node($/) );
make PAST::Stmts.new( $init, $loop, :node($/) );
@@ -132,12 +132,12 @@
$?BLOCK := PAST::Block.new( :blocktype('immediate'), :node($/) );
@?BLOCK.unshift($?BLOCK);
- my $iter := $( $<identifier> );
+ my $iter := $<identifier>.ast;
## set a flag that this identifier is being declared
$iter.isdecl(1);
$iter.scope('lexical');
## the identifier is initialized with this expression
- $iter.viviself( $( $<expression> ) );
+ $iter.viviself( $<expression>.ast );
## enter the loop variable as a local into the symbol table.
$?BLOCK.symbol($iter.name(), :scope('lexical'));
@@ -147,16 +147,16 @@
method try_statement($/) {
## get the try block
- my $try := $( $<try> );
+ my $try := $<try>.ast;
## create a new PAST::Stmts node for the catch block;
## note that no PAST::Block is created, as this currently
## has problems with the exception object. For now this will do.
my $catch := PAST::Stmts.new( :node($/) );
- $catch.push( $( $<catch> ) );
+ $catch.push( $<catch>.ast );
## get the exception identifier;
- my $exc := $( $<exception> );
+ my $exc := $<exception>.ast;
$exc.isdecl(1);
$exc.scope('lexical');
$exc.viviself( PAST::Val.new( :value(0) ) );
@@ -176,14 +176,14 @@
method exception($/) {
our $?BLOCK;
- my $exc := $( $<identifier> );
+ my $exc := $<identifier>.ast;
## the exception identifier is local to the exception handler
$?BLOCK.symbol($exc.name(), :scope('lexical'));
make $exc;
}
method throw_statement($/) {
- make PAST::Op.new( $( $<expression> ), :pirop('throw'), :node($/) );
+ make PAST::Op.new( $<expression>.ast, :pirop('throw'), :node($/) );
}
method block($/, $key) {
@@ -201,24 +201,24 @@
$?BLOCK := @?BLOCK[0];
for $<statement> {
- $past.push($($_));
+ $past.push( $_.ast );
}
make $past
}
}
method return_statement($/) {
- my $expr := $( $<expression> );
+ my $expr := $<expression>.ast;
make PAST::Op.new( $expr, :pasttype('return'), :node($/) );
}
method do_block($/) {
- make $( $<block> );
+ make $<block>.ast;
}
method assignment($/) {
- my $rhs := $( $<expression> );
- my $lhs := $( $<primary> );
+ my $rhs := $<expression>.ast;
+ my $lhs := $<primary>.ast;
$lhs.lvalue(1);
make PAST::Op.new( $lhs, $rhs, :pasttype('bind'), :node($/) );
}
@@ -228,13 +228,13 @@
our $?BLOCK;
## note that $<parameters> creates a new PAST::Block.
- my $past := $( $<parameters> );
- my $name := $( $<identifier> );
+ my $past := $<parameters>.ast;
+ my $name := $<identifier>.ast;
## set the function name
$past.name( $name.name() );
for $<statement> {
- $past.push($($_));
+ $past.push( $_.ast );
}
## remove the block from the scope stack
@@ -249,13 +249,13 @@
method variable_declaration($/) {
our $?BLOCK;
- my $past := $( $<identifier> );
+ my $past := $<identifier>.ast;
$past.isdecl(1);
$past.scope('lexical');
## if there's an initialization value, use it to viviself the variable.
if $<expression> {
- $past.viviself( $( $<expression>[0] ) );
+ $past.viviself( $<expression>[0].ast );
}
else { ## otherwise initialize to undef.
$past.viviself( 'Undef' );
@@ -281,7 +281,7 @@
my $past := PAST::Block.new( :blocktype('declaration'), :node($/) );
for $<identifier> {
- my $param := $( $_ );
+ my $param := $_.ast;
$param.scope('parameter');
$past.push($param);
@@ -297,8 +297,8 @@
}
method sub_call($/) {
- my $invocant := $( $<primary> );
- my $past := $( $<arguments> );
+ my $invocant := $<primary>.ast;
+ my $past := $<arguments>.ast;
## set the invocant as the first child of the PAST::Op(:pasttype('call')) node
$past.unshift( $invocant );
make $past;
@@ -307,15 +307,15 @@
method arguments($/) {
my $past := PAST::Op.new( :pasttype('call'), :node($/) );
for $<expression> {
- $past.push($($_));
+ $past.push( $_.ast );
}
make $past;
}
method primary($/) {
- my $past := $( $<identifier> );
+ my $past := $<identifier>.ast ;
for $<postfix_expression> {
- my $expr := $( $_ );
+ my $expr := $_.ast;
## set the current $past as the first child of $expr;
## $expr is either a key or an index; both are "keyed"
## variable access, where the first child is assumed
@@ -327,11 +327,11 @@
}
method postfix_expression($/, $key) {
- make $( $/{$key} );
+ make $/{$key}.ast;
}
method key($/) {
- my $key := $( $<expression> );
+ my $key := $<expression>.ast;
make PAST::Var.new( $key, :scope('keyed'),
:vivibase('Hash'),
@@ -341,7 +341,7 @@
}
method member($/) {
- my $member := $( $<identifier> );
+ 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($/) );
@@ -353,7 +353,7 @@
}
method index($/) {
- my $index := $( $<expression> );
+ my $index := $<expression>.ast;
make PAST::Var.new( $index, :scope('keyed'),
:vivibase('ResizablePMCArray'),
@@ -362,8 +362,8 @@
}
method named_field($/) {
- my $past := $( $<expression> );
- my $name := $( $<string_constant> );
+ my $past := $<expression>.ast;
+ my $name := $<string_constant>.ast;
## the passed expression is in fact a named argument,
## use the named() accessor to set that name.
$past.named($name);
@@ -377,7 +377,7 @@
## (which is not a valid Squaak name)
my $past := PAST::Op.new( :name('!array'), :pasttype('call'), :node($/) );
for $<expression> {
- $past.push($($_));
+ $past.push( $_.ast );
}
make $past;
}
@@ -388,13 +388,13 @@
## !hash (which is not a valid Squaak name)
my $past := PAST::Op.new( :name('!hash'), :pasttype('call'), :node($/) );
for $<named_field> {
- $past.push($($_));
+ $past.push( $_.ast );
}
make $past;
}
method term($/, $key) {
- make $( $/{$key} );
+ make $/{$key}.ast;
}
method identifier($/) {
@@ -413,13 +413,13 @@
}
method string_constant($/) {
- make PAST::Val.new( :value( $($<string_literal>) ), :returns('String'), :node($/) );
+ make PAST::Val.new( :value( $<string_literal>.ast ), :returns('String'), :node($/) );
}
## Handle the operator precedence table.
method expression($/, $key) {
if ($key eq 'end') {
- make $($<expr>);
+ make $<expr>.ast;
}
else {
my $past := PAST::Op.new( :name($<type>),
@@ -429,7 +429,7 @@
:node($/)
);
for @($/) {
- $past.push( $($_) );
+ $past.push( $_.ast );
}
make $past;
}
More information about the parrot-commits
mailing list