rustcc 0.1.1

An little C Complier( now it's just WIP :) )
//! # Abstract Syntax Tree (AST) for RustCC
//! Defines the structure of the abstract syntax tree used by the parser and interpreter.

/// Enumeration of all possible AST node types.
/// Each variant represents a different kind of expression or operation.
#[derive(Debug, PartialEq)]
pub enum NodeType {
    /// Addition operation (+)
    Add,
    /// Subtraction operation (-)
    Subtract,
    /// Multiplication operation (*)
    Multiply,
    /// Division operation (/)
    Divide,
    /// Integer literal value
    IntLit,
}

/// An abstract syntax tree node.
/// Represents a single expression or operation in the parsed code.
#[derive(Debug)]
pub struct ASTNode {
    /// The type of this node (e.g., operation, literal)
    pub op: NodeType,
    /// Left child node (for binary operations)
    pub left: Option<Box<ASTNode>>,
    /// Right child node (for binary operations)
    pub right: Option<Box<ASTNode>>,
    /// Integer value (for IntLit nodes)
    pub int_value: Option<i32>,
}

impl ASTNode {
    /// Creates a new leaf node representing an integer literal.
    /// 
    /// # Arguments
    /// * `value` - The integer value of the literal
    pub fn new_int_lit(value: i32) -> Self {
        ASTNode {
            op: NodeType::IntLit,
            left: None,
            right: None,
            int_value: Some(value),
        }
    }

    /// Creates a new binary operation node.
    /// 
    /// # Arguments
    /// * `op` - The operation type
    /// * `left` - Left operand node
    /// * `right` - Right operand node
    pub fn new_binary_op(
        op: NodeType,
        left: Box<ASTNode>,
        right: Box<ASTNode>,
    ) -> Self {
        ASTNode {
            op,
            left: Some(left),
            right: Some(right),
            int_value: None,
        }
    }
}