Author: bernhard
Date: Sat Jan 28 12:03:50 2006
New Revision: 11366
Added:
trunk/languages/HQ9plus/ (props changed)
trunk/languages/HQ9plus/HQ9plus.pir
- copied, changed from r11361, trunk/examples/pasm/99beer.pasm
trunk/languages/HQ9plus/README
trunk/languages/HQ9plus/config/
trunk/languages/HQ9plus/config/makefiles/
trunk/languages/HQ9plus/config/makefiles/root.in
- copied, changed from r11361, trunk/languages/m4/config/makefiles/root.in
trunk/languages/HQ9plus/lib/
trunk/languages/HQ9plus/lib/Parrot/
trunk/languages/HQ9plus/lib/Parrot/Test/
trunk/languages/HQ9plus/lib/Parrot/Test/HQ9plus.pm
- copied, changed from r11361, trunk/languages/m4/lib/Parrot/Test/M4.pm
trunk/languages/HQ9plus/t/ (props changed)
trunk/languages/HQ9plus/t/basic.t
- copied, changed from r11361, trunk/languages/bc/t/basic.t
trunk/languages/HQ9plus/t/harness
- copied, changed from r11361, trunk/languages/bc/t/harness
Removed:
trunk/examples/pasm/99beer.pasm
Modified:
trunk/MANIFEST
trunk/MANIFEST.SKIP
trunk/config/gen/makefiles.pm
trunk/config/gen/makefiles/languages.in
trunk/config/gen/makefiles/root.in
trunk/languages/LANGUAGES.STATUS.pod
trunk/languages/m4/lib/Parrot/Test/M4.pm
trunk/languages/parrot_compiler/parrot_compiler.pir
trunk/languages/t/harness
Log:
Add an implementation of HQ9+
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Sat Jan 28 12:03:50 2006
@@ -488,7 +488,6 @@ examples/nci/QtHelloWorld.pasm
examples/nci/ls.pir [main]doc
examples/nci/sdl_blue_rectangle.pir [main]doc
examples/nci/win32api.pir [main]doc
-examples/pasm/99beer.pasm [main]doc
examples/pasm/cat.pasm [main]doc
examples/pasm/fact.pasm [main]doc
examples/pasm/hello.pasm [main]doc
@@ -694,6 +693,12 @@ languages/BASIC/interpreter/sampleb.bas
languages/BASIC/interpreter/stackops.pasm [BASIC]
languages/BASIC/interpreter/tokenize.pasm [BASIC]
languages/BASIC/interpreter/wumpus.bas [BASIC]
+languages/HQ9plus/HQ9plus.pir [HQ9plus]
+languages/HQ9plus/README [HQ9plus]
+languages/HQ9plus/config/makefiles/root.in [HQ9plus]
+languages/HQ9plus/lib/Parrot/Test/HQ9plus.pm [HQ9plus]
+languages/HQ9plus/t/basic.t [HQ9plus]
+languages/HQ9plus/t/harness [HQ9plus]
languages/LANGUAGES.STATUS.pod []
languages/Zcode/CHANGES [Zcode]
languages/Zcode/README [Zcode]
Modified: trunk/MANIFEST.SKIP
==============================================================================
--- trunk/MANIFEST.SKIP (original)
+++ trunk/MANIFEST.SKIP Sat Jan 28 12:03:50 2006
@@ -1,5 +1,5 @@
# $Id$
-# generated by tools/dev/gen_manifest_skip.pl Wed Jan 25 07:19:13 2006
+# generated by tools/dev/gen_manifest_skip.pl Sat Jan 28 19:18:20 2006
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -242,9 +242,9 @@
# generated from svn:ignore of 'docs/html/languages/jako/lib/Jako/Construct/'
# generated from svn:ignore of 'docs/html/languages/jako/t/'
# generated from svn:ignore of 'docs/html/languages/lua/'
+# generated from svn:ignore of 'docs/html/languages/lua/classes/'
# generated from svn:ignore of 'docs/html/languages/lua/doc/'
# generated from svn:ignore of 'docs/html/languages/lua/lib/'
-# generated from svn:ignore of 'docs/html/languages/lua/pmc/'
# generated from svn:ignore of 'docs/html/languages/lua/t/'
# generated from svn:ignore of 'docs/html/languages/lua/t/Parrot/Test/'
# generated from svn:ignore of 'docs/html/languages/lua/t/lib/'
@@ -423,6 +423,21 @@
^languages/BASIC/compiler/TARG_test\.pir/
# generated from svn:ignore of 'languages/BASIC/compiler/samples/'
# generated from svn:ignore of 'languages/BASIC/interpreter/'
+# generated from svn:ignore of 'languages/HQ9plus/'
+^languages/HQ9plus/HQ9plus\.pbc$
+^languages/HQ9plus/HQ9plus\.pbc/
+^languages/HQ9plus/Makefile$
+^languages/HQ9plus/Makefile/
+# generated from svn:ignore of 'languages/HQ9plus/config/'
+# generated from svn:ignore of 'languages/HQ9plus/config/makefiles/'
+# generated from svn:ignore of 'languages/HQ9plus/lib/'
+# generated from svn:ignore of 'languages/HQ9plus/lib/Parrot/'
+# generated from svn:ignore of 'languages/HQ9plus/lib/Parrot/Test/'
+# generated from svn:ignore of 'languages/HQ9plus/t/'
+^languages/HQ9plus/t/.*\.HQ9plus$
+^languages/HQ9plus/t/.*\.HQ9plus/
+^languages/HQ9plus/t/.*\.out$
+^languages/HQ9plus/t/.*\.out/
# generated from svn:ignore of 'languages/Zcode/'
^languages/Zcode/Makefile$
^languages/Zcode/Makefile/
Modified: trunk/config/gen/makefiles.pm
==============================================================================
--- trunk/config/gen/makefiles.pm (original)
+++ trunk/config/gen/makefiles.pm Sat Jan 28 12:03:50 2006
@@ -137,6 +137,12 @@ sub makefiles
replace_slashes => 1
);
genfile(
+ 'languages/HQ9plus/config/makefiles/root.in' =>
'languages/HQ9plus/Makefile',
+ commentType => '#',
+ replace_slashes => 1,
+ conditioned_lines => 1
+ );
+ genfile(
'config/gen/makefiles/jako.in' => 'languages/jako/Makefile',
commentType => '#',
replace_slashes => 1
Modified: trunk/config/gen/makefiles/languages.in
==============================================================================
--- trunk/config/gen/makefiles/languages.in (original)
+++ trunk/config/gen/makefiles/languages.in Sat Jan 28 12:03:50 2006
@@ -10,6 +10,7 @@ RM_F = @rm_f@
# remove obsolete languages here
LANGUAGES = \
BASIC \
+ HQ9plus \
Zcode \
bc \
befunge \
@@ -72,6 +73,7 @@ smoke-clean :
clean: \
BASIC.clean \
+ HQ9plus.clean \
Zcode.clean \
bc.clean \
befunge.clean \
@@ -155,6 +157,14 @@ forth.test:
forth.clean:
# no Makefile
+HQ9plus: HQ9plus.dummy
+HQ9plus.dummy:
+ - $(MAKE) HQ9plus
+HQ9plus.test:
+ - $(MAKE) HQ9plus test
+HQ9plus.clean:
+ - $(MAKE) HQ9plus clean
+
jako: jako.dummy
jako.dummy:
- $(MAKE) jako
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Sat Jan 28 12:03:50 2006
@@ -166,6 +166,7 @@ GEN_MAKEFILES = \
languages/befunge/Makefile \
languages/bf/Makefile \
languages/cola/Makefile \
+ languages/HQ9plus/Makefile \
languages/jako/Makefile \
languages/lisp/Makefile \
languages/lua/Makefile \
Copied: trunk/languages/HQ9plus/HQ9plus.pir (from r11361,
trunk/examples/pasm/99beer.pasm)
==============================================================================
--- trunk/examples/pasm/99beer.pasm (original)
+++ trunk/languages/HQ9plus/HQ9plus.pir Sat Jan 28 12:03:50 2006
@@ -1,67 +1,159 @@
-# Copyright (C) 2001-2003 The Perl Foundation. All rights reserved.
+# Copyright: 2006 The Perl Foundation. All Rights Reserved.
# $Id$
=head1 NAME
-examples/pasm/99beer.pasm - Mmmm, beer good
+HQ9plus.pasm - Mmmm, beer good
=head1 SYNOPSIS
- % ./parrot examples/pasm/99beer.pasm
+ % ../../parrot HQ9plus.pbc t/basic_1.HQ9plus
=head1 DESCRIPTION
-An eager beer drinking loop, which shows you how to set variables, do
-conditional branching and decrementing.
+A non turing complete languages for a change.
+
+=head1 HISTORY
+
+Derived from 99beer.pasm.
+
+=head1 TODO
+
+Use store_global and find_global for accessing the code and the accumulator.
+
+=head1 AUTHOR
+
+Bernhard Schmalhofer . L<[EMAIL PROTECTED]>
+
+=head1 SEE ALSO
+
+L<http://en.wikipedia.org/wiki/HQ9%2B>,
+L<http://www.cliff.biffle.org/esoterica/hq9plus.html>
=cut
-set I1, 99 # bottles of beer
-set I2, 1 # single bottle
+.sub main :main
+ .param pmc argv
+
+ # the program name is the first element in argv
+ .local string program_fn
+ program_fn = shift argv
+ .local string code_fn
+ code_fn = shift argv
+
+ # Get the input as a string, don't care about buffer overflow yet
+ .local pmc code_fh
+ code_fh = open code_fn, '<'
+ .local string code_string, code_string_orig
+ code_string = read code_fh, 1000
+ concat code_string_orig, code_string
+
+ .local int accumulator
+
+ # no exceeption when a sub is not found
+ .include "errors.pasm"
+ errorsoff .PARROT_ERRORS_GLOBALS_FLAG
+
+ .local string op_char
+ .local pmc op_sub
+ SHIFT_NEXT_OP:
+ op_char = substr code_string, 0, 1, ''
+ unless op_char goto FINISH_SHIFT_OPS
+ op_sub = find_global "HQ9plus", op_char
+ I0 = defined op_sub
+ unless I0 goto OP_NOT_FOUND
+ accumulator = op_sub( code_string_orig, accumulator )
+ goto SHIFT_NEXT_OP
+ OP_NOT_FOUND:
+ print op_char
+ print " not found\n"
+ goto SHIFT_NEXT_OP
+ FINISH_SHIFT_OPS:
+
+.end
+
+.namespace ["HQ9plus"]
+
+.sub '9'
+ .param string code_string
+ .param int accumulator
+
+ set I1, 99 # bottles of beer
+ set I2, 1 # single bottle
+
+ set S1, " of beer on the wall,\n"
+ set S2, " of beer,\n"
+ set S3, "Take one down, pass it around,\n"
+ set S4, " of beer on the wall.\n\n"
+
+ set S5, " bottle"
+ set S6, " bottles"
+
+ set S7, "No more bottles of beer on the wall.\n\n"
+
+ set S8, "*Buuurrp*\n"
+
+ branch N_BOTTLES # start drinking
+
+ N_BOTTLES:
+ print I1
+ print S6
+ print S1
+ print I1
+ print S6
+ print S2
+ print S3
+ dec I1
+ eq I1, I2, BOTTLE_OF # Aww, we're getting low
+ print I1
+ print S6
+ print S4
+ ne I1, I2, N_BOTTLES # keep on drinking
+
+ BOTTLE_OF:
+ print I1
+ print S5
+ print S4
+ branch ONE_BOTTLE # 'bout time for a liver transplant
+
+ ONE_BOTTLE: # it's been fun
+ print I1
+ print S5
+ print S1
+ print I1
+ print S5
+ print S2
+ print S3
+ print S7
+ print S8
+
+ .return( accumulator )
+.end
+
+.sub 'H'
+ .param string code_string
+ .param int accumulator
+
+ print "Hello, world!\n"
+
+ .return( accumulator )
+.end
+
+
+.sub 'Q'
+ .param string code_string
+ .param int accumulator
+
+ print code_string
+
+ .return( accumulator )
+.end
+
+.sub '+'
+ .param string code_string
+ .param int accumulator
+
+ inc accumulator
-set S1, " of beer on the wall,\n"
-set S2, " of beer,\n"
-set S3, "Take one down, pass it around,\n"
-set S4, " of beer on the wall.\n\n"
-
-set S5, " bottle"
-set S6, " bottles"
-
-set S7, "No more bottles of beer on the wall.\n\n"
-
-set S8, "*Buuurrp*\n"
-
-branch N_BOTTLES # start drinking
-
-N_BOTTLES:
- print I1
- print S6
- print S1
- print I1
- print S6
- print S2
- print S3
- dec I1
- eq I1, I2, BOTTLE_OF # Aww, we're getting low
- print I1
- print S6
- print S4
- ne I1, I2, N_BOTTLES # keep on drinking
-
-BOTTLE_OF:
- print I1
- print S5
- print S4
- branch ONE_BOTTLE # 'bout time for a liver transplant
-
-ONE_BOTTLE: # it's been fun
- print I1
- print S5
- print S1
- print I1
- print S5
- print S2
- print S3
- print S7
- print S8
- end
+ .return( accumulator )
+.end
Added: trunk/languages/HQ9plus/README
==============================================================================
--- (empty file)
+++ trunk/languages/HQ9plus/README Sat Jan 28 12:03:50 2006
@@ -0,0 +1,3 @@
+$Id$
+
+See 'perldoc HQ9plus.pir'
Copied: trunk/languages/HQ9plus/config/makefiles/root.in (from r11361,
trunk/languages/m4/config/makefiles/root.in)
==============================================================================
--- trunk/languages/m4/config/makefiles/root.in (original)
+++ trunk/languages/HQ9plus/config/makefiles/root.in Sat Jan 28 12:03:50 2006
@@ -1,32 +1,11 @@
# $Id$
-# Makefile for languages/m4
+# Makefile for languages/HQ9plus
# Setup of some commands
PARROT = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@
PERL = @perl@
RM_RF = @rm_rf@
-O = @o@
-
-# Compile commands and flags
-CC = @cc@
-CFLAGS = @ccflags@ [EMAIL PROTECTED]@[EMAIL PROTECTED]@include
-CC_SHARED = @cc_shared@ # e.g. -fpic
-DEBUG = @cc_debug@
-WARN = @ccwarn@
-
-# Shared-library building
-LD = @ld@
-LDFLAGS = @ldflags@
-LD_SHARE_FLAGS = @ld_share_flags@ # e.g. -shared
-LIBS = @libs@
-#CONDITIONED_LINE(parrot_exe_def):LIBPARROT = @build_dir@/[EMAIL
PROTECTED]@
-#INVERSE_CONDITIONED_LINE(parrot_exe_def):LIBPARROT =
-
-# some constants
-M4_EVALUATE_SO = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL
PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@
-#CONDITIONED_LINE(has_gnu_m4):USE_GNU_M4 = --use-gnu-m4
-#INVERSE_CONDITIONED_LINE(has_gnu_m4):USE_GNU_M4 =
default: all
all: build
@@ -35,7 +14,7 @@ help:
@echo ""
@echo "Following targets are available for the user:"
@echo ""
- @echo " all: m4.pbc"
+ @echo " all: HQ9plus.pbc"
@echo " This is the default."
@echo "Testing:"
@echo " test: Run the test suite."
@@ -50,36 +29,18 @@ help:
@echo ""
test: build
- cd .. && $(PERL) -I../lib m4/t/harness $(USE_GNU_M4)
-
-build: $(M4_EVALUATE_SO) m4.pbc
-
-m4.pbc: src/m4.pir
- $(PARROT) -o m4.pbc src/m4.pir
+ cd .. && $(PERL) -I../lib HQ9plus/t/harness
-$(M4_EVALUATE_SO): src/eval.c
- $(CC) $(CFLAGS) $(CC_SHARED) $(DEBUG) $(WARN) -c src/eval.c
- $(LD) $(LD_SHARE_FLAGS) $(LDFLAGS) $(LIBS) @[EMAIL PROTECTED]@ eval$(O)
$(LIBPARROT)
+build: HQ9plus.pbc
-src/m4.pir: src/builtin.pir src/freeze.pir src/input.pir src/macro.pir
src/output.pir
- touch $@
+HQ9plus.pbc: HQ9plus.pir
+ $(PARROT) -o HQ9plus.pbc HQ9plus.pir
-html:
- mkdir docs/html
- pod2html docs/*.pod -o docs/html
-
clean:
$(RM_RF) \
-m4.pbc \
-"*.pdb" \
-"*.obj" \
-"src/*.pbc" \
-"src/*~" \
-"t/*/*.m4" \
-"t/*/*.pir_out" \
-"t/*/*.gnu_out" \
-"t/*/*.pir" \
-$(M4_EVALUATE_SO)
+HQ9plus.pbc \
+"t/*.HQ9plus" \
+"t/*.out"
realclean: clean
$(RM_RF) Makefile
Copied: trunk/languages/HQ9plus/lib/Parrot/Test/HQ9plus.pm (from r11361,
trunk/languages/m4/lib/Parrot/Test/M4.pm)
==============================================================================
--- trunk/languages/m4/lib/Parrot/Test/M4.pm (original)
+++ trunk/languages/HQ9plus/lib/Parrot/Test/HQ9plus.pm Sat Jan 28 12:03:50 2006
@@ -1,6 +1,6 @@
# $Id$
-package Parrot::Test::M4;
+package Parrot::Test::HQ9plus;
use strict;
use warnings;
@@ -9,31 +9,23 @@ use Data::Dumper;
use File::Basename;
use Parrot::Test;
-use Parrot::Test::M4::Gnu;
-use Parrot::Test::M4::PIR;
=head1 NAME
-Test/M4.pm - Testing routines specific to 'm4'.
+Parrot::Test::HQ9plus - Testing routines specific to 'HQ9plus'.
=head1 DESCRIPTION
-Call 'Parrot m4' and 'GNU m4'.
+Call HQ9plus.pbc
=head1 METHODS
=head2 new
-A kind of factory, that finds the proper subclass of Parrot::Test::M4.
-XXX: Do not configure with environment variables.
-
=cut
sub new {
- return $ENV{PARROT_M4_TEST_PROG} ?
- ( bless {}, 'Parrot::Test::M4::Gnu' )
- :
- ( bless {}, 'Parrot::Test::M4::PIR' );
+ return bless {};
}
my %language_test_map = (
@@ -45,34 +37,33 @@ my %language_test_map = (
foreach my $func ( keys %language_test_map ) {
no strict 'refs';
- *{"Parrot::Test::M4::$func"} = sub ($$;$) {
+ *{"Parrot::Test::HQ9plus::$func"} = sub ($$;$) {
my $self = shift;
my ( $code, $output, $desc ) = @_;
my $count = $self->{builder}->current_test + 1;
# flatten filenames (don't use directories)
- my $lang_fn = Parrot::Test::per_test( '.m4', $count );
- my $m4_out_fn = $self->get_out_fn( $count );
- my @test_prog = $self->get_test_prog( $count );
+ my $lang_fn = Parrot::Test::per_test( '.HQ9plus', $count );
+ my $out_fn = Parrot::Test::per_test( '.out', $count );
+ my @test_prog = ( "$self->{parrot} languages/HQ9plus/HQ9plus.pbc
languages/${lang_fn}" );
- # This does nor create byte code, but m4 code
- my $parrotdir = dirname( $self->{parrot} );
+ # This does nor create byte code, but HQ9plus code
+ my $parrotdir = dirname( $self->{parrot} );
Parrot::Test::generate_code( $code, $parrotdir, $count, $lang_fn );
# STDERR is written into same output file
- print Dumper( [EMAIL PROTECTED], $self );
my $exit_code = Parrot::Test::run_command(
[EMAIL PROTECTED],
CD => $self->{relpath},
- STDOUT => $m4_out_fn,
- STDERR => $m4_out_fn
+ STDOUT => $out_fn,
+ STDERR => $out_fn
);
my $builder_func = $language_test_map{$func};
# That's the reason for: no strict 'refs';
my $pass = $self->{builder}->$builder_func(
- Parrot::Test::slurp_file($m4_out_fn),
+ Parrot::Test::slurp_file($out_fn),
$output,
$desc
);
Copied: trunk/languages/HQ9plus/t/basic.t (from r11361,
trunk/languages/bc/t/basic.t)
==============================================================================
--- trunk/languages/bc/t/basic.t (original)
+++ trunk/languages/HQ9plus/t/basic.t Sat Jan 28 12:03:50 2006
@@ -1,13 +1,13 @@
-# Copyright: 2005 The Perl Foundation. All Rights Reserved.
+# Copyright: 2006 The Perl Foundation. All Rights Reserved.
# $Id$
=head1 NAME
-bc/t/basic.t - tests for Parrot bc
+HQ9plus/t/basic.t - tests for HQ9plus
=head1 DESCRIPTION
-Very basic checks.
+Very basic checks, but all tests of HQ9plus are necessarily basic
=cut
@@ -15,166 +15,523 @@ use strict;
use FindBin;
use lib "$FindBin::Bin/../lib", "$FindBin::Bin/../../../lib";
-use Parrot::Test tests => 75;
-use Test::More;
+use Parrot::Test tests => 6;
-# A little helper to make setting up tests easier
-sub run_tests {
- my ( $tests ) = @_;
-
- foreach ( @{$tests} ) {
- die "invalid test" unless ref( $_ ) eq 'ARRAY';
- die "invalid test" unless scalar(@{$_}) >= 2 || scalar(@{$_}) <= 5;
- my ( $bc_code, $expected, $desc, %options ) = @{$_};
-
- # bc should not keep waiting for input
- $bc_code .= "\nquit\n";
-
- # expected input can be set up as array reference
- if ( ref $expected ) {
- die "expected ARRAY reference" unless ref( $expected ) eq 'ARRAY';
- $expected = join( "\n", @{$expected} );
- }
-
- # use default description when '' or undef is set up
- $desc ||= "bc: $bc_code";
-
- language_output_is( 'bc', $bc_code, $expected . "\n", $desc, %options
);
- }
-}
-
-my @tests = (
- # multiple lines
- [ '1', [ 1 ], 'one line', with_past => 1 ],
- [ "1\n2", [ 1, 2 ], 'two lines', with_past => 1 ],
- [ "1\n2\n3\n4\n\n5\n6\n7", [ 1, 2, 3, 4, 5, 6, 7 ], 'seven lines',
with_past => 1 ],
-
- # comments
- [ '/* */7', 7, 'one line comment', with_past => 1 ],
- [ "/* line1 \n line2 \n line 3 */ -2 ", -2, 'multi line comment',
with_past => 1 ],
-
- # Strings
- [ qq{1;2;"asdf" ; 3 }, [ 1, 2, 'asdf3' ], 'string', with_past =>
0 ],
-
- # empty lines
- [ "\n-1", '-1', 'single newline', with_past => 1, ],
- [ " \n \n - 1 \n 2", [ -1, 2 ], 'multiple empty
lines', with_past => 1 ],
-
- # positive and negative Integers
- #[ '+1', '1', 'unary +', with_past => 1, ], Surprise, there is no unary
+ in POSIX bc
- [ '-1', '-1', 'unary -', with_past => 1, ],
- [ '0', '0', undef, with_past => 1, ],
- [ '-0', '0', undef, with_past => 1, ],
- [ '1', '1', undef, with_past => 1, ],
- [ '-10', '-10', undef, with_past => 1, ],
- [ '123456789', '123456789', undef, with_past => 1, ],
- [ '-123456789', '-123456789', undef, with_past => 1, ],
- [ '0001', '1', undef, with_past => 1, ],
- [ '-0001', '-1', undef, with_past => 1 ],
-
- # floats
- [ '-1.0001', '-1.0001' ],
- [ '1.2', '1.2' ],
- [ '1.2 *2 - 2.0 + 3', '3.4' ],
-
- # binary PLUS
- [ '1 + 2', '3' ],
- [ '1 + 2 + 3', '6' ],
- [ '1 + 0 + 3', '4' ],
- [ '1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14', '105',
'Gauss was right' ],
-
- # binary '-'
- [ '2 - 1', '1' ],
- [ '1 - 1', '0' ],
- [ '1 - 2', '-1' ],
- [ '-1 - -2', '1' ],
- [ '-1 + -2 - -4 + 10', '11' ],
-
- # multiplication
- [ '2 * 2', '4' ],
-
- # division
- [ '2 / 2', '1' ],
-
- # modulus
- [ '2 % 2', '0' ],
-
- # precedence of mul, diff, mod
- [ '2 / 2 + .1', '1.1' ],
- [ '2 * 2 + .4', '4.4' ],
- [ '.1 - 6 / 2', '-2.9' ],
- [ '2 % 2 + 4', '4' ],
-
- # parenthesis
- [ ' ( 1 ) ', '1', 'one in parenthesis', with_past => 1 ],
- [ ' ( 1 + 2 ) * 3 ', '9' ],
- [ ' ( 1 * 2 ) * 3 ', '6' ],
- [ ' ( 1 * 2 ) + 3 ', '5' ],
- [ ' ( 1 * 2 ) + ( ( ( ( 3 + 4 ) + 5 ) * 6 ) * 7 ) ', '506' ],
-
- # semicolons
- [ '1; 2', [1, 2], 'two expressions seperated by a semicolon', with_past
=> 1 ],
- [ '1+1*1; 2+2*2', [2, 6] ],
- [ '3-3/3; 4+4%4; 5-5+5', [2, 4, 5] ],
-
- # keyword quit
- [ "1; 2\nquit\n 3", [1, 2] ],
-
- # named expressions
- [ "a", [0], 'uninitialized a' ],
- [ "a; a = 1; a", [0,1], 'assign number to lexical' ],
- [ 'a; b; a = 4; b = a; c = 1; "a = "; a; "b = "; b; "c = "; c', [ 0,
0, 'a = 4', 'b = 4', 'c = 1' ], 'assing lexical to lexical' ],
-
- # increment and decrement
- [ "a; a = 1; a; ++a; a", [0,1,2,2], 'increment' ],
- [ "a; a = 1; a; --a; a", [0,1,0,0], 'decrement' ],
-
- # If
- [ "1; if ( 1 ) 2; 3", [1,2,3], 'if with a true condition' ],
- [ "1; if ( 0 ) 2; 3", [1,3], 'if with a true condition' ],
- [ "1; if ( 1 < 2 ) 2; 3", [1, 2, 3], 'if with a relational operator' ],
-
- # If with '<'
- [ "1; if ( 3 + 4 < 8*2 - 10 ) 2; 3", [1, 3] ],
- [ "1; if ( 3 + 4 < 8*2 - 9 ) 2; 3", [1, 3] ],
- [ "1; if ( 3 + 4 < 8*2 + 10 ) 2; 3", [1, 2, 3] ],
-
- # If with '<='
- [ "1; if ( 3 + 4 <= 8*2 - 10 ) 2; 3", [1, 3] ],
- [ "1; if ( 3 + 4 <= 8*2 - 9 ) 2; 3", [1, 2, 3] ],
- [ "1; if ( 3 + 4 <= 8*2 + 10 ) 2; 3", [1, 2, 3] ],
- # If with '==', still TODO
- [ "1; if ( 3 + 4 == 8*2 - 10 ) 2; 3", [1, 3] ],
- [ "1; if ( 3 + 4 == 8*2 - 9 ) 2; 3", [1, 2, 3] ],
- [ "1; if ( 3 + 4 == 8*2 + 10 ) 2; 3", [1, 3] ],
- # If with '!='
- [ "1; if ( 3 + 4 != 8*2 - 10 ) 2; 3", [1, 2, 3] ],
- [ "1; if ( 3 + 4 != 8*2 - 9 ) 2; 3", [1, 3] ],
- [ "1; if ( 3 + 4 != 8*2 + 10 ) 2; 3", [1, 2, 3] ],
- # If with '>='
- [ "1; if ( 3 + 4 >= 8*2 - 10 ) 2; 3", [1, 2, 3] ],
- [ "1; if ( 3 + 4 >= 8*2 - 9 ) 2; 3", [1, 2, 3] ],
- [ "1; if ( 3 + 4 >= 8*2 + 10 ) 2; 3", [1, 3] ],
-
- # If with '>'
- [ "1; if ( 3 + 4 > 8*2 - 10 ) 2; 3", [1, 2, 3] ],
- [ "1; if ( 3 + 4 > 8*2 - 9 ) 2; 3", [1, 3] ],
- [ "1; if ( 3 + 4 > 8*2 + 10 ) 2; 3", [1, 3] ],
- );
-
-run_tests([EMAIL PROTECTED]);
-
-TODO:
-{
- local $TODO = 'not implemented';
- my @todo_tests = (
- # floats
- [ '.1', '.1', 'Parrot bc says 0.1', with_past => 1 ],
- [ '-.1', '-.1', 'Parrot bc says -0.1', with_past => 1],
- [ '-1.0000001', '-1.0000001', 'propably limited precission of Float
PMC', with_past => 1 ],
-
- # keyword quit
- [ "0\n1; 2; quit; 3", [ 0 ], 'is that correct in GNU bc?',
with_past => 1 ],
- );
- run_tests( [EMAIL PROTECTED] );
-};
+my $song_text = <<'END_SONG';
+99 bottles of beer on the wall,
+99 bottles of beer,
+Take one down, pass it around,
+98 bottles of beer on the wall.
+
+98 bottles of beer on the wall,
+98 bottles of beer,
+Take one down, pass it around,
+97 bottles of beer on the wall.
+
+97 bottles of beer on the wall,
+97 bottles of beer,
+Take one down, pass it around,
+96 bottles of beer on the wall.
+
+96 bottles of beer on the wall,
+96 bottles of beer,
+Take one down, pass it around,
+95 bottles of beer on the wall.
+
+95 bottles of beer on the wall,
+95 bottles of beer,
+Take one down, pass it around,
+94 bottles of beer on the wall.
+
+94 bottles of beer on the wall,
+94 bottles of beer,
+Take one down, pass it around,
+93 bottles of beer on the wall.
+
+93 bottles of beer on the wall,
+93 bottles of beer,
+Take one down, pass it around,
+92 bottles of beer on the wall.
+
+92 bottles of beer on the wall,
+92 bottles of beer,
+Take one down, pass it around,
+91 bottles of beer on the wall.
+
+91 bottles of beer on the wall,
+91 bottles of beer,
+Take one down, pass it around,
+90 bottles of beer on the wall.
+
+90 bottles of beer on the wall,
+90 bottles of beer,
+Take one down, pass it around,
+89 bottles of beer on the wall.
+
+89 bottles of beer on the wall,
+89 bottles of beer,
+Take one down, pass it around,
+88 bottles of beer on the wall.
+
+88 bottles of beer on the wall,
+88 bottles of beer,
+Take one down, pass it around,
+87 bottles of beer on the wall.
+
+87 bottles of beer on the wall,
+87 bottles of beer,
+Take one down, pass it around,
+86 bottles of beer on the wall.
+
+86 bottles of beer on the wall,
+86 bottles of beer,
+Take one down, pass it around,
+85 bottles of beer on the wall.
+
+85 bottles of beer on the wall,
+85 bottles of beer,
+Take one down, pass it around,
+84 bottles of beer on the wall.
+
+84 bottles of beer on the wall,
+84 bottles of beer,
+Take one down, pass it around,
+83 bottles of beer on the wall.
+
+83 bottles of beer on the wall,
+83 bottles of beer,
+Take one down, pass it around,
+82 bottles of beer on the wall.
+
+82 bottles of beer on the wall,
+82 bottles of beer,
+Take one down, pass it around,
+81 bottles of beer on the wall.
+
+81 bottles of beer on the wall,
+81 bottles of beer,
+Take one down, pass it around,
+80 bottles of beer on the wall.
+
+80 bottles of beer on the wall,
+80 bottles of beer,
+Take one down, pass it around,
+79 bottles of beer on the wall.
+
+79 bottles of beer on the wall,
+79 bottles of beer,
+Take one down, pass it around,
+78 bottles of beer on the wall.
+
+78 bottles of beer on the wall,
+78 bottles of beer,
+Take one down, pass it around,
+77 bottles of beer on the wall.
+
+77 bottles of beer on the wall,
+77 bottles of beer,
+Take one down, pass it around,
+76 bottles of beer on the wall.
+
+76 bottles of beer on the wall,
+76 bottles of beer,
+Take one down, pass it around,
+75 bottles of beer on the wall.
+
+75 bottles of beer on the wall,
+75 bottles of beer,
+Take one down, pass it around,
+74 bottles of beer on the wall.
+
+74 bottles of beer on the wall,
+74 bottles of beer,
+Take one down, pass it around,
+73 bottles of beer on the wall.
+
+73 bottles of beer on the wall,
+73 bottles of beer,
+Take one down, pass it around,
+72 bottles of beer on the wall.
+
+72 bottles of beer on the wall,
+72 bottles of beer,
+Take one down, pass it around,
+71 bottles of beer on the wall.
+
+71 bottles of beer on the wall,
+71 bottles of beer,
+Take one down, pass it around,
+70 bottles of beer on the wall.
+
+70 bottles of beer on the wall,
+70 bottles of beer,
+Take one down, pass it around,
+69 bottles of beer on the wall.
+
+69 bottles of beer on the wall,
+69 bottles of beer,
+Take one down, pass it around,
+68 bottles of beer on the wall.
+
+68 bottles of beer on the wall,
+68 bottles of beer,
+Take one down, pass it around,
+67 bottles of beer on the wall.
+
+67 bottles of beer on the wall,
+67 bottles of beer,
+Take one down, pass it around,
+66 bottles of beer on the wall.
+
+66 bottles of beer on the wall,
+66 bottles of beer,
+Take one down, pass it around,
+65 bottles of beer on the wall.
+
+65 bottles of beer on the wall,
+65 bottles of beer,
+Take one down, pass it around,
+64 bottles of beer on the wall.
+
+64 bottles of beer on the wall,
+64 bottles of beer,
+Take one down, pass it around,
+63 bottles of beer on the wall.
+
+63 bottles of beer on the wall,
+63 bottles of beer,
+Take one down, pass it around,
+62 bottles of beer on the wall.
+
+62 bottles of beer on the wall,
+62 bottles of beer,
+Take one down, pass it around,
+61 bottles of beer on the wall.
+
+61 bottles of beer on the wall,
+61 bottles of beer,
+Take one down, pass it around,
+60 bottles of beer on the wall.
+
+60 bottles of beer on the wall,
+60 bottles of beer,
+Take one down, pass it around,
+59 bottles of beer on the wall.
+
+59 bottles of beer on the wall,
+59 bottles of beer,
+Take one down, pass it around,
+58 bottles of beer on the wall.
+
+58 bottles of beer on the wall,
+58 bottles of beer,
+Take one down, pass it around,
+57 bottles of beer on the wall.
+
+57 bottles of beer on the wall,
+57 bottles of beer,
+Take one down, pass it around,
+56 bottles of beer on the wall.
+
+56 bottles of beer on the wall,
+56 bottles of beer,
+Take one down, pass it around,
+55 bottles of beer on the wall.
+
+55 bottles of beer on the wall,
+55 bottles of beer,
+Take one down, pass it around,
+54 bottles of beer on the wall.
+
+54 bottles of beer on the wall,
+54 bottles of beer,
+Take one down, pass it around,
+53 bottles of beer on the wall.
+
+53 bottles of beer on the wall,
+53 bottles of beer,
+Take one down, pass it around,
+52 bottles of beer on the wall.
+
+52 bottles of beer on the wall,
+52 bottles of beer,
+Take one down, pass it around,
+51 bottles of beer on the wall.
+
+51 bottles of beer on the wall,
+51 bottles of beer,
+Take one down, pass it around,
+50 bottles of beer on the wall.
+
+50 bottles of beer on the wall,
+50 bottles of beer,
+Take one down, pass it around,
+49 bottles of beer on the wall.
+
+49 bottles of beer on the wall,
+49 bottles of beer,
+Take one down, pass it around,
+48 bottles of beer on the wall.
+
+48 bottles of beer on the wall,
+48 bottles of beer,
+Take one down, pass it around,
+47 bottles of beer on the wall.
+
+47 bottles of beer on the wall,
+47 bottles of beer,
+Take one down, pass it around,
+46 bottles of beer on the wall.
+
+46 bottles of beer on the wall,
+46 bottles of beer,
+Take one down, pass it around,
+45 bottles of beer on the wall.
+
+45 bottles of beer on the wall,
+45 bottles of beer,
+Take one down, pass it around,
+44 bottles of beer on the wall.
+
+44 bottles of beer on the wall,
+44 bottles of beer,
+Take one down, pass it around,
+43 bottles of beer on the wall.
+
+43 bottles of beer on the wall,
+43 bottles of beer,
+Take one down, pass it around,
+42 bottles of beer on the wall.
+
+42 bottles of beer on the wall,
+42 bottles of beer,
+Take one down, pass it around,
+41 bottles of beer on the wall.
+
+41 bottles of beer on the wall,
+41 bottles of beer,
+Take one down, pass it around,
+40 bottles of beer on the wall.
+
+40 bottles of beer on the wall,
+40 bottles of beer,
+Take one down, pass it around,
+39 bottles of beer on the wall.
+
+39 bottles of beer on the wall,
+39 bottles of beer,
+Take one down, pass it around,
+38 bottles of beer on the wall.
+
+38 bottles of beer on the wall,
+38 bottles of beer,
+Take one down, pass it around,
+37 bottles of beer on the wall.
+
+37 bottles of beer on the wall,
+37 bottles of beer,
+Take one down, pass it around,
+36 bottles of beer on the wall.
+
+36 bottles of beer on the wall,
+36 bottles of beer,
+Take one down, pass it around,
+35 bottles of beer on the wall.
+
+35 bottles of beer on the wall,
+35 bottles of beer,
+Take one down, pass it around,
+34 bottles of beer on the wall.
+
+34 bottles of beer on the wall,
+34 bottles of beer,
+Take one down, pass it around,
+33 bottles of beer on the wall.
+
+33 bottles of beer on the wall,
+33 bottles of beer,
+Take one down, pass it around,
+32 bottles of beer on the wall.
+
+32 bottles of beer on the wall,
+32 bottles of beer,
+Take one down, pass it around,
+31 bottles of beer on the wall.
+
+31 bottles of beer on the wall,
+31 bottles of beer,
+Take one down, pass it around,
+30 bottles of beer on the wall.
+
+30 bottles of beer on the wall,
+30 bottles of beer,
+Take one down, pass it around,
+29 bottles of beer on the wall.
+
+29 bottles of beer on the wall,
+29 bottles of beer,
+Take one down, pass it around,
+28 bottles of beer on the wall.
+
+28 bottles of beer on the wall,
+28 bottles of beer,
+Take one down, pass it around,
+27 bottles of beer on the wall.
+
+27 bottles of beer on the wall,
+27 bottles of beer,
+Take one down, pass it around,
+26 bottles of beer on the wall.
+
+26 bottles of beer on the wall,
+26 bottles of beer,
+Take one down, pass it around,
+25 bottles of beer on the wall.
+
+25 bottles of beer on the wall,
+25 bottles of beer,
+Take one down, pass it around,
+24 bottles of beer on the wall.
+
+24 bottles of beer on the wall,
+24 bottles of beer,
+Take one down, pass it around,
+23 bottles of beer on the wall.
+
+23 bottles of beer on the wall,
+23 bottles of beer,
+Take one down, pass it around,
+22 bottles of beer on the wall.
+
+22 bottles of beer on the wall,
+22 bottles of beer,
+Take one down, pass it around,
+21 bottles of beer on the wall.
+
+21 bottles of beer on the wall,
+21 bottles of beer,
+Take one down, pass it around,
+20 bottles of beer on the wall.
+
+20 bottles of beer on the wall,
+20 bottles of beer,
+Take one down, pass it around,
+19 bottles of beer on the wall.
+
+19 bottles of beer on the wall,
+19 bottles of beer,
+Take one down, pass it around,
+18 bottles of beer on the wall.
+
+18 bottles of beer on the wall,
+18 bottles of beer,
+Take one down, pass it around,
+17 bottles of beer on the wall.
+
+17 bottles of beer on the wall,
+17 bottles of beer,
+Take one down, pass it around,
+16 bottles of beer on the wall.
+
+16 bottles of beer on the wall,
+16 bottles of beer,
+Take one down, pass it around,
+15 bottles of beer on the wall.
+
+15 bottles of beer on the wall,
+15 bottles of beer,
+Take one down, pass it around,
+14 bottles of beer on the wall.
+
+14 bottles of beer on the wall,
+14 bottles of beer,
+Take one down, pass it around,
+13 bottles of beer on the wall.
+
+13 bottles of beer on the wall,
+13 bottles of beer,
+Take one down, pass it around,
+12 bottles of beer on the wall.
+
+12 bottles of beer on the wall,
+12 bottles of beer,
+Take one down, pass it around,
+11 bottles of beer on the wall.
+
+11 bottles of beer on the wall,
+11 bottles of beer,
+Take one down, pass it around,
+10 bottles of beer on the wall.
+
+10 bottles of beer on the wall,
+10 bottles of beer,
+Take one down, pass it around,
+9 bottles of beer on the wall.
+
+9 bottles of beer on the wall,
+9 bottles of beer,
+Take one down, pass it around,
+8 bottles of beer on the wall.
+
+8 bottles of beer on the wall,
+8 bottles of beer,
+Take one down, pass it around,
+7 bottles of beer on the wall.
+
+7 bottles of beer on the wall,
+7 bottles of beer,
+Take one down, pass it around,
+6 bottles of beer on the wall.
+
+6 bottles of beer on the wall,
+6 bottles of beer,
+Take one down, pass it around,
+5 bottles of beer on the wall.
+
+5 bottles of beer on the wall,
+5 bottles of beer,
+Take one down, pass it around,
+4 bottles of beer on the wall.
+
+4 bottles of beer on the wall,
+4 bottles of beer,
+Take one down, pass it around,
+3 bottles of beer on the wall.
+
+3 bottles of beer on the wall,
+3 bottles of beer,
+Take one down, pass it around,
+2 bottles of beer on the wall.
+
+2 bottles of beer on the wall,
+2 bottles of beer,
+Take one down, pass it around,
+1 bottle of beer on the wall.
+
+1 bottle of beer on the wall,
+1 bottle of beer,
+Take one down, pass it around,
+No more bottles of beer on the wall.
+
+*Buuurrp*
+END_SONG
+
+my $hello = "Hello, world!\n";
+
+my $code = 'H';
+language_output_is( 'HQ9plus', $code, $hello, "code: $code" );
+
+$code = 'Q';
+language_output_is( 'HQ9plus', $code, $code, "code: $code" );
+
+$code = '9';
+language_output_is( 'HQ9plus', $code, $song_text, "code: $code" );
+
+$code = '+';
+language_output_is( 'HQ9plus', $code, '', "code: $code" );
+
+$code = 'HQ9+';
+language_output_is( 'HQ9plus', $code, $hello . $code . $song_text, "code:
$code" );
+
+$code = 'QQQQ';
+language_output_is( 'HQ9plus', $code, $code x length($code), "code: $code" );
Copied: trunk/languages/HQ9plus/t/harness (from r11361,
trunk/languages/bc/t/harness)
==============================================================================
--- trunk/languages/bc/t/harness (original)
+++ trunk/languages/HQ9plus/t/harness Sat Jan 28 12:03:50 2006
@@ -2,18 +2,16 @@
=head1 NAME
-languages/bc/t/harness - A harness for Parrot bc
+languages/HQ9plus/t/harness - A harness for Parrot HQ9plus
=head1 SYNOPSIS
- cd languages && perl -I../lib bc/t/harness --files
+ cd languages && perl -I../lib HQ9plus/t/harness --files
- cd languages && perl -I../lib bc/t/harness
+ cd languages && perl -I../lib HQ9plus/t/harness
- cd languages && perl -I../lib bc/t/harness --use-gnu-bc
-
- cd languages && perl -I../lib bc/t/harness \
- bc/t/basic/integer.t
+ cd languages && perl -I../lib HQ9plus/t/harness \
+ HQ9plus/t/basic/integer.t
=head1 DESCRIPTION
@@ -35,7 +33,7 @@ use Data::Dumper;
use File::Spec;
use Test::Harness();
-my $language = 'bc';
+my $language = 'HQ9plus';
if ( grep { m/^--files$/ } @ARGV ) {
# Only the Makefile in 'parrot/languages' uses --files
@@ -46,8 +44,6 @@ if ( grep { m/^--files$/ } @ARGV ) {
} else {
my @files;
# TODO: use Getopt::Long or such
- my $use_gnu_bc = ( grep { m/^--use-gnu-bc$/ } @ARGV ) ? 1 : 0;
- @ARGV = grep { ! m/^--use-gnu-bc$/ } @ARGV;
if ( scalar(@ARGV) ) {
# Someone specified tests for me to run.
@files = grep { -f $_ } @ARGV
@@ -64,21 +60,10 @@ if ( grep { m/^--files$/ } @ARGV ) {
}
}
- # Always test Parrot bc
eval
{
- $ENV{PARROT_BC_TEST_PROG} = '';
Test::Harness::runtests( @files ) if scalar( @files );
};
- # XXX There should be a better to indicate which implementation should be
used
- if ( $use_gnu_bc ) {
- if ($^O =~ /MSWin32/) {
- $ENV{PARROT_BC_TEST_PROG} = 'bc';
- } else {
- $ENV{PARROT_BC_TEST_PROG} = 'bc --standard --quiet';
- }
- Test::Harness::runtests( @files ) if scalar( @files );
- }
}
=head1 HISTORY
Modified: trunk/languages/LANGUAGES.STATUS.pod
==============================================================================
--- trunk/languages/LANGUAGES.STATUS.pod (original)
+++ trunk/languages/LANGUAGES.STATUS.pod Sat Jan 28 12:03:50 2006
@@ -306,6 +306,33 @@ C<languages/forth>
=back
+=head2 HQ9plus
+
+=over 4
+
+=item Author
+
+Bernhard Schmalhofer
+
+=item Description
+
+A joke language.
+
+=item Status
+
+Works.
+
+=item Last verified with parrot version
+
+0.4.1
+
+=item Location
+
+C<languages/HQ9plus>
+
+=back
+
+
=head2 Jako
=over 4
Modified: trunk/languages/m4/lib/Parrot/Test/M4.pm
==============================================================================
--- trunk/languages/m4/lib/Parrot/Test/M4.pm (original)
+++ trunk/languages/m4/lib/Parrot/Test/M4.pm Sat Jan 28 12:03:50 2006
@@ -61,7 +61,6 @@ foreach my $func ( keys %language_test_m
Parrot::Test::generate_code( $code, $parrotdir, $count, $lang_fn );
# STDERR is written into same output file
- print Dumper( [EMAIL PROTECTED], $self );
my $exit_code = Parrot::Test::run_command(
[EMAIL PROTECTED],
CD => $self->{relpath},
Modified: trunk/languages/parrot_compiler/parrot_compiler.pir
==============================================================================
--- trunk/languages/parrot_compiler/parrot_compiler.pir (original)
+++ trunk/languages/parrot_compiler/parrot_compiler.pir Sat Jan 28 12:03:50 2006
@@ -1,4 +1,4 @@
-# Copyright: 2002-2005 The Perl Foundation. All Rights Reserved.
+# Copyright: 2002-2006 The Perl Foundation. All Rights Reserved.
# $Id$
.sub main :main
Modified: trunk/languages/t/harness
==============================================================================
--- trunk/languages/t/harness (original)
+++ trunk/languages/t/harness Sat Jan 28 12:03:50 2006
@@ -90,7 +90,8 @@ my $do_gen_html = grep { $_ eq '--html'
my @unified_testable_languages =
- qw( Zcode
+ qw( HQ9plus
+ Zcode
bc
befunge
bf