Skip to main content

Module ast

Module ast 

Source
Expand description

Typed AST for bash, mirroring tree-sitter-bash’s node-types.json 1:1.

Every named node kind in the grammar has a representation here. The three supertypes (_statement, _expression, _primary_expression) become Rust enums; the 12 nodes with named fields become structs with field-named members; everything else gets a leaf struct carrying its text and span.

Where the grammar allows a wider type set than a supertype enum covers (e.g. binary_expression.left permits subscript and variable_name in addition to _expression), we define small ad-hoc operand enums rather than widening Expression itself — keeps the mapping faithful.

@yah:ticket(R155-T1, “Add Deserialize + PartialEq to bash-ast::ast::Program + BashShape; round-trip JSON test”) @yah:assignee(agent:claude) @yah:at(2026-05-13T00:20:06Z) @yah:status(review) @yah:phase(P1) @yah:parent(R155) @arch:see(.yah/docs/working/W113-yah-bash-snapshot-and-permissions.md)

Structs§

AnsiCString
ArithmeticExpansion
Array
BinaryExpression
BinaryOperator
All operators the grammar lists for binary_expression. We keep the raw text alongside so callers can pretty-print without a table lookup.
BraceExpression
CStyleForStatement
CaseItem
CaseStatement
Command
CommandName
CommandSubstitution
Comment
CompoundStatement
Concatenation
DeclarationCommand
DoGroup
ElifClause
ElseClause
Expansion
ExpansionOperator
ExtglobPattern
FileDescriptor
FileRedirect
ForStatement
FunctionDefinition
HeredocBody
HeredocContent
HeredocEnd
HeredocRedirect
HeredocStart
HerestringRedirect
IfStatement
List
NegatedCommand
Number
ParenthesizedExpression
Pipeline
Point
PostfixExpression
ProcessSubstitution
Program
RawString
RedirectedStatement
Regex
SimpleExpansion
Span
Source byte + (row, column) span. Owned (no lifetime) so the AST can be passed around freely.
SpecialVariableName
StringContent
StringNode
Subscript
Subshell
TernaryExpression
TestCommand
TestOperator
TranslatedString
UnaryExpression
UnaryOperator
UnsetCommand
VariableAssignment
VariableAssignments
a=1 b=2 c=3 as a free-standing prefix without a command.
VariableName
WhileStatement
Word

Enums§

ArrayElement
AssignmentTarget
Name slot of variable_assignment — either a plain name or a subscript.
AssignmentValue
What appears in variable_assignment.value.
BinaryExtra
BinaryOperatorKind
BinaryRightOperand
Permitted on binary_expression.right — adds extglob_pattern and regex.
CStyleForPart
Element inside the parenthesized header of a C-style for ((..;..;..)).
CaseFallthrough
CasePattern
Permitted in the value field of case_statement and case_item.value.
CaseTermination
CommandArgument
Argument list slot of command — adds $, ==, =~, regex as bare tokens.
CommandNameInner
ConditionPart
Single condition step in if_statement.condition / while_statement.condition (the grammar admits a statement plus a terminator token).
DeclarationPart
ExpansionElement
Element inside an expansion body.
Expression
FunctionBody
Permitted as the body of a function_definition.
HeredocOperator
HerestringValue
ListOperator
LoopBody
Body of a for / while loop.
PostfixOperator
PrimaryExpression
Redirect
Permitted in a redirected_statement.redirect slot.
RedirectDestination
SimpleExpansionElement
SimpleRedirect
Restricted redirect set used by command.redirect and function_definition.redirect.
Statement
StringPart
SubscriptIndex
What subscript.index may contain.
TestOperand
Permitted operand at binary_expression.left, unary_expression, postfix_expression, ternary_expression.{condition,consequence,alternative}.
UnaryOperatorKind
UnsetPart

Type Aliases§

CommandSubBody
What command_substitution wraps: a sequence of statements.