feat: const 编译期常量 — const N = 42;

Token(77): +TOK_CONST, AST_LET_STMT 新增 is_const, Symbol 新增 const_value
sema: 字面量初始化自动折叠为编译期常量值

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 14:26:59 +08:00
parent f7710ede9d
commit 0a0667776a
8 changed files with 19 additions and 8 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
#include <inttypes.h>
static const char* NAMES[] = {
[TOK_FN] = "fn", [TOK_LET] = "let", [TOK_VAR] = "var", [TOK_IF] = "if", [TOK_GUARD] = "guard",
[TOK_FN] = "fn", [TOK_LET] = "let", [TOK_VAR] = "var", [TOK_CONST] = "const", [TOK_IF] = "if", [TOK_GUARD] = "guard",
[TOK_PUB] = "pub", [TOK_MOD] = "mod", [TOK_USE] = "use",
[TOK_TRAIT] = "trait", [TOK_SELF] = "Self",
[TOK_ELSE] = "else", [TOK_WHILE] = "while", [TOK_FOR] = "for", [TOK_IN] = "in", [TOK_RETURN] = "return",