Open jackdeguest opened 2 years ago
At least for that specific case (specialised syntax for sub
-like blocks), I believe it would be a case of augmenting the lexer. In the past I have added keywords defined by Function::Parameters
(e.g., method
) by adding to the %PPI::Lexer::STATEMENT_CLASSES
hash.
If you are willing to use PPR
+ Babble
instead, it is pretty easy to extend the grammar by using pieces of the existing grammar. I have an example of this in this PR that adds a class
keyword in the tests.
I can imagine a plugin that takes
async sub { ... }
and turns it into
sub :async { ... }
then processes it with the PPI interface and then transforms back into
async sub { ... }
Is there a possibility to extend PPI recognised grammar. I know there is
PPI::Transform
and I looked at it, but it seems more of a post-processing api. What I have in mind is a way to have something like:be recognised as a
PPI::Statement::Sub
object and not as aPPI::Statement
object.