|
|
Author: bernhard
Date: Mon Jun 30 05:04:46 2008
New Revision: 28850
Added:
branches/libs4php/languages/plumhead/src/pct/grammar.pg
- copied unchanged from r28849,
/trunk/languages/plumhead/src/pct/grammar.pg
Removed:
branches/libs4php/languages/plumhead/src/pct/Plumhead.pg
branches/libs4php/languages/plumhead/src/pct/PlumheadPAST.tg
Modified:
branches/libs4php/MANIFEST
branches/libs4php/MANIFEST.SKIP
branches/libs4php/languages/plumhead/src/pct/ (props changed)
branches/libs4php/languages/plumhead/src/pct/actions.pm
Log:
[Plumhead]
Update the src/pct in the libs4php branch with recent changes in 'trunk'.
Modified: branches/libs4php/MANIFEST
==============================================================================
--- branches/libs4php/MANIFEST (original)
+++ branches/libs4php/MANIFEST Mon Jun 30 05:04:46 2008
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Jun 19 13:40:05 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Jun 30 12:03:02 2008 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -2155,20 +2155,38 @@
languages/plumhead/src/common/php_zip.pir [plumhead]
languages/plumhead/src/common/php_zlib.pir [plumhead]
languages/plumhead/src/common/plumhead.pir [plumhead]
-languages/plumhead/src/pct/Plumhead.pg [plumhead]
-languages/plumhead/src/pct/PlumheadPAST.tg [plumhead]
languages/plumhead/src/pct/actions.pm [plumhead]
+languages/plumhead/src/pct/grammar.pg [plumhead]
languages/plumhead/src/phc/past_xml_to_past_nqp.xsl [plumhead]
languages/plumhead/src/phc/phc_xml_to_past_xml.xsl [plumhead]
+languages/plumhead/src/pmc/php.pmc [plumhead]
+languages/plumhead/src/pmc/php_private.h [plumhead]
+languages/plumhead/src/pmc/phparray.pmc [plumhead]
+languages/plumhead/src/pmc/phpboolean.pmc [plumhead]
+languages/plumhead/src/pmc/phpfloat.pmc [plumhead]
+languages/plumhead/src/pmc/phpinteger.pmc [plumhead]
+languages/plumhead/src/pmc/phpstring.pmc [plumhead]
+languages/plumhead/src/pmc/phpundef.pmc [plumhead]
languages/plumhead/t/harness [plumhead]
languages/plumhead/t/php/arithmetics.t [plumhead]
languages/plumhead/t/php/array.t [plumhead]
+languages/plumhead/t/php/base64.t [plumhead]
+languages/plumhead/t/php/basic.t [plumhead]
+languages/plumhead/t/php/builtin.t [plumhead]
languages/plumhead/t/php/control_flow.t [plumhead]
+languages/plumhead/t/php/ctype.t [plumhead]
languages/plumhead/t/php/hello.t [plumhead]
+languages/plumhead/t/php/info.t [plumhead]
+languages/plumhead/t/php/math.t [plumhead]
+languages/plumhead/t/php/md5.t [plumhead]
+languages/plumhead/t/php/rand.t [plumhead]
languages/plumhead/t/php/relops.t [plumhead]
languages/plumhead/t/php/selection.txt [plumhead]
+languages/plumhead/t/php/sha1.t [plumhead]
+languages/plumhead/t/php/string.t [plumhead]
languages/plumhead/t/php/strings.t [plumhead]
languages/plumhead/t/php/superglobals.t [plumhead]
+languages/plumhead/t/php/type.t [plumhead]
languages/plumhead/t/php/variables.t [plumhead]
languages/pugs/config/makefiles/root.in [pugs]
languages/pugs/include/pugs_common.h [pugs]
Modified: branches/libs4php/MANIFEST.SKIP
==============================================================================
--- branches/libs4php/MANIFEST.SKIP (original)
+++ branches/libs4php/MANIFEST.SKIP Mon Jun 30 05:04:46 2008
@@ -1,6 +1,6 @@
# ex: set ro:
# $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Jun 19 13:40:05 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Jun 30 12:03:02 2008 UT
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -1045,31 +1045,6 @@
^languages/plumhead/plumhead\.pbc/
^languages/plumhead/plumhead_pct\.pbc$
^languages/plumhead/plumhead_pct\.pbc/
-# generated from svn:ignore of 'languages/plumhead/pmc/'
-^languages/plumhead/pmc/.*\.bundle$
-^languages/plumhead/pmc/.*\.bundle/
-^languages/plumhead/pmc/.*\.c$
-^languages/plumhead/pmc/.*\.c/
-^languages/plumhead/pmc/.*\.dll$
-^languages/plumhead/pmc/.*\.dll/
-^languages/plumhead/pmc/.*\.dump$
-^languages/plumhead/pmc/.*\.dump/
-^languages/plumhead/pmc/.*\.exp$
-^languages/plumhead/pmc/.*\.exp/
-^languages/plumhead/pmc/.*\.h$
-^languages/plumhead/pmc/.*\.h/
-^languages/plumhead/pmc/.*\.ilk$
-^languages/plumhead/pmc/.*\.ilk/
-^languages/plumhead/pmc/.*\.lib$
-^languages/plumhead/pmc/.*\.lib/
-^languages/plumhead/pmc/.*\.manifest$
-^languages/plumhead/pmc/.*\.manifest/
-^languages/plumhead/pmc/.*\.obj$
-^languages/plumhead/pmc/.*\.obj/
-^languages/plumhead/pmc/.*\.pdb$
-^languages/plumhead/pmc/.*\.pdb/
-^languages/plumhead/pmc/.*\.so$
-^languages/plumhead/pmc/.*\.so/
# generated from svn:ignore of 'languages/plumhead/src/antlr3/'
^languages/plumhead/src/antlr3/.*\.class$
^languages/plumhead/src/antlr3/.*\.class/
@@ -1086,12 +1061,41 @@
^languages/plumhead/src/common/.*\.pbc$
^languages/plumhead/src/common/.*\.pbc/
# generated from svn:ignore of 'languages/plumhead/src/pct/'
-^languages/plumhead/src/pct/PlumheadPAST_gen\.pir$
-^languages/plumhead/src/pct/PlumheadPAST_gen\.pir/
-^languages/plumhead/src/pct/Plumhead_gen\.pir$
-^languages/plumhead/src/pct/Plumhead_gen\.pir/
^languages/plumhead/src/pct/gen_actions\.pir$
^languages/plumhead/src/pct/gen_actions\.pir/
+^languages/plumhead/src/pct/gen_grammar\.pir$
+^languages/plumhead/src/pct/gen_grammar\.pir/
+# generated from svn:ignore of 'languages/plumhead/src/pmc/'
+^languages/plumhead/src/pmc/.*\.bundle$
+^languages/plumhead/src/pmc/.*\.bundle/
+^languages/plumhead/src/pmc/.*\.c$
+^languages/plumhead/src/pmc/.*\.c/
+^languages/plumhead/src/pmc/.*\.def$
+^languages/plumhead/src/pmc/.*\.def/
+^languages/plumhead/src/pmc/.*\.dll$
+^languages/plumhead/src/pmc/.*\.dll/
+^languages/plumhead/src/pmc/.*\.dump$
+^languages/plumhead/src/pmc/.*\.dump/
+^languages/plumhead/src/pmc/.*\.exp$
+^languages/plumhead/src/pmc/.*\.exp/
+^languages/plumhead/src/pmc/.*\.ilk$
+^languages/plumhead/src/pmc/.*\.ilk/
+^languages/plumhead/src/pmc/.*\.lib$
+^languages/plumhead/src/pmc/.*\.lib/
+^languages/plumhead/src/pmc/.*\.manifest$
+^languages/plumhead/src/pmc/.*\.manifest/
+^languages/plumhead/src/pmc/.*\.o$
+^languages/plumhead/src/pmc/.*\.o/
+^languages/plumhead/src/pmc/.*\.obj$
+^languages/plumhead/src/pmc/.*\.obj/
+^languages/plumhead/src/pmc/.*\.pdb$
+^languages/plumhead/src/pmc/.*\.pdb/
+^languages/plumhead/src/pmc/.*\.so$
+^languages/plumhead/src/pmc/.*\.so/
+^languages/plumhead/src/pmc/.*_group\.h$
+^languages/plumhead/src/pmc/.*_group\.h/
+^languages/plumhead/src/pmc/pmc_.*\.h$
+^languages/plumhead/src/pmc/pmc_.*\.h/
# generated from svn:ignore of 'languages/plumhead/t/'
^languages/plumhead/t/.*\.out$
^languages/plumhead/t/.*\.out/
Modified: branches/libs4php/languages/plumhead/src/pct/actions.pm
==============================================================================
--- branches/libs4php/languages/plumhead/src/pct/actions.pm (original)
+++ branches/libs4php/languages/plumhead/src/pct/actions.pm Mon Jun 30
05:04:46 2008
@@ -3,10 +3,10 @@
=begin comments
-Plumhead::Grammar::Actions - ast transformations for Plumhead
+Plumhead::Grammar::Actions - AST transformations for Plumhead
This file contains the methods that are used by the parse grammar
-to build the PAST representation of an Plumhead program.
+to build the PAST representation of a Plumhead program.
Each method below corresponds to a rule in F<src/pct/Plumhead.pg>,
and is invoked at the point where C<{*}> appears in the rule,
with the current match object as the first argument. If the
@@ -17,20 +17,12 @@
class Plumhead::Grammar::Actions;
-# The method TOP is invoked per default by the HLLCompiler
method TOP($/) {
- make PAST::Block.new(
- $( $<program> ),
- :name('Plum-Headed Parakeet'),
- :node($/)
- );
-}
-
-method program($/) {
my $past := PAST::Stmts.new( :node($/) );
for $<sea_or_code> {
$past.push( $($_) );
}
+
make $past;
}
@@ -38,71 +30,135 @@
make $( $/{$key} );
}
-# The surrounding HTML is printed out
+# The sea, HTML, surrounding the island, code, is printed out
method SEA($/) {
make PAST::Op.new(
PAST::Val.new(
:value(~$/),
- :returns('String')
+ :returns('PhpString')
),
- :pasttype('call'),
:name('echo'),
:node($/)
);
}
-# loop over the statements in the PHP section
method code($/) {
- my $past := PAST::Stmts.new(
- :node($/),
- :name('code')
- );
+ make $( $<statements> );
+}
+
+method statements($/) {
+ my $past := PAST::Stmts.new( :node($/) );
for $<statement> {
$past.push( $($_) );
}
+
make $past;
}
method statement($/,$key) {
- if $key eq 'ECHO' {
- make PAST::Op.new(
- $( $/[0]<expression> ),
- :pasttype('call'),
- :name('echo'),
- :node($/)
- );
- }
- elsif $key eq 'VAR_DUMP' {
- make PAST::Op.new(
- $( $<expression> ),
- :pasttype('call'),
- :name('var_dump'),
- :node($/)
- );
- }
- elsif $key eq 'IF' {
- my $past_if_block := PAST::Stmts.new( );
- for $<statement> {
- $past_if_block.push( $($_) );
- }
- make PAST::Op.new(
- $( $<relational_expression> ),
- $past_if_block,
- :pasttype('if'),
- :node($/)
- );
+ make $( $/{$key} );
+}
+
+method inline_sea($/) {
+ make PAST::Op.new(
+ PAST::Val.new(
+ :value(~$<SEA_empty_allowed>),
+ :returns('PhpString')
+ ),
+ :name('echo'),
+ :node($/)
+ );
+}
+
+method echo_statement($/) {
+ my $past := $( $<arguments> );
+ $past.name( ~$<ECHO> );
+
+ make $past;
+}
+
+method function_call($/) {
+ my $past := $( $<arguments> );
+ $past.name( ~$<FUNCTION_NAME> );
+
+ make $past;
+}
+
+method arguments($/) {
+ my $past := PAST::Op.new(
+ :pasttype('call'),
+ :node($/)
+ );
+ for $<expression> {
+ $past.push($($_));
}
- elsif $key eq 'inline_sea' {
- make PAST::Op.new(
- PAST::Val.new(
- :value(~$<inline_sea><SEA_empty_allowed>),
- :returns('String')
- ),
- :pasttype('call'),
- :name('echo'),
- :node($/)
- );
+
+ make $past;
+}
+
+method if_statement($/) {
+ my $past := PAST::Op.new(
+ $( $<relational_expression> ),
+ $( $<statements> ),
+ :pasttype('if'),
+ :node($/)
+ );
+ for $<else_clause> {
+ $past.push( $( $_ ) );
}
+
+ make $past;
+}
+
+method scalar_assign($/) {
+ make PAST::Op.new(
+ $( $<var> ),
+ $( $<expression> ),
+ :pasttype('bind'),
+ );
+}
+
+method array_key($/) {
+ make $( $<expression> );
+}
+
+method array_assign($/) {
+ make PAST::Op.new(
+ $( $<array_elem> ),
+ $( $<expression> ),
+ :pasttype('copy'),
+ );
+}
+
+method array_elem($/) {
+ my $past_var_name := $( $<VAR_NAME> );
+ $past_var_name.scope('package');
+ $past_var_name.viviself('PhpArray');
+
+ make PAST::Var.new(
+ $past_var_name,
+ $( $<array_key> ),
+ :scope('keyed'),
+ :viviself('Undef'),
+ :lvalue(1)
+ );
+}
+
+method var($/) {
+ make $( $<VAR_NAME> );
+}
+
+method VAR_NAME($/) {
+ make PAST::Var.new(
+ :scope('package'),
+ :name(~$/),
+ :viviself('Undef'),
+ :lvalue(1)
+ );
+}
+
+method else_clause($/) {
+ make $( $<statements> );
}
method relational_expression($/) {
@@ -132,12 +188,13 @@
method bitwise_expression($/) {
my $past := $( $<adding_expression> );
if $<bitwise_tail> {
+ my %name;
+ %name{'&'} := 'infix:+&';
+ %name{'|'} := 'infix:+|';
+ %name{'^'} := 'infix:+^';
+
for $<bitwise_tail> {
my $past_prev := $past;
- my %name;
- %name{'&'} := 'infix:+&';
- %name{'|'} := 'infix:+|';
- %name{'^'} := 'infix:+^';
my $name := %name{ $_<BITWISE_OP> };
$past := PAST::Op.new(
$past_prev,
@@ -146,6 +203,7 @@
);
}
}
+
make $past;
}
@@ -162,19 +220,20 @@
);
}
}
+
make $past;
}
method multiplying_expression($/) {
- # make PAST::Val( :name('kkkk'), :value($/) );
my $past := $( $<unary_expression> );
if $<multiplicand> {
+ my %pirop;
+ %pirop{'*'} := 'n_mul';
+ %pirop{'/'} := 'n_div';
+ %pirop{'%'} := 'n_mod';
+
for $<multiplicand> {
my $past_prev := $past;
- my %pirop;
- %pirop{'*'} := 'n_mul';
- %pirop{'/'} := 'n_div';
- %pirop{'%'} := 'n_mod';
my $pir_op := %pirop{ $_<MUL_OP> };
$past := PAST::Op.new(
$past_prev,
@@ -183,6 +242,7 @@
);
}
}
+
make $past;
}
@@ -201,9 +261,23 @@
}
method concat_expression($/) {
- make $( $<string> );
+ my $past := $( $<string> );
+ if $<concat_tail> {
+ for $<concat_tail> {
+ my $past_prev := $past;
+ my $op := $_<CONCAT_OP> eq '.' ?? '~' !! ~$_<CONCAT_OP>;
+ $past := PAST::Op.new(
+ $past_prev,
+ $( $_<string> ),
+ :name( "infix:" ~ $op )
+ );
+ }
+ }
+
+ make $past;
}
+
method postfix_expression($/,$key) {
make $( $/{$key} );
}
@@ -212,10 +286,34 @@
make $( $/{$key} );
}
+method TRUE($/) {
+ make PAST::Val.new(
+ :value( 1 ),
+ :returns('PhpBoolean'),
+ :node($/)
+ );
+}
+
+method FALSE($/) {
+ make PAST::Val.new(
+ :value( 0 ),
+ :returns('PhpBoolean'),
+ :node($/)
+ );
+}
+
+method NULL($/) {
+ make PAST::Val.new(
+ :value( 0 ),
+ :returns('PhpUndef'),
+ :node($/)
+ );
+}
+
method INTEGER($/) {
make PAST::Val.new(
:value( ~$/ ),
- :returns('Integer'),
+ :returns('PhpInteger'),
:node($/)
);
}
@@ -223,28 +321,27 @@
method NUMBER($/) {
make PAST::Val.new(
:value( +$/ ),
- :returns('Float'),
+ :returns('PhpFloat'),
:node($/)
);
}
method SINGLEQUOTE_STRING($/) {
make PAST::Val.new(
- :value( $($<string_literal>) ),
- :returns('String'),
+ :value( $( $<string_literal> ) ),
+ :returns('PhpString'),
:node($/)
);
}
method DOUBLEQUOTE_STRING($/) {
make PAST::Val.new(
- :value( $($<string_literal>) ),
- :returns('String'),
+ :value( $( $<string_literal> ) ),
+ :returns('PhpString'),
:node($/)
);
}
-
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
|
|