feat: 字符串类型 + 字面量 + print_str
- 新增 TYPE_STR 类型 (i8* 指针)
- lexer: 双引号字符串字面量 + str 关键字
- parser: TOK_STR_LIT → AST_LITERAL_EXPR(str_val)
- sema: print_str 内置函数注册 + 字符串拼接类型检查
- codegen: GlobalStringPtr 生成字符串常量,print_str → printf("%s")
- 新增集成测试 07_hello_str.l
基于 Codex 分析报告 P0 建议。
This commit is contained in:
@@ -112,6 +112,13 @@ AstNode* ast_make_literal_bool(void* alloc, bool val, int line, int col) {
|
||||
return n;
|
||||
}
|
||||
|
||||
AstNode* ast_make_literal_str(void* alloc, const char* val, int line, int col) {
|
||||
NEW(alloc, AST_LITERAL_EXPR);
|
||||
n->as.literal.lit_type = TYPE_STR; n->as.literal.str_val = val;
|
||||
n->type.kind = TYPE_STR;
|
||||
return n;
|
||||
}
|
||||
|
||||
AstNode* ast_make_ident(void* alloc, const char* name, int line, int col) {
|
||||
NEW(alloc, AST_IDENT_EXPR);
|
||||
n->as.ident.name = name;
|
||||
|
||||
Reference in New Issue
Block a user