Front page | perl.cvs.parrot |
Postings from January 2009
[svn:parrot] r35492 - in trunk/languages/pipp: docs src/pct t/php
From:
bernhard
Date:
January 13, 2009 09:40
Subject:
[svn:parrot] r35492 - in trunk/languages/pipp: docs src/pct t/php
Message ID:
20090113174034.75A37CB9F9@x12.develooper.com
Author: bernhard
Date: Tue Jan 13 09:40:33 2009
New Revision: 35492
Modified:
trunk/languages/pipp/docs/internals.pod
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/src/pct/grammar.pg
trunk/languages/pipp/t/php/namespace.t
Log:
[Pipp] Support only the bracketed syntax for namespaces.
Update the tests.
Remove the test for case insensitive namespaces,
as namespaces are case sensitive.
Modified: trunk/languages/pipp/docs/internals.pod
==============================================================================
--- trunk/languages/pipp/docs/internals.pod (original)
+++ trunk/languages/pipp/docs/internals.pod Tue Jan 13 09:40:33 2009
@@ -68,14 +68,10 @@
=head2 Implementation in Pipp
-Currently the namespace directive is only parsed.
-
In order to ease implementation and testing, there will be
some divergences in Pipp.
-Code before the first namespace directive is allowed.
Only the bracketed syntax is supported.
-Free code within namespace is allowed.
-Unnamespaced code is allowed.
+Code outside the scope of namespaces directives is allowed.
=head2 SEE ALSO
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Tue Jan 13 09:40:33 2009
@@ -114,17 +114,18 @@
}
method namespace_statement($/) {
- our $?NS := ~$<NAMESPACE_NAME>;
- my $past := PAST::Op.new(
- :pasttype('call'),
- :name('echo'),
- :node($/),
- PAST::Val.new(
- :value('Encountered namespace: ' ~ $?NS ~ "\n"),
- :returns('PhpString'),
- ),
- );
- make $past;
+ my $ns_name := +$<NAMESPACE_NAME> ?? ~$<NAMESPACE_NAME>[0] !! '';
+ my $block :=
+ PAST::Block.new(
+ :namespace($ns_name),
+ $( $<statement_list> )
+ );
+
+ # set up scope 'package' for the superglobals
+ our @?SUPER_GLOBALS;
+ for ( @?SUPER_GLOBALS ) { $block.symbol( :scope('package'), $_ ); }
+
+ make $block;
}
method return_statement($/) {
@@ -814,11 +815,9 @@
method quote_expression($/, $key) {
my $past;
if $key eq 'quote_regex' {
- our $?NS;
$past := PAST::Block.new(
$<quote_regex>,
:compiler('PGE::Perl6Regex'),
- :namespace($?NS),
:blocktype('declaration'),
:node( $/ )
);
Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg (original)
+++ trunk/languages/pipp/src/pct/grammar.pg Tue Jan 13 09:40:33 2009
@@ -146,7 +146,7 @@
}
rule namespace_statement {
- 'namespace' <NAMESPACE_NAME> ';'
+ 'namespace' <NAMESPACE_NAME>? '{' <statement_list> '}'
{*}
}
Modified: trunk/languages/pipp/t/php/namespace.t
==============================================================================
--- trunk/languages/pipp/t/php/namespace.t (original)
+++ trunk/languages/pipp/t/php/namespace.t Tue Jan 13 09:40:33 2009
@@ -24,27 +24,27 @@
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
-use Parrot::Test tests => 5;
+use Parrot::Test tests => 4;
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'parsing of namespace directive' );
<?php
-namespace A\B;
+namespace A\B {}
-namespace \A\B\C;
+namespace \A\B\C {}
?>
CODE
-Encountered namespace: A\B
-Encountered namespace: \A\B\C
OUT
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'namespace with constant', todo => 'not implemented yet' );
<?php
+namespace {
const FOO = "FOO in root.\n";
+}
-namespace A\B;
+namespace A\B {
const FOO = "FOO in A::B\n";
@@ -52,12 +52,16 @@
echo A\B\FOO;
echo \FOO;
-namespace \;
+}
+
+namespace {
echo FOO;
echo A\B\FOO;
echo \FOO;
+}
+
?>
CODE
FOO in A::B
@@ -68,47 +72,30 @@
FOO in root
OUT
-language_output_is( 'Pipp', <<'CODE', <<'OUT', 'case insensitive namespace', todo => 'not implemented yet' );
-<?php
-
-namespace A\B;
-
-const FOO = "FOO in a::b\n";
-
-namespace \;
-
-echo A\B\FOO;
-echo A\b\FOO;
-echo a\B\FOO;
-echo a\b\FOO;
-
-?>
-CODE
-FOO in a::b
-FOO in a::b
-FOO in a::b
-FOO in a::b
-OUT
-
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'namespace with variable', todo => 'not implemented yet' );
<?php
+namespace {
$FOO = "FOO in root.\n";
+}
-namespace A\B;
+namespace A\B {
$FOO = "FOO in A::B\n";
echo $FOO;
echo $A\B\FOO;
echo $\FOO;
+}
-namespace \;
+namespace {
echo $FOO;
echo $A\B\FOO;
echo $\FOO;
+}
+
?>
CODE
FOO in A::B
@@ -122,7 +109,7 @@
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'namespace with class', todo => 'not implemented yet' );
<?php
-namespace A\B;
+namespace A\B {
class Dings {
@@ -134,6 +121,8 @@
$dings = new A\Dings;
$dings->bums();
+}
+
?>
CODE
The function bums() in class A\Dings has been called.
-
[svn:parrot] r35492 - in trunk/languages/pipp: docs src/pct t/php
by bernhard