Skip to content

About

A light version of Rust subset AST

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

Repository files navigation

RustLightAST

A lightweight Rust subset AST, source parser, and printer in one crate.

[dependencies]
rustlightast = { path = "../RustLightAST" }
use rustlightast::{parse_rust_source, RustCodeGenerator};

fn main() -> Result<(), rustlightast::ParseError> {
    let module = parse_rust_source("fn identity(x: u32) -> u32 { x }", "example")?;
    println!("{}", RustCodeGenerator::new().generate_module_code(&module));
    Ok(())
}
  • rustlight_ast defines the syntax tree.
  • rustlight_parser converts supported Rust source into that tree.
  • rustlight_print renders the tree as Rust source.

parse_rust_type_facts extracts declarations and signatures for analysis, with function bodies omitted. Unsupported parser syntax returns ParseError.

Run tests with cargo test --all-targets --locked.

About

A light version of Rust subset AST

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages