ryo-pattern 0.1.0

RyoPattern - AST pattern matching and lint rules for Ryo
Documentation

ryo-pattern

crates.io docs.rs License: MIT OR Apache-2.0

Status: stable. Part of the ryo workspace — AST-centric Rust programming for AI agents.

RyoPattern — declarative AST pattern matching and lint rules for Rust. Read-only structural matching with composable any / all / none grouping, schema-driven definitions for LLM-perfect query generation, and pre-computed relation graphs.

Install

cargo add ryo-pattern

Quickstart

use ryo_pattern::{parse_pattern, RuleEngine};

// Parse a concrete pattern
let pattern = parse_pattern("fn $name($args) -> Result<$ok, $err> { $body }")?;

// Match against AST nodes
let engine = RuleEngine::new();
let matches = engine.run(&pattern, &ast_root);

for m in matches {
    println!("matched: {:?} with captures {:?}", m.node, m.captures);
}

API Summary

Item Purpose
CodePattern AST node predicate (structural matching)
parse_pattern / ConcreteParser Pattern DSL parser
RuleEngine / Rule Query + message + severity bundles
MatchResult Match outcome with {$VAR: Node} captures
generator::* Template-based code generation
loader::* Pattern loading from files

Status

API surface considered stable for the v0.1.0 release. Pattern matching remains read-only; mutations are owned by downstream crates such as ryo-mutations.

License

Licensed under either of Apache-2.0 or MIT at your option.