From: Brendan Hansen Date: Thu, 8 Dec 2022 16:36:46 +0000 (-0600) Subject: added new cast syntax; bugfixes X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=cadc10d10b5b1be1085617a0a7760c2823ddef45;p=onyx.git added new cast syntax; bugfixes --- diff --git a/compiler/src/checker.c b/compiler/src/checker.c index 113682f4..23462ce0 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -171,7 +171,7 @@ CheckStatus check_return(AstReturn* retnode) { return Check_Success; } - if ((*expected_return_type)->Basic.size > 0) { + if ((*expected_return_type) != &basic_types[Basic_Kind_Void]) { ERROR_(retnode->token->pos, "Returning from non-void function without a value. Expected a value of type '%s'.", type_get_name(*expected_return_type)); diff --git a/compiler/src/onyx.c b/compiler/src/onyx.c index a629fa9e..d2b07193 100644 --- a/compiler/src/onyx.c +++ b/compiler/src/onyx.c @@ -769,7 +769,7 @@ static CompilerProgress onyx_flush_module() { if (context.options->documentation_file != NULL) { OnyxDocumentation docs = onyx_docs_generate(); - docs.format = Doc_Format_Human; + docs.format = Doc_Format_Tags; onyx_docs_emit(&docs, context.options->documentation_file); } diff --git a/compiler/src/parser.c b/compiler/src/parser.c index 77dbcddb..cae57cdb 100644 --- a/compiler/src/parser.c +++ b/compiler/src/parser.c @@ -452,9 +452,16 @@ static AstTyped* parse_factor(OnyxParser* parser) { expect_token(parser, '('); cast_node->type_node = parse_type(parser); - expect_token(parser, ')'); - cast_node->expr = parse_factor(parser); + if (peek_token(0)->type == ',') { + expect_token(parser, ','); + cast_node->expr = parse_factor(parser); + expect_token(parser, ')'); + + } else { + expect_token(parser, ')'); + cast_node->expr = parse_factor(parser); + } retval = (AstTyped *) cast_node; break; @@ -1477,6 +1484,7 @@ static AstNode* parse_statement(OnyxParser* parser) { case Token_Type_Literal_Integer: case Token_Type_Literal_Float: case Token_Type_Literal_String: + case Token_Type_Keyword_Cast: retval = (AstNode *) parse_compound_expression(parser, 1); if (retval->kind == Ast_Kind_Call || retval->kind == Ast_Kind_Method_Call) { if (parser->curr->type == '{') {