sdl phase 1
This commit is contained in:
@@ -292,6 +292,28 @@ pub const Parser = struct {
|
||||
self.advance();
|
||||
return try self.createNode(start, .{ .type_expr = .{ .name = name, .is_generic = true } });
|
||||
}
|
||||
// Function pointer type: (ParamTypes) -> ReturnType
|
||||
if (self.current.tag == .l_paren) {
|
||||
self.advance(); // skip '('
|
||||
var param_types = std.ArrayList(*Node).empty;
|
||||
while (self.current.tag != .r_paren and self.current.tag != .eof) {
|
||||
if (param_types.items.len > 0) {
|
||||
try self.expect(.comma);
|
||||
}
|
||||
try param_types.append(self.allocator, try self.parseTypeExpr());
|
||||
}
|
||||
try self.expect(.r_paren);
|
||||
var return_type: ?*Node = null;
|
||||
if (self.current.tag == .arrow) {
|
||||
self.advance(); // skip '->'
|
||||
return_type = try self.parseTypeExpr();
|
||||
}
|
||||
return try self.createNode(start, .{ .function_type_expr = .{
|
||||
.param_types = try param_types.toOwnedSlice(self.allocator),
|
||||
.return_type = return_type,
|
||||
} });
|
||||
}
|
||||
|
||||
if (self.current.tag.isTypeKeyword() or self.current.tag == .identifier) {
|
||||
var name = self.tokenSlice(self.current);
|
||||
self.advance();
|
||||
|
||||
Reference in New Issue
Block a user