added if expression

This commit is contained in:
Andrew Segavac
2021-09-14 21:15:39 -06:00
parent e00aef5ef3
commit 26e477204a
9 changed files with 237 additions and 5 deletions

View File

@@ -128,6 +128,12 @@ pub struct LiteralFloat {
pub type_: TypeUsage,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LiteralBool {
pub value: Spanned<String>,
pub type_: TypeUsage,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LiteralStruct {
pub name: Identifier,
@@ -167,13 +173,23 @@ pub struct VariableUsage {
pub type_: TypeUsage,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct IfExpression {
pub condition: Expression,
pub block: Block,
pub else_: Option<Block>,
pub type_: TypeUsage,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Subexpression {
LiteralInt(LiteralInt),
LiteralFloat(LiteralFloat),
LiteralBool(LiteralBool),
LiteralStruct(LiteralStruct),
FunctionCall(FunctionCall),
VariableUsage(VariableUsage),
If(IfExpression),
StructGetter(StructGetter),
Block(Block),
Op(Operation),