From: Brendan Hansen Date: Sat, 18 Jul 2020 04:53:09 +0000 (-0500) Subject: added top-level procs without binding to symbol X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=5cdd9ca00484dc28ece486a2dfeae2d94151d9ab;p=onyx.git added top-level procs without binding to symbol --- diff --git a/onyx b/onyx index ccc9e930..0dd2270d 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/arrays.onyx b/progs/arrays.onyx index c4f6bd4c..d0d56b65 100644 --- a/progs/arrays.onyx +++ b/progs/arrays.onyx @@ -47,7 +47,8 @@ printarr :: proc (arr: ^i32, len: i32) { } } -main :: proc #export { +// Don't need to bind this function to a symbol +proc #export "main" { print(min(10.0, 12.0)); global_arr = 0 as ^i32; diff --git a/src/onyxparser.c b/src/onyxparser.c index 2110bfed..8895cc42 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -125,7 +125,6 @@ static AstNumLit* parse_numeric_literal(OnyxParser* parser) { // ( ) // - // ! -// proc ... // ( '(' ')' )? // // 'true' @@ -330,6 +329,7 @@ static inline i32 get_precedence(BinaryOp kind) { // *= // /= // %= +// // With expected precedence rules static AstTyped* parse_expression(OnyxParser* parser) { bh_arr(AstBinaryOp*) tree_stack = NULL; @@ -885,6 +885,9 @@ static AstTyped* parse_global_declaration(OnyxParser* parser) { return (AstTyped *) global_node; } +// +// +// static AstTyped* parse_top_level_expression(OnyxParser* parser) { if (parser->curr->type == Token_Type_Keyword_Proc) { AstFunction* func_node = parse_function_definition(parser); @@ -914,6 +917,10 @@ static AstNode* parse_top_level_statement(OnyxParser* parser) { return (AstNode *) use_node; } + case Token_Type_Keyword_Proc: + parse_top_level_expression(parser); + return NULL; + case Token_Type_Symbol: { OnyxToken* symbol = parser->curr;