small bug fixes and repo cleanup
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 16:45:27 +0000 (10:45 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 16:45:27 +0000 (10:45 -0600)
docs/api_design [deleted file]
docs/cli [deleted file]
docs/todo
examples/01_hello_world.onyx
examples/02_variables.onyx
examples/03_basics.onyx
misc/onyx.sublime-syntax
onyx
src/onyxchecker.c
src/onyxsymres.c

diff --git a/docs/api_design b/docs/api_design
deleted file mode 100644 (file)
index 4ce6ebf..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-                        The Onyx Standard Library
----------------------------------------------------------------------------
-
-Through Onyx has only one compilation target, WebAssembly 32-bit, there are
-fundamentally two different use cases: in a browser, or with WASI. Both of
-these use cases are to be treated as equally important. To accommodate for
-their very different runtimes, a common standard library must be established
-that they can share the functionality.
-
-The standard high level topics to cover are:
-       - standard output
-       - allocation
-       - standard math functions
-       - strings
-       - files
-       - utility functions
-               * random
-               * clock
-    - arrays
-    - maps
-    - common conversions
-
-
-
-
-
-
-
diff --git a/docs/cli b/docs/cli
deleted file mode 100644 (file)
index e372cc0..0000000
--- a/docs/cli
+++ /dev/null
@@ -1,21 +0,0 @@
-Thoughts about the CLI for Onyx
--------------------------------
-
-Right now, unless a specific argument is recognized, it is treated as a file to add to the compilation.
-This has worked well, but as the amount of functionality that is being added to the compiler is increasing,
-the need for a better CLI system is imminent.
-
-Here are all the things the compiler should be able to do:
-    * Compile a file or a set of files
-    * Validate a file or set of files
-        - Everything done in compilations
-        - No outputting to final WASM file
-    * Generate documentation for a compilation
-        - In Human, Tags, or Html format
-    * Print a help menu
-
-
-
-  $ onyx compile progs/poly_test.onyx -I other_folder
-
-  $ onyx doc progs/poly_test.onyx --format tag
index b30dff4cfdc58b2d4fd9838a7e7e07a169d19062..236a3fa10e5b3d01524da5d8d9b1f9964f6b0408 100644 (file)
--- a/docs/todo
+++ b/docs/todo
@@ -87,5 +87,6 @@ Usability:
     restriction due completely to my laziness and lack of access to a
     Windows / MacOS computer.
 
+    [ ] Make README on GitHub better, and actually describe what to do
     [ ] Make compiler work on Windows
     [ ] Make compiler work on MacOS
index 4e1e7e68e26e064b1e0924a181750cb556ebf94e..c1217e87c9266eaad4b5d5fbf9c795dfbaa82769 100644 (file)
@@ -22,7 +22,7 @@ package main
 // prevents a cluttered global namespace.
 //
 // In Onyx, there are a couple way to control the 'use package' statement. The example below
-// brings in ALL symbols from the 'core' package to the current package scope. This is handy,
+// brings in ALL symbols from the 'core' package to the current file scope. This is handy,
 // but if there are symbols with the same name in multiple packages, there will be conflicts.
 // To address this, Onyx has two ways of controlling which symbols are included.
 //
@@ -34,10 +34,10 @@ package main
 //
 //      use package core { some_symbol, some_other_symbol as sos }
 //
-// This next exmaple makes the symbol, 'some_symbol', accessible in the current package scope.
+// This next exmaple makes the symbol, 'some_symbol', accessible in the current file scope.
 // This is useful if there is only one thing you need from a package and you do not want to
 // worry about conflicting symbol names in the future. This example also makes the symbol,
-// 'some_other_symbol', accessible in the current package scope under the name, 'sos'. This
+// 'some_other_symbol', accessible in the current file scope under the name, 'sos'. This
 // is useful if a symbol name is long and you use it a lot in a package.
 //
 // As you may expect, you can also combine both of these features into one statement, such as,
@@ -49,9 +49,9 @@ use package core
 // procedure is called when the program starts. There is nothing really special going on here;
 // you can go look in core/sys/wasi.onyx to see how the actual _start procedure works. At the
 // end it simply calls main.main, which is this procedure. By convention, main takes a slice
-// of cstrings, which were the arguments passed from the command line. We will talk about
+// of cstr's, which were the arguments passed from the command line. We will talk about
 // slices later.
-main :: proc (args: [] cstring) {
+main :: proc (args: [] cstr) {
 
     // This is the actual call to print, which will print the message 'Hello World!\n' onto the screen.
     // It is not too important to know how this works, but if you are interested you can find the
index 253c7fb7d5e6dd03271fa7b27a558f87261fc649..0cb2144a71d0344c67661d7f7d59f5438eada478 100644 (file)
@@ -5,7 +5,7 @@
 
 use package core
 
-main :: proc (args: [] cstring) {
+main :: proc (args: [] cstr) {
 
     // This is the syntax for declaring a local variable in a procedure.
     foo: i32;
index 0ce0ecbd53235596cdd20dcaa802bd8e2cf7024b..356f3b6595fe8a2df60144536ad300ca673fac41 100644 (file)
@@ -4,7 +4,7 @@
 
 use package core
 
-main :: proc (args: [] cstring) {
+main :: proc (args: [] cstr) {
     // Here is a list of all the builtin types:
     //       void
     //       bool
@@ -14,8 +14,8 @@ main :: proc (args: [] cstring) {
     //        i64  u64
     //        f32  f64
     //     rawptr
-    //     string
-    //    cstring
+    //        str
+    //       cstr
     //      range
     //
     // If you look in core/builtin.onyx, you can see the definition for some
@@ -28,7 +28,7 @@ main :: proc (args: [] cstring) {
     //
     // Here foo is an i32. The unary prefix ^ operator takes the address of a value.
     // The type of foo_ptr is ^i32, or a pointer to an i32. Another example of a pointer
-    // is the cstring builtin. It is ^u8, which is what C would call a char*.
+    // is the cstr builtin. It is ^u8, which is what C would call a char*.
     foo     := 10;
     foo_ptr := ^foo;
 
@@ -36,7 +36,7 @@ main :: proc (args: [] cstring) {
     print(foo);
     print("\n");
     print("foo_ptr is ");
-    print(foo_ptr);
+    printf("%p", foo_ptr);
     print("\n");
 
 
@@ -91,13 +91,13 @@ main :: proc (args: [] cstring) {
     // pointer, a count, and a capacity. The extra capacity field allows implementations
     // to know how many elements can fit into the space allocated for the array, and not
     // just how many elements are currently in the array. To facilitate using dynamic
-    // arrays, there are many array_ procedures in the core package. Take this example.
+    // arrays, there are many procedures in the core.array package. Take this example.
     dyn_arr : [..] i32;
-    array_init(^dyn_arr);
-    defer array_free(^dyn_arr);
+    array.init(^dyn_arr);
+    defer array.free(^dyn_arr);
 
-    for i: 0 .. 100 {
-        array_push(^dyn_arr, i * i * i);
+    for i: 0 .. 10 {
+        array.push(^dyn_arr, i * i * i);
     }
 
     print("dyn_arr is ");
index ed980ee63e065f1543dd8fc828f9c3d49884f7f8..f23f3e51e5adc3882a51108a0755322f6b174ff2 100644 (file)
@@ -52,7 +52,7 @@ contexts:
       captures:
         1: meta.function-call.onyx
 
-    - match: '([a-zA-Z_][a-zA-Z0-9_]+)\s*:'
+    - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*:'
       captures:
         1: variable
 
diff --git a/onyx b/onyx
index de21dca2cce922ab2830d5a0d010175921835528..0c0be048b51fce9ed0255301950c9956d05017fb 100755 (executable)
Binary files a/onyx and b/onyx differ
index e8b0911860fe113c1de04f72bf69cef5f1764658..98133c321f4d1c0e52317fdd032c5d37887eedd8 100644 (file)
@@ -1282,7 +1282,8 @@ b32 check_overloaded_function(AstOverloadedFunction* func) {
         }
 
         if ((*node)->kind != Ast_Kind_Function) {
-            onyx_report_error((*node)->token->pos, "Overload option not function.");
+            onyx_report_error((*node)->token->pos, "Overload option not function. Got '%s'",
+                onyx_ast_node_kind_string((*node)->kind));
 
             return 1;
         }
index f1683e3c88c22745e32af4b35f51eb8a8224604a..99343dcf4fbdafa51aacaeac89b0d52cd9f9d7b9 100644 (file)
@@ -680,9 +680,7 @@ static void symres_global(AstGlobal* global) {
 
 static void symres_overloaded_function(AstOverloadedFunction* ofunc) {
     bh_arr_each(AstTyped *, node, ofunc->overloads) {
-        if ((*node)->kind == Ast_Kind_Symbol) {
-            *node = (AstTyped *) symbol_resolve(semstate.curr_scope, (*node)->token);
-        }
+        symres_expression(node);
     }
 }