ralix 0.2.0

A simple, type-safe, tree walking interpreter
use std::rc::Rc;

use serde::Serialize;

use crate::{Expression, types::Type};

#[derive(Debug, Clone, Serialize, PartialEq)]
pub enum ExpressionType {
    Identifier,
    Integer,
    Float,
    Boolean,
    String,
    Char,
    Null,
    TypeOf,
    Type,
    Try,
    Infix,
    Prefix,
    Scope,
    IfElse,
    Function,
    Call,
    Array,
    HashMap,
    Index,
}

pub type Identifier = Rc<str>;

#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
pub enum InfixOperator {
    Add,
    Subtract,
    Multiply,
    Divide,
    Remainder,
    Equals,
    NotEquals,
    Or,
    And,
    Greater,
    GreatEq,
    Less,
    LessEq,
    BitwiseAnd,
    BitwiseOr,
    BitwiseXOr,
    BitShiftRight,
    BitShiftLeft,
}

#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
pub enum PrefixOperator {
    Not,
    Neg,
    Deref,
    AddrOf,
    BitwiseNot,
}

/// (Condition, Consequence)
pub type IfConsequence = (Expression, Expression);
pub type ElseConsequence = Box<Expression>;

#[derive(Debug, Clone, Serialize, PartialEq)]
pub struct FunctionParameter {
    pub type_def: Type,
    pub name: Identifier,
    pub is_constant: bool,
}

#[derive(Debug, Clone, Serialize, PartialEq)]
pub struct HashMapItem {
    pub key: Expression,
    pub value: Expression,
}

#[derive(Debug, Clone, Serialize, PartialEq)]
pub struct ImportedItem {
    pub name: Identifier,
    pub as_naming: Option<Identifier>,
}