Added lambda expressions, lambda types, no body yet

This commit is contained in:
Krzosa Karol
2022-05-20 17:16:53 +02:00
parent 30736d37b6
commit 236ff0cd64
8 changed files with 329 additions and 153 deletions

View File

@@ -1,35 +1,57 @@
/*
Player :: struct
id : int
name: String
compound_of_struct: Player = {
id = 10,
name = "Guy",
}
second_compound_syntax := :Player{...}
max :: (a: int, b: int) { if a > b then return a; return b; }
max :: (a: int, b: int)
if a > b then return a
return b
; - treated as new line
{ and } - treated as new line scope and end of new line scope
*/
test_function :: (thing: int): ^int
//-----------------------------------------------------------------------------
// Booleans
//-----------------------------------------------------------------------------
boolean: bool = true
value_of_bool: int = cast(boolean: int)
base := null
//-----------------------------------------------------------------------------
// Compound expressions
//-----------------------------------------------------------------------------
array1: [4]int = {1,2,3,4}
array2: [32]int = {1,2,3,4}
array3: [32]int = {
[0] = 0,
[1] = 1,
[31] = 31,
}
array_item := array1[0]
array_item_imp: int = array2[2]
/*
//-----------------------------------------------------------------------------
// Pointers
//-----------------------------------------------------------------------------
pointer_decl : ^int
variable_from_deref: int = pointer_decl^
pointer_from_var : ^int = ^variable_from_deref
boolean_pointer := ^boolean
pointer: *int
variable: int = *pointer
pointer_from_var := ^variable
pointer := &base
base_from_pointer := *pointer
structure: Data = {}
array2: [4]int = {
[0] = 0,
[1] = 1
}
array_to_pointer: *[4]int = &array1
array_to_pointer_imp : = &array1
*/
//-----------------------------------------------------------------------------
// Implicit type
//-----------------------------------------------------------------------------
@@ -39,9 +61,9 @@ implicit_str :: "Hello world"
//-----------------------------------------------------------------------------
// Pointers
//-----------------------------------------------------------------------------
pointer: *int = cast(null: *int)
pointer2: *int = null
pointer3: **int = null
pointer: ^int = cast(null: ^int)
pointer2: ^int = null
pointer3: ^^int = null
//-----------------------------------------------------------------------------
// String types