Skip to content
Permalink
Browse files

parse list-embedded curlies as hash constructors

  • Loading branch information...
s-nez authored and wchristian committed Nov 2, 2017
1 parent eaa601f commit 7fd14b0a4334a1073ec93d6f5f7d0ed97eb3015f
@@ -1197,17 +1197,20 @@ sub _curly {
### FIXME This is possibly a bad choice, but will have to do for now.
return 'PPI::Structure::Block' if $Element;

# Special case: Are we the param of a core function
# i.e. map({ $_ => 1 } @foo)
if (
$Parent->isa('PPI::Statement')
and
_INSTANCE($Parent->parent, 'PPI::Structure::List')
) {
# Special case: Are we the param of a core function
# i.e. map({ $_ => 1 } @foo)
my $function = $Parent->parent->parent->schild(-2);
if ( $function and $function->content =~ /^(?:map|grep|sort)$/ ) {
if ( $function and $function->content =~ /^(?:map|grep|sort|eval|do)$/ ) {
return 'PPI::Structure::Block';
}

# Other cases of list-embedded curlies are constructors
return 'PPI::Structure::Constructor';
}

# We need to scan ahead.
@@ -5,7 +5,7 @@

use lib 't/lib';
use PPI::Test::pragmas;
use Test::More tests => 218 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
use Test::More tests => 236 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

use File::Spec::Functions ':ALL';
use PPI::Lexer;
@@ -0,0 +1 @@
$hashref = ({ %base_args, arg => $mod_value });
@@ -0,0 +1,22 @@
PPI::Document
PPI::Statement
PPI::Token::Symbol '$hashref'
PPI::Token::Whitespace ' '
PPI::Token::Operator '='
PPI::Token::Whitespace ' '
PPI::Structure::List ( ... )
PPI::Statement
PPI::Structure::Constructor { ... }
PPI::Token::Whitespace ' '
PPI::Statement
PPI::Token::Symbol '%base_args'
PPI::Token::Operator ','
PPI::Token::Whitespace ' '
PPI::Token::Word 'arg'
PPI::Token::Whitespace ' '
PPI::Token::Operator '=>'
PPI::Token::Whitespace ' '
PPI::Token::Symbol '$mod_value'
PPI::Token::Whitespace ' '
PPI::Token::Structure ';'
PPI::Token::Whitespace '\n'
@@ -2,7 +2,7 @@ PPI::Document
PPI::Statement
PPI::Token::Word 'eval'
PPI::Structure::List ( ... )
PPI::Statement::Compound
PPI::Statement
PPI::Token::Whitespace ' '
PPI::Structure::Block { ... }
PPI::Statement

0 comments on commit 7fd14b0

Please sign in to comment.
You can’t perform that action at this time.