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

provide delimiters for PPI::Token::QuoteLike::{Words,Regexp,Command}, PPI::Token::Quote::{Literal,Interpolate} #256

Open
FractalBoy opened this issue Feb 24, 2021 · 0 comments

Comments

@FractalBoy
Copy link

When parsing qw, qr, qx, q, and qq strings, it would be nice to be able to get which delimiters are being used. It looks like these are already being stored in {sections}[0]{type}, but not publically available. Ideally, it would always return a two-element array.

For example:

my $doc = PPI::Document->new(\q{my @a = qw(a b c);});
my ($start, $end) = $doc->schild(0)->schild(3)->delimiters();
print "start: $start end: $end\n";
# prints "start: ( end: )"

Here is code that currently works, but seems like it wouldn't be safe to rely on:

my $doc = PPI::Document->new(\q{my @a = qw(a b c);});
my ($start, $end) = split //, $doc->schild(0)->schild(3)->{sections}[0]{type};
print "start: $start end: $end\n";
# prints "start: ( end: )"
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