Skip to main content

Crate panproto_parse

Crate panproto_parse 

Source
Expand description

§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

source code ──parse──→ Schema ──merge/diff/check──→ Schema ──emit──→ source code

Re-exports§

pub use error::ParseError;
pub use id_scheme::IdGenerator;
pub use registry::AstParser;
pub use registry::ParserRegistry;
pub use theory_extract::ExtractedTheoryMeta;
pub use theory_extract::extract_theory_from_node_types;
pub use walker::AstWalker;
pub use walker::WalkerConfig;

Modules§

error
Error types for full-AST parsing and emission. Error types for full-AST parsing and emission.
id_scheme
Scope-aware vertex ID generation for full-AST schemas. Scope-aware vertex ID generation for full-AST schemas.
languages
Per-language parser and emitter implementations. Language parser infrastructure.
registry
Parser registry mapping protocol names to implementations. Parser registry mapping protocol names to full-AST parser implementations.
theory_extract
Automated theory extraction from tree-sitter grammar metadata. Automated theory extraction from tree-sitter grammar metadata.
walker
Generic tree-sitter AST walker. Generic tree-sitter AST walker that converts parse trees to panproto schemas.