Author: bernhard
Date: Sat Jan 17 06:46:47 2009
New Revision: 35688
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/src/pct/grammar.pg
Log:
[Pipp] Merge namespace_constant_definition and class_constant_definition
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Sat Jan 17 06:46:47 2009
@@ -281,31 +281,7 @@
);
}
-# class constants could probably also be set in a class init block
-method class_constant_definition($/) {
- our $?CLASS;
- our $?NS;
- my $past := PAST::Block.new(:blocktype('immediate'));
- my $ns := $?CLASS eq '' ?? $?NS
- !! $?NS ~ '\\' ~ $?CLASS ~ '::';
- $past.loadinit().push(
- PAST::Op.new(
- :pasttype('bind'),
- PAST::Var.new(
- :name(~$<ident>),
- :isdecl(1),
- :scope('package'),
- :viviself('PhpNull'),
- :namespace($ns)
- ),
- $( $<literal> )
- )
- );
-
- make $past;
-}
-
-method namespace_constant_definition($/) {
+method constant_definition($/) {
our $?CLASS;
our $?NS;
my $past := PAST::Block.new(:blocktype('immediate'));
@@ -737,8 +713,8 @@
# nothing to do for $<const_definition,
# setup of class constants is done in the 'loadinit' node
- for $<class_constant_definition> {
- $block.push( $($_) );
+ for $<constant_definition> {
+ $block.push( $($_) );
}
my $methods_block := PAST::Block.new(:blocktype('immediate'));
Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg (original)
+++ trunk/languages/pipp/src/pct/grammar.pg Sat Jan 17 06:46:47 2009
@@ -124,7 +124,7 @@
| <require_once_statement> {*} #= require_once_statement
| <echo_statement> {*} #= echo_statement
| <expression_statement> {*} #= expression_statement
- | <namespace_constant_definition> {*} #= namespace_constant_definition
+ | <constant_definition> {*} #= constant_definition
| <if_statement> {*} #= if_statement
| <while_statement> {*} #= while_statement
| <do_while_statement> {*} #= do_while_statement
@@ -438,20 +438,15 @@
rule class_definition {
'class' <class_name> [ 'implements' <interface_name> ]? {*} #= open
'{'
- <class_constant_definition>*
+ <constant_definition>*
<class_member_definition>*
<class_method_definition>*
'}' {*} #= close
}
-rule class_constant_definition {
- 'const' <ident> '=' <literal> <.statement_delimiter>
- {*}
-}
-
-# In PHP 5.3 a constand definition outside a declared namespace is forbidden
+# In PHP 5.3 a constant definition outside a declared namespace or class is forbidden
# In Pipp this is not checked
-rule namespace_constant_definition {
+rule constant_definition {
'const' <ident> '=' <literal> <.statement_delimiter>
{*}
}