diff --git a/perlito5.pl b/perlito5.pl index 35e0942cd..617dd440b 100644 --- a/perlito5.pl +++ b/perlito5.pl @@ -4839,7 +4839,7 @@ $MATCH->{'capture'} = Perlito5::AST::Block::->new('stmts' => \@ast) } elsif ($Perlito5::EMIT_USE) {; - $MATCH->{'capture'} = Perlito5::Grammar::Block::ast_nop() + $MATCH->{'capture'} = Perlito5::AST::Apply::->new('code' => 'use', 'special_arg' => Perlito5::AST::Apply::->new('code' => $full_ident, 'bareword' => 1, 'arguments' => []), 'arguments' => $list) } else {; $MATCH->{'capture'} = parse_time_eval({'mod' => $full_ident, 'code' => $use_decl, 'arguments' => $list}) @@ -15880,7 +15880,7 @@ if ($self->{'code'} eq 'package') {; return ['stmt' => 'package', ['bareword' => $self->{'namespace'}]] } - if ($code eq 'map' || $code eq 'grep' || $code eq 'sort' || $code eq 'print') { + if ($code eq 'map' || $code eq 'grep' || $code eq 'sort' || $code eq 'print' || $code eq 'use') { if ($self->{'special_arg'}) {; return ['op' => 'prefix:<' . $code . '>', $self->{'special_arg'}->emit_perl5(), ['op' => 'list:<,>', $self->emit_perl5_args()]] } @@ -16033,7 +16033,7 @@ $op{'prefix:<' . $_ . '>'} = {'fix' => 'prefix', 'prec' => 8, 'str' => $_ . ' '} for '-r', '-w', '-x', '-o', '-R', '-W', '-X', '-O', '-e', '-z', '-s', '-f', '-d', '-l', '-p', '-S', '-b', '-c', '-t', '-u', '-g', '-k', '-T', '-B', '-M', '-A', '-C'; $op{'prefix:<' . $_ . '>'} = {'fix' => 'parsed', 'prec' => 15, 'str' => $_} - for 'do', 'sub', 'my', 'our', 'state', 'local', 'eval', 'map', 'grep', 'sort', 'print'; + for 'do', 'sub', 'my', 'our', 'state', 'local', 'eval', 'map', 'grep', 'sort', 'print', 'use'; my %tab; sub Perlito5::Perl5::PrettyPrinter::tab { my $level = $_[0]; @@ -29008,8 +29008,8 @@ '; my $copyright_message = 'This is Perlito5 ' . $_V5_COMPILER_VERSION . ', an implementation of the Perl language. -The Perl language is Copyright 1987-2012, Larry Wall -The Perlito5 implementation is Copyright 2011, 2012 by Flavio Soibelmann Glock and others. +The Perl language is Copyright 1987-2017, Larry Wall +The Perlito5 implementation is Copyright 2011-2017 by Flavio Soibelmann Glock and others. Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. diff --git a/src5/lib/Perlito5/CompileTime/Dumper.pm b/src5/lib/Perlito5/CompileTime/Dumper.pm index 3ea2d1321..282a18633 100644 --- a/src5/lib/Perlito5/CompileTime/Dumper.pm +++ b/src5/lib/Perlito5/CompileTime/Dumper.pm @@ -32,6 +32,7 @@ sub generate_eval_string { sub _dump_AST_from_scope { my ($name, $item, $vars, $dumper_seen,) = @_; + no strict 'refs'; my $sigil = substr($name, 0, 1); if (ref($item) eq 'Perlito5::AST::Sub' && $item->{name}) { @@ -240,6 +241,7 @@ sub emit_globals_after_BEGIN { # dump @ISA for my $pkg (keys %{$Perlito5::PACKAGES}) {; + no strict 'refs'; if (@{ $pkg . "::ISA" }) { $scope->{ '@' . $pkg . "::ISA" } //= { 'ast' => Perlito5::AST::Var->new( diff --git a/src5/lib/Perlito5/Grammar/Attribute.pm b/src5/lib/Perlito5/Grammar/Attribute.pm index eacffd6a1..cc07d9fc2 100644 --- a/src5/lib/Perlito5/Grammar/Attribute.pm +++ b/src5/lib/Perlito5/Grammar/Attribute.pm @@ -15,7 +15,7 @@ sub opt_attribute { $ws = Perlito5::Grammar::Space::opt_ws( $str, $ws->{to} + 1 ); my $p = $ws->{to}; my $m = Perlito5::Grammar::ident($str, $p); - Perlito5::Compiler::error "syntax error" if !$m; + Perlito5::Compiler::error( "syntax error" ) if !$m; my $to; while (1) { @@ -26,7 +26,7 @@ sub opt_attribute { if ($delimiter eq '(') { # "ident(params)" my $params = Perlito5::Grammar::String::string_interpolation_parse($str, $m->{to} + 1, '(', ')', 0); - Perlito5::Compiler::error "syntax error" if !$params; + Perlito5::Compiler::error( "syntax error" ) if !$params; $attr->[1] = Perlito5::Match::flat($params)->{buf}; $to = $params->{to}; } diff --git a/src5/lib/Perlito5/Grammar/Sigil.pm b/src5/lib/Perlito5/Grammar/Sigil.pm index 88fdbda23..dfa76b7df 100644 --- a/src5/lib/Perlito5/Grammar/Sigil.pm +++ b/src5/lib/Perlito5/Grammar/Sigil.pm @@ -270,7 +270,7 @@ sub term_sigil { } if ($str->[$p] eq '}') { # ${} - Perlito5::Compiler::error "syntax error"; + Perlito5::Compiler::error( "syntax error" ); } $m = Perlito5::Grammar::block( $str, $p0 ); if ($m) { diff --git a/src5/lib/Perlito5/Grammar/Use.pm b/src5/lib/Perlito5/Grammar/Use.pm index ce6660dcc..6e196d8a8 100644 --- a/src5/lib/Perlito5/Grammar/Use.pm +++ b/src5/lib/Perlito5/Grammar/Use.pm @@ -75,7 +75,7 @@ token stmt_use { { # "use v5", "use v5.8" - check perl version my $version = $MATCH->{"version_string"}{capture}{buf}; Perlito5::test_perl_version($version); - $MATCH->{capture} = Perlito5::Grammar::Block::ast_nop; + $MATCH->{capture} = Perlito5::Grammar::Block::ast_nop(); } | [ '-' ]? @@ -162,7 +162,17 @@ token stmt_use { } else { if ($Perlito5::EMIT_USE) { - $MATCH->{capture} = Perlito5::Grammar::Block::ast_nop; + $MATCH->{capture} = Perlito5::AST::Apply->new( + code => 'use', + # namespace => 'CORE', + special_arg => + Perlito5::AST::Apply->new( + code => $full_ident, + bareword => 1, + arguments => [], + ), + arguments => $list, + ); } else { $MATCH->{capture} = parse_time_eval( @@ -249,7 +259,7 @@ sub parse_time_eval { bootstrapping_use($ast); } - return Perlito5::Grammar::Block::ast_nop; + return Perlito5::Grammar::Block::ast_nop(); } sub emit_time_eval { diff --git a/src5/lib/Perlito5/Perl5/Emitter.pm b/src5/lib/Perlito5/Perl5/Emitter.pm index 1a5b53f8f..ccc05ee4f 100644 --- a/src5/lib/Perlito5/Perl5/Emitter.pm +++ b/src5/lib/Perlito5/Perl5/Emitter.pm @@ -389,6 +389,7 @@ package Perlito5::AST::Apply; || $code eq 'grep' || $code eq 'sort' || $code eq 'print' + || $code eq 'use' ) { if ( $self->{special_arg} ) { # TODO - test 'special_arg' type (scalar, block, ...) diff --git a/src5/lib/Perlito5/Perl5/PrettyPrinter.pm b/src5/lib/Perlito5/Perl5/PrettyPrinter.pm index bd3e633d5..e36881d87 100644 --- a/src5/lib/Perlito5/Perl5/PrettyPrinter.pm +++ b/src5/lib/Perlito5/Perl5/PrettyPrinter.pm @@ -161,7 +161,7 @@ $op{ "prefix:<$_>" } = { fix => 'prefix', prec => 8, str => "$_ " } ); $op{ "prefix:<$_>" } = { fix => 'parsed', prec => 15, str => "$_" } for qw( do sub my our state local - eval map grep sort print ); + eval map grep sort print use ); my %tab; sub tab {