From 1201a6c45a0d27a05ea8b733a776d2bb5b5f1eac Mon Sep 17 00:00:00 2001 From: janis Date: Fri, 31 Oct 2025 13:17:47 +0100 Subject: [PATCH] comments, skip empty semis in blocks --- lang/src/ast.asm | 7 +++++++ lang/src/tokeniser.asm | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lang/src/ast.asm b/lang/src/ast.asm index fe86cac..5343dec 100644 --- a/lang/src/ast.asm +++ b/lang/src/ast.asm @@ -658,6 +658,13 @@ parse_block: call peek_expect_token test rax, rax jnz .done + + ; skip semicolons + mov dil, TOKEN_SEMI + call expect_token + test rax, rax + jnz .loop + mov rdi, [rsp + 56] ; Ast call parse_statement lea rdi, [rsp + 8] ; vec diff --git a/lang/src/tokeniser.asm b/lang/src/tokeniser.asm index 21afb01..40eea1a 100644 --- a/lang/src/tokeniser.asm +++ b/lang/src/tokeniser.asm @@ -547,7 +547,8 @@ expect_token: add rsp, 0x30 pop rbp ret - + +;; Returns the next token if it matches the expected token, else panics ;; dil: expected token unwrap_token: push rbp @@ -561,6 +562,7 @@ unwrap_token: call panic ;; returns 0 if token not found, else returns lexeme (ptr, len) +;; doesn't advance the cursor ;; dil: expected token peek_expect_token: push rbp @@ -573,6 +575,7 @@ peek_expect_token: pop rbp ret +;; returns the next lexeme without advancing the cursor ;; rdi: out-struct pointer peek_lexeme: push rbp