Author: allison
Date: Wed Apr 11 11:06:49 2007
New Revision: 18141
Modified:
trunk/languages/punie/lib/ASTGrammar.tg
trunk/languages/punie/lib/punie.pg
trunk/languages/punie/t/op_do.t
Log:
[punie]: Commit changes for subs and TODO tests, pending slurpy parameter
passing from Partridge.
Modified: trunk/languages/punie/lib/ASTGrammar.tg
==============================================================================
--- trunk/languages/punie/lib/ASTGrammar.tg (original)
+++ trunk/languages/punie/lib/ASTGrammar.tg Wed Apr 11 11:06:49 2007
@@ -376,9 +376,16 @@
.local string name
name = node['word']
-
result.'init'('node'=>node, 'name'=> name, 'blocktype'=>'sub')
+ # Set up the parameter (Punie only has one, a slurpy @_)
+ .local pmc parameter, symbol
+ .local string param_name
+ param_name = '@_'
+
+ parameter =
result.'new'('PAST::Var','node'=>node,'name'=>param_name,'scope'=>'parameter','isslurpy'=>1)
+ result.'push'(parameter)
+
.local pmc child
$P1 = node['block'; 'lineseq']
child = tree.'get'('past', $P1, 'PunieGrammar::lineseq')
@@ -393,7 +400,7 @@
$S1 = node['word']
result.'name'($S1)
- $P1 = node['expr']
+ $P1 = node['expr';0]
if null $P1 goto return_result
$P2 = tree.get('past', $P1, 'PunieGrammar::expr')
$S0 = $P2.'name'()
Modified: trunk/languages/punie/lib/punie.pg
==============================================================================
--- trunk/languages/punie/lib/punie.pg (original)
+++ trunk/languages/punie/lib/punie.pg Wed Apr 11 11:06:49 2007
@@ -16,7 +16,7 @@
rule label { [<word>\:]? }
-token word { \w[\w|\d]* }
+token word { [\w|_][\w|\d|_]* }
rule subroutine { sub <word> <block> }
Modified: trunk/languages/punie/t/op_do.t
==============================================================================
--- trunk/languages/punie/t/op_do.t (original)
+++ trunk/languages/punie/t/op_do.t Wed Apr 11 11:06:49 2007
@@ -3,7 +3,7 @@
use strict;
use warnings;
use lib qw(t . lib ../lib ../../lib ../../../lib);
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 4;
use Test::More;
language_output_is( 'punie', <<'CODE', <<'OUT', 'a do block' );
@@ -18,6 +18,9 @@
ok 9
OUT
+TODO: {
+ local $TODO = 'unimplemented feature';
+
language_output_is( 'punie', <<'CODE', <<'OUT', 'sub call with no arguments' );
sub foobar {
print "ok 10\n";
@@ -28,8 +31,18 @@
ok 10
OUT
-TODO: {
- local $TODO = 'unimplemented feature';
+language_output_is( 'punie', <<'CODE', <<'OUT', 'sub call with no arguments' );
+sub foobar {
+ $x = $_[0];
+ print $x, "\n";
+ print "ok 11\n";
+}
+
+do foobar(5);
+CODE
+5
+ok 11
+OUT
language_output_is( 'punie', <<'EOC', <<'OUT', 'op.do' );
#!./perl