+++ /dev/null
- 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
-
-
-
-
-
-
-
+++ /dev/null
-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
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
// 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.
//
//
// 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,
// 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
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;
use package core
-main :: proc (args: [] cstring) {
+main :: proc (args: [] cstr) {
// Here is a list of all the builtin types:
// void
// bool
// i64 u64
// f32 f64
// rawptr
- // string
- // cstring
+ // str
+ // cstr
// range
//
// If you look in core/builtin.onyx, you can see the definition for some
//
// 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;
print(foo);
print("\n");
print("foo_ptr is ");
- print(foo_ptr);
+ printf("%p", foo_ptr);
print("\n");
// 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 ");
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
}
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;
}
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);
}
}