r2rust_core/
ast.rs

1/// Abstract Syntax Tree (AST) module.
2///
3/// This module defines the data structures used to represent parsed expressions
4/// and statements in the interpreter.
5
6/// Represents an expression in the language.
7#[derive(Debug, PartialEq)]
8pub enum Expr {
9    /// A literal number.
10    Number(f64),
11    /// Addition of two expressions.
12    Add(Box<Expr>, Box<Expr>),
13    /// Subtraction of two expressions.
14    Sub(Box<Expr>, Box<Expr>),
15    /// A variable reference.
16    Variable(String),
17}
18
19/// Represents a statement in the language.
20#[derive(Debug, PartialEq)]
21pub enum Statement {
22    /// Assignment of a value to a variable.
23    Assign(String, Expr),
24    /// A standalone expression.
25    Expr(Expr),
26}