Y-asc

yet another stupid compiler
Log | Files | Refs | README | git clone https://git.ne02ptzero.me/git/Y-asc

commit d4db51a85afeb72fc00709db409cc1f6dbe0ea47
parent 0faca2b93c91ef2a3f5eb9f27da5af77e971f72a
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 26 Jun 2017 19:32:23 +0200

Add(Code): Add some code samples

Diffstat:
Acode/count_to_ten.y | 9+++++++++
Acode/hello_world.y | 4++++
Acode/static_const_heap.y | 8++++++++
Acode/struct.y | 20++++++++++++++++++++
4 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/code/count_to_ten.y b/code/count_to_ten.y @@ -0,0 +1,9 @@ +main(u32 : ac, ubyte[]* : av) : u32 { + ubyte count = 1; + + while (count <= 10) { + print("%d\n", count); + count = count + 1; + } + return 0; +} diff --git a/code/hello_world.y b/code/hello_world.y @@ -0,0 +1,4 @@ +main(u32 : ac, ubyte[]* : av) : u32 { + print("Hello World!\n"); + return 0; +} diff --git a/code/static_const_heap.y b/code/static_const_heap.y @@ -0,0 +1,8 @@ +main(u32 : ac, ubyte[]* : av) : u32 { + u16 __const i = 0; /* Can't change it */ + u32 __static j = 12; + u8* __heap array = {0, 1, 2, 3}; /* Allocate this array */ + u8[] array_2 = {0, 1, 2, 3}; /* On the stack */ + + return 0; +} diff --git a/code/struct.y b/code/struct.y @@ -0,0 +1,20 @@ +struct basestruct_s { + bool some_bool; + u32 some_integer; + ubyte[] some_string_with_def_val = "Hello !"; +}; + +print_struct_info(struct basestruct_s * : ptr) : void { + print("some_bool: %b\n", ptr->some_bool); + print("some_integer: %zu"\n, ptr->some_integer); + print("some_string_with_def_val: %s\n", ptr->some_string_with_def_val); +} + +main(u32 : ac, ubyte[]* : av) : u32 { + struct basestruct_s st; + + st.some_bool = false; + st.some_integer = 4; + print_struct_info(&st); + return 0; +}