bash-ast 0.8.20

Typed Rust AST over tree-sitter-bash. Parses bash source into a strongly-typed tree suitable for structural analysis (permission gating, linting, refactoring) rather than execution.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use bash_ast::parse;

#[test]
fn parses_a_simple_pipeline() {
    let tree = parse("echo hi | grep foo").expect("parse");
    let root = tree.root_node();
    assert_eq!(root.kind(), "program");
    assert!(!root.has_error(), "tree has parse error: {root:?}");
}

#[test]
fn parses_an_empty_string() {
    let tree = parse("").expect("parse");
    assert_eq!(tree.root_node().kind(), "program");
}