Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use assignment instead of binding everywhere ('=' instead of ':=')

  • Loading branch information...
commit 7c12fff056be11c57c8e40641905280cf93147a7 1 parent 30d87e0
@fglock authored
Showing with 1,134 additions and 1,141 deletions.
  1. +2 −1  ChangeLog
  2. +2 −10 TODO
  3. +93 −93 lib/MiniPerl6/Clojure/Emitter.pm
  4. +54 −54 lib/MiniPerl6/Emitter/Token.pm
  5. +42 −42 lib/MiniPerl6/Eval.pm
  6. +165 −165 lib/MiniPerl6/Go/Emitter.pm
  7. +10 −10 lib/MiniPerl6/Grammar.pm
  8. +1 −1  lib/MiniPerl6/Grammar/Control.pm
  9. +1 −1  lib/MiniPerl6/Grammar/Mapping.pm
  10. +2 −2 lib/MiniPerl6/Grammar/Regex.pm
  11. +119 −119 lib/MiniPerl6/Javascript/Emitter.pm
  12. +133 −133 lib/MiniPerl6/Lisp/Emitter.pm
  13. +140 −140 lib/MiniPerl6/Parrot/Emitter.pm
  14. +83 −83 lib/MiniPerl6/Perl5/Emitter.pm
  15. +72 −72 lib/MiniPerl6/Python/Emitter.pm
  16. +52 −52 lib/MiniPerl6/Rakudo/Emitter.pm
  17. +13 −13 lib/Test.pm
  18. +8 −8 lib5/MiniPerl6/Emitter/Token.pm
  19. +3 −3 lib5/MiniPerl6/Grammar.pm
  20. +1 −1  lib5/MiniPerl6/Grammar/Regex.pm
  21. +8 −8 libjs/MiniPerl6/Emitter/Token.js
  22. +3 −3 libjs/MiniPerl6/Grammar.js
  23. +1 −1  libjs/MiniPerl6/Grammar/Regex.js
  24. +12 −12 perlito.js
  25. +1 −1  t/03-num.t
  26. +7 −7 t/04-op.t
  27. +1 −1  t/04-string.t
  28. +3 −3 t/05-anon-sub-lex-block.t
  29. +3 −3 t/05-anon-sub.t
  30. +3 −3 t/05-array.t
  31. +2 −2 t/05-bind.t
  32. +1 −1  t/05-for.t
  33. +2 −2 t/05-hash.t
  34. +2 −2 t/05-lex-block-if.t
  35. +1 −1  t/05-lex-block.t
  36. +5 −5 t/05-while.t
  37. +6 −6 t/10-bind-sub-param.t
  38. +2 −2 t/11-accessor.t
  39. +4 −4 t/11-bind-method-param.t
  40. +5 −5 t/11-class-open.t
  41. +5 −5 t/11-class.t
  42. +2 −2 t/11-hyper.t
  43. +2 −2 t/12-match-more.t
  44. +2 −2 t/12-match.t
  45. +2 −2 t/16-var-redeclare.t
  46. +15 −15 t/20-eval.t
  47. +38 −38 util/mp6.pl
