pr47 0.0.3

A semi-experimental programming language. Still working in progress.
Documentation
use std::marker::PhantomData;

use crate::syntax::expr::{
    CSTLiteralExpr,
    CSTStringLiteralExpr,
    CSTIdRefExpr,
    CSTUnaryExpr,
    CSTBinaryExpr,
    CSTAssignExpr,
    CSTFuncCallExpr,
    CSTSubscriptExpr,
    CSTFieldRefExpr,
    CSTMethodCallExpr,
    CSTAsExpr,

    UnaryOp,
    BinaryOp
};
use crate::syntax::id::Identifier;
use crate::ast::decl::VarDecl;
use crate::ast::ty::Type;
use crate::util::sona::Owner;

pub enum Expr<'a> {
    LiteralExpr(&'a CSTLiteralExpr),
    StringLiteralExpr(&'a CSTStringLiteralExpr),
    IdRefExpr(VarDecl<'a>, &'a CSTIdRefExpr),
    UnaryExpr(UnaryExpr<'a>, &'a CSTUnaryExpr),
    BinaryExpr(BinaryExpr<'a>, &'a CSTBinaryExpr),
    AssignExpr(AssignExpr<'a>, &'a CSTAssignExpr),
    FuncCallExpr(FuncCallExpr<'a>, &'a CSTFuncCallExpr),
    SubscriptExpr(SubscriptExpr<'a>, &'a CSTSubscriptExpr),
    FieldRefExpr(FieldRefExpr<'a>, &'a CSTFieldRefExpr),
    MethodCallExpr(MethodCallExpr<'a>, &'a CSTMethodCallExpr),
    AsExpr(AsExpr<'a>, &'a CSTAsExpr)
}

pub struct UnaryExpr<'a> {
    pub op: UnaryOp,
    pub operand: Owner<'a, Expr<'a>>,
    pub result_type: &'a Type<'a>
}

pub struct BinaryExpr<'a> {
    pub op: BinaryOp,
    pub lhs: Owner<'a, Expr<'a>>,
    pub rhs: Owner<'a, Expr<'a>>,
    pub result_type: &'a Type<'a>
}

pub struct AssignExpr<'a> {
    pub lhs: Owner<'a, Expr<'a>>,
    pub rhs: Owner<'a, Expr<'a>>
}

pub struct FuncCallExpr<'a> {
    // TODO finish this structure after we're able to pretty handle functions
    _phantom: PhantomData<&'a ()>
}

pub struct SubscriptExpr<'a> {
    pub base: Owner<'a, Expr<'a>>,
    pub idx: Owner<'a, Expr<'a>>,
    pub result_type: &'a Type<'a>
}

pub struct FieldRefExpr<'a> {
    pub base: Owner<'a, Expr<'a>>,
    pub id: &'a Identifier,
    pub result_type: &'a Type<'a>
}

pub struct MethodCallExpr<'a> {
    // TODO finish this structure after we're able to pretty handle functions
    _phantom: PhantomData<&'a ()>
}

pub struct AsExpr<'a> {
    pub base: Owner<'a, Expr<'a>>,
    pub target: &'a Type<'a>
}