Permalink
Browse files

Perlito5 - perl5: "use" is compile-time (the emitted code contains al…

…l modules used)
  • Loading branch information...
1 parent b44f592 commit b4f4a35270ef6bbdb9aea3b0f231ae00275a9a92 @fglock committed May 2, 2012
Showing with 10,223 additions and 10,795 deletions.
  1. +6 −6 README-perlito5
  2. +3 −1 TODO-perlito5
  3. +8 −2 html/perlito5.js
  4. +0 −251 lib5/Perlito5/AST.pm
  5. +0 −32 lib5/Perlito5/Dumper.pm
  6. +0 −239 lib5/Perlito5/Emitter/Token.pm
  7. +0 −209 lib5/Perlito5/Eval.pm
  8. +0 −1,594 lib5/Perlito5/Expression.pm
  9. +0 −1,360 lib5/Perlito5/Grammar.pm
  10. +0 −150 lib5/Perlito5/Grammar/Bareword.pm
  11. +0 −233 lib5/Perlito5/Grammar/Block.pm
  12. +0 −769 lib5/Perlito5/Grammar/Control.pm
  13. +0 −932 lib5/Perlito5/Grammar/Regex.pm
  14. +0 −310 lib5/Perlito5/Grammar/Space.pm
  15. +0 −1,237 lib5/Perlito5/Grammar/String.pm
  16. +0 −293 lib5/Perlito5/Grammar/Use.pm
  17. +0 −12 lib5/Perlito5/Javascript/CORE.pm
  18. +0 −1,282 lib5/Perlito5/Javascript/Emitter.pm
  19. +0 −12 lib5/Perlito5/Javascript/IO.pm
  20. +0 −12 lib5/Perlito5/Javascript/Runtime.pm
  21. +0 −45 lib5/Perlito5/Macro.pm
  22. +0 −13 lib5/Perlito5/Match.pm
  23. +0 −423 lib5/Perlito5/Perl5/Emitter.pm
  24. +0 −49 lib5/Perlito5/Perl5/Runtime.pm
  25. +0 −509 lib5/Perlito5/Perl6/Emitter.pm
  26. +0 −57 lib5/Perlito5/Perl6/Runtime.pm
  27. +0 −389 lib5/Perlito5/Precedence.pm
  28. +0 −16 lib5/Perlito5/Runtime.pm
  29. +0 −147 lib5/Perlito5/Test.pm
  30. +0 −14 lib5/Perlito5/bytes.pm
  31. +0 −14 lib5/Perlito5/strict.pm
  32. +0 −14 lib5/Perlito5/utf8.pm
  33. +0 −14 lib5/Perlito5/warnings.pm
  34. +10,181 −41 perlito5.pl
  35. +4 −12 src5/lib/Perlito5/Perl5/Emitter.pm
  36. +14 −17 src5/lib/Perlito5/Perl5/Runtime.pm
  37. +2 −5 src5/lib/Perlito5/Perl6/Emitter.pm
  38. +4 −12 src5/util/perlito5.pl
  39. +1 −1 util-js/make-perlito5-js.sh
  40. +0 −67 util-perl5/bootstrap-perlito5-perl5.sh
