Skip to main content

perl_parser_core/pir/
mod.rs

1//! PIR v0: a source-anchored tooling intermediate representation.
2//!
3//! PIR is lowered from [`HirFile`](crate::hir::HirFile). It models data access,
4//! calls, and control flow for editor tooling and static analysis without
5//! executing Perl. PIR v0 is a compiler-substrate data layer only: it does not
6//! replace HIR, does not promote provider behavior, does not claim determinism,
7//! and does not run real Perl.
8//!
9//! See [`PLSP-SPEC-0025`](../../../../docs/specs/PLSP-SPEC-0025-pir-v0.md) for
10//! the authoritative contract.
11//!
12//! # Quick start
13//!
14//! ```rust
15//! use perl_parser_core::Parser;
16//! use perl_parser_core::hir::lower_ast;
17//! use perl_parser_core::pir::lower_hir;
18//!
19//! let mut parser = Parser::new("my $x = foo();");
20//! let output = parser.parse_with_recovery();
21//! let hir = lower_ast(&output.ast);
22//! let pir = lower_hir(&hir);
23//!
24//! // Every source-derived node preserves a source anchor.
25//! assert!(pir.nodes.iter().all(|n| n.source_anchor.is_anchored()));
26//! // Provider behavior never changes from lowering alone.
27//! assert!(!pir.receipt.provider_behavior_changed);
28//! ```
29
30mod extractor;
31mod lower;
32mod model;
33
34pub use extractor::{
35    BodyExtractionResult, LEXICAL_EXTRACTOR_RECEIPT_VERSION, LexicalBindingFact,
36    LexicalExtractorReceipt, LexicalRole, extract_lexical_facts,
37};
38pub use lower::{
39    lower_hir, lower_hir_bodies, lower_hir_bodies_with_identity, lower_hir_with_identity,
40    lower_single_body,
41};
42pub use model::{
43    LexicalName, PIR_RECEIPT_VERSION, PirAnchorCoverage, PirAnchorKind, PirCallee, PirContext,
44    PirDynamicBoundaryKind, PirEdge, PirEdgeKind, PirGraph, PirId, PirLoweringMode, PirMethod,
45    PirNode, PirOperation, PirReceipt, PirReceiver, PirSourceAnchor, SymbolName,
46};