Skip to content

feat: add PPI::Plugin system for parse-time extensibility - #437

Draft
toddr-bot wants to merge 2 commits into
masterfrom
koan.toddr.bot/fix-issue-23
Draft

feat: add PPI::Plugin system for parse-time extensibility#437
toddr-bot wants to merge 2 commits into
masterfrom
koan.toddr.bot/fix-issue-23

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

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

  • New PPI::Plugin base class with three hooks: statement_class, modify_token, feature_includes
  • PPI::Document->new(\$src, plugins => [$plugin]) propagates plugins to Lexer and Tokenizer
  • Lexer calls statement_class before its own classification logic (first plugin to return wins)
  • Tokenizer calls modify_token on every finalized token (all plugins called)
  • Statement::Include::feature_mods calls feature_includes on plugins before built-in detection

Test plan

  • t/ppi_plugin.t covers all three hook types with concrete plugin subclasses
  • Full test suite (53129 tests) passes with no regressions
  • Verified plugin hooks fire at correct pipeline stages

Generated 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

toddr-bot and others added 2 commits April 27, 2026 09:23
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Parse/Token plugins

2 participants