panproto-parse 0.48.0

Tree-sitter full-AST parsers and emitters for panproto language protocols
Documentation
//! # panproto-parse
//!
//! Tree-sitter full-AST parsers and emitters for panproto language protocols.
//!
//! This crate provides the schema-level presentation functors that map between
//! source code text and panproto [`Schema`] models. It operates at the schema
//! level of panproto's two-parameter architecture (complementing `panproto-io`
//! which operates at the instance level).
//!
//! ## Theory extraction
//!
//! Tree-sitter grammars are theory presentations. Each grammar's `node-types.json`
//! is structurally isomorphic to a GAT: named node types become sorts, fields
//! become operations. The [`theory_extract`] module auto-derives panproto theories
//! from grammar metadata, ensuring the theory is always in sync with the parser.
//!
//! ## Generic walker
//!
//! Because theories are auto-derived from the grammar, the AST walker is fully
//! generic: one [`walker::AstWalker`] implementation works for all languages.
//! The node's `kind()` IS the panproto vertex kind; the field name IS the edge
//! kind. Per-language customization is limited to formatting constraints and
//! import resolution hints.
//!
//! ## Pipeline
//!
//! ```text
//! source code ──parse──→ Schema ──merge/diff/check──→ Schema ──emit──→ source code
//! ```
//!
//! [`Schema`]: panproto_schema::Schema

/// Error types for full-AST parsing and emission.
pub mod error;

/// Scope-aware vertex ID generation for full-AST schemas.
pub mod id_scheme;

/// Automated theory extraction from tree-sitter grammar metadata.
pub mod theory_extract;

/// Grammar-driven named-scope detection via tree-sitter `tags.scm` queries.
pub mod scope_detector;

/// Generic tree-sitter AST walker.
pub mod walker;

/// Per-language parser and emitter implementations.
pub mod languages;

/// Parser registry mapping protocol names to implementations.
pub mod registry;

/// De-novo source emission from by-construction schemas.
pub mod emit_pretty;

/// The parse / emit pair as a verified asymmetric lens with explicit
/// law-checkers (retraction in the image of the parser).
pub mod parse_emit_lens;

/// Put-direction of the parse / decorate / emit lens: build a
/// decorated schema from an abstract one by routing through
/// `emit_pretty + parse`.
pub mod decorate;

/// Runtime `LayoutPolicy` for the put-direction of the parse / emit
/// lens; carries whitespace and indentation conventions.
pub mod layout_policy;

/// The parse / decorate / emit lens packaged as a first-class
/// `panproto-lens::Protolens`.
///
/// The protolens describes the schema-level relationship between
/// abstract and decorated schemas.
pub mod parse_emit_protolens;

pub use decorate::decorate_with_parser;
pub use error::ParseError;
pub use id_scheme::IdGenerator;
pub use layout_policy::LayoutPolicy;
pub use parse_emit_lens::{
    LawViolation as ParseEmitLawViolation, ParseEmitLens, check_emit_parse, check_parse_emit,
    edge_multiset, kind_multiset, strip_complement,
};
pub use parse_emit_protolens::parse_emit_protolens;
pub use registry::{AstParser, ParserRegistry};
pub use scope_detector::{NamedScope, ScopeDetector, ScopeKind};
pub use theory_extract::{ExtractedTheoryMeta, extract_theory_from_node_types};
pub use walker::{AstWalker, WalkerConfig};