Skip to main content

Module if_statement

Module if_statement 

Source
Expand description

Conditional statement parser (if / else if / else).

Parses the full if-chain into a tree of nested StatementKind::Conditional nodes. Each else if branch is represented by recursion, so the AST mirrors the source nesting naturally:

if (a) { … } else if (b) { … } else { … }

becomes:

Conditional {
    if_branch:   ConditionalBranch { condition: Some(a), body: […] }
    else_branch: Some(Conditional {
        if_branch:   ConditionalBranch { condition: Some(b), body: […] }
        else_branch: Some(ConditionalBranch { condition: None, body: […] })
    })
}