small bugfix with comments at the start of a file
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 28 Dec 2020 23:21:50 +0000 (17:21 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 28 Dec 2020 23:21:50 +0000 (17:21 -0600)
docs/bugs
onyx
progs/poly_solidify.onyx
src/onyxparser.c

index a308ab8291f8b3f2ef575644cad55824853ecf09..8ded95c4af7dc7273e27ff701d43c2e68a849bd2 100644 (file)
--- a/docs/bugs
+++ b/docs/bugs
@@ -53,6 +53,8 @@ List of known bugs:
        }
        ```
 
+[ ] Polymorphic structs do not recognize default values for members.
+
 [X] `TileData :: [TILE_DATA_WIDTH * TILE_DATA_HEIGHT] bool;` results in a
     segfault because it is an invalid top level node, but that is not checked
     before it is tried to be used.
diff --git a/onyx b/onyx
index 4856420fc52d8ef561ee0d3a5809e0ae148e4da5..1bdc8ffc4851897745aa42d82427efa9bd97f8d3 100755 (executable)
Binary files a/onyx and b/onyx differ
index d03475f1d39286dc01c093db9b5a50402b51131d..8e16c2c559b1aefbe3179a29e55fc0dcc8bcfa3d 100644 (file)
@@ -20,4 +20,22 @@ main :: proc (args: [] cstr) {
                2,
                proc (a: f32) -> f32 { return ~~(a * 2); },
                proc (b: f32) -> f64 { return ~~(b + 6); }));
-}
\ No newline at end of file
+
+
+    arr : [..] i32;
+    array.init(^arr);
+    defer array.free(^arr);
+
+
+    for i: 0 .. 10 do array.push(^arr, i);
+    print_array(arr);
+
+    array_map(arr, double);
+    print_array(arr);
+}
+
+array_map :: proc (arr: [..] $T, f: proc (T) -> T) {
+    for ^v: arr do *v = f(*v);
+}
+
+double :: proc (v: $V) -> V do return v * 2;
\ No newline at end of file
index 1b034777b89f43ea46f13ceefc69b79657ce1809..dbcc22fb2e8e4da26d8802473fda6a2eff5569dc 100644 (file)
@@ -2219,30 +2219,9 @@ void onyx_parser_free(OnyxParser* parser) {
 }
 
 ParseResults onyx_parse(OnyxParser *parser) {
-    // if (parser->curr->type == Token_Type_Keyword_Package) {
-    //     consume_token(parser);
-
-    //     OnyxToken* symbol = expect_token(parser, Token_Type_Symbol);
-
-    //     token_toggle_end(symbol);
-    //     Package *package = program_info_package_lookup_or_create(
-    //         parser->program,
-    //         symbol->text,
-    //         parser->program->global_scope,
-    //         parser->allocator);
-    //     token_toggle_end(symbol);
-
-    //     parser->package = package;
-
-    // } else {
-    //     Package *package = program_info_package_lookup_or_create(
-    //         parser->program,
-    //         "main",
-    //         parser->program->global_scope,
-    //         parser->allocator);
-
-    //     parser->package = package;
-    // }
+    // NOTE: Skip comments at the beginning of the file
+    if (parser->curr->type == Token_Type_Comment)
+        consume_token(parser);
 
     parser->package = parse_package_name(parser)->package;
     parser->file_scope = scope_create(parser->allocator, parser->package->private_scope, parser->tokenizer->tokens[0].pos);