diff --git a/crates/fuse-ast/src/ast.rs b/crates/fuse-ast/src/ast.rs index 8798833..fa58b32 100644 --- a/crates/fuse-ast/src/ast.rs +++ b/crates/fuse-ast/src/ast.rs @@ -95,7 +95,8 @@ pub enum Expression { BooleanLiteral(Box), Identifier(Box), Function(Box), - If(Box) + If(Box), + UnaryOperator(Box), } #[serializable] @@ -218,10 +219,24 @@ pub struct If { pub r#else: Option, } - #[serializable] #[derive(Debug, PartialEq)] pub enum Else { If(Box), Block(Box), } + +#[serializable] +#[derive(Debug, PartialEq)] +pub struct UnaryOperator { + pub kind: UnaryOperatorKind, + pub expression: Expression, +} + +#[serializable] +#[derive(Debug, PartialEq)] +pub enum UnaryOperatorKind { + Not(Span), + Minus(Span), + Plus(Span), +} diff --git a/crates/fuse-ast/src/ast_factory.rs b/crates/fuse-ast/src/ast_factory.rs index 7120106..50ff4c7 100644 --- a/crates/fuse-ast/src/ast_factory.rs +++ b/crates/fuse-ast/src/ast_factory.rs @@ -121,4 +121,8 @@ impl AstFactory { pub fn if_expression(&self, expr: If) -> Expression { Expression::If(Box::from(expr)) } + + pub fn unary_operator_expression(&self, op: UnaryOperator) -> Expression { + Expression::UnaryOperator(Box::from(op)) + } }