Updated AST for extensive expressions

This commit is contained in:
2026-05-17 03:28:22 +02:00
parent 23cf00975d
commit 33fae13c8a
+28 -2
View File
@@ -17,12 +17,19 @@ pub enum BinaryOp {
GreaterThanOrEqual, GreaterThanOrEqual,
And, And,
Or, Or,
ShiftLeft,
ShiftRight,
RangeInclusive,
RangeExclusive,
BitAnd,
BitOr,
BitXor,
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub enum Expression { pub enum Expression {
Literal(Literal), Literal(Literal),
Path(Path), Path(ExprPath), // Updated from Path to support paths containing turbofish segments
Fix { Fix {
initial: Box<Expression>, initial: Box<Expression>,
prefixes: Vec<Prefix>, prefixes: Vec<Prefix>,
@@ -42,6 +49,8 @@ pub enum Literal {
Float(f64), Float(f64),
Bool(bool), Bool(bool),
Tuple(Vec<Expression>), Tuple(Vec<Expression>),
Array(Vec<Expression>),
ArrayRepeat(Box<Expression>, Box<Expression>),
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
@@ -56,11 +65,14 @@ pub enum Pattern {
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub enum Postfix { pub enum Postfix {
FieldAccess(Identifier), FieldAccess(Identifier, Option<Generics>), // Updated to support method turbofish chains
Call(Vec<Expression>), Call(Vec<Expression>),
MacroCall(String), MacroCall(String),
StructCall(Vec<(Identifier, Expression)>), StructCall(Vec<(Identifier, Expression)>),
Index(Expression), Index(Expression),
As(TypeExpr),
RangeInclusive,
RangeExclusive,
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
@@ -70,4 +82,18 @@ pub enum Prefix {
Deref, Deref,
New, New,
Not, Not,
Neg,
RangeInclusive,
RangeExclusive,
}
#[derive(Debug, Clone, Serialize)]
pub struct ExprPathSegment {
pub ident: Identifier,
pub generics: Option<Generics>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ExprPath {
pub segments: Vec<ExprPathSegment>,
} }