Skip to main content

Crate bash_ast

Crate bash_ast 

Source
Expand description

Typed AST over tree-sitter-bash.

tree-sitter gives back a stringly-typed CST (node.kind() == "command"); this crate converts that into a Rust enum tree so downstream consumers (permission rules, linters, refactors) can pattern-match instead of comparing strings.

The typed surface mirrors tree-sitter-bash’s node-types.json one-to-one: every named node kind has a corresponding variant. Conversion is total — an unrecognized node kind returns ParseError::UnknownNode rather than being silently dropped.

Modules§

ast
Typed AST for bash, mirroring tree-sitter-bash’s node-types.json 1:1.
summary
High-level summary extracted from a parsed bash Program.
tier
Danger-tier classifier over the bash AST (R459-T1).
tool_invocation
ToolInvocation extraction from a PeeledCommand (R295-F1).
wrappers
Shared wrapper-command set + peel logic (R155-T9).

Enums§

ParseError

Functions§

parse
Parse bash source into a tree-sitter CST. Useful when callers want to walk the raw CST themselves; most consumers want parse_to_ast instead.
parse_to_ast
Parse bash source and convert to the typed AST. Returns an error if any node kind is unrecognized (we treat unknown kinds as a bug rather than silently dropping them, so the typed surface stays in lockstep with the grammar).