panproto_parse/lib.rs
1//! # panproto-parse
2//!
3//! Tree-sitter full-AST parsers and emitters for panproto language protocols.
4//!
5//! This crate provides the schema-level presentation functors that map between
6//! source code text and panproto [`Schema`] models. It operates at the schema
7//! level of panproto's two-parameter architecture (complementing `panproto-io`
8//! which operates at the instance level).
9//!
10//! ## Theory extraction
11//!
12//! Tree-sitter grammars are theory presentations. Each grammar's `node-types.json`
13//! is structurally isomorphic to a GAT: named node types become sorts, fields
14//! become operations. The [`theory_extract`] module auto-derives panproto theories
15//! from grammar metadata, ensuring the theory is always in sync with the parser.
16//!
17//! ## Generic walker
18//!
19//! Because theories are auto-derived from the grammar, the AST walker is fully
20//! generic: one [`walker::AstWalker`] implementation works for all languages.
21//! The node's `kind()` IS the panproto vertex kind; the field name IS the edge
22//! kind. Per-language customization is limited to formatting constraints and
23//! import resolution hints.
24//!
25//! ## Pipeline
26//!
27//! ```text
28//! source code ──parse──→ Schema ──merge/diff/check──→ Schema ──emit──→ source code
29//! ```
30//!
31//! [`Schema`]: panproto_schema::Schema
32
33/// Error types for full-AST parsing and emission.
34pub mod error;
35
36/// Scope-aware vertex ID generation for full-AST schemas.
37pub mod id_scheme;
38
39/// Automated theory extraction from tree-sitter grammar metadata.
40pub mod theory_extract;
41
42/// Generic tree-sitter AST walker.
43pub mod walker;
44
45/// Per-language parser and emitter implementations.
46pub mod languages;
47
48/// Parser registry mapping protocol names to implementations.
49pub mod registry;
50
51pub use error::ParseError;
52pub use id_scheme::IdGenerator;
53pub use registry::{AstParser, ParserRegistry};
54pub use theory_extract::{ExtractedTheoryMeta, extract_theory_from_node_types};
55pub use walker::{AstWalker, WalkerConfig};