Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - grammar - optimizer fix
  • Loading branch information
fglock committed Oct 9, 2013
1 parent b55f1ec commit a64c91d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions html/perlito5.js
Expand Up @@ -3475,10 +3475,10 @@ var p5100 = p5pkg['main'];
var v_v2;
v_v2 = (p5pkg["Perlito5::Grammar::Expression"].pop_term([v_num_stack], 0));
if ( ((p5str(p5pkg["Perlito5::Grammar::Expression"].ref([v_v2], 0)) == 'Perlito5::AST::Apply') && (p5str(p5call(v_v2, "code", [], 0)) == ('list:<' + p5str((v_last_op || (v_last_op = new p5ArrayRef([])))._array_.p5aget(1)) + '>'))) ) {
(v_num_stack || (v_num_stack = new p5ArrayRef([])))._array_.p5push(p5list_to_a(p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('namespace', p5call(v_v2, "namespace", [], 1), 'code', p5call(v_v2, "code", [], 1), 'arguments', (new p5ArrayRef(p5list_to_a(p5call(v_v2, "arguments", [], p5want)._array_, null)))), 1)));
(v_num_stack || (v_num_stack = new p5ArrayRef([])))._array_.p5push(p5list_to_a(p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('namespace', p5call(v_v2, "namespace", [], 1), 'code', p5call(v_v2, "code", [], 1), 'arguments', (new p5ArrayRef(p5list_to_a(p5call(v_v2, "arguments", [], p5want)._array_)))), 1)));
}
else {
(v_num_stack || (v_num_stack = new p5ArrayRef([])))._array_.p5push(p5list_to_a(p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('namespace', '', 'code', ('list:<' + p5str((v_last_op || (v_last_op = new p5ArrayRef([])))._array_.p5aget(1)) + '>'), 'arguments', (new p5ArrayRef(p5list_to_a(v_v2, null)))), 1)));
(v_num_stack || (v_num_stack = new p5ArrayRef([])))._array_.p5push(p5list_to_a(p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('namespace', '', 'code', ('list:<' + p5str((v_last_op || (v_last_op = new p5ArrayRef([])))._array_.p5aget(1)) + '>'), 'arguments', (new p5ArrayRef([v_v2]))), 1)));
};
(function () { throw(p5context([], p5want)) })();
})();
Expand Down
4 changes: 2 additions & 2 deletions perlito5.pl
Expand Up @@ -1348,10 +1348,10 @@ sub Perlito5::Grammar::Expression::reduce_postfix {
if (scalar(@{$num_stack}) < 2) {
my $v2 = pop_term($num_stack);
if (ref($v2) eq 'Perlito5::AST::Apply' && $v2->code() eq ('list:<' . $last_op->[1] . '>')) {
push(@{$num_stack}, Perlito5::AST::Apply->new('namespace' => $v2->namespace(), 'code' => $v2->code(), 'arguments' => [@{$v2->arguments()}, undef]))
push(@{$num_stack}, Perlito5::AST::Apply->new('namespace' => $v2->namespace(), 'code' => $v2->code(), 'arguments' => [@{$v2->arguments()}]))
}
else {
push(@{$num_stack}, Perlito5::AST::Apply->new('namespace' => '', 'code' => 'list:<' . $last_op->[1] . '>', 'arguments' => [$v2, undef]))
push(@{$num_stack}, Perlito5::AST::Apply->new('namespace' => '', 'code' => 'list:<' . $last_op->[1] . '>', 'arguments' => [$v2]))
}
return()
}
Expand Down
4 changes: 2 additions & 2 deletions src5/lib/Perlito5/Grammar/Expression.pm
Expand Up @@ -248,15 +248,15 @@ my $reduce_to_ast = sub {
Perlito5::AST::Apply->new(
namespace => $v2->namespace,
code => $v2->code,
arguments => [ @{ $v2->arguments }, undef ],
arguments => [ @{ $v2->arguments } ],
);
}
else {
push @$num_stack,
Perlito5::AST::Apply->new(
namespace => '',
code => 'list:<' . $last_op->[1] . '>',
arguments => [ $v2, undef ],
arguments => [ $v2 ],
);
}
return;
Expand Down

0 comments on commit a64c91d

Please sign in to comment.