feat: add PPI::Plugin system for parse-time extensibility - #437
Draft
toddr-bot wants to merge 2 commits into
Draft
feat: add PPI::Plugin system for parse-time extensibility#437toddr-bot wants to merge 2 commits into
toddr-bot wants to merge 2 commits into
Conversation
Tests verify the plugin API that will allow external code to hook into PPI's parsing pipeline. Covers statement classification, token modification, and feature detection hooks. All behavioral tests are marked TODO and properly fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements a plugin API that lets external code hook into PPI's parsing pipeline without modifying PPI internals. Plugins are passed via PPI::Document->new(\$src, plugins => [$plugin]) and provide three hooks: - statement_class($token, $parent): override Lexer statement classification - modify_token($token): inspect/annotate tokens during tokenization - feature_includes($include): detect custom feature-enabling pragmas Closes #23 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a formal plugin API that lets external code hook into PPI's parsing
pipeline without modifying PPI internals. This addresses the long-standing
feature request for non-standard syntax extensions support (Devel::Declare,
custom keywords, etc.).
Fixes #23
Changes
PPI::Pluginbase class with three hooks:statement_class,modify_token,feature_includesPPI::Document->new(\$src, plugins => [$plugin])propagates plugins to Lexer and Tokenizerstatement_classbefore its own classification logic (first plugin to return wins)modify_tokenon every finalized token (all plugins called)Statement::Include::feature_modscallsfeature_includeson plugins before built-in detectionTest plan
t/ppi_plugin.tcovers all three hook types with concrete plugin subclassesGenerated by Kōan /fix
Quality Report
Changes: 7 files changed, 290 insertions(+)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline