AstNode_base;
AstPackage *imported_package;
+
+ AstUse *implicit_use_node;
};
return return_node;
}
-static AstNode* parse_use_stmt(OnyxParser* parser) {
- OnyxToken* use_token = expect_token(parser, Token_Type_Keyword_Use);
- AstUse* use_node = make_node(AstUse, Ast_Kind_Use);
- use_node->token = use_token;
- use_node->expr = parse_expression(parser, 1);
- if (!use_node->expr) return NULL;
-
+static b32 parse_use_stmt_internal(OnyxParser* parser, AstUse* use_node) {
if (consume_token_if_next(parser, '{')) {
- bh_arr_new(global_heap_allocator, use_node->only, 4);
+ if (next_tokens_are(parser, 2, '*', '}')) {
+ consume_tokens(parser, 2);
+ return 1;
+ }
+ bh_arr_new(global_heap_allocator, use_node->only, 4);
while (!consume_token_if_next(parser, '}')) {
- if (parser->hit_unexpected_token) return NULL;
+ if (parser->hit_unexpected_token) return 0;
QualifiedUse qu;
qu.as_name = expect_token(parser, Token_Type_Symbol);
}
}
+ return 1;
+}
+
+static AstNode* parse_use_stmt(OnyxParser* parser) {
+ OnyxToken* use_token = expect_token(parser, Token_Type_Keyword_Use);
+ AstUse* use_node = make_node(AstUse, Ast_Kind_Use);
+ use_node->token = use_token;
+ use_node->expr = parse_expression(parser, 1);
+ if (!use_node->expr) return NULL;
+
+ if (!parse_use_stmt_internal(parser, use_node)) return NULL;
+
if (use_node->expr->kind == Ast_Kind_Package) {
ENTITY_SUBMIT(use_node);
return NULL;
import_node->imported_package = package_node;
+ if (parser->curr->type == '{') {
+ AstUse *use_node = make_node(AstUse, Ast_Kind_Use);
+ use_node->token = parser->curr;
+ use_node->expr = (AstTyped *) package_node;
+
+ if (!parse_use_stmt_internal(parser, use_node)) return NULL;
+
+ import_node->implicit_use_node = use_node;
+ ENTITY_SUBMIT(use_node);
+ }
+
return import_node;
}
#load "core/std"
-#import core
-use core
+#import core {*}
count_ending_paths :: (nums: [..] u32) -> u64 {
tally := array.make(u64, nums.count);
#load "core/std"
-use package core
+#import core {*}
Ship :: struct {
x : i32 = 0;
#load "core/std"
-use package core
+#import core {*}
inv_mod :: (a_: i64, m_: i64) -> i64 {
if m_ <= 1 do return 0;
#load "core/std"
-use package core
+#import core {*}
MASK_SIZE :: 36
Bitmask :: [MASK_SIZE] u8;
#load "core/std"
-use package core
+#import core {*}
initial_numbers := u32.[ 1, 20, 8, 12, 0, 14 ];
#load "core/std"
-use package core
+#import core {*}
Field :: struct {
name : str = "";
#load "core/std"
-use package core
+#import core {*}
parse_factor :: (file: &str) -> u64 {
string.strip_leading_whitespace(file);
#load "core/std"
-use package core
+#import core {*}
// nt -> t
Term :: struct {
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
contents := #file_contents "./tests/aoc-2020/input/day2.txt";
#load "core/std"
-use package core
+#import core {*}
TILE_DATA_WIDTH :: 10
TILE_DATA_HEIGHT :: 10
#load "core/std"
-use package core
+#import core {*}
/*
What questions the data layout needs to answer easily:
#load "core/std"
-use package core
+#import core {*}
key_arena : alloc.arena.ArenaState;
key_alloc : Allocator;
#load "core/std"
-use package core
+#import core {*}
cups : [..] i32;
#load "core/std"
-use package core
+#import core {*}
Vec2 :: struct {
x: i32 = 0;
#load "core/std"
-use package core
+#import core {*}
power_mod :: (base: u32, exp: u32, mod: u32) -> u32 {
t: u64 = 1;
#load "core/std"
-use package core
+#import core {*}
Point :: struct {
x, y : i32;
#load "core/std"
-use package core
+#import core {*}
// Returns the number of fields
process_passport :: (contents: &str) -> u32 {
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
contents := #file_contents "./tests/aoc-2020/input/day5.txt";
#load "core/std"
-use package core
+#import core {*}
part_1 :: (contents: &str) -> u32 {
chars : [26] bool;
#load "core/std"
-use package core
+#import core {*}
BagGraph :: struct {
nodes : [..] &BagNode;
#load "core/std"
-use package core
+#import core {*}
OpCode :: enum (u16) {
Nop; Acc; Jmp;
#load "core/std"
-use package core
+#import core {*}
find_contiguous_subarray_with_sum :: (nums: [..] u64, sum: u64) -> (i32, i32) {
start := 0;
#load "core/std"
-use package core
+#import core.io
+#import core.os
+#import core {printf}
count_increasing :: (arr: [] $T) -> u32 {
increased_count := 0;
PART :: 2
-#load "core/std"
-
-use package core
+#import core {*}
main :: (args) => {
for file: os.with_file("tests/aoc-2021/input/day02.txt") {
#load "core/std"
-use package core
+#import core {*}
read_binary :: (r: &io.Reader) -> i32 {
n := 0;
#load "core/std"
-use package core
+#import core {*}
Cell :: u8
#load "core/std"
-use package core
+#import core {*}
Line :: struct {
x1, y1: i32;
#load "core/std"
-use package core
+#import core {*}
main :: (args) => {
for file: os.with_file("./tests/aoc-2021/input/day06.txt") {
#load "core/std"
-use package core
+#import core {*}
main :: (args) => {
for file: os.with_file("./tests/aoc-2021/input/day07.txt") {
PART :: 2
#load "core/std"
-use package core
+#import core {*}
// Encoded segments
//
#load "core/std"
-use package core
+#import core {*}
Pos :: struct {x,y: i32;}
#match hash.to_u32 (use p: Pos) => x * 13 & 17 * y;
#load "core/std"
-use package core
+#import core {*}
main :: (args) => {
for file: os.with_file("./tests/aoc-2021/input/day10.txt") {
#load "core/std"
-use package core
+#import core {*}
Pos :: struct {x, y:i32;}
#match hash.to_u32 (use p: Pos) => x * 45238271 + y * 34725643;
#load "core/std"
-use package core
+#import core {*}
Communative_Pair :: struct (T: type_expr) where hash.Hashable(T) {
a, b: T;
#load "core/std"
-use package core
+#import core {*}
Point :: struct {
x, y: i32;
#load "core/std"
-use package core
+#import core {*}
Rule :: struct {
pair: Pair(u8, u8);
#load "core/std"
-use package core
+#import core {*}
queued :: struct { x, y: i32; cost: i32; };
#operator == (u1, u2: queued) => u1.x == u2.x && u1.y == u2.y;
#load "core/std"
-use package core
+#import core {*}
base16_to_hex :: (s: str) -> u32 {
res := 0;
#load "core/std"
-use package core
+#import core {*}
tx0: i32
ty0: i32
#load "core/std"
-use package core
+#import core {*}
Vec2 :: struct { x: i32; y: i32; }
#load "core/std"
#load "core/intrinsics/atomics"
-use package core
-use package core.intrinsics.atomics
+#import core {*}
+#import core.intrinsics.atomics {*}
Shared_Data :: struct {
arr: [] i32;
#load "core/std"
-use package core
+#import core {*}
dumb :: (it: Iterator, m: &Map) {
println(it.Iter_Type);
#load "core/std"
-use package core
+#import core {*}
main :: () {
tree: &avl_tree.AVL_Tree(i32);
#load "core/std"
-use package core
+#import core {*}
count_to :: ($N: i32) {
for i: 0 .. N do printf("{} ", i);
#load "core/std"
-use package core
+#import core {*}
Foo :: struct {
x, y: i32;
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
ba := bucket_array.make(i32, 4);
#load "core/std"
-use package core
+#import core {*}
S :: struct {
some_array: [..] struct {
#load "core/std"
-use package core
+#import core {*}
test_macro :: macro () {
defer {
#load "core/std"
-use package core
+#import core {*}
custom_iterator :: () -> Iterator(i32) {
#load "core/std"
-use package core
+#import core {*}
Point :: struct { x, y: i32; }
#load "core/std"
-use package core
+#import core {*}
SomeNamespace :: struct {
foo :: () {
#load "core/std"
-use package core
+#import core {*}
using_callsite :: (value: $T, site := #callsite) {
println(value);
}
}
-#local runtime :: package runtime
+#import runtime
#load "core/std"
-use package core
+#import core {*}
Test_VTable :: struct {
first : (i32) -> i32;
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
baked_proc :: (x: $T, $func: (T) -> typeof x) -> T {
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
defer println("At the end!");
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
println(#defined(stdio));
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
imap : Map(i32, str);
#load "core/std"
-use package core
+#import core {*}
main :: (args) => {
{
#load "core/std"
-use package core
+#import core {*}
first_init :: #init #after second_init () {
println("In an #init proc.");
#load "core/std"
-use package core
+#import core {*}
count_iterator :: (lo: $T, hi: T, step: T = 1) -> Iterator(T) {
return iter.generator(
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
foo :: (x: i32, y: f32) {
#load "core/std"
-#import core
+#import core {printf, map}
main :: (args: [] cstr) {
- core.printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str));
+ printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str));
}
#load "core/std"
-use package core
+#import core {*}
Vec3 :: struct {
#load "core/std"
-use package core
+#import core {*}
Complex :: struct {
re : f32 = 0;
#load "core/std"
-use package core
+#import core {*}
overloaded :: #match {
#order 10 (x: i32) { println("Option X"); },
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
#load "core/std"
-use package core
-info :: package runtime.info
+
+#import core {*}
+#import runtime.info
Base :: struct (T: type_expr) {
const: i32;
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
NewPolyStruct :: struct (T: type_expr, N: i32) {
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
arr := u32.[ 1, 2, 3, 4, 5 ];
#load "core/std"
-use package core
+#import core {*}
main :: (args) => {
x: [..] i32;
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
#load "core/std"
-use package core
+#import core {*}
main :: (args: [] cstr) {
#load "core/std"
-use package core
+#import core {*}
Person_Vtable :: struct {
greet: (&Person) -> void;
#load "core/std"
-use package core
+#import core {*}
Vector2 :: struct { x, y: i32; }
#operator == macro (v1: Vector2, v2: Vector2) => v1.x == v2.x && v1.y == v2.y;
#load "core/std"
-use package core;
+#import core {*};
old_va_test :: (prefix: str, va: ..i32) {
println(prefix);