Rearrange # flags, Add Windows.kl
This commit is contained in:
10
Windows.kl
Normal file
10
Windows.kl
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
DWORD :: U32
|
||||||
|
LPCSTR :: *char
|
||||||
|
HWND :: *void
|
||||||
|
HMENU :: *void
|
||||||
|
HINSTANCE :: *void
|
||||||
|
|
||||||
|
CreateWindowA :: #foreign (dwExStyle: DWORD, lpClassName: *char, lpWindowName: *char, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: *void): HWND
|
||||||
|
|
||||||
|
// @todo: enum #flag
|
||||||
1
ast.cpp
1
ast.cpp
@@ -49,6 +49,7 @@ enum{
|
|||||||
AST_FOREIGN = bit_flag(8),
|
AST_FOREIGN = bit_flag(8),
|
||||||
AST_DECL = bit_flag(9),
|
AST_DECL = bit_flag(9),
|
||||||
AST_PACKAGE_LEVEL = bit_flag(10),
|
AST_PACKAGE_LEVEL = bit_flag(10),
|
||||||
|
AST_FLAG = bit_flag(11),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Ast{
|
struct Ast{
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ Intern_String keyword_enum;
|
|||||||
Intern_String intern_void;
|
Intern_String intern_void;
|
||||||
Intern_String intern_foreign;
|
Intern_String intern_foreign;
|
||||||
Intern_String intern_strict;
|
Intern_String intern_strict;
|
||||||
|
Intern_String intern_flag;
|
||||||
|
|
||||||
|
|
||||||
struct Ast_Scope;
|
struct Ast_Scope;
|
||||||
@@ -212,6 +213,7 @@ lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){
|
|||||||
intern_foreign = intern_string(&l->interns, "foreign"_s);
|
intern_foreign = intern_string(&l->interns, "foreign"_s);
|
||||||
intern_strict = intern_string(&l->interns, "strict"_s);
|
intern_strict = intern_string(&l->interns, "strict"_s);
|
||||||
intern_void = intern_string(&l->interns, "void"_s);
|
intern_void = intern_string(&l->interns, "void"_s);
|
||||||
|
intern_flag = intern_string(&l->interns, "flag"_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
function void
|
function void
|
||||||
|
|||||||
2
enums.kl
2
enums.kl
@@ -1,6 +1,6 @@
|
|||||||
package Memory
|
package Memory
|
||||||
|
|
||||||
Allocator_Kind :: enum
|
Allocator_Kind :: enum #flag
|
||||||
Null
|
Null
|
||||||
Arena
|
Arena
|
||||||
Heap :: 4
|
Heap :: 4
|
||||||
|
|||||||
49
main.cpp
49
main.cpp
@@ -31,50 +31,6 @@ For now I don't thing it should be overloadable.
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
Type resolution cases
|
|
||||||
|
|
||||||
CONST :: expr - dont need to handle
|
|
||||||
make new symbol
|
|
||||||
|
|
||||||
val := expr (1)
|
|
||||||
convert untyped to typed default
|
|
||||||
check bounds
|
|
||||||
make new symbol
|
|
||||||
|
|
||||||
call(default:type = expr) (1)
|
|
||||||
val: type = expr (1)
|
|
||||||
convert untyped to typed based on type
|
|
||||||
make sure expr.type == type
|
|
||||||
check bounds
|
|
||||||
|
|
||||||
expr == expr (2)
|
|
||||||
expr * expr (2)
|
|
||||||
make sure compatible types, floats with ints are ok(convert to float)
|
|
||||||
if only one of them is typed convert the untyped to typed
|
|
||||||
if both types typed make sure they are the same
|
|
||||||
check bounds
|
|
||||||
|
|
||||||
!expr
|
|
||||||
make sure correct type
|
|
||||||
return bool
|
|
||||||
|
|
||||||
compound(expr)
|
|
||||||
call(expr, expr)
|
|
||||||
convert untyped to matching typed
|
|
||||||
check if types match
|
|
||||||
|
|
||||||
cast(expr: type)
|
|
||||||
convert from untyped to typed
|
|
||||||
convert between typed to other typed
|
|
||||||
check if types compatible
|
|
||||||
|
|
||||||
Stmt:
|
|
||||||
Return - Expression should match lambda return type
|
|
||||||
Expr:
|
|
||||||
Lambda - Arguments, default values should match type
|
|
||||||
ArrayT - Should match type int and be constant or not at all
|
|
||||||
Call - Arguments should match type
|
|
||||||
|
|
||||||
|
|
||||||
@todo
|
@todo
|
||||||
[ ] - Should compound resolution use an algorithm to reorder compounds to initialize all fields in order
|
[ ] - Should compound resolution use an algorithm to reorder compounds to initialize all fields in order
|
||||||
@@ -82,7 +38,10 @@ Expr:
|
|||||||
[ ] - Add c string
|
[ ] - Add c string
|
||||||
[ ] - Some way to take slice of data
|
[ ] - Some way to take slice of data
|
||||||
[ ] - slices should be properly displayed in debugger
|
[ ] - slices should be properly displayed in debugger
|
||||||
|
[ ] - Rewrite where # happen,
|
||||||
|
[ ] - cast ->
|
||||||
|
|
||||||
|
[ ] - #assert that handles constants at compile time and vars at runtime
|
||||||
[ ] - Comma notation when declaring variables thing1, thing2: S32
|
[ ] - Comma notation when declaring variables thing1, thing2: S32
|
||||||
[ ] - Array of inferred size
|
[ ] - Array of inferred size
|
||||||
[ ] - Add single line lambda expressions
|
[ ] - Add single line lambda expressions
|
||||||
@@ -90,6 +49,7 @@ Expr:
|
|||||||
[ ] - Disable ability to parse inner structs, functions, constants etc. ?
|
[ ] - Disable ability to parse inner structs, functions, constants etc. ?
|
||||||
[ ] - Write up on order independent declarations
|
[ ] - Write up on order independent declarations
|
||||||
|
|
||||||
|
[ ] - constructor => thing :: (i: S32) -> {i = i, thing = 10}
|
||||||
[ ] - Casting to basic types by call S64(x)
|
[ ] - Casting to basic types by call S64(x)
|
||||||
[ ] - Default values in structs??? Should compound stmts bring values from default values?? Maybe not? Whats the alternative
|
[ ] - Default values in structs??? Should compound stmts bring values from default values?? Maybe not? Whats the alternative
|
||||||
[ ] - Type aliases :: should probably be strictly typed, but assigning constant values should work
|
[ ] - Type aliases :: should probably be strictly typed, but assigning constant values should work
|
||||||
@@ -101,7 +61,6 @@ Expr:
|
|||||||
[ ] - Rust like enum where you associate values(other structs) with keys
|
[ ] - Rust like enum where you associate values(other structs) with keys
|
||||||
[ ] - Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {}
|
[ ] - Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {}
|
||||||
[ ] - Inject stack traces into the program
|
[ ] - Inject stack traces into the program
|
||||||
[ ] - Rewrite constants to embed lambda, types, structs etc.
|
|
||||||
[ ] - Conditional compilation #if
|
[ ] - Conditional compilation #if
|
||||||
|
|
||||||
@donzo
|
@donzo
|
||||||
|
|||||||
12
parsing.cpp
12
parsing.cpp
@@ -562,6 +562,7 @@ function Ast_Decl *
|
|||||||
parse_enum(Token *pos){
|
parse_enum(Token *pos){
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Ast_Expr *typespec = parse_optional_type();
|
Ast_Expr *typespec = parse_optional_type();
|
||||||
|
Token *flag = token_match_pound(intern_flag);
|
||||||
|
|
||||||
token_match(OPEN_SCOPE);
|
token_match(OPEN_SCOPE);
|
||||||
Ast_Scope *scope = begin_decl_scope(scratch, token_get());
|
Ast_Scope *scope = begin_decl_scope(scratch, token_get());
|
||||||
@@ -577,6 +578,7 @@ parse_enum(Token *pos){
|
|||||||
token_expect(CLOSE_SCOPE);
|
token_expect(CLOSE_SCOPE);
|
||||||
|
|
||||||
Ast_Decl *result = ast_enum(pos, typespec, scope);
|
Ast_Decl *result = ast_enum(pos, typespec, scope);
|
||||||
|
if(flag) set_flag(result->flags, AST_FLAG);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,13 +597,11 @@ parse_decl(B32 is_global){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ast_Flag flags = 0;
|
|
||||||
Token *tname = token_get();
|
Token *tname = token_get();
|
||||||
if(token_match(TK_Identifier, TK_DoubleColon)){
|
if(token_match(TK_Identifier, TK_DoubleColon)){
|
||||||
|
|
||||||
if(token_match_pound(intern_strict)){
|
Ast_Flag flags = 0;
|
||||||
set_flag(flags, AST_STRICT);
|
if(token_match_pound(intern_foreign)){
|
||||||
} else if(token_match_pound(intern_foreign)){
|
|
||||||
set_flag(flags, AST_FOREIGN);
|
set_flag(flags, AST_FOREIGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,7 +620,8 @@ parse_decl(B32 is_global){
|
|||||||
|
|
||||||
if(expr->kind == AST_LAMBDA_EXPR){
|
if(expr->kind == AST_LAMBDA_EXPR){
|
||||||
auto a = (Ast_Lambda *)expr;
|
auto a = (Ast_Lambda *)expr;
|
||||||
if(a->scope){
|
if(a->scope || is_flag_set(flags, AST_FOREIGN)){
|
||||||
|
set_flag(result->flags, flags);
|
||||||
result->kind = AST_LAMBDA;
|
result->kind = AST_LAMBDA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -643,7 +644,6 @@ parse_decl(B32 is_global){
|
|||||||
|
|
||||||
if(result){
|
if(result){
|
||||||
result->name = tname->intern_val;
|
result->name = tname->intern_val;
|
||||||
set_flag(result->flags, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user