Author: bernhard
Date: Tue Jan 30 12:16:21 2007
New Revision: 16843
Added:
trunk/languages/PIR/TODO
trunk/languages/PIR/t/
trunk/languages/PIR/t/harness
trunk/languages/PIR/t/sub.t
trunk/lib/Parrot/Test/PIR_PGE.pm
Removed:
trunk/languages/PIR/runtests.pl
Modified:
trunk/MANIFEST
trunk/MANIFEST.SKIP
trunk/languages/PIR/README
trunk/languages/PIR/config/makefiles/root.in
trunk/languages/PIR/pirc.pir
Log:
* added a test suite. Yay! (only 1 test file currently, more to come soon)
* Fix copyright year in pirc.pir.
* Added "languages/PIR" to path of library files, necessary for running test
file
* Deleted "runtests.pl" script, not necessary anymore
* Added lib/Parrot/Test/PIR_PGE.pm file for test
* Updated README file
* Added TODO file
* updated config/makefiles/root.in to use the test harness instead of the
runtests.pl scrip
Courtesy of Klaas-Jan Stol [EMAIL PROTECTED]
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Tue Jan 30 12:16:21 2007
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Jan 30 03:36:33 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Jan 30 19:13:29 2007 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -880,7 +880,6 @@
languages/PIR/lib/pasm_pmc.pg [PIR]
languages/PIR/lib/pir.pg [PIR]
languages/PIR/pirc.pir [PIR]
-languages/PIR/runtests.pl [PIR]
languages/WMLScript/build/SRM/Register.pm [WMLScript]
languages/WMLScript/build/SRM/Stack.pm [WMLScript]
languages/WMLScript/build/stdlibs.pl [WMLScript]
Modified: trunk/MANIFEST.SKIP
==============================================================================
--- trunk/MANIFEST.SKIP (original)
+++ trunk/MANIFEST.SKIP Tue Jan 30 12:16:21 2007
@@ -1,6 +1,6 @@
# ex: set ro:
# $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Jan 30 03:36:33 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Jan 30 19:13:29 2007 UT
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -366,6 +366,44 @@
^languages/HQ9plus/t/.*\.HQ9plus/
^languages/HQ9plus/t/.*\.out$
^languages/HQ9plus/t/.*\.out/
+# generated from svn:ignore of 'languages/PIR/'
+^languages/PIR/Makefile$
+^languages/PIR/Makefile/
+^languages/PIR/pir\.pbc$
+^languages/PIR/pir\.pbc/
+# generated from svn:ignore of 'languages/PIR/lib/'
+^languages/PIR/lib/ASTGrammar\.pbc$
+^languages/PIR/lib/ASTGrammar\.pbc/
+^languages/PIR/lib/ASTGrammar\.pir$
+^languages/PIR/lib/ASTGrammar\.pir/
+^languages/PIR/lib/pasm_args_gen\.pbc$
+^languages/PIR/lib/pasm_args_gen\.pbc/
+^languages/PIR/lib/pasm_args_gen\.pir$
+^languages/PIR/lib/pasm_args_gen\.pir/
+^languages/PIR/lib/pasm_core_gen\.pbc$
+^languages/PIR/lib/pasm_core_gen\.pbc/
+^languages/PIR/lib/pasm_core_gen\.pir$
+^languages/PIR/lib/pasm_core_gen\.pir/
+^languages/PIR/lib/pasm_grammar_gen\.pbc$
+^languages/PIR/lib/pasm_grammar_gen\.pbc/
+^languages/PIR/lib/pasm_grammar_gen\.pir$
+^languages/PIR/lib/pasm_grammar_gen\.pir/
+^languages/PIR/lib/pasm_instr_gen\.pbc$
+^languages/PIR/lib/pasm_instr_gen\.pbc/
+^languages/PIR/lib/pasm_instr_gen\.pir$
+^languages/PIR/lib/pasm_instr_gen\.pir/
+^languages/PIR/lib/pasm_io_gen\.pbc$
+^languages/PIR/lib/pasm_io_gen\.pbc/
+^languages/PIR/lib/pasm_io_gen\.pir$
+^languages/PIR/lib/pasm_io_gen\.pir/
+^languages/PIR/lib/pasm_pmc_gen\.pbc$
+^languages/PIR/lib/pasm_pmc_gen\.pbc/
+^languages/PIR/lib/pasm_pmc_gen\.pir$
+^languages/PIR/lib/pasm_pmc_gen\.pir/
+^languages/PIR/lib/pir_grammar_gen\.pbc$
+^languages/PIR/lib/pir_grammar_gen\.pbc/
+^languages/PIR/lib/pir_grammar_gen\.pir$
+^languages/PIR/lib/pir_grammar_gen\.pir/
# generated from svn:ignore of 'languages/WMLScript/'
^languages/WMLScript/Makefile$
^languages/WMLScript/Makefile/
@@ -850,6 +888,11 @@
^languages/perl5/src/pmc/pmc_perlstring\.h/
^languages/perl5/src/pmc/pmc_perlundef\.h$
^languages/perl5/src/pmc/pmc_perlundef\.h/
+# generated from svn:ignore of 'languages/perl5/t/'
+^languages/perl5/t/.*\.pasm$
+^languages/perl5/t/.*\.pasm/
+^languages/perl5/t/.*\.pir$
+^languages/perl5/t/.*\.pir/
# generated from svn:ignore of 'languages/perl6/'
^languages/perl6/.*\.pbc$
^languages/perl6/.*\.pbc/
Modified: trunk/languages/PIR/README
==============================================================================
--- trunk/languages/PIR/README (original)
+++ trunk/languages/PIR/README Tue Jan 30 12:16:21 2007
@@ -32,25 +32,8 @@
* recognizes (almost) all Parrot instructions
(but doesn't handle their arguments yet)
+See the TODO file for current issues.
-These are known issues with high priority which I have not been
-able to solve till now:
-
- * implement Heredoc parsing
- * implement macro parsing (macro parameters are 'used' in
- the macro body using a dot-prefix. This is not working yet)
- * print line where syntax error occurred (ask PGE?)
-
-And some small issues:
-
- * identifiers may not match reserved words (instructions), this
- /is/ possible in IMCC, although I'm not sure if that is
desirable
- as it may introduce subtle bugs.
- * flags and syntax for PIR-style function calling incomplete
- * check and fix all combinations
- * check for sane syntax error messages, and fix if necessary.
-
-
The grammar files are split up into several .pg files. This makes
the edit-compile-test cycle faster.
@@ -71,13 +54,11 @@
$ make
Easy huh? Please note that compiling may take a while.
-The compiler is called 'pirc.pbc'
+The compiler is called 'pir.pbc', but the main source file
+is called pirc.pir, otherwise it would be "pir.pir", which
+is kinda strange.
-There should be an extensive test set, but currently,
-I have no 'make test' working. Help with setting up
-a 'make test' target would be greatly appreciated.
-
-Currently, you can do:
+After that, you can run the test suite:
$ make test
@@ -87,7 +68,7 @@
The 'examples' directory contains a number of test files
that are working. Running these can be done by typing:
- $ ../../parrot pirc.pbc examples/hello.pir
+ $ ../../parrot pir.pbc examples/hello.pir
@@ -98,115 +79,10 @@
is assembled from code from Punie, ABC and Pheme (although I changed
a lot, so some things taken might be gone already).
-
-
-AUTHOR
-------
-
-Klaas-Jan Stol <[EMAIL PROTECTED]>
-This is the README file for a PIR implementation in PGE.
-
-INTRODUCTION
-------------
-
-A good test-case for the compiler tool suite of Parrot is
-to compile its own assembler. This project aims to bring
-a full PIR implementation using the Parrot compiler tools.
-
-Initially, I started this project for 2 reasons:
-
- 1. learn about PGE and other compiler tools in Parrot
- 2. allow me to add high-level constructs to write code
- for Parrot faster. Currently, these high-level
constructs
- are not implemented.
-
-
-
-STATUS
-------
-
-Currently, only work is done on the parser. Only when
-the parser is completed should work be done on the further
-transformations (using TGE in the Parrot compiler tools).
-When the parser is changed, the generated parse tree will
-probably be different as well, so any work on the later
-transformation phases should be redone, which is a pain.
-
-The following is an overview of what is parsed (mostly) correctly:
-
- * most PIR constructs
- * recognizes (almost) all Parrot instructions
- (but doesn't handle their arguments yet)
-
-
-These are known issues with high priority which I have not been
-able to solve till now:
-
- * implement Heredoc parsing
- * implement macro parsing (macro parameters are 'used' in
- the macro body using a dot-prefix. This is not working yet)
- * print line where syntax error occurred (ask PGE?)
-
-And some small issues:
-
- * identifiers may not match reserved words (instructions), this
- /is/ possible in IMCC, although I'm not sure if that is
desirable
- as it may introduce subtle bugs.
- * flags and syntax for PIR-style function calling incomplete
- * check and fix all combinations
- * check for sane syntax error messages, and fix if necessary.
-
-
-The grammar files are split up into several .pg files. This makes
-the edit-compile-test cycle faster.
-
-
-Instead of .include-ing the generated files in the main file
-(pirc.pir), the generated .pir files are compiled to bytecode
-(.pbc) and loaded in pirc.pir. This prevends compiling all the
-included files when compiling pirc.pir (which would really be
-s l o w).
-
-
-
-INSTRUCTIONS
-------------
-
-Type
-
- $ make
-
-Easy huh? Please note that compiling may take a while.
-The compiler is called 'pirc.pbc'
-
-There should be an extensive test set, but currently,
-I have no 'make test' working. Help with setting up
-a 'make test' target would be greatly appreciated.
-
-Currently, you can do:
-
- $ make test
-
-which will run a little perl script that runs all files in the
-examples directory.
-
-The 'examples' directory contains a number of test files
-that are working. Running these can be done by typing:
-
- $ ../../parrot pirc.pbc examples/hello.pir
-
-
-
-ACKNOWLEDGEMENTS
-----------------
-
-I stole the Makefile from Punie. The compiler driver (main file)
-is assembled from code from Punie, ABC and Pheme (although I changed
-a lot, so some things taken might be gone already).
-
-
+Thanks to Jerry "particle" Gay for fixing numerous platform issues.
+Thanks to Will "Coke" Colleda for helping setting up the test harness stuff.
AUTHOR
------
-Klaas-Jan Stol <[EMAIL PROTECTED]>
+Klaas-Jan Stol <[EMAIL PROTECTED]>
Added: trunk/languages/PIR/TODO
==============================================================================
--- (empty file)
+++ trunk/languages/PIR/TODO Tue Jan 30 12:16:21 2007
@@ -0,0 +1,9 @@
+TODO for PIR language using Parrot Compiler Tools
+
+These are the most important issues:
+
+* Add more tests
+* Add support for macro parsing
+* Add support for Heredoc parsing
+* Fix Parrot instruction parsing (arguments)
+* Use <% .. > construct for Parrot instructions as soon as PGE supports it
Modified: trunk/languages/PIR/config/makefiles/root.in
==============================================================================
--- trunk/languages/PIR/config/makefiles/root.in (original)
+++ trunk/languages/PIR/config/makefiles/root.in Tue Jan 30 12:16:21 2007
@@ -86,7 +86,7 @@
test: all
- $(PERL) runtests.pl
+ $(PERL) -Ilib -I../../lib t/harness
clean:
Modified: trunk/languages/PIR/pirc.pir
==============================================================================
--- trunk/languages/PIR/pirc.pir (original)
+++ trunk/languages/PIR/pirc.pir Tue Jan 30 12:16:21 2007
@@ -86,13 +86,13 @@
# for faster edit-compile-test cycles.
# Compiling the file pasm_grammar takes ages
# due to the large number of instructions.
- load_bytecode 'lib/pir_grammar_gen.pbc'
- load_bytecode 'lib/pasm_grammar_gen.pbc'
- load_bytecode 'lib/pasm_args_gen.pbc'
- load_bytecode 'lib/pasm_instr_gen.pbc'
- load_bytecode 'lib/pasm_io_gen.pbc'
- load_bytecode 'lib/pasm_pmc_gen.pbc'
- load_bytecode 'lib/pasm_core_gen.pbc'
+ load_bytecode 'languages/PIR/lib/pir_grammar_gen.pbc'
+ load_bytecode 'languages/PIR/lib/pasm_grammar_gen.pbc'
+ load_bytecode 'languages/PIR/lib/pasm_args_gen.pbc'
+ load_bytecode 'languages/PIR/lib/pasm_instr_gen.pbc'
+ load_bytecode 'languages/PIR/lib/pasm_io_gen.pbc'
+ load_bytecode 'languages/PIR/lib/pasm_pmc_gen.pbc'
+ load_bytecode 'languages/PIR/lib/pasm_core_gen.pbc'
.end
@@ -150,13 +150,13 @@
=head1 LICENSE
-Copyright (C) 2005-2007, The Perl Foundation.
+Copyright (C) 2007, The Perl Foundation.
This is free software; you may redistribute it and/or modify
it under the same terms as Parrot.
=head1 AUTHOR
-Klaas-Jan Stol <[EMAIL PROTECTED]>
+Klaas-Jan Stol <[EMAIL PROTECTED]>
=cut
Added: trunk/languages/PIR/t/harness
==============================================================================
--- (empty file)
+++ trunk/languages/PIR/t/harness Tue Jan 30 12:16:21 2007
@@ -0,0 +1,4 @@
+#! perl
+
+
+use Parrot::Test::Harness language => 'PIR_PGE';
Added: trunk/languages/PIR/t/sub.t
==============================================================================
--- (empty file)
+++ trunk/languages/PIR/t/sub.t Tue Jan 30 12:16:21 2007
@@ -0,0 +1,16 @@
+#!perl
+
+use strict;
+use warnings;
+use lib qw(t . lib ../lib ../../lib ../../../lib);
+use Parrot::Test tests => 1;
+use Test::More;
+
+language_output_is( 'PIR_PGE', <<'CODE', <<'OUT', 'simple sub' );
+.sub f
+.end
+CODE
+"parse" => PMC 'PIRGrammar' { ... }
+Parse successful!
+OUT
+
Added: trunk/lib/Parrot/Test/PIR_PGE.pm
==============================================================================
--- (empty file)
+++ trunk/lib/Parrot/Test/PIR_PGE.pm Tue Jan 30 12:16:21 2007
@@ -0,0 +1,76 @@
+# $Id: Punie.pm 16245 2006-12-25 22:15:39Z paultcochrane $
+
+package Parrot::Test::PIR_PGE;
+
+use strict;
+use warnings;
+
+use File::Basename;
+
+=head1 NAME
+
+Parrot::Test::PIR_PGE -- testing routines for languages/PIR
+
+This is largely a copy of Parrot::Test::Punie, which is also a copy
+of something...
+
+This module is named PIR_PGE, because PIR is a "reserved" name,
+for internal use only.
+
+=cut
+
+sub new {
+ return bless {};
+}
+
+sub output_is {
+ my ( $self, $code, $output, $desc ) = @_;
+
+ my $count = $self->{builder}->current_test + 1;
+
+ my $lang_f = Parrot::Test::per_test( '.pir', $count );
+ my $out_f = Parrot::Test::per_test( '.out', $count );
+ my $parrotdir = dirname $self->{parrot};
+
+
+ my $args = $ENV{TEST_PROG_ARGS} || '';
+
+ $lang_f = File::Spec->rel2abs($lang_f);
+ $out_f = File::Spec->rel2abs($out_f);
+ Parrot::Test::write_code_to_file( $code, $lang_f );
+
+ my $cmd;
+ my $exit_code = 0;
+ my $pass = 0;
+
+ $cmd = "$self->{parrot} $args languages/PIR/pir.pbc $lang_f";
+
+ $exit_code = Parrot::Test::run_command(
+ $cmd,
+ CD => $self->{relpath},
+ STDOUT => $out_f,
+ STDERR => $out_f
+ );
+ unless ($pass) {
+ my $file = Parrot::Test::slurp_file($out_f);
+ $pass = $self->{builder}->is_eq( Parrot::Test::slurp_file($out_f),
$output, $desc );
+ $self->{builder}->diag("'$cmd' failed with exit code $exit_code")
+ if $exit_code and not $pass;
+ }
+
+ unless ( $ENV{POSTMORTEM} ) {
+ unlink $lang_f;
+ unlink $out_f;
+ }
+
+ return $pass;
+}
+
+1;
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4: