booleans, comparisons, and if/else
This commit is contained in:
@@ -68,6 +68,7 @@ Expr_Kind :: enum u8 {
|
||||
Integer,
|
||||
Float,
|
||||
String,
|
||||
Bool,
|
||||
Array,
|
||||
None,
|
||||
Name,
|
||||
@@ -81,7 +82,16 @@ Expr_Kind :: enum u8 {
|
||||
Struct_Literal,
|
||||
Keyed,
|
||||
Negate,
|
||||
Not,
|
||||
Add,
|
||||
Eq,
|
||||
Ne,
|
||||
Lt,
|
||||
Le,
|
||||
Gt,
|
||||
Ge,
|
||||
And,
|
||||
Or,
|
||||
Call,
|
||||
}
|
||||
|
||||
@@ -109,6 +119,7 @@ Stmt_Kind :: enum u8 {
|
||||
Assignment,
|
||||
Return,
|
||||
Expression,
|
||||
If,
|
||||
}
|
||||
|
||||
Stmt :: struct {
|
||||
@@ -119,6 +130,11 @@ Stmt :: struct {
|
||||
immutable: bool,
|
||||
target: Expr_Id,
|
||||
expr: Expr_Id,
|
||||
// `If` statements use `expr` as the condition, `body` as the then-block, and
|
||||
// `else_body` as the else-block. An `else if` chain is represented as an
|
||||
// `else_body` holding a single nested `If` statement.
|
||||
body: []Stmt_Id,
|
||||
else_body: []Stmt_Id,
|
||||
diagnostic: source.Diagnostic_Id,
|
||||
}
|
||||
|
||||
@@ -234,6 +250,10 @@ destroy_module :: proc(module: ^Module) {
|
||||
for expr in module.exprs {
|
||||
delete(expr.args, module.allocator)
|
||||
}
|
||||
for statement in module.statements {
|
||||
delete(statement.body, module.allocator)
|
||||
delete(statement.else_body, module.allocator)
|
||||
}
|
||||
for function in module.functions {
|
||||
delete(function.params, module.allocator)
|
||||
delete(function.body, module.allocator)
|
||||
|
||||
Reference in New Issue
Block a user