9a53d97274
- 新增 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 建议。
41 lines
974 B
C
41 lines
974 B
C
#ifndef L_LANG_H
|
||
#define L_LANG_H
|
||
|
||
#include <stddef.h>
|
||
#include <stdbool.h>
|
||
#include <stdint.h>
|
||
|
||
// === 类型系统 ===
|
||
typedef enum {
|
||
TYPE_I64,
|
||
TYPE_F64,
|
||
TYPE_BOOL,
|
||
TYPE_STR,
|
||
TYPE_VOID,
|
||
TYPE_UNKNOWN, // 尚未推断
|
||
TYPE_ERROR, // 类型错误
|
||
} TypeKind;
|
||
|
||
static inline const char* type_name(TypeKind kind) {
|
||
switch (kind) {
|
||
case TYPE_I64: return "i64";
|
||
case TYPE_F64: return "f64";
|
||
case TYPE_BOOL: return "bool";
|
||
case TYPE_STR: return "str";
|
||
case TYPE_VOID: return "void";
|
||
default: return "<unknown>";
|
||
}
|
||
}
|
||
|
||
// === 向前声明 ===
|
||
typedef struct Token Token;
|
||
typedef struct AstNode AstNode;
|
||
typedef struct Scope Scope;
|
||
typedef struct Arena Arena;
|
||
|
||
// === 跨模块分配器接口(避免循环依赖,各模块通过 void* 使用 arena)===
|
||
void* arena_alloc_impl(void* alloc, size_t size);
|
||
char* arena_strdup_impl(void* alloc, const char* src, size_t len);
|
||
|
||
#endif
|