Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Perlito6 - rename namespace from Perlito to Perlito6

  • Loading branch information...
commit 1cb9dfa121553a917faa0227a8be7043537494d4 1 parent e4641d7
@fglock authored
Showing with 520 additions and 520 deletions.
  1. +3 −3 README-perlito6
  2. +40 −40 perlito6.pl
  3. +1 −1  src6/lib/{Perlito → Perlito6}/AST.pm
  4. +8 −8 src6/lib/{Perlito → Perlito6}/Clojure/Emitter.pm
  5. +3 −3 src6/lib/{Perlito → Perlito6}/Emitter/Token.pm
  6. +1 −1  src6/lib/{Perlito → Perlito6}/Eval.pm
  7. +78 −78 src6/lib/{Perlito → Perlito6}/Expression.pm
  8. +16 −16 src6/lib/{Perlito → Perlito6}/Go/Emitter.pm
  9. +3 −3 src6/lib/{Perlito → Perlito6}/Go/Prelude.pm
  10. 0  src6/lib/{Perlito → Perlito6}/Go/Runtime.go
  11. +25 −25 src6/lib/{Perlito → Perlito6}/Grammar.pm
  12. +2 −2 src6/lib/{Perlito → Perlito6}/Grammar/Control.pm
  13. +26 −26 src6/lib/{Perlito → Perlito6}/Grammar/Regex.pm
  14. +16 −16 src6/lib/{Perlito → Perlito6}/Java/Emitter.pm
  15. 0  src6/lib/{Perlito → Perlito6}/Java/Runtime.java
  16. +16 −16 src6/lib/{Perlito → Perlito6}/Javascript/Emitter.pm
  17. +2 −2 src6/lib/{Perlito → Perlito6}/Javascript/Prelude.pm
  18. +21 −21 src6/lib/{Perlito → Perlito6}/Javascript/Runtime.js
  19. +10 −10 src6/lib/{Perlito → Perlito6}/Lisp/Emitter.pm
  20. +2 −2 src6/lib/{Perlito → Perlito6}/Lisp/Prelude.pm
  21. 0  src6/lib/{Perlito → Perlito6}/Lisp/Runtime.lisp
  22. +1 −1  src6/lib/{Perlito → Perlito6}/Macro.pm
  23. +1 −1  src6/lib/{Perlito → Perlito6}/Parrot/Emitter.pm
  24. +2 −2 src6/lib/{Perlito → Perlito6}/Parrot/Match.pm
  25. +5 −5 src6/lib/{Perlito → Perlito6}/Perl5/Emitter.pm
  26. +2 −2 src6/lib/{Perlito → Perlito6}/Perl5/Prelude.pm
  27. +7 −7 src6/lib/{Perlito → Perlito6}/Perl5/Runtime.pm
  28. +6 −6 src6/lib/{Perlito → Perlito6}/Precedence.pm
  29. +31 −31 src6/lib/{Perlito → Perlito6}/Python/Emitter.pm
  30. +1 −1  src6/lib/{Perlito → Perlito6}/Python/Prelude.pm
  31. +19 −19 src6/lib/{Perlito → Perlito6}/Python/Runtime.py
  32. +1 −1  src6/lib/{Perlito → Perlito6}/Rakudo/Emitter.pm
  33. +19 −19 src6/lib/{Perlito → Perlito6}/Ruby/Emitter.pm
  34. +2 −2 src6/lib/{Perlito → Perlito6}/Ruby/Prelude.pm
  35. +13 −13 src6/lib/{Perlito → Perlito6}/Ruby/Runtime.rb
  36. 0  src6/lib/{Perlito → Perlito6}/Runtime.pm
  37. +19 −19 src6/lib/{Perlito → Perlito6}/Test.pm
  38. +12 −12 src6/util/perlito6-browser.pl
  39. +34 −34 src6/util/perlito6.pl
  40. +0 −8 t/21-test.t
  41. 0  {t → t6}/01-sanity.t
  42. 0  {t → t6}/02-int.t
  43. 0  {t → t6}/03-num.t
  44. 0  {t → t6}/04-op.t
  45. 0  {t → t6}/04-string.t
  46. 0  {t → t6}/05-anon-sub-lex-block.t
  47. 0  {t → t6}/05-anon-sub.t
  48. 0  {t → t6}/05-array.t
  49. 0  {t → t6}/05-bind.t
  50. 0  {t → t6}/05-for.t
  51. 0  {t → t6}/05-hash.t
  52. 0  {t → t6}/05-if.t
  53. 0  {t → t6}/05-lex-block-if.t
  54. 0  {t → t6}/05-lex-block.t
  55. 0  {t → t6}/05-while.t
  56. 0  {t → t6}/06-bool.t
  57. 0  {t → t6}/09-namespace.t
  58. 0  {t → t6}/10-bind-sub-param.t
  59. 0  {t → t6}/11-accessor.t
  60. 0  {t → t6}/11-bind-method-param.t
  61. 0  {t → t6}/11-class-open.t
  62. 0  {t → t6}/11-class.t
  63. 0  {t → t6}/11-hyper.t
  64. +3 −3 {t → t6}/12-match-more.t
  65. +1 −1  {t → t6}/12-match.t
  66. 0  {t → t6}/14-grammar-subrule.t
  67. 0  {t → t6}/14-grammar.t
  68. 0  {t → t6}/16-var-redeclare.t
  69. 0  {t → t6}/17-hash-autovivify.t
  70. 0  {t → t6}/18-array-autovivify.t
  71. +8 −0 t6/21-test.t
  72. +2 −2 {t → t6}/22-unicode.t
  73. +58 −58 util-perl5/bootstrap-perlito6-perl5.sh
