Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
109 lines (89 sloc) 3.54 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>"Perlito" Perl5 to Perl6 Compiler</title>
</head>
<body>
<h1><a href="http://fglock.github.io/Perlito">"Perlito" Perl5 to Perl6 Compiler</a></h1>
<p>Perlito is a compiler collection that implements a Perl5 and a Perl6 compiler.</p>
<p>Main Perlito repository: <a href="http://github.com/fglock/Perlito">http://github.com/fglock/Perlito</a></p>
<script type="text/javascript" src="perlito5to6.js"></script>
<p>Source program:</p>
<textarea id="source" cols="70" rows="10">
use v5;
use strict;
use feature 'say';
package Main;
say <<"HELLO";
"Perlito Perl5" running in $^O
HELLO
my @x = qw/ x y z /;
print $x[1], "\n";
for my $x ( reverse @x ) { say $x }
for ( my $i = 0 ; $i < 10 ; $i++ ) { say $i }
while (<>) { print "Hello, world!"; }
sub mysub {
my $x = shift;
my $y = shift;
$x + $y;
}
</textarea><br/>
<input type="button" value="Execute" onclick="execute()"/>
<p>Compiler log:</p>
<textarea id="log-result" readonly="true" cols="70" rows="5"></textarea><br/>
<p>Compiled to Perl6:</p>
<textarea id="js-result" readonly="true" cols="70" rows="5"></textarea><br/>
<script type="text/javascript">
function execute() {
window.p5is_file = function(s) {
return '';
};
p5typeglob_set("Perlito5::IO", "print", function(filehandle, List__) {
if (filehandle == 'STDOUT' || filehandle == 'main::STDOUT') {
var i;
for (i = 0; i < List__.length; i++) {
document.getElementById('log-result').value += p5str(List__[i]);
}
return true;
}
else {
// STDERR
var i;
List__.push("\n");
for (i = 0; i < List__.length; i++) {
document.getElementById('log-result').value += p5str(List__[i]);
}
return true;
}
} );
p5pkg["main"]["v_^O"] = "browser";
p5pkg["main"]["Hash_INC"]["Perlito5X/strict.pm"] = "Perlito5X/strict.pm";
p5pkg["main"]["Hash_INC"]["Perlito5X/warnings.pm"] = "Perlito5X/warnings.pm";
p5pkg["main"]["Hash_INC"]["Perlito5X/feature.pm"] = "Perlito5X/feature.pm";
var source = document.getElementById('source').value;
var pos = 0;
var ast;
var match;
document.getElementById('log-result').value = "";
document.getElementById('js-result').value = "";
try {
// compile
document.getElementById('log-result').value += "Compiling.\n";
var start = new Date().getTime();
var js_source = p5pkg["Perlito5"].compile_p5_to_p6([source]);
var end = new Date().getTime();
var time = end - start;
document.getElementById('log-result').value += "Compilation time: " + time + "ms\n";
document.getElementById('js-result').value += js_source + ";\n";
p5pkg.CORE.print(["\nDone.\n"]);
}
catch(err) {
document.getElementById('log-result').value += "Error:\n";
document.getElementById('log-result').value += err + "\n";
// document.getElementById('log-result').value += err.stack + "\n";
document.getElementById('log-result').value += "Compilation aborted.\n";
}
}
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.