New approach, new lexer

This commit is contained in:
Krzosa Karol
2022-05-06 10:13:16 +02:00
parent 557dde1936
commit e3b5e9b33a
33 changed files with 3331 additions and 784 deletions

View File

@@ -1,36 +1,16 @@
function S32 os_main();
const SizeU page_size = 4096;
LRESULT CALLBACK
WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
return DefWindowProcW(hwnd, uMsg, wParam, lParam);;
}
int
WinMain(HINSTANCE hInstance, HINSTANCE a, LPSTR b, int nShowCmd){
wchar_t *CLASS_NAME = L"Cool window class";
wchar_t *WINDOW_NAME = L"Have a good day!";
WNDCLASSW wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClassW(&wc);
HWND window_handle = CreateWindowExW(0, CLASS_NAME, WINDOW_NAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hInstance, 0);
ShowWindow(window_handle, nShowCmd);
return os_main();
}
function String
os_read_file(String name){
String result = {};
os_read_file(Arena *arena, String name){
String result = {0};
FILE *f = fopen((char *)name.str, "rb");
assert(f);
fseek(f, 0, SEEK_END);
result.len = ftell(f);
fseek(f, 0, SEEK_SET); /* same as rewind(f); */
result.str = malloc(result.len + 1);
result.str = arena_push_size(arena, result.len + 1);
fread(result.str, result.len, 1, f);
fclose(f);