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

Parse DSL as a sub #272

Closed
shantanu-deriv opened this issue Jun 8, 2022 · 2 comments
Closed

Parse DSL as a sub #272

shantanu-deriv opened this issue Jun 8, 2022 · 2 comments

Comments

@shantanu-deriv
Copy link

PPI::Statement::Sub can correctly parse subs from a module like this

use PPI;

my $FILE = "Module.pm";
my $doc = PPI::Document->new($FILE);
my $subs = $doc->find('PPI::Statement::Sub');

foreach my $sub (@$subs) {
    print $sub->name;
}

However when it comes to parsing special subs defined as another keywords, consider:

use PPI:
use Future::AsyncAwait; # provides a DSL to define 'async' subs

my $FILE = "AsyncModule.pm";
my $doc = PPI::Document->new($FILE);
my $subs = $doc->find('PPI::Statement::Sub');

foreach my $sub (@$subs) {
    print $sub->name;
}

Where the AsyncModule.pm may look like this:

async sub do {
    ...
}

sub that { ... }

1;

The output of the above script would be only

that

Is there a way to output do also? If not can it be supported?

@oalders
Copy link
Collaborator

oalders commented Jun 9, 2022

Unfortunately, this isn't yet possible. I'm going to close this as discussion for this should probably happen in #213. See also #270.

@oalders oalders closed this as completed Jun 9, 2022
@oalders
Copy link
Collaborator

oalders commented Jun 9, 2022

Having said that, if you're volunteering to dig into this, I'm happy for someone to try to tackle it.

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

2 participants