docs: 整理文档——修复全部 file:// 失效链接、补齐缺失模块 README
- 将 7 个文档中的 mac 绝对路径链接(file:///Users/qingsong/...)转换为仓库相对路径, 并修正错误目标:aibox 入口 main.py → aibox.py、pymsg C++ 实现 → libmsg/inc/us/Msg.hpp、 bot4cj cpp/cnn → cuda - 主 README 补 liblogc 基础库条目与 confs2 归档说明,安装顺序补 ca - 新增 liblogc / libtry / confs2 / 3d / memdb README - 同步 db2 脚本迁移(db/create_sqlite3.sql → db2/scripts/)导致的失效引用
This commit is contained in:
1 parent
7072e33d6f
commit
7467e7bd42
13 files changed
+158
-92
No files matched your search
@@ -0,0 +1,10 @@
|
||||
# libtry — 嵌入式脚本解释器
|
||||
|
||||
基于 C 语言手写的教学级脚本解释器(~741 行),魔改自 GitHub 上的 tryC 项目,用于解析 `.try` 脚本,设计目标为嵌入式操作界面 shell。
|
||||
|
||||
- **零依赖**:仅标准 C 库 + `console.h` 输出接口。
|
||||
- **递归下降**:手写词法/语法/执行引擎,边解析边执行。
|
||||
- **宽字符**:`wchar_t` 支持中文/多语言脚本。
|
||||
- **嵌入式 API**:`init_tryc` / `enqueue_tryc` / `eval_tryc` / `free_tryc` 四个核心入口(单文件 [try.c](try.c) + `console.h` 输出接口)。
|
||||
|
||||
详细技术手册(含局限性与改进路线)见 [README.robot.md](README.robot.md)。
|
||||
+13
-13
@@ -580,20 +580,20 @@ puts("1");
|
||||
|
||||
| ID | 位置 | 描述 | 影响 |
|
||||
|----|------|------|------|
|
||||
| L1 | [L20](file:///Users/qingsong/micro_servers/libtry/try.c#L20) | **缓冲区大小固定**:`POOLSIZE = 128` 字节,无法修改 | 长脚本将溢出 |
|
||||
| L2 | [L702](file:///Users/qingsong/micro_servers/libtry/try.c#L702) | **`__exit()` 死循环**:`while(1);` 错误时直接挂死程序 | 无法恢复 |
|
||||
| L3 | [L186](file:///Users/qingsong/micro_servers/libtry/try.c#L186) | **字符串内存泄漏**:`malloc` 分配的字符串在重新赋值时未释放 | 长期运行泄漏 |
|
||||
| L4 | [L528](file:///Users/qingsong/micro_servers/libtry/try.c#L528) | **数组越界**:无越界检查 | 未定义行为 |
|
||||
| L1 | [L20](try.c#L20) | **缓冲区大小固定**:`POOLSIZE = 128` 字节,无法修改 | 长脚本将溢出 |
|
||||
| L2 | [L702](try.c#L702) | **`__exit()` 死循环**:`while(1);` 错误时直接挂死程序 | 无法恢复 |
|
||||
| L3 | [L186](try.c#L186) | **字符串内存泄漏**:`malloc` 分配的字符串在重新赋值时未释放 | 长期运行泄漏 |
|
||||
| L4 | [L528](try.c#L528) | **数组越界**:无越界检查 | 未定义行为 |
|
||||
|
||||
### 🟡 中等问题
|
||||
|
||||
| ID | 位置 | 描述 |
|
||||
|----|------|------|
|
||||
| L5 | [L598](file:///Users/qingsong/micro_servers/libtry/try.c#L598) | **`puts` 实现存疑**:原 `wprintf` 被注释,改用 `printtovga` |
|
||||
| L6 | [L518](file:///Users/qingsong/micro_servers/libtry/try.c#L518) | **`clearThis()` 被注释**:作者注释说"不知为何需要注释了才能跑" |
|
||||
| L7 | [L706](file:///Users/qingsong/micro_servers/libtry/try.c#L706) | **文件模式仅限 `_DEBUG`**:正常构建时 `main()` 不编译 |
|
||||
| L8 | [L103](file:///Users/qingsong/micro_servers/libtry/try.c#L103) | **栈缓冲区溢出风险**:`nameBuffer[16]` 但标识符长度限制由 `MAXNAMESIZE=16` 控制 |
|
||||
| L9 | [L21](file:///Users/qingsong/micro_servers/libtry/try.c#L21) | **符号表大小固定**:`SYMTABSIZE = 128` 个符号 |
|
||||
| L5 | [L598](try.c#L598) | **`puts` 实现存疑**:原 `wprintf` 被注释,改用 `printtovga` |
|
||||
| L6 | [L518](try.c#L518) | **`clearThis()` 被注释**:作者注释说"不知为何需要注释了才能跑" |
|
||||
| L7 | [L706](try.c#L706) | **文件模式仅限 `_DEBUG`**:正常构建时 `main()` 不编译 |
|
||||
| L8 | [L103](try.c#L103) | **栈缓冲区溢出风险**:`nameBuffer[16]` 但标识符长度限制由 `MAXNAMESIZE=16` 控制 |
|
||||
| L9 | [L21](try.c#L21) | **符号表大小固定**:`SYMTABSIZE = 128` 个符号 |
|
||||
|
||||
### 🟢 轻微问题
|
||||
|
||||
@@ -609,7 +609,7 @@ puts("1");
|
||||
|
||||
#### 优先级 1(安全相关)
|
||||
|
||||
1. **修复数组越界**:在 [L528](file:///Users/qingsong/micro_servers/libtry/try.c#L528) 添加检查
|
||||
1. **修复数组越界**:在 [L528](try.c#L528) 添加检查
|
||||
```c
|
||||
if (index < 0 || index >= s->value) {
|
||||
printtovga(L"Array index out of bounds\n");
|
||||
@@ -650,7 +650,7 @@ puts("1");
|
||||
|
||||
### 8.1 添加新关键字
|
||||
|
||||
在 [init_tryc()](file:///Users/qingsong/micro_servers/libtry/try.c#L650) 中添加:
|
||||
在 [init_tryc()](try.c#L650) 中添加:
|
||||
|
||||
```c
|
||||
// 1. 在 enum 中添加新 token 类型
|
||||
@@ -678,7 +678,7 @@ else if (token == NewKeyword) {
|
||||
|
||||
### 8.2 添加新运算符
|
||||
|
||||
在 [next()](file:///Users/qingsong/micro_servers/libtry/try.c#L85) 中添加识别逻辑:
|
||||
在 [next()](try.c#L85) 中添加识别逻辑:
|
||||
|
||||
```c
|
||||
// 例如:+= 运算符
|
||||
@@ -690,7 +690,7 @@ else if (token == L'+') {
|
||||
}
|
||||
```
|
||||
|
||||
在 [statement()](file:///Users/qingsong/micro_servers/libtry/try.c#L466) 中添加执行逻辑。
|
||||
在 [statement()](try.c#L466) 中添加执行逻辑。
|
||||
|
||||
### 8.3 自定义输出
|
||||
|
||||
|
||||
Reference in new issue
Block a user