Generating valid c code, more work on null values
This commit is contained in:
30
test3.kl
30
test3.kl
@@ -1,7 +1,5 @@
|
||||
|
||||
/*
|
||||
|
||||
Player :: struct
|
||||
Player :: struct
|
||||
id : int
|
||||
name: String
|
||||
|
||||
@@ -12,7 +10,7 @@ compound_of_struct: Player = {
|
||||
|
||||
second_compound_syntax := :Player{...}
|
||||
|
||||
max :: (a: int, b: int) { if a > b then return a; return b; }
|
||||
max_folding :: (a: int, b: int) { if a > b { return a; } return b; }
|
||||
|
||||
max :: (a: int, b: int)
|
||||
if a > b then return a
|
||||
@@ -22,22 +20,34 @@ max :: (a: int, b: int)
|
||||
{ and } - treated as new line scope and end of new line scope
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function types
|
||||
//-----------------------------------------------------------------------------
|
||||
test_function :: (thing: int): ^int
|
||||
function_type: (thing: int): ^int = test_function
|
||||
const_function_alias :: test_function
|
||||
null_function: (t: int): ^int = null
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Booleans
|
||||
//-----------------------------------------------------------------------------
|
||||
boolean: bool = true
|
||||
value_of_bool: int = cast(boolean: int)
|
||||
base := null
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Nulls
|
||||
//-----------------------------------------------------------------------------
|
||||
int_null: int = null
|
||||
str_null: String = null
|
||||
bool_null: bool = null
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Compound expressions
|
||||
//-----------------------------------------------------------------------------
|
||||
array1: [4]int = {1,2,3,4}
|
||||
array1: [4]int = {1,2,3,4}
|
||||
array2: [32]int = {1,2,3,4}
|
||||
array3: [32]int = {
|
||||
[0] = 0,
|
||||
array3: [32]int = {
|
||||
[0] = null,
|
||||
[1] = 1,
|
||||
[31] = 31,
|
||||
}
|
||||
@@ -61,8 +71,8 @@ implicit_str :: "Hello world"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Pointers
|
||||
//-----------------------------------------------------------------------------
|
||||
pointer: ^int = cast(null: ^int)
|
||||
pointer2: ^int = null
|
||||
pointer1: ^int = null
|
||||
pointer2: ^int = pointer1
|
||||
pointer3: ^^int = null
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user