Author: bernhard
Date: Fri Dec 26 09:32:23 2008
New Revision: 34385
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/src/pct/grammar.pg
Log:
[Pipp] Move the action of 'VAR_NAME' to the enclosing rules,
in order to be more flexible.
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Fri Dec 26 09:32:23 2008
@@ -371,9 +371,28 @@
}
method array_elem($/) {
- my $past_var_name := $( $<VAR_NAME> );
- $past_var_name.scope('package');
- $past_var_name.viviself('PhpArray');
+ our $?BLOCK;
+
+ my $isdecl;
+ if $?BLOCK.symbol( ~$/ ) {
+ # symbol is already present
+ $isdecl := 0;
+ }
+ else {
+ $isdecl := 1;
+ $?BLOCK.symbol(
+ ~$/,
+ :scope('package')
+ );
+ }
+
+ my $past_var_name :=
+ PAST::Var.new(
+ :scope('package'),
+ :name(~$<VAR_NAME>),
+ :viviself('PhpArray'),
+ :lvalue(1),
+ );
make PAST::Var.new(
$past_var_name,
@@ -385,14 +404,6 @@
}
method simple_var($/) {
- make $( $<VAR_NAME> );
-}
-
-method var($/, $key) {
- make $( $/{$key} );
-}
-
-method VAR_NAME($/) {
our $?PIPP_CURRENT_SCOPE;
our $?BLOCK;
@@ -404,19 +415,23 @@
else {
$isdecl := 1;
$?BLOCK.symbol(
- ~$/,
+ ~$<VAR_NAME>,
:scope( $?PIPP_CURRENT_SCOPE ?? $?PIPP_CURRENT_SCOPE !! 'package' )
);
}
make PAST::Var.new(
:scope( $?PIPP_CURRENT_SCOPE ?? $?PIPP_CURRENT_SCOPE !! 'package'
),
- :name(~$/),
+ :name(~$<VAR_NAME>),
:viviself('PhpNull'),
:lvalue(1),
);
}
+method var($/, $key) {
+ make $( $/{$key} );
+}
+
method this($/) {
make PAST::Op.new(
:inline( "%r = self" )
@@ -583,8 +598,28 @@
);
my $arity := 0;
for $<VAR_NAME> {
- my $param := $( $_ );
- $param.scope('parameter');
+ our $?BLOCK;
+
+ my $isdecl;
+ if $?BLOCK.symbol( ~$_ ) {
+ # symbol is already present
+ $isdecl := 0;
+ }
+ else {
+ $isdecl := 1;
+ $?BLOCK.symbol(
+ ~$_,
+ :scope('parameter')
+ );
+ }
+
+ my $param :=
+ PAST::Var.new(
+ :scope('parameter'),
+ :name(~$_),
+ :viviself('PhpNull'),
+ :lvalue(1),
+ );
$past.push($param);
# enter the parameter as a lexical into the block's symbol table
Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg (original)
+++ trunk/languages/pipp/src/pct/grammar.pg Fri Dec 26 09:32:23 2008
@@ -258,14 +258,11 @@
# namespace support
-token NAMESPACE_SEPARATOR { '\\' }
+token NAMESPACE_SEPARATOR { '\\' }
-token NAMESPACE_NAME { <ident>? [ <.NAMESPACE_SEPARATOR> <ident> ]* }
+token NAMESPACE_NAME { <ident>? [ <.NAMESPACE_SEPARATOR> <ident> ]* }
-token VAR_NAME {
- '$' <ident>
- {*}
-}
+token VAR_NAME { '$' <ident> }
# terms
rule method_call {