| Language-Kemuri documentation | Contained in the Language-Kemuri distribution. |
Language::Kemuri - Kemuri Interpreter.
use Language::Kemuri;
kemuri('`|'); # => Hello, world!
An interpreter for Kemuri language.
run the kemuri, and return the output value.
No bugs have been reported.
Tokuhiro Matsuno <tokuhiro __at__ mobilefactory.jp>
Copyright (c) 2007, Tokuhiro Matsuno <tokuhiro __at__ mobilefactory.jp>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
| Language-Kemuri documentation | Contained in the Language-Kemuri distribution. |
package Language::Kemuri; use strict; use warnings; use Carp; our $VERSION = '0.06'; use Exporter; use Switch; our @EXPORT_OK = qw/kemuri/; sub kemuri { my $code = shift; my @stack; my $buf = ""; for my $c ( split //, $code ) { switch ($c) { case '`' { push @stack, unpack("C*", reverse "Hello, world!"); } case '"' { my $x = pop @stack; push @stack, $x; push @stack, $x; } case "'" { my $x = pop @stack; my $y = pop @stack; my $z = pop @stack; push @stack, $x; push @stack, $z; push @stack, $y; } case '^' { my $x = pop @stack; my $y = pop @stack; push @stack, $x ^ $y; } case '~' { my $x = pop @stack; push @stack, -($x+1); } case '|' { $buf .= reverse map { chr($_ % 256) } @stack; } else { croak "unknown kemuri token $c in $code"; } } } return $buf; } 1; __END__