View
@@ -1,7 +1,7 @@
Running the tests using "node.js":
# this command will compile "perlito5.js"
- perl -Ilib5 perlito5.pl -I./src5/lib -Cjs src5/util/perlito5.pl > perlito5.js
+ perl perlito5.pl -I./src5/lib -Cjs src5/util/perlito5.pl > perlito5.js
# this will run a single test script
node perlito5.js -Isrc5/lib t5/01-perlito/01-sanity.t
@@ -14,25 +14,25 @@ Compile the compiler to Javascript into perlito5.js:
-- using perl and perlito5.pl:
- perl -Ilib5 perlito5.pl -I./src5/lib -Cjs src5/util/perlito5.pl > perlito5.js
+ perl perlito5.pl -I./src5/lib -Cjs src5/util/perlito5.pl > perlito5.js
-- using node.js and perlito5.js:
node perlito5.js -I./src5/lib -Cjs src5/util/perlito5.pl > perlito5-new.js
Compile the compiler to Perl5 using perl:
- perl util-perl5/bootstrap-perlito5-perl5.sh
+ perl perlito5.pl -I./src5/lib -Cperl5 src5/util/perlito5.pl > perlito5-new.pl
-Compiler perlito5-in-browser using perl:
+Compile perlito5-in-browser using perl:
perl util-js/make-perlito5-js.sh
Running the tests using "perl":
# this will run all tests
- prove -r -e 'perl -Ilib5 perlito5.pl -I./src5/lib ' t5
+ prove -r -e 'perl perlito5.pl -I./src5/lib ' t5
@@ -42,7 +42,7 @@ Running the tests using perl6:
# TODO - this is not implemented yet
. util-perl6/setup-perlito5-perl6.sh
- find t5/01-perlito/*.t | perl -ne ' print "*** $_"; chomp; print ` perl -Ilib5 perlito5.pl -I./src5/lib -Cperl6 $_ > tmp.p6 && perl6 tmp.p6 ` '
+ find t5/01-perlito/*.t | perl -ne ' print "*** $_"; chomp; print ` perl perlito5.pl -I./src5/lib -Cperl6 $_ > tmp.p6 && perl6 tmp.p6 ` '
View
@@ -35,6 +35,8 @@ TODO list for Perlito5
* Parser
+-- no __END__
+
-- "sub _" should be in package "main"
-- "given" statement not implemented
@@ -201,7 +203,7 @@ TODO list for Perlito5
-- use the same error messages and warnings as 'perl'
-- no warnings 'redefine';
--- __END__, __LINE__, __DATA__, __FILE__
+-- __LINE__, __DATA__, __FILE__
-- INIT{}, END{}
look at the implementation in perlito6-in-Go
View
@@ -1559,7 +1559,7 @@ var p5100 = p5pkg['main'];
// our p5pkg["Perlito5::Javascript"]["Hash_op_to_num"]
(p5pkg["Perlito5::Javascript"]["Hash_op_to_num"] = p5a_to_h(p5list_to_a(p5map(p5pkg["Perlito5::Javascript"], function (p5want) {
return ((p5context([p5pkg["Perlito5::Javascript"]["v__"], 1], p5want)));
- }, ['length', 'index', 'ord', 'oct', 'infix:<->', 'infix:<+>', 'infix:<*>', 'infix:</>', 'infix:<%>']))));
+ }, ['length', 'index', 'ord', 'oct', 'infix:<->', 'infix:<+>', 'infix:<*>', 'infix:</>', 'infix:<%>', 'infix:<**>']))));
var Hash_safe_char = {};
(Hash_safe_char = p5a_to_h([' ', 1, '!', 1, '"', 1, '#', 1, '$', 1, '%', 1, '&', 1, '(', 1, ')', 1, '*', 1, '+', 1, ',', 1, '-', 1, '.', 1, '/', 1, ':', 1, ';', 1, '<', 1, '=', 1, '>', 1, '?', 1, '@', 1, '[', 1, ']', 1, '^', 1, '_', 1, '`', 1, '{', 1, '|', 1, '}', 1, '~', 1]));
p5make_sub("Perlito5::Javascript", "escape_string", function (List__, p5want) {
@@ -2000,7 +2000,7 @@ var p5100 = p5pkg['main'];
p5pkg["Perlito5::Javascript::LexicalBlock"].push([List_str, p5list_to_a(p5call(((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] || ((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] = new p5ArrayRef([])))._array_[p5idx(((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] || ((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] = new p5ArrayRef([])))._array_,0)], "emit_javascript_init", [], 1))], null);
};
};
- if ( ((p5bool(p5call(v_last_statement, "isa", ['Perlito5::AST::Apply'], 0)) && (p5str(p5call(v_last_statement, "code", [], 0)) == 'return')) && p5bool((v_self || (v_self = new p5HashRef({})))._hash_['top_level'])) ) {
+ if ( (((p5bool(p5call(v_last_statement, "isa", ['Perlito5::AST::Apply'], 0)) && (p5str(p5call(v_last_statement, "code", [], 0)) == 'return')) && p5bool((v_self || (v_self = new p5HashRef({})))._hash_['top_level'])) && p5bool(((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] || ((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] = new p5ArrayRef([])))._array_)) ) {
(v_last_statement = (((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] || ((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] = new p5ArrayRef([])))._array_[p5idx(((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] || ((v_last_statement || (v_last_statement = new p5HashRef({})))._hash_['arguments'] = new p5ArrayRef([])))._array_,0)]));
};
if ( p5bool(p5call(v_last_statement, "isa", ['Perlito5::AST::If'], 0)) ) {
@@ -2636,6 +2636,12 @@ var p5100 = p5pkg['main'];
return (p5context([('p5cmp(' + p5pkg["Perlito5::AST::Apply"].join([', ', p5list_to_a(p5map(p5pkg["Perlito5::AST::Apply"], function (p5want) {
return (p5pkg["Perlito5::Javascript"].to_num([p5pkg["Perlito5::AST::Apply"]["v__"]], p5want));
}, p5list_to_a(((v_self || (v_self = new p5HashRef({})))._hash_['arguments'] || ((v_self || (v_self = new p5HashRef({})))._hash_['arguments'] = new p5ArrayRef([])))._array_)))], 0) + ')')], p5want));
+ }, 'infix:<**>', function (List__, p5want) {
+ var v_self = null;
+ (v_self = (List__[p5idx(List__,0)]));
+ return (p5context([('Math.pow(' + p5pkg["Perlito5::AST::Apply"].join([', ', p5list_to_a(p5map(p5pkg["Perlito5::AST::Apply"], function (p5want) {
+ return (p5pkg["Perlito5::Javascript"].to_num([p5pkg["Perlito5::AST::Apply"]["v__"]], p5want));
+}, p5list_to_a(((v_self || (v_self = new p5HashRef({})))._hash_['arguments'] || ((v_self || (v_self = new p5HashRef({})))._hash_['arguments'] = new p5ArrayRef([])))._array_)))], 0) + ')')], p5want));
}, 'prefix:<!>', function (List__, p5want) {
var v_self = null;
(v_self = (p5pkg["Perlito5::AST::Apply"].shift([List__])));
View
@@ -1,251 +0,0 @@
-# Do not edit this file - Generated by Perlito5 9.0
-use v5.10;
-use Perlito5::Perl5::Runtime;
-package main;
-undef();
-package Perlito5::AST::CompUnit;
-sub Perlito5::AST::CompUnit::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::CompUnit::name {
- $_[0]->{ 'name'}
-};
-sub Perlito5::AST::CompUnit::body {
- $_[0]->{ 'body'}
-};
-package Perlito5::AST::Val::Int;
-sub Perlito5::AST::Val::Int::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Val::Int::int {
- $_[0]->{ 'int'}
-};
-package Perlito5::AST::Val::Num;
-sub Perlito5::AST::Val::Num::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Val::Num::num {
- $_[0]->{ 'num'}
-};
-package Perlito5::AST::Val::Buf;
-sub Perlito5::AST::Val::Buf::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Val::Buf::buf {
- $_[0]->{ 'buf'}
-};
-package Perlito5::AST::Lit::Block;
-sub Perlito5::AST::Lit::Block::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Lit::Block::sig {
- $_[0]->{ 'sig'}
-};
-sub Perlito5::AST::Lit::Block::stmts {
- $_[0]->{ 'stmts'}
-};
-package Perlito5::AST::Index;
-sub Perlito5::AST::Index::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Index::obj {
- $_[0]->{ 'obj'}
-};
-sub Perlito5::AST::Index::index_exp {
- $_[0]->{ 'index_exp'}
-};
-package Perlito5::AST::Lookup;
-sub Perlito5::AST::Lookup::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Lookup::obj {
- $_[0]->{ 'obj'}
-};
-sub Perlito5::AST::Lookup::index_exp {
- $_[0]->{ 'index_exp'}
-};
-sub Perlito5::AST::Lookup::autoquote {
- ((my $self) = shift());
- ((my $index) = shift());
- if (($index->isa('Perlito5::AST::Apply') && $index->{'bareword'})) {
- return (Perlito5::AST::Val::Buf->new('buf', ((($index->{'namespace'} ? ($index->{'namespace'} . '::') : '')) . $index->{'code'})))
- };
- $index
-};
-package Perlito5::AST::Var;
-sub Perlito5::AST::Var::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Var::sigil {
- $_[0]->{ 'sigil'}
-};
-sub Perlito5::AST::Var::namespace {
- $_[0]->{ 'namespace'}
-};
-sub Perlito5::AST::Var::name {
- $_[0]->{ 'name'}
-};
-sub Perlito5::AST::Var::plain_name {
- ((my $self) = shift());
- if ($self->namespace()) {
- return (($self->namespace() . '::' . $self->name()))
- };
- return ($self->name())
-};
-package Perlito5::AST::Proto;
-sub Perlito5::AST::Proto::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Proto::name {
- $_[0]->{ 'name'}
-};
-package Perlito5::AST::Call;
-sub Perlito5::AST::Call::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Call::invocant {
- $_[0]->{ 'invocant'}
-};
-sub Perlito5::AST::Call::method {
- $_[0]->{ 'method'}
-};
-sub Perlito5::AST::Call::arguments {
- $_[0]->{ 'arguments'}
-};
-package Perlito5::AST::Apply;
-sub Perlito5::AST::Apply::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Apply::code {
- $_[0]->{ 'code'}
-};
-sub Perlito5::AST::Apply::arguments {
- $_[0]->{ 'arguments'}
-};
-sub Perlito5::AST::Apply::namespace {
- $_[0]->{ 'namespace'}
-};
-package Perlito5::AST::If;
-sub Perlito5::AST::If::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::If::cond {
- $_[0]->{ 'cond'}
-};
-sub Perlito5::AST::If::body {
- $_[0]->{ 'body'}
-};
-sub Perlito5::AST::If::otherwise {
- $_[0]->{ 'otherwise'}
-};
-package Perlito5::AST::When;
-sub Perlito5::AST::When::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::When::cond {
- $_[0]->{ 'cond'}
-};
-sub Perlito5::AST::When::body {
- $_[0]->{ 'body'}
-};
-package Perlito5::AST::While;
-sub Perlito5::AST::While::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::While::init {
- $_[0]->{ 'init'}
-};
-sub Perlito5::AST::While::cond {
- $_[0]->{ 'cond'}
-};
-sub Perlito5::AST::While::continue {
- $_[0]->{ 'continue'}
-};
-sub Perlito5::AST::While::body {
- $_[0]->{ 'body'}
-};
-package Perlito5::AST::For;
-sub Perlito5::AST::For::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::For::cond {
- $_[0]->{ 'cond'}
-};
-sub Perlito5::AST::For::continue {
- $_[0]->{ 'continue'}
-};
-sub Perlito5::AST::For::body {
- $_[0]->{ 'body'}
-};
-package Perlito5::AST::Decl;
-sub Perlito5::AST::Decl::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Decl::decl {
- $_[0]->{ 'decl'}
-};
-sub Perlito5::AST::Decl::type {
- $_[0]->{ 'type'}
-};
-sub Perlito5::AST::Decl::var {
- $_[0]->{ 'var'}
-};
-package Perlito5::AST::Sig;
-sub Perlito5::AST::Sig::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Sig::positional {
- $_[0]->{ 'positional'}
-};
-package Perlito5::AST::Sub;
-sub Perlito5::AST::Sub::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Sub::name {
- $_[0]->{ 'name'}
-};
-sub Perlito5::AST::Sub::sig {
- $_[0]->{ 'sig'}
-};
-sub Perlito5::AST::Sub::block {
- $_[0]->{ 'block'}
-};
-package Perlito5::AST::Do;
-sub Perlito5::AST::Do::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Do::block {
- $_[0]->{ 'block'}
-};
-package Perlito5::AST::Use;
-sub Perlito5::AST::Use::new {
- ((my $class) = shift());
- bless({@_}, $class)
-};
-sub Perlito5::AST::Use::mod {
- $_[0]->{ 'mod'}
-};
-sub Perlito5::AST::Use::code {
- $_[0]->{ 'code'}
-};
-
-1;
View
@@ -1,32 +0,0 @@
-# Do not edit this file - Generated by Perlito5 9.0
-use v5.10;
-use Perlito5::Perl5::Runtime;
-package main;
-package Perlito5::Dumper;
-sub Perlito5::Dumper::Dumper {
- ((my $obj) = $_[0]);
- ((my $level) = ($_[1] || 0));
- if (!(defined($obj))) {
- return ('undef')
- };
- ((my $ref) = ref($obj));
- ((my $tab) = join("", ' ' x $level));
- ((my $tab1) = ($tab . ' '));
- if (($ref eq 'ARRAY')) {
- return (('[' . chr(10) . join('', map(($tab1 . Dumper($_, ($level + 1)) . ',' . chr(10)), @{$obj})) . $tab . ']'))
- }
- else {
- if (($ref eq 'HASH')) {
- return (('{' . chr(10) . join('', map(($tab1 . (chr(39) . $_ . chr(39) . ' => ') . Dumper($obj->{$_}, ($level + 1)) . ',' . chr(10)), sort(keys(%{$obj})))) . $tab . '}'))
- }
- else {
- if ($ref) {
- return (('bless({' . chr(10) . join('', map(($tab1 . (chr(39) . $_ . chr(39) . ' => ') . Dumper($obj->{$_}, ($level + 1)) . ',' . chr(10)), sort(keys(%{$obj})))) . $tab . ('}, ' . chr(39) . $ref . chr(39) . ')')))
- }
- }
- };
- return ((chr(39) . $obj . chr(39)))
-};
-1;
-
-1;
Oops, something went wrong.

0 comments on commit b4f4a35

Please sign in to comment.