View
3  ChangeLog
@@ -1,4 +1,5 @@
(5.0)
+- use variable assignment instead of binding - that is, use '=' instead of ':='
- 'use' - all backends can use Test.pm
- 'elsif'
- regex quantifiers
@@ -6,7 +7,7 @@
4.1 2010-03-24
- floating point numbers
-- while loop
+- 'while' loop
4.0 2010-03-20
- Go backend bootstrap.
View
12 TODO
@@ -6,11 +6,11 @@ Eval.pm module
Command line compiler (mp6.pl)
-- implement -Clisp-bin (requires some changes in the lisp emitter)
+(no issues at the moment)
Command line compiler (util/mp6.pl)
-- migrate all bootstrap scripts to use util/mp6.pl (we now depend on shell and perl5)
+- migrate all bootstrap scripts to use util/mp6.pl - FIXED
- build Ast cache using JSON (we currently use Perl5 Data::Dumper) or XML (Go has XML and JSON input)
@@ -28,8 +28,6 @@ MiniPerl6 in Rakudo
MiniPerl6 in Lisp
-- fix warnings (SBCL)
-
- test other Lisp implementations
MiniPerl6 in Go
@@ -79,10 +77,6 @@ Missing Features of the Token sub-compiler
Nice to Have
-- replace := with = everywhere. Alternately, impl both := and = in all backends
-
-- impl 'elsif' - FIXED
-
- 'mp6-format' script (see gofmt and perltidy)
- run some tests from the standard test suite
@@ -104,5 +98,3 @@ Grammar
- all statements need a semicolon - FIXED but hack
-- autoquote hash keys - FIXED
-
View
186 lib/MiniPerl6/Clojure/Emitter.pm
@@ -6,35 +6,35 @@ class MiniPerl6::Clojure::LexicalBlock {
if !(@.block) {
return 'nil';
}
- my $str := '';
- my $has_my_decl := 0;
- my $my_decl := '';
- # my $silence_unused_warning := '';
+ my $str = '';
+ my $has_my_decl = 0;
+ my $my_decl = '';
+ # my $silence_unused_warning = '';
for @.block -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'my' ) {
- $has_my_decl := 1;
- $my_decl := $my_decl ~ '(' ~ ($decl.var).emit_clojure ~ ' (sv-undef))';
- # $silence_unused_warning := $silence_unused_warning ~ ' ' ~ ($decl.var).emit_clojure;
+ $has_my_decl = 1;
+ $my_decl = $my_decl ~ '(' ~ ($decl.var).emit_clojure ~ ' (sv-undef))';
+ # $silence_unused_warning = $silence_unused_warning ~ ' ' ~ ($decl.var).emit_clojure;
}
if $decl.isa( 'Bind' ) && ($decl.parameters).isa( 'Decl' ) && ( ($decl.parameters).decl eq 'my' ) {
- $has_my_decl := 1;
- $my_decl := $my_decl ~ '(' ~ (($decl.parameters).var).emit_clojure ~ ' (sv-undef))';
- # $silence_unused_warning := $silence_unused_warning ~ ' ' ~ (($decl.parameters).var).emit_clojure;
+ $has_my_decl = 1;
+ $my_decl = $my_decl ~ '(' ~ (($decl.parameters).var).emit_clojure ~ ' (sv-undef))';
+ # $silence_unused_warning = $silence_unused_warning ~ ' ' ~ (($decl.parameters).var).emit_clojure;
}
}
if $has_my_decl {
- $str := $str ~ '(let (' ~ $my_decl ~ ') ';
+ $str = $str ~ '(let (' ~ $my_decl ~ ') ';
# silence warning "The variable X is defined but never used." in SBCL
- # $str := $str ~ '(list ' ~ $silence_unused_warning ~ ') ';
+ # $str = $str ~ '(list ' ~ $silence_unused_warning ~ ') ';
}
else {
- $str := $str ~ '(do ';
+ $str = $str ~ '(do ';
};
for @.block -> $decl {
if (!( $decl.isa( 'Decl' ) && ( $decl.decl eq 'my' ))) {
- $str := $str ~ ($decl).emit_clojure;
+ $str = $str ~ ($decl).emit_clojure;
}
};
return $str ~ ')';
@@ -49,37 +49,37 @@ class CompUnit {
has @.body;
method emit_clojure {
- my $class_name := Main::to_lisp_namespace($.name);
- my $str := ';; class ' ~ $.name ~ Main.newline;
+ my $class_name = Main::to_lisp_namespace($.name);
+ my $str = ';; class ' ~ $.name ~ Main.newline;
- $str := $str ~ '(defpackage ' ~ $class_name ~ Main.newline
+ $str = $str ~ '(defpackage ' ~ $class_name ~ Main.newline
~ ' (:use common-lisp mp-Main))' ~ Main.newline
~ ';; (in-package ' ~ $class_name ~ ')' ~ Main.newline;
- # my $silence_unused_warning := '';
+ # my $silence_unused_warning = '';
- my $has_my_decl := 0;
- my $my_decl := '';
+ my $has_my_decl = 0;
+ my $my_decl = '';
for @.body -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'my' ) {
- $has_my_decl := 1;
- $my_decl := $my_decl ~ '(' ~ ($decl.var).emit_clojure ~ ' (sv-undef))';
- # $silence_unused_warning := $silence_unused_warning ~ ' ' ~ ($decl.var).emit_clojure;
+ $has_my_decl = 1;
+ $my_decl = $my_decl ~ '(' ~ ($decl.var).emit_clojure ~ ' (sv-undef))';
+ # $silence_unused_warning = $silence_unused_warning ~ ' ' ~ ($decl.var).emit_clojure;
}
if $decl.isa( 'Bind' ) && ($decl.parameters).isa( 'Decl' ) && ( ($decl.parameters).decl eq 'my' ) {
- $has_my_decl := 1;
- $my_decl := $my_decl ~ '(' ~ (($decl.parameters).var).emit_clojure ~ ' (sv-undef))';
- # $silence_unused_warning := $silence_unused_warning ~ ' ' ~ (($decl.parameters).var).emit_clojure;
+ $has_my_decl = 1;
+ $my_decl = $my_decl ~ '(' ~ (($decl.parameters).var).emit_clojure ~ ' (sv-undef))';
+ # $silence_unused_warning = $silence_unused_warning ~ ' ' ~ (($decl.parameters).var).emit_clojure;
}
}
if $has_my_decl {
- $str := $str ~ '(let (' ~ $my_decl ~ ')' ~ Main.newline;
+ $str = $str ~ '(let (' ~ $my_decl ~ ')' ~ Main.newline;
# silence warning "The variable X is defined but never used." in SBCL
- # $str := $str ~ '(list ' ~ $silence_unused_warning ~ ') ';
+ # $str = $str ~ '(list ' ~ $silence_unused_warning ~ ') ';
}
- $str := $str ~
+ $str = $str ~
'(if (not (ignore-errors (find-class \'' ~ $class_name ~ ')))
(defclass ' ~ $class_name ~ ' () ()))
@@ -88,18 +88,18 @@ class CompUnit {
(defun proto-' ~ $class_name ~ ' () x))
';
- my $dumper := '';
+ my $dumper = '';
for @.body -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'has' ) {
- my $accessor_name := ($decl.var).name;
+ my $accessor_name = ($decl.var).name;
- $dumper := $dumper ~ '(let ((m (make-instance \'mp-Pair))) '
+ $dumper = $dumper ~ '(let ((m (make-instance \'mp-Pair))) '
~ '(setf (sv-key m) "' ~ Main::lisp_escape_string($accessor_name) ~ '") '
~ '(setf (sv-value m) (' ~ Main::to_lisp_identifier($accessor_name) ~ ' self)) m) ';
# suggested by Arthur Lemmens in: http://osdir.com/ml/lisp.lispworks.general/2005-07/msg00153.html
- $str := $str ~
+ $str = $str ~
';; has $.' ~ $accessor_name ~ '
(let ((new-slots (list (list :name \'' ~ Main::to_lisp_identifier($accessor_name) ~ '
:readers \'(' ~ Main::to_lisp_identifier($accessor_name) ~ ')
@@ -118,21 +118,21 @@ new-slots))
';
}
if $decl.isa( 'Method' ) {
- my $sig := $decl.sig;
- my $invocant := $sig.invocant;
- my $pos := $sig.positional;
- my $str_specific := '(' ~ $invocant.emit_clojure ~ ' ' ~ $class_name ~ ')';
- # my $str_generic := $invocant.emit_clojure;
- my $str_optionals := '';
+ my $sig = $decl.sig;
+ my $invocant = $sig.invocant;
+ my $pos = $sig.positional;
+ my $str_specific = '(' ~ $invocant.emit_clojure ~ ' ' ~ $class_name ~ ')';
+ # my $str_generic = $invocant.emit_clojure;
+ my $str_optionals = '';
for @$pos -> $field {
- $str_optionals := $str_optionals ~ ' ' ~ $field.emit_clojure;
+ $str_optionals = $str_optionals ~ ' ' ~ $field.emit_clojure;
};
if ( $str_optionals ) {
- $str_specific := $str_specific ~ ' &optional' ~ $str_optionals;
- # $str_generic := $str_generic ~ ' &optional' ~ $str_optionals;
+ $str_specific = $str_specific ~ ' &optional' ~ $str_optionals;
+ # $str_generic = $str_generic ~ ' &optional' ~ $str_optionals;
}
- my $block := MiniPerl6::Clojure::LexicalBlock.new( block => $decl.block );
- $str := $str ~
+ my $block = MiniPerl6::Clojure::LexicalBlock.new( block => $decl.block );
+ $str = $str ~
';; method ' ~ $decl.name ~ '
(if (not (ignore-errors (find-method \'' ~ Main::to_lisp_identifier($decl.name) ~ ' () ())))
(defmulti ' ~ Main::to_lisp_identifier($decl.name) ~ ' class)
@@ -143,7 +143,7 @@ new-slots))
';
}
if $decl.isa( 'Sub' ) {
- $str := $str
+ $str = $str
~ '(in-package ' ~ $class_name ~ ')' ~ Main.newline
~ ' ' ~ ($decl).emit_clojure ~ Main.newline
~ '(in-package mp-Main)' ~ Main.newline;
@@ -152,7 +152,7 @@ new-slots))
if $.name ne 'Pair' {
# .perl()
- $str := $str ~ '(defmethod sv-perl ((self ' ~ $class_name ~ '))' ~ Main.newline
+ $str = $str ~ '(defmethod sv-perl ((self ' ~ $class_name ~ '))' ~ Main.newline
~ ' (mp-Main::sv-lisp_dump_object "::' ~ Main::lisp_escape_string($.name) ~ '"'
~ ' (list ' ~ $dumper ~ ')))' ~ Main.newline ~ Main.newline;
}
@@ -162,15 +162,15 @@ new-slots))
&& (!( $decl.isa( 'Method')))
&& (!( $decl.isa( 'Sub')))
{
- $str := $str ~ ($decl).emit_clojure ~ Main.newline;
+ $str = $str ~ ($decl).emit_clojure ~ Main.newline;
}
};
if $has_my_decl {
# close paren for '(let '
- $str := $str ~ ')';
+ $str = $str ~ ')';
}
- $str := $str ~ Main.newline ~ Main.newline;
+ $str = $str ~ Main.newline ~ Main.newline;
}
}
@@ -210,13 +210,13 @@ class Lit::Array {
has @.array1;
method emit_clojure {
if @.array1 {
- my $str := '';
+ my $str = '';
for @.array1 -> $elem {
if $elem.isa( 'Apply' ) && $elem.code eq 'prefix:<@>' {
- $str := $str ~ ' ' ~ $elem.emit_clojure;
+ $str = $str ~ ' ' ~ $elem.emit_clojure;
}
else {
- $str := $str ~ ' (list ' ~ $elem.emit_clojure ~ ')';
+ $str = $str ~ ' (list ' ~ $elem.emit_clojure ~ ')';
}
}
return '(concatenate \'list ' ~ $str ~ ')';
@@ -231,10 +231,10 @@ class Lit::Hash {
has @.hash1;
method emit_clojure {
if @.hash1 {
- my $fields := @.hash1;
- my $str := '';
+ my $fields = @.hash1;
+ my $str = '';
for @$fields -> $field {
- $str := $str ~ '(setf (gethash ' ~ ($field[0]).emit_clojure ~ ' h) ' ~ ($field[1]).emit ~ ')';
+ $str = $str ~ '(setf (gethash ' ~ ($field[0]).emit_clojure ~ ' h) ' ~ ($field[1]).emit ~ ')';
};
return '(let ((h (make-hash-table :test \'equal))) ' ~ $str ~ ' h)';
}
@@ -253,10 +253,10 @@ class Lit::Object {
has @.fields;
method emit_clojure {
if @.fields {
- my $fields := @.fields;
- my $str := '';
+ my $fields = @.fields;
+ my $str = '';
for @$fields -> $field {
- $str := $str ~ '(setf (' ~ Main::to_lisp_identifier(($field[0]).buf) ~ ' m) ' ~ ($field[1]).emit_clojure ~ ')';
+ $str = $str ~ '(setf (' ~ Main::to_lisp_identifier(($field[0]).buf) ~ ' m) ' ~ ($field[1]).emit_clojure ~ ')';
};
'(let ((m (make-instance \'' ~ Main::to_lisp_namespace($.class) ~ '))) ' ~ $str ~ ' m)'
}
@@ -298,9 +298,9 @@ class Var {
# @x => $List_x
# %x => $Hash_x
# &x => $Code_x
- my $ns := '';
+ my $ns = '';
if $.namespace {
- $ns := Main::to_lisp_namespace( $.namespace ) ~ '::';
+ $ns = Main::to_lisp_namespace( $.namespace ) ~ '::';
}
( $.twigil eq '.' )
?? ( '(' ~ Main::to_lisp_identifier( $.name ) ~ ' sv-self)' )
@@ -317,21 +317,21 @@ class Bind {
method emit_clojure {
if $.parameters.isa( 'Lit::Object' ) {
- # Obj.new(:$a, :$b) := $obj
+ # Obj.new(:$a, :$b) = $obj
- my $class := $.parameters.class;
- my $a := $.parameters.fields;
- my $b := $.arguments;
- my $str := 'do { ';
- my $i := 0;
+ my $class = $.parameters.class;
+ my $a = $.parameters.fields;
+ my $b = $.arguments;
+ my $str = 'do { ';
+ my $i = 0;
my $arg;
for @$a -> $var {
- my $bind := Bind.new(
+ my $bind = Bind.new(
parameters => $var[1],
arguments => Call.new( invocant => $b, method => ($var[0]).buf, arguments => [ ], hyper => 0 )
);
- $str := $str ~ ' ' ~ $bind.emit_clojure ~ ' ';
- $i := $i + 1;
+ $str = $str ~ ' ' ~ $bind.emit_clojure ~ ' ';
+ $i = $i + 1;
};
return $str ~ $.parameters.emit_clojure ~ ' }';
};
@@ -357,14 +357,14 @@ class Call {
has @.arguments;
method emit_clojure {
- my $arguments := '';
+ my $arguments = '';
if @.arguments {
- $arguments := (@.arguments.>>emit_clojure).join(' ');
+ $arguments = (@.arguments.>>emit_clojure).join(' ');
}
- my $invocant := $.invocant.emit_clojure;
+ my $invocant = $.invocant.emit_clojure;
if $invocant eq 'self' {
- $invocant := 'sv-self';
+ $invocant = 'sv-self';
};
if ($.method eq 'values')
@@ -407,9 +407,9 @@ class Call {
}
};
- my $meth := Main::to_lisp_identifier($.method) ~ ' ';
+ my $meth = Main::to_lisp_identifier($.method) ~ ' ';
if $.method eq 'postcircumfix:<( )>' {
- $meth := '';
+ $meth = '';
};
if ($.hyper) {
@@ -427,14 +427,14 @@ class Apply {
has @.arguments;
has $.namespace;
method emit_clojure {
- my $ns := '';
+ my $ns = '';
if $.namespace {
- $ns := Main::to_lisp_namespace( $.namespace ) ~ '::';
+ $ns = Main::to_lisp_namespace( $.namespace ) ~ '::';
}
- my $code := $ns ~ $.code;
- my $args := '';
+ my $code = $ns ~ $.code;
+ my $args = '';
if @.arguments {
- $args := (@.arguments.>>emit_clojure).join(' ');
+ $args = (@.arguments.>>emit_clojure).join(' ');
}
if $code eq 'self' { return 'sv-self' };
@@ -491,8 +491,8 @@ class If {
has @.body;
has @.otherwise;
method emit_clojure {
- my $block1 := MiniPerl6::Clojure::LexicalBlock.new( block => @.body );
- my $block2 := MiniPerl6::Clojure::LexicalBlock.new( block => @.otherwise );
+ my $block1 = MiniPerl6::Clojure::LexicalBlock.new( block => @.body );
+ my $block2 = MiniPerl6::Clojure::LexicalBlock.new( block => @.otherwise );
'(if (sv-bool ' ~ $.cond.emit_clojure ~ ') ' ~ $block1.emit ~ ' ' ~ $block2.emit ~ ')';
}
}
@@ -502,12 +502,12 @@ class For {
has @.body;
has @.topic;
method emit_clojure {
- my $cond := $.cond;
- my $block := MiniPerl6::Clojure::LexicalBlock.new( block => @.body );
+ my $cond = $.cond;
+ my $block = MiniPerl6::Clojure::LexicalBlock.new( block => @.body );
if $cond.isa( 'Var' )
&& $cond.sigil eq '@'
{
- $cond := Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
+ $cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
'(dolist (' ~ $.topic.emit_clojure ~ ' ' ~ $cond.emit ~ ') ' ~ $block.emit ~ ')';
}
@@ -518,8 +518,8 @@ class Decl {
has $.type;
has $.var;
method emit_clojure {
- my $decl := $.decl;
- my $name := $.var.name;
+ my $decl = $.decl;
+ my $name = $.var.name;
( $decl eq 'has' )
?? ( 'sub ' ~ $name ~ ' { ' ~
'@_ == 1 ' ~
@@ -553,17 +553,17 @@ class Sub {
has $.sig;
has @.block;
method emit_clojure {
- my $sig := $.sig;
- my $pos := $sig.positional;
- my $block := MiniPerl6::Clojure::LexicalBlock.new( block => @.block );
+ my $sig = $.sig;
+ my $pos = $sig.positional;
+ my $block = MiniPerl6::Clojure::LexicalBlock.new( block => @.block );
my $str;
if @$pos {
for @$pos -> $field {
- $str := $str ~ $field.emit_clojure ~ ' ';
+ $str = $str ~ $field.emit_clojure ~ ' ';
}
}
if $str {
- $str := '&optional ' ~ $str;
+ $str = '&optional ' ~ $str;
}
if $.name {
@@ -584,7 +584,7 @@ class Sub {
class Do {
has @.block;
method emit_clojure {
- my $block := MiniPerl6::Clojure::LexicalBlock.new( block => @.block );
+ my $block = MiniPerl6::Clojure::LexicalBlock.new( block => @.block );
return $block.emit_clojure;
}
}
View
108 lib/MiniPerl6/Emitter/Token.pm
@@ -6,16 +6,16 @@ use v6;
class Rul {
sub constant ( $str ) {
- my $len := $str.chars;
+ my $len = $str.chars;
if $str eq '\\' {
- $str := '\\\\';
+ $str = '\\\\';
};
if $str eq '\'' {
- $str := '\\\'';
+ $str = '\\\'';
};
if ( $len ) {
'( ( \'' ~ $str ~ '\' eq substr( $str, $MATCH.to, ' ~ $len ~ ')) ' ~
- ' ?? (1 + ( $MATCH.to := ' ~ $len ~ ' + $MATCH.to ))' ~
+ ' ?? (1 + ( $MATCH.to = ' ~ $len ~ ' + $MATCH.to ))' ~
' !! false ' ~
')';
}
@@ -40,21 +40,21 @@ class Rul::Quantifier {
$.term.set_captures_to_array;
return
'do { '
- ~ 'my $last_match_null := 0; '
- ~ 'my $last_pos := $MATCH.to; '
- ~ 'my $count := 0; '
+ ~ 'my $last_match_null = 0; '
+ ~ 'my $last_pos = $MATCH.to; '
+ ~ 'my $count = 0; '
~ 'while ' ~ $.term.emit ~ ' && ($last_match_null < 2) '
~ '{ '
~ 'if $last_pos == $MATCH.to { '
- ~ '$last_match_null := $last_match_null + 1; '
+ ~ '$last_match_null = $last_match_null + 1; '
~ '} '
~ 'else { '
- ~ '$last_match_null := 0; '
+ ~ '$last_match_null = 0; '
~ '} '
- ~ '$last_pos := $MATCH.to; '
- ~ '$count := $count + 1; '
+ ~ '$last_pos = $MATCH.to; '
+ ~ '$count = $count + 1; '
~ '}; '
- ~ '$MATCH.to := $last_pos; '
+ ~ '$MATCH.to = $last_pos; '
~ '$count > 0; '
~ '}';
}
@@ -62,19 +62,19 @@ class Rul::Quantifier {
$.term.set_captures_to_array;
return
'do { '
- ~ 'my $last_match_null := 0; '
- ~ 'my $last_pos := $MATCH.to; '
+ ~ 'my $last_match_null = 0; '
+ ~ 'my $last_pos = $MATCH.to; '
~ 'while ' ~ $.term.emit ~ ' && ($last_match_null < 2) '
~ '{ '
~ 'if $last_pos == $MATCH.to { '
- ~ '$last_match_null := $last_match_null + 1; '
+ ~ '$last_match_null = $last_match_null + 1; '
~ '} '
~ 'else { '
- ~ '$last_match_null := 0; '
+ ~ '$last_match_null = 0; '
~ '} '
- ~ '$last_pos := $MATCH.to; '
+ ~ '$last_pos = $MATCH.to; '
~ '}; '
- ~ '$MATCH.to := $last_pos; '
+ ~ '$MATCH.to = $last_pos; '
~ '1 '
~ '}';
}
@@ -82,10 +82,10 @@ class Rul::Quantifier {
$.term.set_captures_to_array;
return
'do { '
- ~ 'my $last_pos := $MATCH.to; '
+ ~ 'my $last_pos = $MATCH.to; '
~ 'if !(do {' ~ $.term.emit ~ '}) '
~ '{ '
- ~ '$MATCH.to := $last_pos; '
+ ~ '$MATCH.to = $last_pos; '
~ '}; '
~ '1 '
~ '}';
@@ -104,8 +104,8 @@ class Rul::Or {
has @.or_list;
method emit {
'do { ' ~
- 'my $pos1 := $MATCH.to; do{ ' ~
- (@.or_list.>>emit).join('} || do { $MATCH.to := $pos1; ') ~
+ 'my $pos1 = $MATCH.to; do{ ' ~
+ (@.or_list.>>emit).join('} || do { $MATCH.to = $pos1; ') ~
'} }';
}
method set_captures_to_array {
@@ -127,39 +127,39 @@ class Rul::Subrule {
has $.metasyntax;
has $.captures;
method emit {
- my $meth := ( 1 + index( $.metasyntax, '.' ) )
+ my $meth = ( 1 + index( $.metasyntax, '.' ) )
?? $.metasyntax
!! ( '$grammar.' ~ $.metasyntax );
my $code;
if $.captures == 1 {
- $code := 'if $m2 { $MATCH.to := $m2.to; $MATCH{\'' ~ $.metasyntax ~ '\'} := $m2; 1 } else { false } '
+ $code = 'if $m2 { $MATCH.to = $m2.to; $MATCH{\'' ~ $.metasyntax ~ '\'} = $m2; 1 } else { false } '
}
elsif $.captures > 1 {
# TODO: capture level > 2
- $code := 'if $m2 { '
- ~ '$MATCH.to := $m2.to; '
+ $code = 'if $m2 { '
+ ~ '$MATCH.to = $m2.to; '
~ 'if exists $MATCH{\'' ~ $.metasyntax ~ '\'} { '
~ '($MATCH{\'' ~ $.metasyntax ~ '\'}).push( $m2 ); '
~ '} '
~ 'else { '
- ~ '$MATCH{\'' ~ $.metasyntax ~ '\'} := [ $m2 ]; '
+ ~ '$MATCH{\'' ~ $.metasyntax ~ '\'} = [ $m2 ]; '
~ '} '
~ '1 '
~ '} else { false } '
}
else {
- $code := 'if $m2 { $MATCH.to := $m2.to; 1 } else { false } '
+ $code = 'if $m2 { $MATCH.to = $m2.to; 1 } else { false } '
}
'do { '
- ~ 'my $m2 := ' ~ $meth ~ '($str, $MATCH.to); '
+ ~ 'my $m2 = ' ~ $meth ~ '($str, $MATCH.to); '
~ $code
~ '}'
}
method set_captures_to_array {
if $.captures > 0 {
- $.captures := $.captures + 1;
+ $.captures = $.captures + 1;
}
}
}
@@ -174,7 +174,7 @@ class Rul::Var {
# @x => $List_x
# %x => $Hash_x
# &x => $Code_x
- my $table := {
+ my $table = {
'$' => '$',
'@' => '$List_',
'%' => '$Hash_',
@@ -187,7 +187,7 @@ class Rul::Var {
class Rul::Constant {
has $.constant;
method emit {
- my $str := $.constant;
+ my $str = $.constant;
Rul::constant( $str );
}
method set_captures_to_array { }
@@ -196,7 +196,7 @@ class Rul::Constant {
class Rul::Dot {
method emit {
'( (\'\' ne substr( $str, $MATCH.to, 1 )) ' ~
- ' ?? (1 + ($MATCH.to := 1 + $MATCH.to ))' ~
+ ' ?? (1 + ($MATCH.to = 1 + $MATCH.to ))' ~
' !! false ' ~
')';
}
@@ -206,25 +206,25 @@ class Rul::Dot {
class Rul::SpecialChar {
has $.char;
method emit {
- my $char := $.char;
+ my $char = $.char;
if $char eq 'n' {
- my $rul := Rul::Subrule.new( metasyntax => 'is_newline', captures => 0 );
- $rul := $rul.emit;
+ my $rul = Rul::Subrule.new( metasyntax => 'is_newline', captures => 0 );
+ $rul = $rul.emit;
return $rul;
};
if $char eq 'N' {
- my $rul := Rul::Subrule.new( metasyntax => 'not_newline', captures => 0 );
- $rul := $rul.emit;
+ my $rul = Rul::Subrule.new( metasyntax => 'not_newline', captures => 0 );
+ $rul = $rul.emit;
return $rul;
};
if $char eq 'd' {
- my $rul := Rul::Subrule.new( metasyntax => 'digit', captures => 0 );
- $rul := $rul.emit;
+ my $rul = Rul::Subrule.new( metasyntax => 'digit', captures => 0 );
+ $rul = $rul.emit;
return $rul;
};
if $char eq 's' {
- my $rul := Rul::Subrule.new( metasyntax => 'space', captures => 0 );
- $rul := $rul.emit;
+ my $rul = Rul::Subrule.new( metasyntax => 'space', captures => 0 );
+ $rul = $rul.emit;
return $rul;
};
return Rul::constant( $char );
@@ -253,7 +253,7 @@ class Rul::NamedCapture {
has $.rule_exp;
has $.capture_ident;
method emit {
- say '# TODO: named capture ' ~ $.capture_ident ~ ' := ' ~ $.rule_exp.emit ~ '';
+ say '# TODO: named capture ' ~ $.capture_ident ~ ' = ' ~ $.rule_exp.emit ~ '';
die();
}
method set_captures_to_array {
@@ -265,13 +265,13 @@ class Rul::Before {
has $.rule_exp;
method emit {
'do { ' ~
- 'my $tmp := $MATCH; ' ~
- '$MATCH := MiniPerl6::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
- '$MATCH.bool := ' ~
+ 'my $tmp = $MATCH; ' ~
+ '$MATCH = MiniPerl6::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
+ '$MATCH.bool = ' ~
$.rule_exp.emit ~
'; ' ~
- '$tmp.bool := ?$MATCH; ' ~
- '$MATCH := $tmp; ' ~
+ '$tmp.bool = ?$MATCH; ' ~
+ '$MATCH = $tmp; ' ~
'?$MATCH; ' ~
'}'
}
@@ -282,13 +282,13 @@ class Rul::NotBefore {
has $.rule_exp;
method emit {
'do { ' ~
- 'my $tmp := $MATCH; ' ~
- '$MATCH := MiniPerl6::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
- '$MATCH.bool := ' ~
+ 'my $tmp = $MATCH; ' ~
+ '$MATCH = MiniPerl6::Match.new( \'str\' => $str, \'from\' => $tmp.to, \'to\' => $tmp.to, \'bool\' => 1 ); ' ~
+ '$MATCH.bool = ' ~
$.rule_exp.emit ~
'; ' ~
- '$tmp.bool := !$MATCH; ' ~
- '$MATCH := $tmp; ' ~
+ '$tmp.bool = !$MATCH; ' ~
+ '$MATCH = $tmp; ' ~
'?$MATCH; ' ~
'}'
}
@@ -343,7 +343,7 @@ MiniPerl6::Emitter::Token - Code generator for MiniPerl6 Regex
=head1 SYNOPSIS
- my $match := $source.rule;
+ my $match = $source.rule;
($$match).emit; # generated MiniPerl6 source code
=head1 DESCRIPTION
View
84 lib/MiniPerl6/Eval.pm
@@ -6,7 +6,7 @@ class CompUnit {
has %.methods;
has @.body;
method eval ($env) {
- my $env1 := [ {}, @$env ];
+ my $env1 = [ {}, @$env ];
for @.body -> $stmt {
$stmt.eval($env1);
}
@@ -62,7 +62,7 @@ class Lit::Hash {
method eval ($env) {
my %h;
for @.hash1 -> $field {
- %h{ ($field[0]).eval($env) } := ($field[1]).eval($env);
+ %h{ ($field[0]).eval($env) } = ($field[1]).eval($env);
};
return %h;
}
@@ -73,10 +73,10 @@ class Lit::Object {
has @.fields;
method eval ($env) {
warn "Interpreter TODO: Lit::Object";
- my $fields := @.fields;
- my $str := '';
+ my $fields = @.fields;
+ my $str = '';
for @$fields -> $field {
- $str := $str ~ ($field[0]).eval ~ ' => ' ~ ($field[1]).eval ~ ',';
+ $str = $str ~ ($field[0]).eval ~ ' => ' ~ ($field[1]).eval ~ ',';
};
$.class ~ '->new( ' ~ $str ~ ' )';
}
@@ -104,9 +104,9 @@ class Var {
has $.namespace;
has $.name;
method eval ($env) {
- my $ns := '';
+ my $ns = '';
if $.namespace {
- $ns := $.namespace ~ '::';
+ $ns = $.namespace ~ '::';
}
else {
if ($.sigil eq '@') && ($.twigil eq '*') && ($.name eq 'ARGS') {
@@ -122,7 +122,7 @@ class Var {
}
}
- my $name := $.sigil ~ $ns ~ $.name;
+ my $name = $.sigil ~ $ns ~ $.name;
for @($env) -> $e {
if exists( $e{ $name } ) {
return $e{ $name };
@@ -154,11 +154,11 @@ class Bind {
if $.parameters.isa( 'Decl' ) {
$.parameters.eval($env);
}
- my $name := $.parameters.plain_name;
- my $value := $.arguments.eval($env);
+ my $name = $.parameters.plain_name;
+ my $value = $.arguments.eval($env);
for @($env) -> $e {
if exists( $e{ $name } ) {
- $e{ $name } := $value;
+ $e{ $name } = $value;
return $value;
}
}
@@ -180,9 +180,9 @@ class Call {
has @.arguments;
method eval ($env) {
warn "Interpreter TODO: Call";
- my $invocant := $.invocant.eval($env);
+ my $invocant = $.invocant.eval($env);
if $invocant eq 'self' {
- $invocant := '$self';
+ $invocant = '$self';
}
if ($.hyper) {
# '[ map { $_' ~ $call ~ ' } @{ ' ~ $invocant ~ ' } ]';
@@ -199,11 +199,11 @@ class Apply {
has @.arguments;
has $.namespace;
method eval ($env) {
- my $ns := '';
+ my $ns = '';
if $.namespace {
- $ns := $.namespace ~ '::';
+ $ns = $.namespace ~ '::';
}
- my $code := $ns ~ $.code;
+ my $code = $ns ~ $.code;
# warn "Apply ", $env.perl, " code: '", $code, "'";
for @($env) -> $e {
if exists( $e{ $code } ) {
@@ -228,27 +228,27 @@ class If {
has @.body;
has @.otherwise;
method eval ($env) {
- my $cond := $.cond;
+ my $cond = $.cond;
if $cond.isa( 'Apply' )
&& $cond.code eq 'prefix:<!>'
{
- my $if := If.new( cond => ($cond.arguments)[0], body => @.otherwise, otherwise => @.body );
+ my $if = If.new( cond => ($cond.arguments)[0], body => @.otherwise, otherwise => @.body );
return $if.eval($env);
}
# if $cond.isa( 'Var' )
# && $cond.sigil eq '@'
# {
- # $cond := Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
+ # $cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
# }
if $cond.eval($env) {
- my $env1 := [ {}, @$env ];
+ my $env1 = [ {}, @$env ];
for @.body -> $stmt {
$stmt.eval($env1);
}
}
else {
- my $env1 := [ {}, @$env ];
+ my $env1 = [ {}, @$env ];
for @.otherwise -> $stmt {
$stmt.eval($env1);
}
@@ -262,16 +262,16 @@ class For {
has @.body;
has @.topic;
method eval ($env) {
- my $cond := $.cond;
+ my $cond = $.cond;
# if $cond.isa( 'Var' )
# && $cond.sigil eq '@'
# {
- # $cond := Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
+ # $cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
# }
- my $topic_name := $.topic.plain_name;
- my $env1 := [ {}, @$env ];
+ my $topic_name = $.topic.plain_name;
+ my $env1 = [ {}, @$env ];
for @( $cond.eval($env) ) -> $topic {
- $env1[0] := { $topic_name => $topic };
+ $env1[0] = { $topic_name => $topic };
for @.body -> $stmt {
$stmt.eval($env1);
}
@@ -301,13 +301,13 @@ class Decl {
has $.type;
has $.var;
method eval ($env) {
- my $decl := $.decl;
- my $name := $.var.plain_name;
+ my $decl = $.decl;
+ my $name = $.var.plain_name;
if $decl eq 'has' {
warn "Interpreter TODO: has";
}
if !( exists ($env[0]){ $name } ) {
- ($env[0]){ $name } := undef;
+ ($env[0]){ $name } = undef;
}
return undef;
}
@@ -331,10 +331,10 @@ class Method {
has @.block;
method eval ($env) {
warn "Interpreter TODO: Method";
- my $sig := $.sig;
- my $invocant := $sig.invocant;
- my $pos := $sig.positional;
- my $str := 'my $List__ = \\@_; ';
+ my $sig = $.sig;
+ my $invocant = $sig.invocant;
+ my $pos = $sig.positional;
+ my $str = 'my $List__ = \\@_; ';
# ...
}
@@ -349,24 +349,24 @@ class Sub {
for @( $.sig.positional ) -> $field {
push( @param_name, $field.plain_name );
}
- my $sub :=
+ my $sub =
sub ( $env, $args ) {
my %context;
- my $n := 0;
- %context{'@_'} := $args;
+ my $n = 0;
+ %context{'@_'} = $args;
for @param_name -> $name {
- %context{$name} := ($args[$n]).eval($env);
- $n := $n + 1;
+ %context{$name} = ($args[$n]).eval($env);
+ $n = $n + 1;
}
- my $env1 := [ %context, @$env ];
+ my $env1 = [ %context, @$env ];
my $r;
for @.block -> $stmt {
- $r := $stmt.eval($env1);
+ $r = $stmt.eval($env1);
}
return $r;
};
if $.name {
- ($env[0]){$.name} := $sub;
+ ($env[0]){$.name} = $sub;
}
return $sub;
}
@@ -375,7 +375,7 @@ class Sub {
class Do {
has @.block;
method eval ($env) {
- my $env1 := [ {}, @$env ];
+ my $env1 = [ {}, @$env ];
for @.block -> $stmt {
$stmt.eval($env1);
}
View
330 lib/MiniPerl6/Go/Emitter.pm
@@ -8,61 +8,61 @@ class MiniPerl6::Go::LexicalBlock {
if !(@.block) {
return '';
}
- my $str := '';
+ my $str = '';
my %decl_seen;
for @.block -> $decl1 {
- my $decl := $decl1;
+ my $decl = $decl1;
if $decl.isa( 'Bind' ) && ($decl.parameters).isa( 'Decl' ) && ( ($decl.parameters).decl eq 'my' ) {
- $decl := $decl.parameters;
+ $decl = $decl.parameters;
}
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'my' ) {
- my $var_name := (($decl).var).emit_go;
+ my $var_name = (($decl).var).emit_go;
if !(%decl_seen{ $var_name }) {
- $str := $str ~ $decl.emit_go_init;
- %decl_seen{ $var_name } := 1;
+ $str = $str ~ $decl.emit_go_init;
+ %decl_seen{ $var_name } = 1;
}
}
}
my $last_statement;
if $.needs_return {
- $last_statement := pop @.block;
+ $last_statement = pop @.block;
}
for @.block -> $decl {
if (!( $decl.isa( 'Decl' ) && ( $decl.decl eq 'my' ))) {
- $str := $str ~ ($decl).emit_go ~ ';';
+ $str = $str ~ ($decl).emit_go ~ ';';
}
};
if $.needs_return && $last_statement {
if $last_statement.isa( 'If' ) {
- my $cond := $last_statement.cond;
- my $body := $last_statement.body;
- my $otherwise := $last_statement.otherwise;
+ my $cond = $last_statement.cond;
+ my $body = $last_statement.body;
+ my $otherwise = $last_statement.otherwise;
if $cond.isa( 'Apply' ) && $cond.code eq 'prefix:<!>' {
- $cond := ($cond.arguments)[0];
- $body := $last_statement.otherwise;
- $otherwise := $last_statement.body;
+ $cond = ($cond.arguments)[0];
+ $body = $last_statement.otherwise;
+ $otherwise = $last_statement.body;
}
if $cond.isa( 'Var' ) && $cond.sigil eq '@' {
- $cond := Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
+ $cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
- $body := MiniPerl6::Go::LexicalBlock.new( block => $body, needs_return => 1, top_level => $.top_level );
- $otherwise := MiniPerl6::Go::LexicalBlock.new( block => $otherwise, needs_return => 1, top_level => $.top_level );
- $str := $str
+ $body = MiniPerl6::Go::LexicalBlock.new( block => $body, needs_return => 1, top_level => $.top_level );
+ $otherwise = MiniPerl6::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 { '
~ $otherwise.emit_go ~ ' }';
}
elsif $last_statement.isa( 'Return' ) || $last_statement.isa( 'For' ) {
# Return, For - no changes for now
- $str := $str ~ $last_statement.emit_go
+ $str = $str ~ $last_statement.emit_go
}
else {
- $last_statement := Return.new( result => $last_statement );
+ $last_statement = Return.new( result => $last_statement );
if $.top_level {
- $str := $str ~ $last_statement.emit_go
+ $str = $str ~ $last_statement.emit_go
}
else {
- $str := $str ~ $last_statement.emit_go_simple
+ $str = $str ~ $last_statement.emit_go_simple
}
}
}
@@ -76,48 +76,48 @@ class CompUnit {
has %.methods;
has @.body;
method emit_go {
- my $class_name := Main::to_go_namespace($.name);
- my $str :=
+ my $class_name = Main::to_go_namespace($.name);
+ my $str =
'// instances of class ' ~ $.name ~ "\n"
~ 'type ' ~ $class_name ~ ' struct {' ~ "\n";
for (%.attributes).values -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'has' ) {
- $str := $str ~ ' ' ~ 'v_' ~ ($decl.var).name ~ ' *Any;' ~ "\n"
+ $str = $str ~ ' ' ~ 'v_' ~ ($decl.var).name ~ ' *Any;' ~ "\n"
}
}
- $str := $str ~ '}' ~ "\n";
+ $str = $str ~ '}' ~ "\n";
- $str := $str
+ $str = $str
~ '// methods in class ' ~ $.name ~ "\n"
~ 'var Method_' ~ $class_name ~ ' struct {' ~ "\n";
for (%.methods).values -> $decl {
if $decl.isa( 'Method' ) {
- $str := $str ~ ' ' ~ 'f_' ~ $decl.name ~ ' func (*' ~ $class_name ~ ', Capture) *Any;' ~ "\n";
+ $str = $str ~ ' ' ~ 'f_' ~ $decl.name ~ ' func (*' ~ $class_name ~ ', Capture) *Any;' ~ "\n";
}
}
for (%.attributes).values -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'has' ) {
- $str := $str ~ ' ' ~ 'f_' ~ ($decl.var).name ~ ' func (*' ~ $class_name ~ ', Capture) *Any;' ~ "\n";
+ $str = $str ~ ' ' ~ 'f_' ~ ($decl.var).name ~ ' func (*' ~ $class_name ~ ', Capture) *Any;' ~ "\n";
}
}
- $str := $str ~ '}' ~ "\n";
+ $str = $str ~ '}' ~ "\n";
- $str := $str
+ $str = $str
~ '// namespace ' ~ $.name ~ "\n"
~ 'var Namespace_' ~ $class_name ~ ' struct {' ~ "\n";
for @.body -> $decl {
if $decl.isa( 'Sub' ) {
- $str := $str ~ ' ' ~ 'f_' ~ $decl.name ~ ' Function;' ~ "\n";
+ $str = $str ~ ' ' ~ 'f_' ~ $decl.name ~ ' Function;' ~ "\n";
}
}
- $str := $str ~ '}' ~ "\n";
- $str := $str ~ 'var Run_' ~ $class_name ~ ' func ();' ~ "\n";
+ $str = $str ~ '}' ~ "\n";
+ $str = $str ~ 'var Run_' ~ $class_name ~ ' func ();' ~ "\n";
- $str := $str
+ $str = $str
~ '// method wrappers for ' ~ $.name ~ "\n";
for (%.methods).values -> $decl {
if $decl.isa( 'Method' ) {
- $str := $str
+ $str = $str
~ 'func (v_self *' ~ $class_name ~ ') f_' ~ $decl.name ~ ' (v Capture) *Any {' ~ "\n"
~ ' return Method_' ~ $class_name ~ '.f_' ~ $decl.name ~ '(v_self, v);'~ "\n"
~ '}'~ "\n";
@@ -125,50 +125,50 @@ class CompUnit {
}
for (%.attributes).values -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'has' ) {
- $str := $str
+ $str = $str
~ 'func (v_self *' ~ $class_name ~ ') f_' ~ ($decl.var).name ~ ' (v Capture) *Any {' ~ "\n"
~ ' return Method_' ~ $class_name ~ '.f_' ~ ($decl.var).name ~ '(v_self, v);'~ "\n"
~ '}'~ "\n";
}
}
if !( (%.methods){'isa'} ) {
- $str := $str ~ 'func (v_self *' ~ $class_name ~ ') f_isa (v Capture) *Any { '
+ $str = $str ~ 'func (v_self *' ~ $class_name ~ ') f_isa (v Capture) *Any { '
~ 'return toBool( "' ~ $.name ~ '" == tostr( v.p[0] ) ) '
~ '}' ~ "\n";
}
if !( (%.methods){'perl'} ) {
- $str := $str ~ 'func (v_self *' ~ $class_name ~ ') f_perl (v Capture) *Any { '
+ $str = $str ~ 'func (v_self *' ~ $class_name ~ ') f_perl (v Capture) *Any { '
~ 'return toStr( "::' ~ $.name ~ '(" ';
- my $sep := '';
+ my $sep = '';
for (%.attributes).values -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'has' ) {
- $str := $str
+ $str = $str
~ $sep
~ '+ "' ~ ($decl.var).name ~ ' => "'
~ '+ tostr((*(*v_self).f_' ~ ($decl.var).name ~ '(Capture{})).(perl_er).f_perl(Capture{})) ';
- $sep := '+ ", " ';
+ $sep = '+ ", " ';
}
}
- $str := $str ~ '+ ")" ) }' ~ "\n";
+ $str = $str ~ '+ ")" ) }' ~ "\n";
}
if (!( (%.methods){'Bool'} ))
&& (!( (%.attributes){'Bool'} ))
{
- $str := $str ~ 'func (v_self *' ~ $class_name ~ ') f_Bool (v Capture) *Any { '
+ $str = $str ~ 'func (v_self *' ~ $class_name ~ ') f_Bool (v Capture) *Any { '
~ 'return b_true() '
~ '}' ~ "\n";
}
- $str := $str
+ $str = $str
~ '// prototype of ' ~ $.name ~ "\n"
~ 'var Proto_' ~ $class_name ~ ' *Any;' ~ "\n";
- $str := $str ~ 'func Init_' ~ $class_name ~ '() {' ~ "\n";
+ $str = $str ~ 'func Init_' ~ $class_name ~ '() {' ~ "\n";
- $str := $str
+ $str = $str
~ ' this_namespace := &Namespace_' ~ $class_name ~ ';' ~ "\n"
~ ' this_namespace = this_namespace;' ~ "\n";
- $str := $str
+ $str = $str
~ ' Proto_' ~ $class_name ~ ' = '
~ 'func() *Any { '
~ 'var m = new(' ~ $class_name ~ '); '
@@ -178,15 +178,15 @@ class CompUnit {
my %decl_seen;
for @.body -> $decl1 {
- my $decl := $decl1;
+ my $decl = $decl1;
if $decl.isa( 'Bind' ) && ($decl.parameters).isa( 'Decl' ) && ( ($decl.parameters).decl eq 'my' ) {
- $decl := $decl.parameters;
+ $decl = $decl.parameters;
}
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'my' ) {
- my $var_name := (($decl).var).emit_go;
+ my $var_name = (($decl).var).emit_go;
if !(%decl_seen{ $var_name }) {
- $str := $str ~ $decl.emit_go_init;
- %decl_seen{ $var_name } := 1;
+ $str = $str ~ $decl.emit_go_init;
+ %decl_seen{ $var_name } = 1;
}
}
@@ -194,12 +194,12 @@ class CompUnit {
for @.body -> $decl {
if $decl.isa( 'Decl' ) && ( $decl.decl eq 'has' ) {
- $str := $str
+ $str = $str
~ ' // accessor ' ~ ($decl.var).name ~ "\n"
~ ' Method_' ~ $class_name ~ '.f_' ~ ($decl.var).name
~ ' = func (v_self *' ~ $class_name ~ ', v Capture) *Any {' ~ "\n";
- $str := $str
+ $str = $str
~ ' ' ~ 'if v_self.v_' ~ ($decl.var).name ~ ' == nil {' ~ "\n"
~ ' ' ~ (Decl.new(
decl => 'my',
@@ -210,7 +210,7 @@ class CompUnit {
~ (Var.new( sigil => ($decl.var).sigil, twigil => '', namespace => '', name => 'tmp' )).emit_go ~ ';' ~ "\n"
~ ' ' ~ '}' ~ "\n";
- $str := $str
+ $str = $str
~ ' ' ~ 'if *v_self.v_' ~ ($decl.var).name ~ ' == nil {' ~ "\n"
~ ' ' ~ (Decl.new(
decl => 'my',
@@ -221,46 +221,46 @@ class CompUnit {
~ (Var.new( sigil => ($decl.var).sigil, twigil => '', namespace => '', name => 'tmp' )).emit_go ~ ';' ~ "\n"
~ ' ' ~ '}' ~ "\n";
- $str := $str
+ $str = $str
~ ' ' ~ 'return v_self.v_' ~ ($decl.var).name ~ "\n"
~ ' };' ~ "\n";
}
if $decl.isa( 'Method' ) {
- my $sig := $decl.sig;
- my $block := MiniPerl6::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
- $str := $str
+ my $sig = $decl.sig;
+ my $block = MiniPerl6::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ $str = $str
~ ' // method ' ~ $decl.name ~ "\n"
~ ' Method_' ~ $class_name ~ '.f_' ~ $decl.name
~ ' = func (self *' ~ $class_name ~ ', v Capture) *Any {' ~ "\n";
- $str := $str
+ $str = $str
~ ' var self1 Any = self;' ~ "\n"
~ ' var ' ~ ($sig.invocant).emit_go ~ ' *Any = &self1;' ~ "\n"
~ ' ' ~ ($sig.invocant).emit_go ~ ' = ' ~ ($sig.invocant).emit_go ~ ';' ~ "\n"
~ ' ' ~ $sig.emit_go_bind ~ "\n";
- $str := $str
+ $str = $str
~ ' p := make(chan *Any); go func () { ' ~ "\n"
~ ' ' ~ $block.emit_go ~ '; p <- nil }(); ' ~ "\n"
~ ' return <-p; ' ~ "\n"
~ ' };' ~ "\n"
}
if $decl.isa( 'Sub' ) {
- my $sig := $decl.sig;
- my $block := MiniPerl6::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
- $str := $str
+ my $sig = $decl.sig;
+ my $block = MiniPerl6::Go::LexicalBlock.new( block => $decl.block, needs_return => 1, top_level => 1 );
+ $str = $str
~ ' // sub ' ~ $decl.name ~ "\n"
~ ' Namespace_' ~ $class_name ~ '.f_' ~ $decl.name
~ ' = Function( func (v Capture) *Any {' ~ "\n";
- $str := $str
+ $str = $str
~ ' ' ~ $sig.emit_go_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
~ ' ' ~ $block.emit_go ~ '; p <- nil }(); ' ~ "\n";
- $str := $str
+ $str = $str
~ ' return <-p; ' ~ "\n"
~ ' } );' ~ "\n";
}
};
- $str := $str
+ $str = $str
~ ' // main runtime block of ' ~ $.name ~ "\n"
~ ' Run_' ~ $class_name ~ ' = func () {' ~ "\n";
for @.body -> $decl {
@@ -268,17 +268,17 @@ class CompUnit {
&& (!( $decl.isa( 'Method')))
&& (!( $decl.isa( 'Sub')))
{
- $str := $str ~ ' ' ~ ($decl).emit_go ~ ';' ~ "\n";
+ $str = $str ~ ' ' ~ ($decl).emit_go ~ ';' ~ "\n";
}
};
- $str := $str ~ ' }' ~ "\n";
+ $str = $str ~ ' }' ~ "\n";
- $str := $str ~ '}' ~ "\n";
+ $str = $str ~ '}' ~ "\n";
return $str;
}
sub emit_go_program( $comp_units ) {
- my $str := '';
+ my $str = '';
# join classes that have the same name
# if there are method or accessor collisions, classes declared later have higher priority
@@ -286,26 +286,26 @@ class CompUnit {
my %unit_seen;
my @tmp_comp_unit;
for @($comp_units) -> $comp_unit {
- my $name := $comp_unit.name;
+ my $name = $comp_unit.name;
if %unit_seen{$name} {
for @( $comp_unit.body ) -> $stmt {
push (%unit_seen{$name}).body, $stmt;
}
}
else {
- %unit_seen{$name} := $comp_unit;
+ %unit_seen{$name} = $comp_unit;
push @tmp_comp_unit, $comp_unit;
}
}
- $comp_units := @tmp_comp_unit;
+ $comp_units = @tmp_comp_unit;
for @($comp_units) -> $comp_unit {
for @( $comp_unit.body ) -> $stmt {
if $stmt.isa('Method') {
- ($comp_unit.methods){ $stmt.name } := $stmt;
+ ($comp_unit.methods){ $stmt.name } = $stmt;
}
if $stmt.isa('Decl') && ( $stmt.decl eq 'has' ) {
- ($comp_unit.attributes){ ($stmt.var).name } := $stmt;
+ ($comp_unit.attributes){ ($stmt.var).name } = $stmt;
}
}
}
@@ -313,13 +313,13 @@ class CompUnit {
# emit the code for all classes
for @($comp_units) -> $comp_unit {
- $str := $str ~ $comp_unit.emit_go;
+ $str = $str ~ $comp_unit.emit_go;
}
if !(%unit_seen{"MiniPerl6::Grammar"}) {
- $str := $str ~ "type MiniPerl6__Grammar struct{}\n";
+ $str = $str ~ "type MiniPerl6__Grammar struct{}\n";
}
- $str := $str ~ "// interfaces for all methods\n";
- my %meth_seen := {
+ $str = $str ~ "// interfaces for all methods\n";
+ my %meth_seen = {
join => 1,
perl => 1,
scalar => 1,
@@ -346,37 +346,37 @@ class CompUnit {
for @($comp_units) -> $comp_unit {
for @( $comp_unit.body ) -> $stmt {
if $stmt.isa('Method') && !(%meth_seen{ $stmt.name }) {
- my $meth := $stmt.name;
- $str := $str ~ "type "
+ my $meth = $stmt.name;
+ $str = $str ~ "type "
~ $meth
~ "_er interface { f_"
~ $meth
~ " (Capture) *Any }\n";
- %meth_seen{$meth} := 1;
+ %meth_seen{$meth} = 1;
}
if $stmt.isa('Decl') && ( $stmt.decl eq 'has' ) && !(%meth_seen{ ($stmt.var).name }) {
- my $meth := ($stmt.var).name;
- $str := $str ~ "type "
+ my $meth = ($stmt.var).name;
+ $str = $str ~ "type "
~ $meth
~ "_er interface { f_"
~ $meth
~ " (Capture) *Any }\n";
- %meth_seen{$meth} := 1;
+ %meth_seen{$meth} = 1;
}
}
}
- $str := $str ~ "\n"
+ $str = $str ~ "\n"
~ "func main () {\n"
~ " Init_MiniPerl6__Match();\n";
for @($comp_units) -> $comp_unit {
- $str := $str ~ " Init_" ~ Main::to_go_namespace( $comp_unit.name ) ~ "();\n"
+ $str = $str ~ " Init_" ~ Main::to_go_namespace( $comp_unit.name ) ~ "();\n"
}
- $str := $str ~ " Init_Prelude();\n";
+ $str = $str ~ " Init_Prelude();\n";
for @($comp_units) -> $comp_unit {
- $str := $str ~ " Run_" ~ Main::to_go_namespace( $comp_unit.name ) ~ "();\n"
+ $str = $str ~ " Run_" ~ Main::to_go_namespace( $comp_unit.name ) ~ "();\n"
}
- $str := $str ~ '}' ~ "\n";
+ $str = $str ~ '}' ~ "\n";
return $str;
}
}
@@ -416,18 +416,18 @@ class Val::Object {
class Lit::Array {
has @.array1;
method emit_go {
- my $str := '';
+ my $str = '';
for @.array1 -> $item {
if ( $item.isa( 'Var' ) && $item.sigil eq '@' )
|| ( $item.isa( 'Apply' ) && $item.code eq 'prefix:<@>' )
{
- $str := $str
+ $str = $str
~ 'func(a_ *Array) { '
~ 'for i_ := 0; i_ <= a_.n; i_++ { (*a).(push_er).f_push( Capture{ p: []*Any{ a_.v[i_] } } ) } '
~ '}( (*' ~ Call::emit_go_call( $item, 'array' ) ~ ').(*Array) ); '
}
else {
- $str := $str ~ '(*a).(push_er).f_push( Capture{ p: []*Any{ ' ~ $item.emit_go ~ ' } } ); '
+ $str = $str ~ '(*a).(push_er).f_push( Capture{ p: []*Any{ ' ~ $item.emit_go ~ ' } } ); '
}
}
'func () *Any { '
@@ -441,10 +441,10 @@ class Lit::Array {
class Lit::Hash {
has @.hash1;
method emit_go {
- my $fields := @.hash1;
- my $str := '';
+ my $fields = @.hash1;
+ my $str = '';
for @$fields -> $field {
- $str := $str
+ $str = $str
~ '*(*m).(lookup_er).f_lookup( Capture{ p : []*Any{ ' ~ ($field[0]).emit_go ~ ' }} ) = *(' ~ ($field[1]).emit_go ~ '); ';
};
'func() *Any { '
@@ -463,10 +463,10 @@ class Lit::Object {
has $.class;
has @.fields;
method emit_go {
- my $fields := @.fields;
- my $str := '';
+ my $fields = @.fields;
+ my $str = '';
for @$fields -> $field {
- $str := $str
+ $str = $str
~ 'if m.v_' ~ ($field[0]).buf ~ ' == nil {' ~ "\n"
~ 'var p Any; ' ~ "\n"
@@ -513,15 +513,15 @@ class Var {
# @x => $List_x
# %x => $Hash_x
# &x => $Code_x
- my $table := {
+ my $table = {
'$' => 'v_',
'@' => 'List_',
'%' => 'Hash_',
'&' => 'Code_',
};
- my $ns := '';
+ my $ns = '';
if $.namespace {
- $ns := Main::to_go_namespace($.namespace) ~ '.';
+ $ns = Main::to_go_namespace($.namespace) ~ '.';
}
( $.twigil eq '.' )
?? ( '(*v_self).(' ~ $.name ~ '_er).f_' ~ $.name ~ '(Capture{})' )
@@ -544,76 +544,76 @@ class Bind {
method emit_go {
if $.parameters.isa( 'Lit::Array' ) {
- # [$a, [$b, $c]] := [1, [2, 3]]
+ # [$a, [$b, $c]] = [1, [2, 3]]
- my $a := $.parameters.array1;
- #my $b := $.arguments.array1;
- my $str :=
+ my $a = $.parameters.array1;
+ #my $b = $.arguments.array1;
+ my $str =
'func () *Any { '
~ 'List_tmp := ' ~ $.arguments.emit_go ~ '; ';
- my $i := 0;
+ my $i = 0;
for @$a -> $var {
- my $bind := Bind.new(
+ my $bind = Bind.new(
parameters => $var,
arguments => Index.new(
obj => Var.new( sigil => '@', twigil => '', namespace => '', name => 'tmp' ),
index_exp => Val::Int.new( int => $i )
)
);
- $str := $str ~ ' ' ~ $bind.emit_go ~ '; ';
- $i := $i + 1;
+ $str = $str ~ ' ' ~ $bind.emit_go ~ '; ';
+ $i = $i + 1;
};
return $str ~ ' return List_tmp }()';
};
if $.parameters.isa( 'Lit::Hash' ) {
- # {:$a, :$b} := { a => 1, b => [2, 3]}
+ # {:$a, :$b} = { a => 1, b => [2, 3]}
- my $a := $.parameters.hash1;
- my $b := $.arguments.hash1;
- my $str := 'do { ';
- my $i := 0;
+ my $a = $.parameters.hash1;
+ my $b = $.arguments.hash1;
+ my $str = 'do { ';
+ my $i = 0;
my $arg;
for @$a -> $var {
- $arg := Val::Undef.new();
+ $arg = Val::Undef.new();
for @$b -> $var2 {
#say "COMPARE ", ($var2[0]).buf, ' eq ', ($var[0]).buf;
if ($var2[0]).buf eq ($var[0]).buf {
- $arg := $var2[1];
+ $arg = $var2[1];
}
};
- my $bind := Bind.new( parameters => $var[1], arguments => $arg );
- $str := $str ~ ' ' ~ $bind.emit_go ~ '; ';
- $i := $i + 1;
+ my $bind = Bind.new( parameters => $var[1], arguments => $arg );
+ $str = $str ~ ' ' ~ $bind.emit_go ~ '; ';
+ $i = $i + 1;
};
return $str ~ $.parameters.emit_go ~ ' }';
};
if $.parameters.isa( 'Lit::Object' ) {
- # Obj.new(:$a, :$b) := $obj
+ # Obj.new(:$a, :$b) = $obj
- my $class := $.parameters.class;
- my $a := $.parameters.fields;
- my $b := $.arguments;
- my $str := 'do { ';
- my $i := 0;
+ my $class = $.parameters.class;
+ my $a = $.parameters.fields;
+ my $b = $.arguments;
+ my $str = 'do { ';
+ my $i = 0;
my $arg;
for @$a -> $var {
- my $bind := Bind.new(
+ my $bind = Bind.new(
parameters => $var[1],
arguments => Call.new( invocant => $b, method => ($var[0]).buf, arguments => [ ], hyper => 0 )
);
- $str := $str ~ ' ' ~ $bind.emit_go ~ '; ';
- $i := $i + 1;
+ $str = $str ~ ' ' ~ $bind.emit_go ~ '; ';
+ $i = $i + 1;
};
return $str ~ $.parameters.emit_go ~ ' }';
};
if $.parameters.isa( 'Call' ) {
- # $var.attr := 3;
+ # $var.attr = 3;
return
'func () *Any { '
~ 'var tmp = ' ~ Call::emit_go_call( $.parameters.invocant, $.parameters.method ) ~ '; '
@@ -640,20 +640,20 @@ class Call {
has @.arguments;
#has $.hyper;
method emit_go {
- my $invocant := $.invocant.emit_go;
+ my $invocant = $.invocant.emit_go;
if ($.invocant).isa( 'Proto' ) {
if $.invocant.name eq 'self' {
- $invocant := 'v_self'
+ $invocant = 'v_self'
}
else {
- $invocant := 'Proto_' ~ $invocant
+ $invocant = 'Proto_' ~ $invocant
}
}
- my $meth := $.method;
+ my $meth = $.method;
if $meth eq 'postcircumfix:<( )>' {
if ($.hyper) {
- $meth := ''; # ???
+ $meth = ''; # ???
}
else {
# ((*v_a).(function_er).f_function(Capture{}))
@@ -679,11 +679,11 @@ class Call {
}
sub emit_go_call ( $invocant, $meth_name ) {
- my $invocant1 := $invocant.emit_go;
+ my $invocant1 = $invocant.emit_go;
if ($invocant).isa( 'Proto' ) {
- $invocant1 := 'Proto_' ~ $invocant1
+ $invocant1 = 'Proto_' ~ $invocant1
}
- my $meth := $meth_name;
+ my $meth = $meth_name;
return
'(*' ~ $invocant1 ~ ').(' ~ $meth ~ '_er).f_' ~ $meth ~ '(Capture{})';
}
@@ -694,7 +694,7 @@ class Apply {
has @.arguments;
has $.namespace;
method emit_go {
- my $code := $.code;
+ my $code = $.code;
if $code.isa( 'Str' ) { }
else {
@@ -765,7 +765,7 @@ class Apply {
~ ')'
};
if $code eq 'exists' {
- my $arg := @.arguments[0];
+ my $arg = @.arguments[0];
if $arg.isa( 'Lookup' ) {
return '(*' ~ ($arg.obj).emit_go ~ ')'
~ '.(exists_er).f_exists(Capture{ p : []*Any{ '
@@ -858,12 +858,12 @@ class Apply {
~ '}()'
};
- $code := 'f_' ~ $.code;
+ $code = 'f_' ~ $.code;
if $.namespace {
- $code := 'Namespace_' ~ Main::to_go_namespace($.namespace) ~ '.' ~ $code;
+ $code = 'Namespace_' ~ Main::to_go_namespace($.namespace) ~ '.' ~ $code;
}
else {
- $code := 'this_namespace.' ~ $code;
+ $code = 'this_namespace.' ~ $code;
}
$code ~ '( Capture{ p : []*Any{ ' ~ (@.arguments.>>emit_go).join(', ') ~ ' } } )';
}
@@ -873,7 +873,7 @@ class Return {
has $.result;
method emit_go {
if ($.result).isa( 'Bind' ) {
- my $tmp := ($.result).parameters;
+ my $tmp = ($.result).parameters;
return
'(func () { '
~ ($.result).emit_go ~ '; '
@@ -890,7 +890,7 @@ class Return {
}
method emit_go_simple {
if ($.result).isa( 'Bind' ) {
- my $tmp := ($.result).parameters;
+ my $tmp = ($.result).parameters;
return
'return (func () *Any { '
~ ($.result).emit_go ~ '; '
@@ -907,20 +907,20 @@ class If {
has @.body;
has @.otherwise;
method emit_go {
- my $cond := $.cond;
+ my $cond = $.cond;
if $cond.isa( 'Apply' )
&& $cond.code eq 'prefix:<!>'
{
- my $if := If.new( cond => ($cond.arguments)[0], body => @.otherwise, otherwise => @.body );
+ my $if = If.new( cond => ($cond.arguments)[0], body => @.otherwise, otherwise => @.body );
return $if.emit_go;
}
if $cond.isa( 'Var' )
&& $cond.sigil eq '@'
{
- $cond := Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
+ $cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
- my $s := 'if tobool( ' ~ Call::emit_go_call( $cond, 'Bool' ) ~ ' ) { '
+ my $s = 'if tobool( ' ~ Call::emit_go_call( $cond, 'Bool' ) ~ ' ) { '
~ (MiniPerl6::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go
~ ' }';
if !(@.otherwise) {
@@ -959,11 +959,11 @@ class While {
has $.cond;
has @.body;
method emit_go {
- my $cond := $.cond;
+ my $cond = $.cond;
if $cond.isa( 'Var' )
&& $cond.sigil eq '@'
{
- $cond := Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
+ $cond = Apply.new( code => 'prefix:<@>', arguments => [ $cond ] );
};
return 'for ;tobool( ' ~ Call::emit_go_call( $cond, 'Bool' ) ~ ' ); { '
~ (MiniPerl6::Go::LexicalBlock.new( block => @.body, needs_return => 0 )).emit_go
@@ -984,17 +984,17 @@ class Decl {
}
method emit_go_init {
if $.decl eq 'my' {
- my $str := "";
- $str := $str ~ 'var ' ~ ($.var).emit_go ~ ' *Any;' ~ "\n";
- $str := $str ~ ($.var).emit_go ~ ' = ' ~ ($.var).emit_go ~ ';' ~ "\n";
+ my $str = "";
+ $str = $str ~ 'var ' ~ ($.var).emit_go ~ ' *Any;' ~ "\n";
+ $str = $str ~ ($.var).emit_go ~ ' = ' ~ ($.var).emit_go ~ ';' ~ "\n";
if ($.var).sigil eq '%' {
- $str := $str ~ ($.var).emit_go ~ ' = h_hash();' ~ "\n";
+ $str = $str ~ ($.var).emit_go ~ ' = h_hash();' ~ "\n";
}
elsif ($.var).sigil eq '@' {
- $str := $str ~ ($.var).emit_go ~ ' = a_array();' ~ "\n";
+ $str = $str ~ ($.var).emit_go ~ ' = a_array();' ~ "\n";
}
else {
- $str := $str ~ ($.var).emit_go ~ ' = u_undef();' ~ "\n";
+ $str = $str ~ ($.var).emit_go ~ ' = u_undef();' ~ "\n";
}
return $str;
}
@@ -1012,17 +1012,17 @@ class Sig {
' print \'Signature - TODO\'; die \'Signature - TODO\'; '
}
method emit_go_bind {
- my $str := '';
- my $i := 0;
+ my $str = '';
+ my $i = 0;
for @($.positional) -> $decl {
- $str := $str
+ $str = $str
~ " var " ~ $decl.emit_go ~ " *Any;\n"
~ " if len(v.p) > " ~ $i ~ " {\n"
~ " " ~ $decl.emit_go ~ " = v.p[" ~ $i ~ "];\n"
~ " }\n";
# avoid "x declared and not used"
- $str := $str ~ $decl.emit_go ~ ' = ' ~ $decl.emit_go ~ '; ';
- $i := $i + 1;
+ $str = $str ~ $decl.emit_go ~ ' = ' ~ $decl.emit_go ~ '; ';
+ $i = $i + 1;
}
return $str;
}
@@ -1033,7 +1033,7 @@ class Method {
has $.sig;
has @.block;
method emit_go {
- my $invocant := ($.sig).invocant;
+ my $invocant = ($.sig).invocant;
'func ' ~ $.name ~ '(v Capture) *Any { '
~ ' ' ~ ($.sig).emit_go_bind ~ "\n"
~ ' p := make(chan *Any); go func () { ' ~ "\n"
View
20 lib/MiniPerl6/Grammar.pm
@@ -64,7 +64,7 @@ token comp_unit {
[ 'class' | 'grammar' ] <.ws> <full_ident> <.ws>?
'{'
- { $Class_name := ~$<full_ident> }
+ { $Class_name = ~$<full_ident> }
<.ws>?
<exp_stmts>
<.ws>?
@@ -137,10 +137,10 @@ token exp {
code => 'infix:<' ~ $<infix_op> ~ '>',
arguments => [ $$<term_meth>, $$<exp> ],
) }
- | <.opt_ws> ':=' <.opt_ws> <exp>
- { make Bind.new( parameters => $$<term_meth>, arguments => $$<exp>) }
| <.opt_ws> '=' <.opt_ws> <exp>
- { die '*** Error in assignment operation: infix<=> not implemented; use infix<:=> instead' }
+ { make Bind.new( parameters => $$<term_meth>, arguments => $$<exp>) }
+ | <.opt_ws> ':=' <.opt_ws> <exp>
+ { die '*** Error in bind operation: infix<:=> not implemented; use infix<=> instead' }
| { make $$<term_meth> }
]
}
@@ -431,7 +431,7 @@ token lit_object {
}
token bind {
- <exp> <.opt_ws> ':=' <.opt_ws> <exp2>
+ <exp> <.opt_ws> '=' <.opt_ws> <exp2>
{
make Bind.new(
parameters => $$<exp>,
@@ -551,14 +551,14 @@ token token {
\}
{
#say 'Token was compiled into: ', ($$<MiniPerl6::Grammar::Regex.rule>).perl;
- my $source := 'method ' ~ $<opt_name> ~ ' ( $grammar: $str, $pos ) { ' ~
- 'my $MATCH; $MATCH := MiniPerl6::Match.new( \'str\' => $str, \'from\' => $pos, \'to\' => $pos, \'bool\' => 1 ); ' ~
- '$MATCH.bool := ( ' ~
+ my $source = 'method ' ~ $<opt_name> ~ ' ( $grammar: $str, $pos ) { ' ~
+ 'my $MATCH; $MATCH = MiniPerl6::Match.new( \'str\' => $str, \'from\' => $pos, \'to\' => $pos, \'bool\' => 1 ); ' ~
+ '$MATCH.bool = ( ' ~
($$<MiniPerl6::Grammar::Regex.rule>).emit ~
'); ' ~
'$MATCH }';
#say 'Intermediate code: ', $source;
- my $ast := MiniPerl6::Grammar.exp_term( $source, 0 );
+ my $ast = MiniPerl6::Grammar.exp_term( $source, 0 );
# say 'Intermediate ast: ', $$ast.emit;
make $$ast;
}
@@ -574,7 +574,7 @@ MiniPerl6::Grammar - Grammar for MiniPerl6
=head1 SYNOPSIS
- my $match := $source.parse;
+ my $match = $source.parse;
($$match).perl; # generated MiniPerl6 AST
=head1 DESCRIPTION
View
2  lib/MiniPerl6/Grammar/Control.pm
@@ -89,7 +89,7 @@ MiniPerl6::Grammar - Grammar for MiniPerl6
=head1 SYNOPSIS
- my $match := $source.parse;
+ my $match = $source.parse;
($$match).perl; # generated MiniPerl6 AST
=head1 DESCRIPTION
View
2  lib/MiniPerl6/Grammar/Mapping.pm
@@ -46,7 +46,7 @@ MiniPerl6::Grammar - Grammar for MiniPerl6
=head1 SYNOPSIS
- my $match := $source.parse;
+ my $match = $source.parse;
($$match).perl; # generated MiniPerl6 AST
=head1 DESCRIPTION
View
4 lib/MiniPerl6/Grammar/Regex.pm
@@ -228,7 +228,7 @@ token rule_term {
|
# { say 'matching variables' }
<variables>
- [ <.ws>? ':=' <.ws>? <named_capture_body>