From 43f424c414c105dde3e7d6e883b33fbbcd42f2b6 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Wed, 15 Jun 2022 09:22:28 +0200 Subject: [PATCH] Add handling of binary numbers 0b1001 --- lexing.cpp | 13 +++++++++++++ programs/main.kl | 28 ++++++++++++++++++++++------ programs/user32.kl | 6 +++--- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/lexing.cpp b/lexing.cpp index 3a6af4d..7c2f2aa 100644 --- a/lexing.cpp +++ b/lexing.cpp @@ -509,6 +509,19 @@ lex__stream(Lexer *lexer){ lex_parse_u64(lexer, &t, 16); break; } + else if(lexc(s) == 'b'){ + lex_advance(s); + while(lexc(s) == '0' || lexc(s) == '1') + lex_advance(s); + lex_set_len(s, &t); + t.str += 2; + t.len -= 2; + if(t.len == 0) + token_error(&t, "Hex constant doesn't have value"_s); + else + lex_parse_u64(lexer, &t, 2); + break; + } } case '1':case '2':case '3':case '4': diff --git a/programs/main.kl b/programs/main.kl index d6c445f..09aefeb 100644 --- a/programs/main.kl +++ b/programs/main.kl @@ -2,6 +2,24 @@ #load "gdi32.kl" #load "user32.kl" +String16 :: struct;; str: *U16; len: S64 +String32 :: struct;; str: *U32; len: S64 +UTF32_Result :: struct + out_str: U32 + advance: S64 + error : Bool +UTF16_Result :: struct + out_str: [2]U16 + len : S32 + error : Bool + +BINARY :: 0b1001 + +utf8_to_utf32 :: (c: *U8, max_advance: S64): UTF32_Result + result: UTF32_Result + return result + + Vec2I :: struct;; x: S32; y: S32 Vec2 :: struct;; x: F32; y: F32 @@ -37,13 +55,11 @@ create_bitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT if msg == WM_DESTROY - pass + PostQuitMessage(0) + return 0 + else;; return DefWindowProc(hwnd, msg, wparam, lparam) main :: (argc: int, argv: **char): int bitmap := create_bitmap({1280, 720}) - WNDCLASS - // memory := os.reserve(size = 10000) - // os.commit(&memory, 1000) - // os.release(&memory) - // os.print("Hello world") + diff --git a/programs/user32.kl b/programs/user32.kl index 1d78c24..5d8ab2a 100644 --- a/programs/user32.kl +++ b/programs/user32.kl @@ -8,6 +8,6 @@ GetDC :: #foreign (hWnd: HWND): HDC 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 CreateWindowExW :: #foreign (dwExStyle: DWORD, lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpPara: LPVOID): HWND -WM_NULL :: 0x0000;; WM_CREATE :: 0x0001; WM_DESTROY :: 0x0002; WM_MOVE :: 0x0003; WM_SIZE :: 0x0005 -WM_ACTIVATE :: 0x0006;; WA_INACTIVE :: 0; WA_ACTIVE :: 1; WA_CLICKACTIVE :: 2 -WM_SETFOCUS :: 0x0007;; WM_KILLFOCUS :: 0x0008; WM_ENABLE :: 0x000A; WM_SETREDRAW :: 0x000B; WM_SETTEXT :: 0x000C; WM_GETTEXT :: 0x000D; WM_GETTEXTLENGTH :: 0x000E; WM_PAINT :: 0x000F; WM_CLOSE :: 0x0010 \ No newline at end of file +WM_NULL :: 0x0000; WM_CREATE :: 0x0001; WM_DESTROY :: 0x0002; WM_MOVE :: 0x0003; WM_SIZE :: 0x0005 +WM_ACTIVATE :: 0x0006; WA_INACTIVE :: 0; WA_ACTIVE :: 1; WA_CLICKACTIVE :: 2 +WM_SETFOCUS :: 0x0007; WM_KILLFOCUS :: 0x0008; WM_ENABLE :: 0x000A; WM_SETREDRAW :: 0x000B; WM_SETTEXT :: 0x000C; WM_GETTEXT :: 0x000D; WM_GETTEXTLENGTH :: 0x000E; WM_PAINT :: 0x000F; WM_CLOSE :: 0x0010 \ No newline at end of file