Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readline operator is not properly detected when preceded by a map block #221

Open
s-nez opened this issue Aug 25, 2017 · 0 comments
Open

Comments

@s-nez
Copy link
Contributor

s-nez commented Aug 25, 2017

When a <> operator is preceded by a map block, it is does not show up as PPI::Token::QuoteLike::Readline in the tree, instead two separate PPI::Token::Operators for '<' and '>' are created.

Example:

use PPI;
use PPI::Dumper;

print "Regular readline:\n";
my $doc_readline = PPI::Document->new(\'@lines = <$fh>');
PPI::Dumper->new($doc_readline)->print;

print "\nReadline with a map:\n";
my $doc_readline_map = PPI::Document->new(\'@lines = map { $_ } <$fh>');
PPI::Dumper->new($doc_readline_map)->print;

Output:

Regular readline:
PPI::Document
  PPI::Statement
    PPI::Token::Symbol  	'@lines'
    PPI::Token::Whitespace  	' '
    PPI::Token::Operator  	'='
    PPI::Token::Whitespace  	' '
    PPI::Token::QuoteLike::Readline  	'<$fh>'

Readline with a map:
PPI::Document
  PPI::Statement
    PPI::Token::Symbol  	'@lines'
    PPI::Token::Whitespace  	' '
    PPI::Token::Operator  	'='
    PPI::Token::Whitespace  	' '
    PPI::Token::Word  	'map'
    PPI::Token::Whitespace  	' '
    PPI::Structure::Block  	{ ... }
      PPI::Token::Whitespace  	' '
      PPI::Statement
        PPI::Token::Magic  	'$_'
      PPI::Token::Whitespace  	' '
    PPI::Token::Whitespace  	' '
    PPI::Token::Operator  	'<'
    PPI::Token::Symbol  	'$fh'
    PPI::Token::Operator  	'>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant