Add ';;' operator, more windows decls

This commit is contained in:
Krzosa Karol
2022-06-14 20:12:52 +02:00
parent 6e56b789e9
commit 107c8435b7
3 changed files with 55 additions and 9 deletions

View File

@@ -302,10 +302,18 @@ lex__stream(Lexer *lexer){
case ';' : {
Token semi = token_make(lexer);
Token *last = lex_last_indent_token(s);
semi.kind = SAME_SCOPE;
semi.indent = last->indent;
lex_advance(s);
array->add(semi);
if(lexc(s) == ';'){
lex_advance(s);
semi.kind = OPEN_SCOPE;
semi.indent = last->indent + 2; // @todo: proper detection of indentation
array->add(semi);
s->indent_stack.add(array->last());
} else{
semi.kind = SAME_SCOPE;
array->add(semi);
}
} break;
case '\n':{

View File

@@ -3,15 +3,47 @@ LPCSTR :: *char
HWND :: *void
HMENU :: *void
HINSTANCE :: *void
HBITMAP :: *void
HDC :: *void
LPVOID :: *void
SIZE_T :: U64
BOOL :: int
HANDLE :: *void
VOID :: void
LPDWORD :: *DWORD
BYTE :: U8 // @todo? unsigned char
WORD :: S16 // short
LONG :: S32 // @todo long
UINT :: U32 // @todo uint
RBGQUAD :: struct
rgbBlue: BYTE
rgbGreen: BYTE
rgbRed: BYTE
rgbReserved: BYTE
BITMAPINFOHEADER :: struct
biSize: DWORD
biWidth: LONG
biHeight: LONG
biPlanes: WORD
biBitCount: WORD
biCompression: DWORD
biSizeImage: DWORD
biXPelsPerMeter: LONG
biYPelsPerMeter: LONG
biClrUsed: DWORD
biClrImportant: DWORD
BITMAPINFO :: struct
bmiHeader :: BITMAPINFOHEADER
bmiColors :: [1]RBGQUAD
// #import #foreign "gdi32.lib" @todo
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
GetDC :: #foreign (hWnd: HWND): HDC
CreateDIBSection :: #foreign (hdc: HDC, pbmi: *BITMAPINFO, usage: UINT, ppvBits: **VOID, hSection: HANDLE, offset: DWORD): HBITMAP
CreateCompatibleDC :: (hdc: HDC): HDC
MEM_COMMIT :: 0x00001000
MEM_RESERVE :: 0x00002000

View File

@@ -1,9 +1,15 @@
#import "base.kl"
os :: #import "os.kl"
// #import "base.kl"
#load "Windows.kl"
Vec2I :: struct ;; x: S32; y: S32
create_bitmap :: (size: Vec2I)
pass
main :: (argc: int, argv: **char): int
memory := os.reserve(size = 10000)
os.commit(&memory, 1000)
os.release(&memory)
os.print("Hello world")
pass
// memory := os.reserve(size = 10000)
// os.commit(&memory, 1000)
// os.release(&memory)
// os.print("Hello world")