Expand description
Perl Intermediate Representation (PIR) for static analysis and tooling. PIR v0: a source-anchored tooling intermediate representation.
PIR is lowered from HirFile. It models data access,
calls, and control flow for editor tooling and static analysis without
executing Perl. PIR v0 is a compiler-substrate data layer only: it does not
replace HIR, does not promote provider behavior, does not claim determinism,
and does not run real Perl.
See PLSP-SPEC-0025 for
the authoritative contract.
§Quick start
use perl_parser_core::Parser;
use perl_parser_core::hir::lower_ast;
use perl_parser_core::pir::lower_hir;
let mut parser = Parser::new("my $x = foo();");
let output = parser.parse_with_recovery();
let hir = lower_ast(&output.ast);
let pir = lower_hir(&hir);
// Every source-derived node preserves a source anchor.
assert!(pir.nodes.iter().all(|n| n.source_anchor.is_anchored()));
// Provider behavior never changes from lowering alone.
assert!(!pir.receipt.provider_behavior_changed);Structs§
- Body
Extraction Result - Extraction results for a single body.
- Lexical
Binding Fact - A single lexical variable binding fact extracted from PIR.
- Lexical
Extractor Receipt - Receipt from the lexical extractor, summarizing all bindings extracted from a file.
- Lexical
Name - A lexical (
my/state) variable named by a PIR operation. - PirAnchor
Coverage - Source-anchor coverage summary for a lowering receipt.
- PirEdge
- One control-flow edge between PIR nodes.
- PirGraph
- A lowered PIR graph plus its receipt.
- PirId
- Stable identifier for a PIR node within one lowering receipt.
- PirNode
- One PIR node.
- PirReceipt
- A PIR lowering receipt.
- PirSource
Anchor - Source anchor for a PIR node.
- Symbol
Name - A package/stash symbol named by a PIR operation.
Enums§
- Lexical
Role - Role of a lexical binding fact (read or write).
- PirAnchor
Kind - Provenance class for a PIR node’s source anchor.
- PirCallee
- Callee of a PIR call operation.
- PirContext
- Expression context modeled by PIR v0.
- PirDynamic
Boundary Kind - Dynamic-boundary category preserved by PIR instead of guessing behavior.
- PirEdge
Kind - Control-flow edge category.
- PirLowering
Mode - Lowering pass that produced a PIR graph.
- PirMethod
- Method named by a PIR method-call operation.
- PirOperation
- A modeled PIR operation.
- PirReceiver
- Receiver of a PIR method-call operation.
Constants§
- LEXICAL_
EXTRACTOR_ RECEIPT_ VERSION - Current schema version for lexical extractor receipts.
- PIR_
RECEIPT_ VERSION - Current PIR lowering-receipt schema version.
Functions§
- extract_
lexical_ facts - Extract lexical binding facts from a HirFile.
- lower_
hir - Lower a
HirFileinto a PIR v0 graph with no caller-supplied identity. - lower_
hir_ bodies - Lower a
HirFile’s canonical body arenas into a PIR-A graph. - lower_
hir_ bodies_ with_ identity - Lower a
HirFile’s canonical body arenas into a PIR-A graph, tagging the receipt with an optional caller-supplied source or fixture identity. - lower_
hir_ with_ identity - Lower a
HirFileinto a PIR v0 graph, tagging the receipt with an optional caller-supplied source or fixture identity. - lower_
single_ body - Lower a single
HirBodyto PIR nodes, preserving body identity.