The implementation of `null_proc` is rather simple, but feels a
little verbose an targential compared to everything else being done
- in the compiler.
\ No newline at end of file
+ in the compiler.
+
+ :TypeValueInterchange
+ Angle brackets are being used to specify types in value expressions
+ and vice versa. This is just a temporary hack. The long term goal
+ is that type expressions are automatically detected in value
+ expressions.
\ No newline at end of file
break;
}
+ // :TypeValueInterchange
+ case '<': {
+ AstTypeAlias* alias = make_node(AstTypeAlias, Ast_Kind_Type_Alias);
+ alias->token = expect_token(parser, '<');
+ alias->to = parse_type(parser);
+ expect_token(parser, '>');
+
+ retval = (AstTyped *) alias;
+ break;
+ }
+
case '#': {
if (parse_possible_directive(parser, "file_contents")) {
AstFileContents* fc = make_node(AstFileContents, Ast_Kind_File_Contents);
break;
}
+ else if (parser->curr->type == '<') {
+ // :TypeValueInterchange
+ expect_token(parser, '<');
+ *next_insertion = (AstType *) parse_expression(parser);
+ next_insertion = NULL;
+ expect_token(parser, '>');
+
+ break;
+ }
+
else {
onyx_report_error(parser->curr->pos, "unexpected token '%b'.", parser->curr->text, parser->curr->length);
consume_token(parser);
printf("PolyStruct<i32, f32>(%i, %f)\n", ps1.t_data, ps1.r_data);
// Currently, this is how you have to do this.
- ps2 := (#type PolyStruct(f32, i32)).{ 1234, 5678 };
+ ps2 := <PolyStruct(f32, i32)>.{ 1234, 5678 };
printf("PolyStruct<f32, i32>(%f, %i)\n", ps2.t_data, ps2.r_data);
}
r_data : R = 5678;
}
- PolyStructTyped :: #type PolyStruct(i32, f32);
+ PolyStructTyped :: <PolyStruct(i32, f32)>;
ps := PolyStructTyped.{};
printf("PolyStruct<i32, f32>(%i, %f)\n", ps.t_data, ps.r_data);