optionals
This commit is contained in:
19
src/ast.zig
19
src/ast.zig
@@ -53,6 +53,9 @@ pub const Node = struct {
|
||||
slice_expr: SliceExpr,
|
||||
pointer_type_expr: PointerTypeExpr,
|
||||
many_pointer_type_expr: ManyPointerTypeExpr,
|
||||
optional_type_expr: OptionalTypeExpr,
|
||||
force_unwrap: ForceUnwrap,
|
||||
null_coalesce: NullCoalesce,
|
||||
deref_expr: DerefExpr,
|
||||
null_literal: void,
|
||||
while_expr: WhileExpr,
|
||||
@@ -192,6 +195,7 @@ pub const Call = struct {
|
||||
pub const FieldAccess = struct {
|
||||
object: *Node,
|
||||
field: []const u8,
|
||||
is_optional: bool = false,
|
||||
};
|
||||
|
||||
pub const IfExpr = struct {
|
||||
@@ -199,6 +203,7 @@ pub const IfExpr = struct {
|
||||
then_branch: *Node,
|
||||
else_branch: ?*Node,
|
||||
is_inline: bool, // true for `if cond then a else b`
|
||||
binding_name: ?[]const u8 = null, // for `if val := expr { ... }` optional binding
|
||||
};
|
||||
|
||||
pub const MatchExpr = struct {
|
||||
@@ -371,6 +376,19 @@ pub const ManyPointerTypeExpr = struct {
|
||||
element_type: *Node,
|
||||
};
|
||||
|
||||
pub const OptionalTypeExpr = struct {
|
||||
inner_type: *Node,
|
||||
};
|
||||
|
||||
pub const ForceUnwrap = struct {
|
||||
operand: *Node,
|
||||
};
|
||||
|
||||
pub const NullCoalesce = struct {
|
||||
lhs: *Node,
|
||||
rhs: *Node,
|
||||
};
|
||||
|
||||
pub const DerefExpr = struct {
|
||||
operand: *Node,
|
||||
};
|
||||
@@ -378,6 +396,7 @@ pub const DerefExpr = struct {
|
||||
pub const WhileExpr = struct {
|
||||
condition: *Node,
|
||||
body: *Node,
|
||||
binding_name: ?[]const u8 = null, // for `while val := expr { ... }` optional binding
|
||||
};
|
||||
|
||||
pub const ForExpr = struct {
|
||||
|
||||
Reference in New Issue
Block a user