名称: REPL开发 描述: 构建具有丰富编辑和评估功能的交互式REPL的专业技能 类别: 工具 允许使用的工具:
- 读取
- 写入
- 编辑
- 全局匹配
- 文本搜索
- Bash
REPL开发技能
概述
构建具有丰富编辑和评估功能的交互式REPL的专业技能。
能力
- 实现带历史记录的readline集成
- 处理多行输入检测
- 为标识符实现Tab键自动补全
- 为REPL设计增量编译
- 处理顶层表达式求值
- 实现持久化的REPL状态
- 设计值的漂亮打印输出
- 支持特殊的REPL命令(如 :help, :type 等)
目标流程
- repl-development.js
- interpreter-implementation.js
- lsp-server-implementation.js
依赖项
- rustyline
- readline库
- linenoise
使用指南
- 行编辑: 使用成熟的readline库进行稳健的行编辑
- 多行: 检测不完整的表达式以支持多行输入
- 补全: 实现上下文感知的Tab键补全
- 历史: 跨会话持久化历史记录
- 命令: 提供有用的元命令(如 :help, :type, :quit 等)
输出模式
{
"type": "object",
"properties": {
"lineLibrary": {
"type": "string",
"enum": ["readline", "rustyline", "linenoise", "custom"]
},
"features": {
"type": "array",
"items": { "type": "string" }
},
"commands": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"description": { "type": "string" }
}
}
},
"generatedFiles": {
"type": "array",
"items": { "type": "string" }
}
}
}