View
6 README-perlito6
@@ -91,15 +91,15 @@ RUNNING TESTS
Perl 5:
- find t/*.t | perl -ne ' print "*** $_"; chomp; print ` perl perlito6.pl -Cperl5 $_ | perl ` '
+ find t6/*.t | perl -ne ' print "*** $_"; chomp; print ` perl perlito6.pl -Cperl5 $_ | perl ` '
Javascript:
- find t/*.t | perl -ne ' print "*** $_"; chomp; print ` d8 perlito6.js -- -Cjs $_ > tmp.js && d8 tmp.js ` '
+ find t6/*.t | perl -ne ' print "*** $_"; chomp; print ` d8 perlito6.js -- -Cjs $_ > tmp.js && d8 tmp.js ` '
Python 2.6:
- find t/*.t | perl -ne ' print "*** $_"; chomp; print ` python perlito6.py -Cpython $_ | python ` '
+ find t6/*.t | perl -ne ' print "*** $_"; chomp; print ` python perlito6.py -Cpython $_ | python ` '
AUTHORS
View
80 perlito6.pl
@@ -1,12 +1,12 @@
-# Do not edit this file - Generated by Perlito 8.0
+# Do not edit this file - Generated by Perlito6 8.0
use v5;
use utf8;
use strict;
use warnings;
no warnings ('redefine', 'once', 'void', 'uninitialized', 'misc', 'recursion');
-use Perlito::Perl5::Runtime;
-use Perlito::Perl5::Prelude;
-our $MATCH = Perlito::Match->new();
+use Perlito6::Perl5::Runtime;
+use Perlito6::Perl5::Prelude;
+our $MATCH = Perlito6::Match->new();
{
package GLOBAL;
sub new { shift; bless { @_ }, "GLOBAL" }
@@ -16,23 +16,23 @@ package GLOBAL;
{
package Main;
sub new { shift; bless { @_ }, "Main" }
- use Perlito::Emitter::Token;
- use Perlito::Expression;
- use Perlito::Go::Emitter;
- use Perlito::Grammar::Control;
- use Perlito::Grammar::Regex;
- use Perlito::Grammar;
- use Perlito::Java::Emitter;
- use Perlito::Javascript::Emitter;
- use Perlito::Lisp::Emitter;
- use Perlito::Macro;
- use Perlito::Parrot::Emitter;
- use Perlito::Perl5::Emitter;
- use Perlito::Precedence;
- use Perlito::Python::Emitter;
- use Perlito::Ruby::Emitter;
- use Perlito::Runtime;
- ((my $_V6_COMPILER_NAME) = 'Perlito');
+ use Perlito6::Emitter::Token;
+ use Perlito6::Expression;
+ use Perlito6::Go::Emitter;
+ use Perlito6::Grammar::Control;
+ use Perlito6::Grammar::Regex;
+ use Perlito6::Grammar;
+ use Perlito6::Java::Emitter;
+ use Perlito6::Javascript::Emitter;
+ use Perlito6::Lisp::Emitter;
+ use Perlito6::Macro;
+ use Perlito6::Parrot::Emitter;
+ use Perlito6::Perl5::Emitter;
+ use Perlito6::Precedence;
+ use Perlito6::Python::Emitter;
+ use Perlito6::Ruby::Emitter;
+ use Perlito6::Runtime;
+ ((my $_V6_COMPILER_NAME) = 'Perlito6');
((my $_V6_COMPILER_VERSION) = '8.0');
((my $source) = '');
((my $backend) = '');
@@ -46,7 +46,7 @@ package GLOBAL;
((my $perl6lib) = '.' . chr(47) . 'src6' . chr(47) . 'lib');
((my $expand_use) = 1);
if ($verbose) {
- warn((chr(47) . chr(47) . ' Perlito compiler'));
+ warn((chr(47) . chr(47) . ' Perlito Perl6 compiler'));
warn((chr(47) . chr(47) . ' ARGS: '), Main::perl((\@ARGV), ))
};
(my $Hash_module_seen = bless {}, 'HASH');
@@ -55,15 +55,15 @@ package GLOBAL;
my $str = $_[1];
my $pos = $_[2];
(my $MATCH);
- ($MATCH = Perlito::Match->new(('str' => $str), ('from' => $pos), ('to' => $pos), ('bool' => 1)));
+ ($MATCH = Perlito6::Match->new(('str' => $str), ('from' => $pos), ('to' => $pos), ('bool' => 1)));
(($MATCH)->{bool} = ((do {
((my $pos1) = $MATCH->to());
(do {
((do {
- ((my $m2) = Perlito::Grammar->ident($str, $MATCH->to()));
+ ((my $m2) = Perlito6::Grammar->ident($str, $MATCH->to()));
if ($m2) {
(($MATCH)->{to} = $m2->to());
- ($MATCH->{'Perlito::Grammar.ident'} = $m2);
+ ($MATCH->{'Perlito6::Grammar.ident'} = $m2);
1
}
else {
@@ -86,7 +86,7 @@ package GLOBAL;
($MATCH->{capture} = (do {
(my $List_a = bless [], 'ARRAY');
(my $List_v = bless [], 'ARRAY');
- push( @{$List_a}, "".($MATCH->{'Perlito::Grammar.ident'}) );
+ push( @{$List_a}, "".($MATCH->{'Perlito6::Grammar.ident'}) );
($List_v = ((${$MATCH->{'module_name'}})));
for my $x ( @{(bless [0 .. ((scalar( @{$List_v} ) - 1))], 'ARRAY')} ) {
push( @{$List_a}, $List_v->[$x] )
@@ -100,7 +100,7 @@ package GLOBAL;
($MATCH->{capture} = (do {
(my $List_a = bless [], 'ARRAY');
(my $List_v = bless [], 'ARRAY');
- push( @{$List_a}, "".($MATCH->{'Perlito::Grammar.ident'}) );
+ push( @{$List_a}, "".($MATCH->{'Perlito6::Grammar.ident'}) );
$List_a
}))
}) || 1))))
@@ -133,7 +133,7 @@ package GLOBAL;
warn((chr(47) . chr(47) . ' now loading: '), $filename)
};
((my $source) = IO::slurp($filename));
- ((my $m) = Perlito::Grammar->exp_stmts($source, 0));
+ ((my $m) = Perlito6::Grammar->exp_stmts($source, 0));
add_comp_unit(${$m})
}
}
@@ -202,20 +202,20 @@ package GLOBAL;
if (($backend && (\@ARGV))) {
(my $prelude_filename);
if (($backend eq 'lisp')) {
- ($prelude_filename = ($perl6lib . chr(47) . 'Perlito' . chr(47) . 'Lisp' . chr(47) . 'Prelude.pm'))
+ ($prelude_filename = ($perl6lib . chr(47) . 'Perlito6' . chr(47) . 'Lisp' . chr(47) . 'Prelude.pm'))
};
if (($backend eq 'js')) {
- ($prelude_filename = ($perl6lib . chr(47) . 'Perlito' . chr(47) . 'Javascript' . chr(47) . 'Prelude.pm'))
+ ($prelude_filename = ($perl6lib . chr(47) . 'Perlito6' . chr(47) . 'Javascript' . chr(47) . 'Prelude.pm'))
};
if (($backend eq 'go')) {
- ($prelude_filename = ($perl6lib . chr(47) . 'Perlito' . chr(47) . 'Go' . chr(47) . 'Prelude.pm'))
+ ($prelude_filename = ($perl6lib . chr(47) . 'Perlito6' . chr(47) . 'Go' . chr(47) . 'Prelude.pm'))
};
if ($prelude_filename) {
if ($verbose) {
warn((chr(47) . chr(47) . ' loading lib: '), $prelude_filename)
};
($source = IO::slurp($prelude_filename));
- ((my $m) = Perlito::Grammar->exp_stmts($source, 0));
+ ((my $m) = Perlito6::Grammar->exp_stmts($source, 0));
add_comp_unit(${$m})
};
if (((\@ARGV)->[0] eq '-e')) {
@@ -235,7 +235,7 @@ package GLOBAL;
warn((chr(47) . chr(47) . ' backend: '), $backend);
warn(('now parsing'))
};
- ((my $m) = Perlito::Grammar->exp_stmts($source, 0));
+ ((my $m) = Perlito6::Grammar->exp_stmts($source, 0));
add_comp_unit(${$m});
($comp_units = do {
(my $List_a = bless [], 'ARRAY');
@@ -249,7 +249,7 @@ package GLOBAL;
};
if (($backend eq 'go')) {
Main::say((chr(47) . chr(47) . ' Do not edit this file - Generated by '), $_V6_COMPILER_NAME, (' '), $_V6_COMPILER_VERSION);
- ((my $filename) = ($perl6lib . chr(47) . 'Perlito' . chr(47) . 'Go' . chr(47) . 'Runtime.go'));
+ ((my $filename) = ($perl6lib . chr(47) . 'Perlito6' . chr(47) . 'Go' . chr(47) . 'Runtime.go'));
if (($verbose)) {
warn((chr(47) . chr(47) . ' now loading: '), $filename)
};
@@ -259,7 +259,7 @@ package GLOBAL;
};
if (($backend eq 'lisp')) {
Main::say((chr(59) . chr(59) . ' Do not edit this file - Generated by '), $_V6_COMPILER_NAME, (' '), $_V6_COMPILER_VERSION);
- ((my $filename) = ($perl6lib . chr(47) . 'Perlito' . chr(47) . 'Lisp' . chr(47) . 'Runtime.lisp'));
+ ((my $filename) = ($perl6lib . chr(47) . 'Perlito6' . chr(47) . 'Lisp' . chr(47) . 'Runtime.lisp'));
if (($verbose)) {
warn((chr(47) . chr(47) . ' now loading: '), $filename)
};
@@ -276,7 +276,7 @@ package GLOBAL;
};
if (($backend eq 'js')) {
Main::say((chr(47) . chr(47) . ' Do not edit this file - Generated by '), $_V6_COMPILER_NAME, (' '), $_V6_COMPILER_VERSION);
- ((my $filename) = ($perl6lib . chr(47) . 'Perlito' . chr(47) . 'Javascript' . chr(47) . 'Runtime.js'));
+ ((my $filename) = ($perl6lib . chr(47) . 'Perlito6' . chr(47) . 'Javascript' . chr(47) . 'Runtime.js'));
if (($verbose)) {
warn((chr(47) . chr(47) . ' now loading: '), $filename)
};
@@ -288,8 +288,8 @@ package GLOBAL;
Main::say((chr(35) . ' Do not edit this file - Generated by '), $_V6_COMPILER_NAME, (' '), $_V6_COMPILER_VERSION);
Main::say((chr(35) . '-*- coding: utf-8 -*-'));
Main::say('');
- Main::say(('from Perlito__Python__Runtime import *'));
- Main::say(('from Perlito__Python__Prelude import *'));
+ Main::say(('from Perlito6__Python__Runtime import *'));
+ Main::say(('from Perlito6__Python__Prelude import *'));
Main::say(('import __builtin__'));
Main::say(('__all__ ' . chr(61) . ' []'));
Main::say('');
@@ -300,8 +300,8 @@ package GLOBAL;
if (($backend eq 'ruby')) {
Main::say((chr(35) . ' Do not edit this file - Generated by '), $_V6_COMPILER_NAME, (' '), $_V6_COMPILER_VERSION);
Main::say('');
- Main::say(('require ' . chr(39) . 'Perlito' . chr(47) . 'Ruby' . chr(47) . 'Runtime.rb' . chr(39)));
- Main::say(('require ' . chr(39) . 'Perlito__Ruby__Prelude.rb' . chr(39)));
+ Main::say(('require ' . chr(39) . 'Perlito6' . chr(47) . 'Ruby' . chr(47) . 'Runtime.rb' . chr(39)));
+ Main::say(('require ' . chr(39) . 'Perlito6__Ruby__Prelude.rb' . chr(39)));
Main::say('');
for my $c ( @{(($comp_units))} ) {
Main::say($c->emit_ruby())
View
2  src6/lib/Perlito/AST.pm → src6/lib/Perlito6/AST.pm
@@ -122,7 +122,7 @@ class Use {
=head1 NAME
-Perlito::AST - Base class for Perlito AST nodes
+Perlito6::AST - Base class for Perlito AST nodes
=head1 SYNOPSIS
View
16 src6/lib/Perlito/Clojure/Emitter.pm → src6/lib/Perlito6/Clojure/Emitter.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Clojure::LexicalBlock {
+class Perlito6::Clojure::LexicalBlock {
has @.block;
method emit_clojure {
if !(@.block) {
@@ -129,7 +129,7 @@ new-slots))
$str_specific = $str_specific ~ ' &optional' ~ $str_optionals;
# $str_generic = $str_generic ~ ' &optional' ~ $str_optionals;
}
- my $block = Perlito::Clojure::LexicalBlock.new( block => $decl.block );
+ my $block = Perlito6::Clojure::LexicalBlock.new( block => $decl.block );
$str = $str ~
';; method ' ~ $decl.name() ~ '
(if (not (ignore-errors (find-method \'' ~ Main::to_lisp_identifier($decl.name) ~ ' () ())))
@@ -384,8 +384,8 @@ class Return {
class If {
method emit_clojure {
- my $block1 = Perlito::Clojure::LexicalBlock.new( block => @.body );
- my $block2 = Perlito::Clojure::LexicalBlock.new( block => @.otherwise );
+ my $block1 = Perlito6::Clojure::LexicalBlock.new( block => @.body );
+ my $block2 = Perlito6::Clojure::LexicalBlock.new( block => @.otherwise );
'(if (sv-bool ' ~ $.cond.emit_clojure() ~ ') ' ~ $block1.emit_clojure() ~ ' ' ~ $block2.emit_clojure() ~ ')';
}
}
@@ -393,7 +393,7 @@ class If {
class For {
method emit_clojure {
my $cond = $.cond;
- my $block = Perlito::Clojure::LexicalBlock.new( block => @.body );
+ my $block = Perlito6::Clojure::LexicalBlock.new( block => @.body );
if $cond.isa( 'Var' )
&& $cond.sigil eq '@'
{
@@ -427,7 +427,7 @@ class Sub {
method emit_clojure {
my $sig = $.sig;
my $pos = $sig.positional;
- my $block = Perlito::Clojure::LexicalBlock.new( block => @.block );
+ my $block = Perlito6::Clojure::LexicalBlock.new( block => @.block );
my $str;
if @$pos {
for @$pos -> $field {
@@ -455,7 +455,7 @@ class Sub {
class Do {
method emit_clojure {
- my $block = Perlito::Clojure::LexicalBlock.new( block => @.block );
+ my $block = Perlito6::Clojure::LexicalBlock.new( block => @.block );
return $block.emit_clojure;
}
}
@@ -471,7 +471,7 @@ class Use {
=head1 NAME
-Perlito::Clojure::Emit - Code generator for Perlito-in-Clojure
+Perlito6::Clojure::Emit - Code generator for Perlito-in-Clojure
=head1 SYNOPSIS
View
6 src6/lib/Perlito/Emitter/Token.pm → src6/lib/Perlito6/Emitter/Token.pm
@@ -259,7 +259,7 @@ class Rul::Before {
method emit_perl6 {
'(do { ' ~
'my $tmp = $MATCH; ' ~
- '$MATCH = Perlito::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
+ '$MATCH = Perlito6::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
'$MATCH.bool = ' ~
$.rule_exp.emit_perl6() ~
'; ' ~
@@ -276,7 +276,7 @@ class Rul::NotBefore {
method emit_perl6 {
'(do { ' ~
'my $tmp = $MATCH; ' ~
- '$MATCH = Perlito::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
+ '$MATCH = Perlito6::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
'$MATCH.bool = ' ~
$.rule_exp.emit_perl6() ~
'; ' ~
@@ -332,7 +332,7 @@ class Rul::After {
=head1 NAME
-Perlito::Emitter::Token - Code generator for Perlito Regex
+Perlito6::Emitter::Token - Code generator for Perlito Regex
=head1 SYNOPSIS
View
2  src6/lib/Perlito/Eval.pm → src6/lib/Perlito6/Eval.pm
@@ -263,7 +263,7 @@ class Use {
=head1 NAME
-Perlito::Eval - AST interpreter for Perlito
+Perlito6::Eval - AST interpreter for Perlito
=head1 SYNOPSIS
View
156 src6/lib/Perlito/Expression.pm → src6/lib/Perlito6/Expression.pm
@@ -1,8 +1,8 @@
-class Perlito::Expression {
- use Perlito::Precedence;
- use Perlito::Grammar;
- use Perlito::Perl5::Emitter;
+class Perlito6::Expression {
+ use Perlito6::Precedence;
+ use Perlito6::Grammar;
+ use Perlito6::Perl5::Emitter;
sub expand_list ($param_list) {
# say "# expand_list: ", $param_list.perl;
@@ -248,7 +248,7 @@ class Perlito::Expression {
elsif $last_op[0] eq 'postfix_or_term' {
$num_stack.push( reduce_postfix( $last_op, pop_term($num_stack) ) );
}
- elsif Perlito::Precedence::is_assoc_type('list', $last_op[1]) {
+ elsif Perlito6::Precedence::is_assoc_type('list', $last_op[1]) {
my $arg;
if $num_stack.elems < 2 {
my $v2 = pop_term($num_stack);
@@ -289,7 +289,7 @@ class Perlito::Expression {
arguments => $arg,
);
}
- elsif Perlito::Precedence::is_assoc_type('chain', $last_op[1]) {
+ elsif Perlito6::Precedence::is_assoc_type('chain', $last_op[1]) {
if $num_stack.elems < 2 {
die("Missing value after operator " ~ $last_op[1]);
}
@@ -299,7 +299,7 @@ class Perlito::Expression {
# TODO - create a special AST node for assoc chain?
# if ($arg[0]).isa('Apply')
- # && Perlito::Precedence::is_assoc_type('chain', ($arg[1]){op} )
+ # && Perlito6::Precedence::is_assoc_type('chain', ($arg[1]){op} )
# {
# push $num_stack,
# Apply.new(
@@ -352,7 +352,7 @@ class Perlito::Expression {
# Var.new( sigil => ~$$<var_sigil>, twigil => '', name => $$<ident> ) ]
token capture_name {
- <Perlito::Grammar.full_ident> [ \. <Perlito::Grammar.ident> ]?
+ <Perlito6::Grammar.full_ident> [ \. <Perlito6::Grammar.ident> ]?
}
token hyper_op {
@@ -365,9 +365,9 @@ class Perlito::Expression {
| '.{' <curly_parse> '}' { make [ 'postfix_or_term', 'block', $$<curly_parse> ] }
| '(' <paren_parse> ')' { make [ 'postfix_or_term', '( )', $$<paren_parse> ] }
| '[' <square_parse> ']' { make [ 'postfix_or_term', '[ ]', $$<square_parse> ] }
- | [ '.<' | '<' ] <Perlito::Grammar.ident> '>' { make [ 'postfix_or_term', 'block', [Val::Buf.new('buf' => $$<Perlito::Grammar.ident>)] ] }
+ | [ '.<' | '<' ] <Perlito6::Grammar.ident> '>' { make [ 'postfix_or_term', 'block', [Val::Buf.new('buf' => $$<Perlito6::Grammar.ident>)] ] }
- | '->' <.Perlito::Grammar.ws>? <list_parse>
+ | '->' <.Perlito6::Grammar.ws>? <list_parse>
{
my $block = ($$<list_parse>)<end_block>;
if $block.sig() {
@@ -375,45 +375,45 @@ class Perlito::Expression {
}
make [ 'postfix_or_term', 'block', $block.stmts, ($$<list_parse>)<exp> ]
}
- | '{' <.Perlito::Grammar.ws>?
- <Perlito::Grammar.exp_stmts> <.Perlito::Grammar.ws>? '}'
- { make [ 'postfix_or_term', 'block', $$<Perlito::Grammar.exp_stmts> ] }
- | 'method' <.Perlito::Grammar.ws> <Perlito::Grammar.method_def>
- { make [ 'term', $$<Perlito::Grammar.method_def> ] }
- | 'sub' <.Perlito::Grammar.ws> <Perlito::Grammar.sub_def>
- { make [ 'term', $$<Perlito::Grammar.sub_def> ] }
- | 'token' <.Perlito::Grammar.ws> <Perlito::Grammar.token>
- { make [ 'term', $$<Perlito::Grammar.token> ] }
- | 'do' <.Perlito::Grammar.ws> <statement_parse>
+ | '{' <.Perlito6::Grammar.ws>?
+ <Perlito6::Grammar.exp_stmts> <.Perlito6::Grammar.ws>? '}'
+ { make [ 'postfix_or_term', 'block', $$<Perlito6::Grammar.exp_stmts> ] }
+ | 'method' <.Perlito6::Grammar.ws> <Perlito6::Grammar.method_def>
+ { make [ 'term', $$<Perlito6::Grammar.method_def> ] }
+ | 'sub' <.Perlito6::Grammar.ws> <Perlito6::Grammar.sub_def>
+ { make [ 'term', $$<Perlito6::Grammar.sub_def> ] }
+ | 'token' <.Perlito6::Grammar.ws> <Perlito6::Grammar.token>
+ { make [ 'term', $$<Perlito6::Grammar.token> ] }
+ | 'do' <.Perlito6::Grammar.ws> <statement_parse>
{ make [ 'term', Do.new( block => $$<statement_parse> ) ] }
| '??' <ternary_parse> '!!' { make [ 'op', '?? !!', $$<ternary_parse> ] }
- | <Perlito::Grammar.var_ident> { make [ 'term', $$<Perlito::Grammar.var_ident> ] }
+ | <Perlito6::Grammar.var_ident> { make [ 'term', $$<Perlito6::Grammar.var_ident> ] }
| '$<' <capture_name> '>'
{ make [ 'term', Lookup.new(
obj => Var.new( sigil => '$', twigil => '', name => '/' ),
index_exp => Val::Buf.new( buf => ~$<capture_name> )
) ] }
- | <Perlito::Precedence.op_parse> { make $$<Perlito::Precedence.op_parse> }
- | <Perlito::Grammar.ident> <before <.Perlito::Grammar.ws>? '=>' > # autoquote
- { make [ 'term', Val::Buf.new( buf => ~$<Perlito::Grammar.ident> ) ] }
- | 'True' <!before [ <.Perlito::Grammar.word> | '(' ] > { make [ 'term', Val::Bit.new( bit => 1 ) ] }
- | 'False' <!before [ <.Perlito::Grammar.word> | '(' ] > { make [ 'term', Val::Bit.new( bit => 0 ) ] }
- | 'and' <!before [ <.Perlito::Grammar.word> | '(' ] > { make [ 'op', 'and' ] }
- | 'not' <!before [ <.Perlito::Grammar.word> | '(' ] > { make [ 'op', 'not' ] }
- | 'use' <.Perlito::Grammar.ws> <Perlito::Grammar.full_ident> [ - <Perlito::Grammar.ident> ]? <list_parse>
- { make [ 'term', Use.new( mod => $$<Perlito::Grammar.full_ident> ) ] }
- | [ 'package' | 'class' | 'grammar' | 'role' ] <.Perlito::Grammar.ws> <Perlito::Grammar.grammar>
- { make [ 'term', $$<Perlito::Grammar.grammar> ] }
- | <Perlito::Grammar.declarator> <.Perlito::Grammar.ws> <Perlito::Grammar.opt_type> <.Perlito::Grammar.opt_ws> <Perlito::Grammar.var_ident> # my Int $variable
- { make [ 'term', Decl.new( decl => $$<Perlito::Grammar.declarator>, type => $$<Perlito::Grammar.opt_type>, var => $$<Perlito::Grammar.var_ident> ) ] }
- | '.' <hyper_op> <Perlito::Grammar.ident>
- [ ':' <.Perlito::Grammar.ws>? <list_parse>
- { make [ 'postfix_or_term', 'methcall', ~$<Perlito::Grammar.ident>, $$<list_parse>, $$<hyper_op> ] }
+ | <Perlito6::Precedence.op_parse> { make $$<Perlito6::Precedence.op_parse> }
+ | <Perlito6::Grammar.ident> <before <.Perlito6::Grammar.ws>? '=>' > # autoquote
+ { make [ 'term', Val::Buf.new( buf => ~$<Perlito6::Grammar.ident> ) ] }
+ | 'True' <!before [ <.Perlito6::Grammar.word> | '(' ] > { make [ 'term', Val::Bit.new( bit => 1 ) ] }
+ | 'False' <!before [ <.Perlito6::Grammar.word> | '(' ] > { make [ 'term', Val::Bit.new( bit => 0 ) ] }
+ | 'and' <!before [ <.Perlito6::Grammar.word> | '(' ] > { make [ 'op', 'and' ] }
+ | 'not' <!before [ <.Perlito6::Grammar.word> | '(' ] > { make [ 'op', 'not' ] }
+ | 'use' <.Perlito6::Grammar.ws> <Perlito6::Grammar.full_ident> [ - <Perlito6::Grammar.ident> ]? <list_parse>
+ { make [ 'term', Use.new( mod => $$<Perlito6::Grammar.full_ident> ) ] }
+ | [ 'package' | 'class' | 'grammar' | 'role' ] <.Perlito6::Grammar.ws> <Perlito6::Grammar.grammar>
+ { make [ 'term', $$<Perlito6::Grammar.grammar> ] }
+ | <Perlito6::Grammar.declarator> <.Perlito6::Grammar.ws> <Perlito6::Grammar.opt_type> <.Perlito6::Grammar.opt_ws> <Perlito6::Grammar.var_ident> # my Int $variable
+ { make [ 'term', Decl.new( decl => $$<Perlito6::Grammar.declarator>, type => $$<Perlito6::Grammar.opt_type>, var => $$<Perlito6::Grammar.var_ident> ) ] }
+ | '.' <hyper_op> <Perlito6::Grammar.ident>
+ [ ':' <.Perlito6::Grammar.ws>? <list_parse>
+ { make [ 'postfix_or_term', 'methcall', ~$<Perlito6::Grammar.ident>, $$<list_parse>, $$<hyper_op> ] }
| '(' <paren_parse> ')'
{ make [ 'postfix_or_term',
'methcall',
- ~$<Perlito::Grammar.ident>,
+ ~$<Perlito6::Grammar.ident>,
{ end_block => Mu,
exp => $$<paren_parse>,
terminated => 0,
@@ -421,39 +421,39 @@ class Perlito::Expression {
$$<hyper_op>
]
}
- | { make [ 'postfix_or_term', 'methcall_no_params', ~$<Perlito::Grammar.ident>, $$<hyper_op> ] }
+ | { make [ 'postfix_or_term', 'methcall_no_params', ~$<Perlito6::Grammar.ident>, $$<hyper_op> ] }
]
- | <Perlito::Grammar.optional_namespace_before_ident> <Perlito::Grammar.ident>
- [ <.Perlito::Grammar.ws> <list_parse>
+ | <Perlito6::Grammar.optional_namespace_before_ident> <Perlito6::Grammar.ident>
+ [ <.Perlito6::Grammar.ws> <list_parse>
{ make [ 'postfix_or_term', 'funcall',
- ~$<Perlito::Grammar.optional_namespace_before_ident>,
- ~$<Perlito::Grammar.ident>, $$<list_parse> ] }
+ ~$<Perlito6::Grammar.optional_namespace_before_ident>,
+ ~$<Perlito6::Grammar.ident>, $$<list_parse> ] }
| <before '.'>
- { my $namespace = ~$<Perlito::Grammar.optional_namespace_before_ident>;
- my $name = ~$<Perlito::Grammar.ident>;
+ { my $namespace = ~$<Perlito6::Grammar.optional_namespace_before_ident>;
+ my $name = ~$<Perlito6::Grammar.ident>;
if $namespace {
$name = $namespace ~ '::' ~ $name;
}
make [ 'term', Proto.new( name => $name ) ]
}
| { make [ 'postfix_or_term', 'funcall_no_params',
- ~$<Perlito::Grammar.optional_namespace_before_ident>,
- ~$<Perlito::Grammar.ident> ] }
+ ~$<Perlito6::Grammar.optional_namespace_before_ident>,
+ ~$<Perlito6::Grammar.ident> ] }
]
- | <Perlito::Grammar.val_num> { make [ 'term', $$<Perlito::Grammar.val_num> ] } # 123.456
- | <Perlito::Grammar.val_int> { make [ 'term', $$<Perlito::Grammar.val_int> ] } # 123
- | <Perlito::Grammar.val_buf> { make [ 'term', $$<Perlito::Grammar.val_buf> ] } # 'moose'
+ | <Perlito6::Grammar.val_num> { make [ 'term', $$<Perlito6::Grammar.val_num> ] } # 123.456
+ | <Perlito6::Grammar.val_int> { make [ 'term', $$<Perlito6::Grammar.val_int> ] } # 123
+ | <Perlito6::Grammar.val_buf> { make [ 'term', $$<Perlito6::Grammar.val_buf> ] } # 'moose'
- | <.Perlito::Grammar.ws> { make [ 'space', ' ' ] }
+ | <.Perlito6::Grammar.ws> { make [ 'space', ' ' ] }
}
token has_newline_after {
| '#'
- | <.Perlito::Grammar.is_newline>
- | <.Perlito::Grammar.space> <.has_newline_after>
+ | <.Perlito6::Grammar.is_newline>
+ | <.Perlito6::Grammar.space> <.has_newline_after>
}
token has_no_comma_or_colon_after {
- <.Perlito::Grammar.ws> <!before [ ',' | ':' ]> .
+ <.Perlito6::Grammar.ws> <!before [ ',' | ':' ]> .
}
method list_parse ($str, $pos) {
@@ -470,7 +470,7 @@ class Perlito::Expression {
$v = $lexer_stack.pop;
if $is_first_token
&& ($v[0] eq 'op')
- && !(Perlito::Precedence::is_fixity_type('prefix', $v[1]))
+ && !(Perlito6::Precedence::is_fixity_type('prefix', $v[1]))
{
# say "# finishing list - first token is: ", $v[1];
$v[0] = 'end';
@@ -485,7 +485,7 @@ class Perlito::Expression {
$v = $$m;
if $is_first_token
&& ($v[0] eq 'op')
- && !(Perlito::Precedence::is_fixity_type('prefix', $v[1]))
+ && !(Perlito6::Precedence::is_fixity_type('prefix', $v[1]))
{
# say "# finishing list - first token is: ", $v[1];
$v[0] = 'end';
@@ -517,12 +517,12 @@ class Perlito::Expression {
return $v;
};
- my $prec = Perlito::Precedence.new(get_token => $get_token, reduce => $reduce_to_ast,
+ my $prec = Perlito6::Precedence.new(get_token => $get_token, reduce => $reduce_to_ast,
end_token => [ 'and', 'or', '!!', ']', ')', '}', ';', 'if', 'else', 'elsif', 'unless', 'when', 'for', 'while', 'loop' ] );
my $res = $prec.precedence_parse;
# say "# list_lexer return: ", $res.perl;
if $res.elems == 0 {
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $last_pos, 'bool' => 1,
capture => {
exp => '*undef*',
@@ -542,7 +542,7 @@ class Perlito::Expression {
$block = Lit::Block.new( stmts => $block[2], sig => $block[3] );
# say "# list exp terminated with a block (2): ", $block.perl;
}
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $last_pos, 'bool' => 1,
capture => {
exp => $result,
@@ -566,7 +566,7 @@ class Perlito::Expression {
# say "# circumfix_lexer " ~ $v.perl;
return $v;
};
- my $prec = Perlito::Precedence.new(get_token => $get_token, reduce => $reduce_to_ast,
+ my $prec = Perlito6::Precedence.new(get_token => $get_token, reduce => $reduce_to_ast,
end_token => $delimiter );
my $res = $prec.precedence_parse;
$res = pop_term($res);
@@ -575,7 +575,7 @@ class Perlito::Expression {
# can't return undef in a capture (BUG in Match object?)
$res = '*undef*';
}
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $last_pos, 'bool' => 1, capture => $res);
}
@@ -631,13 +631,13 @@ class Perlito::Expression {
return $v;
};
- my $prec = Perlito::Precedence.new(get_token => $get_token, reduce => $reduce_to_ast,
+ my $prec = Perlito6::Precedence.new(get_token => $get_token, reduce => $reduce_to_ast,
end_token => [ ']', ')', '}', ';', 'if', 'else', 'elsif', 'unless', 'when', 'for', 'while', 'loop' ] );
my $res = $prec.precedence_parse;
# say "# exp terminated";
if $res.elems == 0 {
# say "# exp terminated with false";
- return Perlito::Match.new(bool => 0);
+ return Perlito6::Match.new(bool => 0);
}
# if the expression terminates in a block, the block was pushed to num_stack
my $block;
@@ -655,7 +655,7 @@ class Perlito::Expression {
# say "# exp terminated with a block (2): ", $block.perl;
}
# say "# exp_parse result: ", $result.perl;
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $last_pos, 'bool' => 1,
capture => {
exp => $result,
@@ -664,12 +664,12 @@ class Perlito::Expression {
}
token exp_stmt {
- | <Perlito::Grammar.if> { make $$<Perlito::Grammar.if> }
- | <Perlito::Grammar.unless> { make $$<Perlito::Grammar.unless> }
- | <Perlito::Grammar.when> { make $$<Perlito::Grammar.when> }
- | <Perlito::Grammar.for> { make $$<Perlito::Grammar.for> }
- | <Perlito::Grammar.while> { make $$<Perlito::Grammar.while> }
- | <Perlito::Grammar.loop> { make $$<Perlito::Grammar.loop> }
+ | <Perlito6::Grammar.if> { make $$<Perlito6::Grammar.if> }
+ | <Perlito6::Grammar.unless> { make $$<Perlito6::Grammar.unless> }
+ | <Perlito6::Grammar.when> { make $$<Perlito6::Grammar.when> }
+ | <Perlito6::Grammar.for> { make $$<Perlito6::Grammar.for> }
+ | <Perlito6::Grammar.while> { make $$<Perlito6::Grammar.while> }
+ | <Perlito6::Grammar.loop> { make $$<Perlito6::Grammar.loop> }
}
token statement_modifier {
@@ -677,9 +677,9 @@ class Perlito::Expression {
}
token delimited_statement {
- <.Perlito::Grammar.ws>?
- [ ';' <.Perlito::Grammar.ws>?
- | <statement_parse> ';'? <.Perlito::Grammar.ws>?
+ <.Perlito6::Grammar.ws>?
+ [ ';' <.Perlito6::Grammar.ws>?
+ | <statement_parse> ';'? <.Perlito6::Grammar.ws>?
{ make $$<statement_parse> }
]
}
@@ -736,7 +736,7 @@ class Perlito::Expression {
$modifier = ~$modifier;
if $modifier eq 'if' {
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $modifier_exp.to, 'bool' => 1,
capture => If.new(
cond => ($$modifier_exp)<exp>,
@@ -744,7 +744,7 @@ class Perlito::Expression {
otherwise => Lit::Block.new(stmts => [ ]) ) );
}
if $modifier eq 'unless' {
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $modifier_exp.to, 'bool' => 1,
capture => If.new(
cond => ($$modifier_exp)<exp>,
@@ -752,14 +752,14 @@ class Perlito::Expression {
otherwise => Lit::Block.new(stmts => [ ($$res)<exp> ]) ) );
}
if $modifier eq 'while' {
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $modifier_exp.to, 'bool' => 1,
capture => While.new(
cond => ($$modifier_exp)<exp>,
body => Lit::Block.new(stmts => [ ($$res)<exp> ] ) ) );
}
if $modifier eq 'for' {
- return Perlito::Match.new(
+ return Perlito6::Match.new(
'str' => $str, 'from' => $pos, 'to' => $modifier_exp.to, 'bool' => 1,
capture => For.new(
cond => ($$modifier_exp)<exp>,
@@ -774,7 +774,7 @@ class Perlito::Expression {
=head1 NAME
-Perlito::Expression - Parser and AST generator for Perlito
+Perlito6::Expression - Parser and AST generator for Perlito
=head1 SYNOPSIS
View
32 src6/lib/Perlito/Go/Emitter.pm → src6/lib/Perlito6/Go/Emitter.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Go::LexicalBlock {
+class Perlito6::Go::LexicalBlock {
has @.block;
has $.needs_return;
has $.top_level;
@@ -45,8 +45,8 @@ class Perlito::Go::LexicalBlock {
if $cond.isa( 'Var' ) && $cond.sigil eq '@' {
$cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
- $body = Perlito::Go::LexicalBlock.new( block => $body, needs_return => 1, top_level => $.top_level );
- $otherwise = Perlito::Go::LexicalBlock.new( block => $otherwise, needs_return => 1, top_level => $.top_level );
+ $body = Perlito6::Go::LexicalBlock.new( block => $body, needs_return => 1, top_level => $.top_level );
+ $otherwise = Perlito6::Go::LexicalBlock.new( block => $otherwise, needs_return => 1, top_level => $.top_level );
$str = $str
~ 'if tobool( ' ~ Call::emit_go_call( $cond, 'Bool' ) ~ ' ) { '
~ $body.emit_go ~ ' } else { '
@@ -225,7 +225,7 @@ class CompUnit {
}
if $decl.isa( 'Method' ) {
my $sig = $decl.sig;
- my $block = Perlito::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ my $block = Perlito6::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
$str = $str
~ ' // method ' ~ $decl.name ~ "\n"
~ ' Method_' ~ $class_name ~ '.f_' ~ $decl.name
@@ -243,7 +243,7 @@ class CompUnit {
}
if $decl.isa( 'Sub' ) {
my $sig = $decl.sig;
- my $block = Perlito::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ my $block = Perlito6::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
$str = $str
~ ' // sub ' ~ $decl.name ~ "\n"
~ ' Namespace_' ~ $class_name ~ '.f_' ~ $decl.name
@@ -313,7 +313,7 @@ class CompUnit {
for @($comp_units) -> $comp_unit {
$str = $str ~ $comp_unit.emit_go;
}
- if !(%unit_seen{"Perlito::Grammar"}) {
+ if !(%unit_seen{"Perlito6::Grammar"}) {
$str = $str ~ "type Perlito__Grammar struct\{}\n";
}
$str = $str ~ "// interfaces for all methods\n";
@@ -555,7 +555,7 @@ class Apply {
if $code eq 'go' {
return 'go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Go::LexicalBlock.new( block => (@.arguments[0]).block, needs_return => 0, top_level => 1 )).emit_go ~ "\n"
+ ~ ' ' ~ (Perlito6::Go::LexicalBlock.new( block => (@.arguments[0]).block, needs_return => 0, top_level => 1 )).emit_go ~ "\n"
~ ' }()'
}
@@ -764,14 +764,14 @@ class If {
$cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
my $s = 'if tobool( ' ~ Call::emit_go_call( $cond, 'Bool' ) ~ ' ) { '
- ~ (Perlito::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go
+ ~ (Perlito6::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go
~ ' }';
if !(@.otherwise) {
return $s;
}
return $s
~ ' else { '
- ~ (Perlito::Go::LexicalBlock.new( block => @.otherwise, needs_return => 0 )).emit_go
+ ~ (Perlito6::Go::LexicalBlock.new( block => @.otherwise, needs_return => 0 )).emit_go
~ ' }';
}
}
@@ -782,7 +782,7 @@ class For {
~ ' var i = (*(*a_).(array_er).f_array(Capture{})).(*Array); ' ~ "\n"
~ ' for pos := 0; pos <= i.n; pos++ { ' ~ "\n"
~ ' func (' ~ $.topic.emit_go ~ ' *Any) { ' ~ "\n"
- ~ ' ' ~ (Perlito::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go ~ "\n"
+ ~ ' ' ~ (Perlito6::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go ~ "\n"
~ ' }(i.v[pos]) ' ~ "\n"
~ ' } ' ~ "\n"
~ '}(' ~ $.cond.emit_go ~ ')'
@@ -806,7 +806,7 @@ class While {
~ 'tobool( ' ~ Call::emit_go_call( $cond, 'Bool' ) ~ ' ); '
~ ( $.continue ?? $.continue.emit_go ~ ' ' !! '' )
~ '{ '
- ~ (Perlito::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go
+ ~ (Perlito6::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go
~ ' }';
}
}
@@ -864,7 +864,7 @@ class Method {
'func ' ~ $.name ~ '(v Capture) *Any { '
~ ' ' ~ ($.sig).emit_go_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Go::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_go
+ ~ ' ' ~ (Perlito6::Go::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_go
~ '; p <- nil }(); ' ~ "\n"
~ ' return <-p; ' ~ "\n"
~ ' }'
@@ -878,7 +878,7 @@ class Sub {
'toFunction( func(v Capture) *Any { '
~ ' ' ~ ($.sig).emit_go_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Go::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_go
+ ~ ' ' ~ (Perlito6::Go::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_go
~ '; p <- nil }(); ' ~ "\n"
~ ' return <-p; ' ~ "\n"
~ '} '
@@ -888,7 +888,7 @@ class Sub {
'func ' ~ $.name ~ '(v Capture) *Any { '
~ ' ' ~ ($.sig).emit_go_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Go::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_go
+ ~ ' ' ~ (Perlito6::Go::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_go
~ '; p <- nil }(); ' ~ "\n"
~ ' return <-p; ' ~ "\n"
~ ' }'
@@ -898,7 +898,7 @@ class Sub {
class Do {
method emit_go {
'(func () *Any { '
- ~ (Perlito::Go::LexicalBlock.new( block => @.block, needs_return => 1 )).emit_go
+ ~ (Perlito6::Go::LexicalBlock.new( block => @.block, needs_return => 1 )).emit_go
~ '; return u_undef() '
~ '})()'
}
@@ -914,7 +914,7 @@ class Use {
=head1 NAME
-Perlito::Go::Emit - Code generator for Perlito-in-Go
+Perlito6::Go::Emit - Code generator for Perlito-in-Go
=head1 SYNOPSIS
View
6 src6/lib/Perlito/Go/Prelude.pm → src6/lib/Perlito6/Go/Prelude.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Match {
+class Perlito6::Match {
has $.from;
has $.to;
has $.str;
@@ -30,7 +30,7 @@ class Perlito::Match {
method exists { die "TODO" }
}
-class Perlito::Grammar {
+class Perlito6::Grammar {
# Note: These tokens are just stubs.
# The actual methods are implemented in Runtime.go
@@ -58,7 +58,7 @@ class Main {
=head1 NAME
-Perlito::Go::Prelude - Runtime for Perlito-in-Go
+Perlito6::Go::Prelude - Runtime for Perlito-in-Go
=head1 SYNOPSIS
View
0  src6/lib/Perlito/Go/Runtime.go → src6/lib/Perlito6/Go/Runtime.go
File renamed without changes
View
50 src6/lib/Perlito/Grammar.pm → src6/lib/Perlito6/Grammar.pm
@@ -1,10 +1,10 @@
use v6;
-grammar Perlito::Grammar {
+grammar Perlito6::Grammar {
-use Perlito::Expression;
-use Perlito::Grammar::Regex;
-use Perlito::Grammar::Control;
+use Perlito6::Expression;
+use Perlito6::Grammar::Regex;
+use Perlito6::Grammar::Control;
token is_newline {
| \c10 \c13?
@@ -76,13 +76,13 @@ token declarator {
token exp_stmts2 { <exp_stmts> { make $$<exp_stmts> } }
token exp {
- <Perlito::Expression.exp_parse>
- { make $$<Perlito::Expression.exp_parse> }
+ <Perlito6::Expression.exp_parse>
+ { make $$<Perlito6::Expression.exp_parse> }
}
token exp2 {
- <Perlito::Expression.exp_parse>
- { make $$<Perlito::Expression.exp_parse> }
+ <Perlito6::Expression.exp_parse>
+ { make $$<Perlito6::Expression.exp_parse> }
}
token opt_ident {
@@ -173,20 +173,20 @@ token double_quoted_unescape {
token double_quoted_buf {
| <before \$ >
- [ <before \$ <.var_twigil> <.ident> > <Perlito::Expression.operator>
- { make ($$<Perlito::Expression.operator>)[1] }
+ [ <before \$ <.var_twigil> <.ident> > <Perlito6::Expression.operator>
+ { make ($$<Perlito6::Expression.operator>)[1] }
| <char_any>
{ make Val::Buf.new( buf => ~$<char_any> ) }
]
| <before \@ >
- [ <before \@ <.var_twigil> <.ident> > <Perlito::Expression.operator> '[]'
- { make ($$<Perlito::Expression.operator>)[1] }
+ [ <before \@ <.var_twigil> <.ident> > <Perlito6::Expression.operator> '[]'
+ { make ($$<Perlito6::Expression.operator>)[1] }
| <char_any>
{ make Val::Buf.new( buf => ~$<char_any> ) }
]
| <before \% >
- [ <before \% <.var_twigil> <.ident> > <Perlito::Expression.operator> '{}'
- { make ($$<Perlito::Expression.operator>)[1] }
+ [ <before \% <.var_twigil> <.ident> > <Perlito6::Expression.operator> '{}'
+ { make ($$<Perlito6::Expression.operator>)[1] }
| <char_any>
{ make Val::Buf.new( buf => ~$<char_any> ) }
]
@@ -225,8 +225,8 @@ token val_int {
}
token exp_stmts {
- <Perlito::Expression.delimited_statement>*
- { make $<Perlito::Expression.delimited_statement>.>>capture }
+ <Perlito6::Expression.delimited_statement>*
+ { make $<Perlito6::Expression.delimited_statement>.>>capture }
}
token opt_name { <ident>? }
@@ -244,14 +244,14 @@ token var_invocant {
token args_sig {
<var_invocant>
<.opt_ws>
- # TODO - Perlito::Expression.list_parse / exp_mapping == positional / named
- <Perlito::Expression.list_parse>
+ # TODO - Perlito6::Expression.list_parse / exp_mapping == positional / named
+ <Perlito6::Expression.list_parse>
{
# say ' invocant: ', ($$<var_invocant>).perl;
# say ' positional: ', ($$<>).perl;
make Sig.new(
invocant => $$<var_invocant>,
- positional => Perlito::Expression::expand_list(($$<Perlito::Expression.list_parse>){'exp'}),
+ positional => Perlito6::Expression::expand_list(($$<Perlito6::Expression.list_parse>){'exp'}),
named => { } );
}
}
@@ -292,18 +292,18 @@ token sub_def {
token token {
<opt_name> <.opt_ws> \{
- <Perlito::Grammar::Regex.rule>
+ <Perlito6::Grammar::Regex.rule>
\}
{
- #say 'Token was compiled into: ', ($$<Perlito::Grammar::Regex.rule>).perl;
+ #say 'Token was compiled into: ', ($$<Perlito6::Grammar::Regex.rule>).perl;
my $source = $<opt_name> ~ ' ( $grammar: $str, $pos ) { ' ~
- 'my $MATCH; $MATCH = Perlito::Match.new( str => $str, from => $pos, to => $pos, bool => 1 ); ' ~
+ 'my $MATCH; $MATCH = Perlito6::Match.new( str => $str, from => $pos, to => $pos, bool => 1 ); ' ~
'$MATCH.bool = ( ' ~
- ($$<Perlito::Grammar::Regex.rule>).emit_perl6() ~
+ ($$<Perlito6::Grammar::Regex.rule>).emit_perl6() ~
'); ' ~
'$MATCH }';
#say 'Intermediate code: ', $source;
- my $ast = Perlito::Grammar.method_def( $source, 0 );
+ my $ast = Perlito6::Grammar.method_def( $source, 0 );
# say 'Intermediate ast: ', $$ast.perl;
make $$ast;
}
@@ -315,7 +315,7 @@ token token {
=head1 NAME
-Perlito::Grammar - Grammar for Perlito
+Perlito6::Grammar - Grammar for Perlito
=head1 SYNOPSIS
View
4 src6/lib/Perlito/Grammar/Control.pm → src6/lib/Perlito6/Grammar/Control.pm
@@ -1,7 +1,7 @@
use v6;
-grammar Perlito::Grammar {
+grammar Perlito6::Grammar {
token unless {
unless <.ws> <exp>
@@ -132,7 +132,7 @@ token loop {
=head1 NAME
-Perlito::Grammar - Grammar for Perlito
+Perlito6::Grammar - Grammar for Perlito
=head1 SYNOPSIS
View
52 src6/lib/Perlito/Grammar/Regex.pm → src6/lib/Perlito6/Grammar/Regex.pm
@@ -1,13 +1,13 @@
use v6;
-grammar Perlito::Grammar::Regex {
+grammar Perlito6::Grammar::Regex {
my %rule_terms;
-token ws { <.Perlito::Grammar.ws> }
+token ws { <.Perlito6::Grammar.ws> }
-token rule_ident { <.Perlito::Grammar.full_ident> | <digit> }
+token rule_ident { <.Perlito6::Grammar.full_ident> | <digit> }
token any { . }
@@ -73,18 +73,18 @@ token variables {
{ make '$/{' ~ '\'' ~ $<rule_ident> ~ '\'' ~ '}' }
|
# TODO
- <Perlito::Grammar.var_sigil>
- <Perlito::Grammar.val_int>
- { make $<Perlito::Grammar.var_sigil> ~ '/[' ~ $<Perlito::Grammar.val_int> ~ ']' }
+ <Perlito6::Grammar.var_sigil>
+ <Perlito6::Grammar.val_int>
+ { make $<Perlito6::Grammar.var_sigil> ~ '/[' ~ $<Perlito6::Grammar.val_int> ~ ']' }
|
- <Perlito::Grammar.var_sigil>
- <Perlito::Grammar.var_twigil>
- <Perlito::Grammar.full_ident>
+ <Perlito6::Grammar.var_sigil>
+ <Perlito6::Grammar.var_twigil>
+ <Perlito6::Grammar.full_ident>
{
make Rul::Var.new(
- sigil => ~$<Perlito::Grammar.var_sigil>,
- twigil => ~$<Perlito::Grammar.var_twigil>,
- name => ~$<Perlito::Grammar.full_ident>
+ sigil => ~$<Perlito6::Grammar.var_sigil>,
+ twigil => ~$<Perlito6::Grammar.var_twigil>,
+ name => ~$<Perlito6::Grammar.full_ident>
)
}
}
@@ -162,10 +162,10 @@ token rule_terms {
# # \x[0021] \X[0021]
# { make Rul::SpecialChar.new( char => '\\' ~ $0 ~ $1 ) }
- | c \[ <Perlito::Grammar.digits> \]
- { make Rul::Constant.new( constant => chr( $<Perlito::Grammar.digits> ) ) }
- | c <Perlito::Grammar.digits>
- { make Rul::Constant.new( constant => chr( $<Perlito::Grammar.digits> ) ) }
+ | c \[ <Perlito6::Grammar.digits> \]
+ { make Rul::Constant.new( constant => chr( $<Perlito6::Grammar.digits> ) ) }
+ | c <Perlito6::Grammar.digits>
+ { make Rul::Constant.new( constant => chr( $<Perlito6::Grammar.digits> ) ) }
| <any>
# \e \E
{ make Rul::SpecialChar.new( char => $$<any> ) }
@@ -256,10 +256,10 @@ token rule_term {
}
token quant_exp {
- | '**' <.Perlito::Grammar.opt_ws>
+ | '**' <.Perlito6::Grammar.opt_ws>
[
- | <Perlito::Grammar.val_int>
- { make $$<Perlito::Grammar.val_int> }
+ | <Perlito6::Grammar.val_int>
+ { make $$<Perlito6::Grammar.val_int> }
| <rule_term>
{ make $$<rule_term> }
]
@@ -269,19 +269,19 @@ token quant_exp {
token greedy_exp { \? | \+ | '' }
token quantifier {
- <.Perlito::Grammar.opt_ws>
+ <.Perlito6::Grammar.opt_ws>
<rule_term>
- <.Perlito::Grammar.opt_ws2>
+ <.Perlito6::Grammar.opt_ws2>
[
<quant_exp> <greedy_exp>
- <.Perlito::Grammar.opt_ws3>
+ <.Perlito6::Grammar.opt_ws3>
{ make Rul::Quantifier.new(
term => $$<rule_term>,
quant => $$<quant_exp>,
greedy => $$<greedy_exp>,
- ws1 => $$<Perlito::Grammar.opt_ws>,
- ws2 => $$<Perlito::Grammar.opt_ws2>,
- ws3 => $$<Perlito::Grammar.opt_ws3>,
+ ws1 => $$<Perlito6::Grammar.opt_ws>,
+ ws2 => $$<Perlito6::Grammar.opt_ws2>,
+ ws3 => $$<Perlito6::Grammar.opt_ws3>,
)
}
|
@@ -335,7 +335,7 @@ token rule {
=head1 NAME
-Perlito::Grammar::Regex - Grammar for Perlito Regex
+Perlito6::Grammar::Regex - Grammar for Perlito Regex
=head1 SYNOPSIS
View
32 src6/lib/Perlito/Java/Emitter.pm → src6/lib/Perlito6/Java/Emitter.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Java::LexicalBlock {
+class Perlito6::Java::LexicalBlock {
has @.block;
has $.needs_return;
has $.top_level;
@@ -45,8 +45,8 @@ class Perlito::Java::LexicalBlock {
if $cond.isa( 'Var' ) && $cond.sigil eq '@' {
$cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
- $body = Perlito::Java::LexicalBlock.new( block => $body, needs_return => 1, top_level => $.top_level );
- $otherwise = Perlito::Java::LexicalBlock.new( block => $otherwise, needs_return => 1, top_level => $.top_level );
+ $body = Perlito6::Java::LexicalBlock.new( block => $body, needs_return => 1, top_level => $.top_level );
+ $otherwise = Perlito6::Java::LexicalBlock.new( block => $otherwise, needs_return => 1, top_level => $.top_level );
$str = $str
~ 'if tobool( ' ~ Call::emit_java_call( $cond, 'Bool' ) ~ ' ) { '
~ $body.emit_java ~ ' } else { '
@@ -225,7 +225,7 @@ class CompUnit {
}
if $decl.isa( 'Method' ) {
my $sig = $decl.sig;
- my $block = Perlito::Java::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ my $block = Perlito6::Java::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
$str = $str
~ ' // method ' ~ $decl.name ~ "\n"
~ ' Method_' ~ $class_name ~ '.f_' ~ $decl.name
@@ -243,7 +243,7 @@ class CompUnit {
}
if $decl.isa( 'Sub' ) {
my $sig = $decl.sig;
- my $block = Perlito::Java::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ my $block = Perlito6::Java::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
$str = $str
~ ' // sub ' ~ $decl.name ~ "\n"
~ ' Namespace_' ~ $class_name ~ '.f_' ~ $decl.name
@@ -313,7 +313,7 @@ class CompUnit {
for @($comp_units) -> $comp_unit {
$str = $str ~ $comp_unit.emit_java;
}
- if !(%unit_seen{"Perlito::Grammar"}) {
+ if !(%unit_seen{"Perlito6::Grammar"}) {
$str = $str ~ "type Perlito__Grammar struct\{}\n";
}
$str = $str ~ "// interfaces for all methods\n";
@@ -555,7 +555,7 @@ class Apply {
if $code eq 'go' {
return 'go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Java::LexicalBlock.new( block => (@.arguments[0]).block, needs_return => 0, top_level => 1 )).emit_java ~ "\n"
+ ~ ' ' ~ (Perlito6::Java::LexicalBlock.new( block => (@.arguments[0]).block, needs_return => 0, top_level => 1 )).emit_java ~ "\n"
~ ' }()'
}
@@ -764,14 +764,14 @@ class If {
$cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
my $s = 'if tobool( ' ~ Call::emit_java_call( $cond, 'Bool' ) ~ ' ) { '
- ~ (Perlito::Java::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_java
+ ~ (Perlito6::Java::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_java
~ ' }';
if !(@.otherwise) {
return $s;
}
return $s
~ ' else { '
- ~ (Perlito::Java::LexicalBlock.new( block => @.otherwise, needs_return => 0 )).emit_java
+ ~ (Perlito6::Java::LexicalBlock.new( block => @.otherwise, needs_return => 0 )).emit_java
~ ' }';
}
}
@@ -782,7 +782,7 @@ class For {
~ ' var i = (*(*a_).(array_er).f_array(Capture{})).(*Array); ' ~ "\n"
~ ' for pos := 0; pos <= i.n; pos++ { ' ~ "\n"
~ ' func (' ~ $.topic.emit_java ~ ' *Any) { ' ~ "\n"
- ~ ' ' ~ (Perlito::Java::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_java ~ "\n"
+ ~ ' ' ~ (Perlito6::Java::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_java ~ "\n"
~ ' }(i.v[pos]) ' ~ "\n"
~ ' } ' ~ "\n"
~ '}(' ~ $.cond.emit_java ~ ')'
@@ -806,7 +806,7 @@ class While {
~ 'tobool( ' ~ Call::emit_java_call( $cond, 'Bool' ) ~ ' ); '
~ ( $.continue ?? $.continue.emit_java ~ ' ' !! '' )
~ '{ '
- ~ (Perlito::Java::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_java
+ ~ (Perlito6::Java::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_java
~ ' }';
}
}
@@ -864,7 +864,7 @@ class Method {
'func ' ~ $.name ~ '(v Capture) *Any { '
~ ' ' ~ ($.sig).emit_java_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Java::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_java
+ ~ ' ' ~ (Perlito6::Java::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_java
~ '; p <- nil }(); ' ~ "\n"
~ ' return <-p; ' ~ "\n"
~ ' }'
@@ -878,7 +878,7 @@ class Sub {
'toFunction( func(v Capture) *Any { '
~ ' ' ~ ($.sig).emit_java_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Java::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_java
+ ~ ' ' ~ (Perlito6::Java::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_java
~ '; p <- nil }(); ' ~ "\n"
~ ' return <-p; ' ~ "\n"
~ '} '
@@ -888,7 +888,7 @@ class Sub {
'func ' ~ $.name ~ '(v Capture) *Any { '
~ ' ' ~ ($.sig).emit_java_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
- ~ ' ' ~ (Perlito::Java::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_java
+ ~ ' ' ~ (Perlito6::Java::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_java
~ '; p <- nil }(); ' ~ "\n"
~ ' return <-p; ' ~ "\n"
~ ' }'
@@ -898,7 +898,7 @@ class Sub {
class Do {
method emit_java {
'(func () *Any { '
- ~ (Perlito::Java::LexicalBlock.new( block => @.block, needs_return => 1 )).emit_java
+ ~ (Perlito6::Java::LexicalBlock.new( block => @.block, needs_return => 1 )).emit_java
~ '; return u_undef() '
~ '})()'
}
@@ -914,7 +914,7 @@ class Use {
=head1 NAME
-Perlito::Java::Emit - Code generator for Perlito-in-Java
+Perlito6::Java::Emit - Code generator for Perlito-in-Java
=head1 SYNOPSIS
View
0  src6/lib/Perlito/Java/Runtime.java → src6/lib/Perlito6/Java/Runtime.java
File renamed without changes
View
32 src6/lib/Perlito/Javascript/Emitter.pm → src6/lib/Perlito6/Javascript/Emitter.pm
@@ -1,6 +1,6 @@
use v6;
-use Perlito::AST;
+use Perlito6::AST;
class Javascript {
sub tab($level) {
@@ -58,7 +58,7 @@ class Javascript {
}
-class Perlito::Javascript::LexicalBlock {
+class Perlito6::Javascript::LexicalBlock {
has @.block;
has $.needs_return;
has $.top_level;
@@ -66,7 +66,7 @@ class Perlito::Javascript::LexicalBlock {
method emit_javascript_indented( $level ) {
if $.top_level {
- my $block = Perlito::Javascript::LexicalBlock.new( block => self.block, needs_return => self.needs_return, top_level => 0 );
+ my $block = Perlito6::Javascript::LexicalBlock.new( block => self.block, needs_return => self.needs_return, top_level => 0 );
return
Javascript::tab($level) ~ 'try {' ~ "\n"
~ $block.emit_javascript_indented( $level + 1 ) ~ ';' ~ "\n"
@@ -119,13 +119,13 @@ class Perlito::Javascript::LexicalBlock {
if $cond.isa( 'Var' ) && $cond.sigil eq '@' {
$cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
}
- $body = Perlito::Javascript::LexicalBlock.new( block => $body.stmts, needs_return => 1 );
+ $body = Perlito6::Javascript::LexicalBlock.new( block => $body.stmts, needs_return => 1 );
@str.push: Javascript::tab($level) ~
'if ( ' ~ Javascript::escape_function('bool') ~ '(' ~ $cond.emit_javascript() ~ ') ) { return (function () {' ~ "\n"
~ $body.emit_javascript_indented($level+1) ~ "\n"
~ Javascript::tab($level) ~ '})(); }';
if $otherwise {
- $otherwise = Perlito::Javascript::LexicalBlock.new( block => $otherwise.stmts, needs_return => 1 );
+ $otherwise = Perlito6::Javascript::LexicalBlock.new( block => $otherwise.stmts, needs_return => 1 );
@str.push:
Javascript::tab($level) ~ 'else { return (function () {' ~ "\n"
~ $otherwise.emit_javascript_indented($level+1) ~ "\n"
@@ -186,7 +186,7 @@ class CompUnit {
my $sig = $decl.sig;
my $pos = $sig.positional;
my $invocant = $sig.invocant;
- my $block = Perlito::Javascript::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ my $block = Perlito6::Javascript::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
$str = $str
~ ' // method ' ~ $decl.name() ~ "\n"
~ ' ' ~ $class_name ~ '.' ~ Javascript::escape_function( $decl.name() )
@@ -199,7 +199,7 @@ class CompUnit {
if $decl.isa( 'Sub' ) {
my $sig = $decl.sig;
my $pos = $sig.positional;
- my $block = Perlito::Javascript::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ my $block = Perlito6::Javascript::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
$str = $str
~ ' // sub ' ~ $decl.name() ~ "\n"
~ ' ' ~ $class_name ~ '.' ~ Javascript::escape_function( $decl.name() )
@@ -258,7 +258,7 @@ class Lit::Block {
}
return
Javascript::tab($level) ~ "(function ($sig) \{\n"
- ~ (Perlito::Javascript::LexicalBlock.new( block => @.stmts, needs_return => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
+ ~ (Perlito6::Javascript::LexicalBlock.new( block => @.stmts, needs_return => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
~ Javascript::tab($level) ~ '})'
}
}
@@ -652,13 +652,13 @@ class If {
{
$cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
}
- my $body = Perlito::Javascript::LexicalBlock.new( block => $.body.stmts, needs_return => 0 );
+ my $body = Perlito6::Javascript::LexicalBlock.new( block => $.body.stmts, needs_return => 0 );
my $s = Javascript::tab($level) ~ 'if ( ' ~ Javascript::escape_function('bool') ~ '(' ~ $cond.emit_javascript() ~ ') ) { '
~ '(function () {' ~ "\n"
~ $body.emit_javascript_indented( $level + 1 ) ~ "\n"
~ Javascript::tab($level) ~ '})(); }';
if $.otherwise {
- my $otherwise = Perlito::Javascript::LexicalBlock.new( block => $.otherwise.stmts, needs_return => 0 );
+ my $otherwise = Perlito6::Javascript::LexicalBlock.new( block => $.otherwise.stmts, needs_return => 0 );
$s = $s
~ "\n"
~ Javascript::tab($level) ~ 'else { '
@@ -674,7 +674,7 @@ class If {
class While {
method emit_javascript { self.emit_javascript_indented(0) }
method emit_javascript_indented( $level ) {
- my $body = Perlito::Javascript::LexicalBlock.new( block => @.body.stmts, needs_return => 0 );
+ my $body = Perlito6::Javascript::LexicalBlock.new( block => @.body.stmts, needs_return => 0 );
return
Javascript::tab($level) ~ 'for ( '
~ ( $.init ?? $.init.emit_javascript() ~ '; ' !! '; ' )
@@ -693,7 +693,7 @@ class For {
if !( $cond.isa( 'Var' ) && $cond.sigil eq '@' ) {
$cond = Lit::Array.new( array1 => [$cond] )
}
- my $body = Perlito::Javascript::LexicalBlock.new( block => @.body.stmts, needs_return => 0 );
+ my $body = Perlito6::Javascript::LexicalBlock.new( block => @.body.stmts, needs_return => 0 );
my $sig = 'v__';
if $.body.sig() {
$sig = $.body.sig.emit_javascript_indented( $level + 1 );
@@ -740,7 +740,7 @@ class Method {
my $pos = $sig.positional;
my $str = $pos.>>emit_javascript.join(', ');
Javascript::tab($level) ~ 'function ' ~ $.name ~ '(' ~ $str ~ ') {' ~ "\n"
- ~ (Perlito::Javascript::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
+ ~ (Perlito6::Javascript::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
~ Javascript::tab($level) ~ '}'
}
}
@@ -752,7 +752,7 @@ class Sub {
my $pos = $sig.positional;
my $str = $pos.>>emit_javascript.join(', ');
Javascript::tab($level) ~ 'function ' ~ $.name ~ '(' ~ $str ~ ') {' ~ "\n"
- ~ (Perlito::Javascript::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
+ ~ (Perlito6::Javascript::LexicalBlock.new( block => @.block, needs_return => 1, top_level => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
~ Javascript::tab($level) ~ '}'
}
}
@@ -763,7 +763,7 @@ class Do {
my $block = self.simplify.block;
return
Javascript::tab($level) ~ '(function () { ' ~ "\n"
- ~ (Perlito::Javascript::LexicalBlock.new( block => $block, needs_return => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
+ ~ (Perlito6::Javascript::LexicalBlock.new( block => $block, needs_return => 1 )).emit_javascript_indented( $level + 1 ) ~ "\n"
~ Javascript::tab($level) ~ '})()'
}
}
@@ -779,7 +779,7 @@ class Use {
=head1 NAME
-Perlito::Javascript::Emit - Code generator for Perlito-in-Javascript
+Perlito6::Javascript::Emit - Code generator for Perlito-in-Javascript
=head1 SYNOPSIS
View
4 src6/lib/Perlito/Javascript/Prelude.pm → src6/lib/Perlito6/Javascript/Prelude.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Match {
+class Perlito6::Match {
has $.from;
has $.to;
has $.str;
@@ -58,7 +58,7 @@ class Main {
=head1 NAME
-Perlito::Lisp::Prelude - Runtime for Perlito-in-Lisp
+Perlito6::Lisp::Prelude - Runtime for Perlito-in-Lisp
=head1 SYNOPSIS
View
42 src6/lib/Perlito/Javascript/Runtime.js → src6/lib/Perlito6/Javascript/Runtime.js
@@ -1,7 +1,7 @@
-// Do not edit this file - Generated by Perlito 8.0
-// lib/Perlito/Javascript/Runtime.js
+// Do not edit this file - Generated by Perlito6 8.0
+// lib/Perlito6/Javascript/Runtime.js
//
-// Runtime for "Perlito" Perlito-in-Javascript
+// Runtime for "Perlito6" Perl6-in-Javascript
//
// AUTHORS
//
@@ -65,21 +65,21 @@ if (typeof Main !== 'object') {
};
})();
-if (typeof Perlito$Match !== 'object') {
- Perlito$Match = function() {};
- Perlito$Match = new Perlito$Match;
- Perlito$Match.isa = function(s) {
- return s == 'Perlito::Match';
+if (typeof Perlito6$Match !== 'object') {
+ Perlito6$Match = function() {};
+ Perlito6$Match = new Perlito6$Match;
+ Perlito6$Match.isa = function(s) {
+ return s == 'Perlito6::Match';
};
- Perlito$Match.perl = function() {
- return 'Perlito::Match.new(' + Main._dump(this) + ')';
+ Perlito6$Match.perl = function() {
+ return 'Perlito6::Match.new(' + Main._dump(this) + ')';
};
}
v_MATCH = {};
-v_MATCH.__proto__ = Perlito$Match;
+v_MATCH.__proto__ = Perlito6$Match;
-Perlito$Match.hash = function() {
+Perlito6$Match.hash = function() {
return this;
};
@@ -453,41 +453,41 @@ str_replicate = function(o, num) {
};
// regex primitives
-if (typeof Perlito$Grammar !== 'object') {
- Perlito$Grammar = function() {};
- Perlito$Grammar = new Perlito$Grammar;
+if (typeof Perlito6$Grammar !== 'object') {
+ Perlito6$Grammar = function() {};
+ Perlito6$Grammar = new Perlito6$Grammar;
}
-Perlito$Grammar.word = function(v_str, v_pos) {
+Perlito6$Grammar.word = function(v_str, v_pos) {
var tmp = {
v_str: v_str,
v_from: v_pos,
v_to: v_pos + 1,
v_bool: v_str.substr(v_pos, 1).match(/\w/) != null
};
- tmp.__proto__ = Perlito$Match;
+ tmp.__proto__ = Perlito6$Match;
return tmp;
};
-Perlito$Grammar.digit = function(v_str, v_pos) {
+Perlito6$Grammar.digit = function(v_str, v_pos) {
var tmp = {
v_str: v_str,
v_from: v_pos,
v_to: v_pos + 1,
v_bool: v_str.substr(v_pos, 1).match(/\d/) != null
};
- tmp.__proto__ = Perlito$Match;
+ tmp.__proto__ = Perlito6$Match;
return tmp;
};
-Perlito$Grammar.space = function(v_str, v_pos) {
+Perlito6$Grammar.space = function(v_str, v_pos) {
var tmp = {
v_str: v_str,
v_from: v_pos,
v_to: v_pos + 1,
v_bool: v_str.substr(v_pos, 1).match(/\s/) != null
};
- tmp.__proto__ = Perlito$Match;
+ tmp.__proto__ = Perlito6$Match;
return tmp;
};
View
20 src6/lib/Perlito/Lisp/Emitter.pm → src6/lib/Perlito6/Lisp/Emitter.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Lisp::LexicalBlock {
+class Perlito6::Lisp::LexicalBlock {
has @.block;
method emit_lisp {
my @block;
@@ -116,7 +116,7 @@ class CompUnit {
if ( $str_optionals ) {
$str_specific = $str_specific ~ ' &optional' ~ $str_optionals;
}
- my $block = Perlito::Lisp::LexicalBlock.new( block => $decl.block );
+ my $block = Perlito6::Lisp::LexicalBlock.new( block => $decl.block );
$str = $str
~ ';; method ' ~ $decl.name() ~ "\n"
~ '(defmethod ' ~ Main::to_lisp_identifier($decl.name) ~ ' (' ~ $str_specific ~ ')'
@@ -138,7 +138,7 @@ class CompUnit {
if $param {
$sig = '&optional ' ~ $param;
}
- my $block = Perlito::Lisp::LexicalBlock.new( block => $decl.block );
+ my $block = Perlito6::Lisp::LexicalBlock.new( block => $decl.block );
$str = $str
~ '(defmethod ' ~ $class_name ~ '-' ~ Main::to_lisp_identifier($decl.name) ~ ' (' ~ $sig ~ ')'
~ $ignorable ~ "\n"
@@ -520,9 +520,9 @@ class Return {
class If {
method emit_lisp {
- my $block1 = Perlito::Lisp::LexicalBlock.new( block => $.body.stmts );
+ my $block1 = Perlito6::Lisp::LexicalBlock.new( block => $.body.stmts );
if $.otherwise {
- my $block2 = Perlito::Lisp::LexicalBlock.new( block => $.otherwise.stmts );
+ my $block2 = Perlito6::Lisp::LexicalBlock.new( block => $.otherwise.stmts );
return '(if (sv-bool ' ~ $.cond.emit_lisp() ~ ') ' ~ $block1.emit_lisp() ~ ' ' ~ $block2.emit_lisp() ~ ')';
}
else {
@@ -534,7 +534,7 @@ class If {
class For {
method emit_lisp {
my $cond = $.cond;
- my $block = Perlito::Lisp::LexicalBlock.new( block => @.body );
+ my $block = Perlito6::Lisp::LexicalBlock.new( block => @.body );
if $cond.isa( 'Var' )
&& $cond.sigil eq '@'
{
@@ -561,7 +561,7 @@ class While {
'(progn '
~ ( $.init ?? $.init.emit_lisp() ~ ' ' !! '' )
~ '(loop while (sv-bool ' ~ $.cond.emit_lisp() ~ ') do '
- ~ (Perlito::Lisp::LexicalBlock.new( block => @body )).emit_lisp()
+ ~ (Perlito6::Lisp::LexicalBlock.new( block => @body )).emit_lisp()
~ '))';
}
}
@@ -601,7 +601,7 @@ class Sub {
method emit_lisp {
my $sig = $.sig;
my $pos = $sig.positional;
- my $block = Perlito::Lisp::LexicalBlock.new( block => @.block );
+ my $block = Perlito6::Lisp::LexicalBlock.new( block => @.block );
my $str;
if @$pos {
for @$pos -> $field {
@@ -629,7 +629,7 @@ class Sub {
class Do {
method emit_lisp {
- my $block = Perlito::Lisp::LexicalBlock.new( block => @.block );
+ my $block = Perlito6::Lisp::LexicalBlock.new( block => @.block );
return $block.emit_lisp;
}
}
@@ -645,7 +645,7 @@ class Use {
=head1 NAME
-Perlito::Lisp::Emit - Code generator for Perlito-in-Lisp (SBCL)
+Perlito6::Lisp::Emit - Code generator for Perlito-in-Lisp (SBCL)
=head1 SYNOPSIS
View
4 src6/lib/Perlito/Lisp/Prelude.pm → src6/lib/Perlito6/Lisp/Prelude.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Match {
+class Perlito6::Match {
has $.from;
has $.to;
has $.str;
@@ -60,7 +60,7 @@ class Main {
=head1 NAME
-Perlito::Lisp::Prelude - Runtime for Perlito-in-Lisp
+Perlito6::Lisp::Prelude - Runtime for Perlito-in-Lisp
=head1 SYNOPSIS
View
0  src6/lib/Perlito/Lisp/Runtime.lisp → src6/lib/Perlito6/Lisp/Runtime.lisp
File renamed without changes
View
2  src6/lib/Perlito/Macro.pm → src6/lib/Perlito6/Macro.pm
@@ -237,7 +237,7 @@ class Do {
=head1 NAME
-Perlito::Macro - Ast macros for Perlito
+Perlito6::Macro - Ast macros for Perlito
=head1 SYNOPSIS
View
2  src6/lib/Perlito/Parrot/Emitter.pm → src6/lib/Perlito6/Parrot/Emitter.pm
@@ -732,7 +732,7 @@ class Use {
=head1 NAME
-Perlito::Parrot::Emit - Code generator for Perlito-in-Parrot
+Perlito6::Parrot::Emit - Code generator for Perlito-in-Parrot
=head1 SYNOPSIS
View
4 src6/lib/Perlito/Parrot/Match.pm → src6/lib/Perlito6/Parrot/Match.pm
@@ -3,8 +3,8 @@ use v6;
# See also: parrot/compilers/pge/PGE/Match.pir
-# XXX - class name - fix Perlito::Emitter::Token to emit 'Perlito::Runtime::Match' instead
-class Perlito::Perl5::Match {
+# XXX - class name - fix Perlito6::Emitter::Token to emit 'Perlito6::Runtime::Match' instead
+class Perlito6::Perl5::Match {
has $.str;
has $.array;
has $.hash;
View
10 src6/lib/Perlito/Perl5/Emitter.pm → src6/lib/Perlito6/Perl5/Emitter.pm
@@ -1,6 +1,6 @@
use v6;
-use Perlito::AST;
+use Perlito6::AST;
class Perl5 {
sub tab($level) {
@@ -72,9 +72,9 @@ class CompUnit {
~ "use strict;\n"
~ "use warnings;\n"
~ "no warnings ('redefine', 'once', 'void', 'uninitialized', 'misc', 'recursion');\n"
- ~ "use Perlito::Perl5::Runtime;\n"
- ~ "use Perlito::Perl5::Prelude;\n"
- ~ "our \$MATCH = Perlito::Match->new();\n";
+ ~ "use Perlito6::Perl5::Runtime;\n"
+ ~ "use Perlito6::Perl5::Prelude;\n"
+ ~ "our \$MATCH = Perlito6::Match->new();\n";
for @($comp_units) -> $comp_unit {
$str ~= $comp_unit.emit_perl5_indented(0)
}
@@ -557,7 +557,7 @@ class Use {
=head1 NAME
-Perlito::Perl5::Emit - Code generator for Perlito-in-Perl5
+Perlito6::Perl5::Emit - Code generator for Perlito-in-Perl5
=head1 SYNOPSIS
View
4 src6/lib/Perlito/Perl5/Prelude.pm → src6/lib/Perlito6/Perl5/Prelude.pm
@@ -1,6 +1,6 @@
use v6;
-class Perlito::Match {
+class Perlito6::Match {
has $.from;
has $.to;
has $.str;
@@ -25,7 +25,7 @@ class Pair {
=head1 NAME
-Perlito::Perl5::Prelude - Runtime for Perlito-in-Perl5
+Perlito6::Perl5::Prelude - Runtime for Perlito-in-Perl5
=head1 SYNOPSIS
View
14 src6/lib/Perlito/Perl5/Runtime.pm → src6/lib/Perlito6/Perl5/Runtime.pm
@@ -8,7 +8,7 @@ $_ = Encode::decode('utf-8', $_)
for @ARGV;
{
- package Perlito::Match;
+ package Perlito6::Match;
use strict;
use warnings;
@@ -76,11 +76,11 @@ $_ = Encode::decode('utf-8', $_)
}
-package Perlito::Grammar;
+package Perlito6::Grammar;
sub space {
# my $grammar = $_[0];
my $str = $_[1]; my $pos = $_[2];
- my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito::Match';
+ my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito6::Match';
$MATCH->{bool} = (
substr($str, $MATCH->{to}) =~ m/^([[:space:]])/
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} )))
@@ -91,7 +91,7 @@ package Perlito::Grammar;
sub digit {
# my $grammar = $_[0];
my $str = $_[1]; my $pos = $_[2];
- my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito::Match';
+ my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito6::Match';
$MATCH->{bool} = (
substr($str, $MATCH->{to}) =~ m/^([[:digit:]])/
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} )))
@@ -103,7 +103,7 @@ package Perlito::Grammar;
sub word {
# my $grammar = $_[0];
my $str = $_[1]; my $pos = $_[2];
- my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito::Match';
+ my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito6::Match';
$MATCH->{bool} = (
substr($str, $MATCH->{to}) =~ m/^([[:word:]])/
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} )))
@@ -299,11 +299,11 @@ __END__
=head1 NAME
-Perlito::Perl5::Runtime
+Perlito6::Perl5::Runtime
=head1 DESCRIPTION
-Provides runtime routines for the Perlito-in-Perl5 compiled code
+Provides runtime routines for the Perl6-in-Perl5 compiled code
=head1 AUTHORS
View
12 src6/lib/Perlito/Precedence.pm → src6/lib/Perlito6/Precedence.pm
@@ -1,5 +1,5 @@
-class Perlito::Precedence {
+class Perlito6::Precedence {
has $.get_token;
has $.reduce;
@@ -42,7 +42,7 @@ class Perlito::Precedence {
if is_ident_middle($c1) && ( is_ident_middle($c2) || $c2 eq '(' ) {
}
else {
- return Perlito::Match.new( 'str' => $str, 'from' => $from, 'to' => $pos+2, 'bool' => 1,
+ return Perlito6::Match.new( 'str' => $str, 'from' => $from, 'to' => $pos+2, 'bool' => 1,
capture => ['end', $s] );
}
}
@@ -81,13 +81,13 @@ class Perlito::Precedence {
$hyper_right = $c02;
$pos = $pos + 2;
}
- return Perlito::Match.new( 'str' => $str, 'from' => $from, 'to' => $pos, 'bool' => 1,
+ return Perlito6::Match.new( 'str' => $str, 'from' => $from, 'to' => $pos, 'bool' => 1,
capture => [ 'op', $op, { 'hyper_left' => $hyper_left, 'hyper_right' => $hyper_right } ] );
}
}
}
- return Perlito::Match.new( bool => 0 );
+ return Perlito6::Match.new( bool => 0 );
}
sub add_op ( $fixity, $name, $precedence, $param ) {
@@ -338,11 +338,11 @@ class Perlito::Precedence {
=head1 NAME
-Perlito::Precedence - precedence parser for Perlito
+Perlito6::Precedence - precedence parser for Perlito
=head1 SYNOPSIS
- my $prec = Perlito::Precedence.new(
+ my $prec = Perlito6::Precedence.new(
get_token => $get_token,
reduce => $reduce_to_ast,
end_token => [ ']', ')', '}', ';' ] );
View
62 src6/lib/Perlito/Python/Emitter.pm → src6/lib/Perlito6/Python/Emitter.pm
<
@@ -1,6 +1,6 @@
use v6;
-use Perlito::AST;
+use Perlito6::AST;
class Python {
sub tab($level) {
@@ -49,7 +49,7 @@ class Python {
}
-class Perlito::Python::AnonSub {
+class Perlito6::Python::AnonSub {
has $.name;
has $.sig;
has @.block;
@@ -62,7 +62,7 @@ class Perlito::Python::AnonSub {
for @$pos -> $field {
$args.push( $field.emit_python_name );