EPSON SPEL+ Language Support
VS Code extension that recognizes .prg files as EPSON SPEL+ robot
programs (the language used by EPSON RC+ 7.x) and provides:
- Syntax highlighting for keywords, motion commands, IO, tasks, point
management, coordinate changes, torque, file management, built-in
functions, types, constants, strings (both
"..." and [...]), numbers
(&H, &B, &O, decimal), preprocessor pseudo-statements, and comments.
- Autocompletion for 481 SPEL+ entries — every keyword, motion
command, IO command, task control, point / coordinate / file management
command, type, constant and built-in function in the official
EPSON RC+ 7.0 (Ver.7.1) SPEL+ Language Reference.
Trigger fires on every letter A–Z / a–z,
$ (the string suffix), the
common operators and brackets; the list is filtered by the current
word at the caret (typing Str shows only String and Str$).
- Hover documentation in Chinese / English with the exact byte size
and value range for each data type, official §6.8 table for string
functions, and the full signature for every command.
- Go to Definition for user-declared
Function / Sub, point
labels (pickPnt = XY(...)), line labels (errHandler:), and local
variables (Integer i, Real x, String msg$, ...). Triggered with
Ctrl+Click or F12 — the caret lands precisely on the identifier.
- Document Outline / Symbols so the Explorer shows a tree of
Functions, Subs, and labels.
- Snippets — 125 entries covering 14 data types, 22 string
functions, motion / IO / task / coordinate / file management, and
preprocessor pseudo statements.
- Lightweight validation that warns on unclosed
If / For / While
/ Select / Function / Sub blocks and stray closers.
- Document formatter that normalises indentation to a configurable
size.
- Signature help that pops up inside
Mid$(...), InStr(...),
Sin(...) and other call sites, parsing the parameters straight out of
the knowledge-base signature string.
Project layout
.
├─ package.json # extension manifest
├─ tsconfig.json
├─ language-configuration.json
├─ syntaxes/
│ └─ spel.tmLanguage.json # TextMate grammar
├─ snippets/
│ └─ spel.json # 125 code snippets
├─ src/
│ ├─ extension.ts # extension entry
│ ├─ definitionProvider.ts # client-side go-to-definition
│ ├─ common/
│ │ ├─ spelKnowledge.ts # 481-entry SPEL+ catalogue
│ │ └─ spelIndex.ts # pure indexer (no vscode imports)
│ └─ providers/ # all client-side language features
│ ├─ completionProvider.ts
│ ├─ hoverProvider.ts
│ ├─ documentSymbolProvider.ts
│ ├─ documentFormatter.ts
│ ├─ diagnostics.ts
│ └─ signatureHelpProvider.ts
├─ examples/
│ └─ demo.prg # sample SPEL+ program
└─ out/ # compiled artefacts
└─ extension.js # single-file extension entry
Knowledge base
All 481 entries are in src/common/spelKnowledge.ts, grouped into 17
categories:
| Category |
Count |
Source |
| Keywords (program control) |
59 |
§6.3 命令和语句 |
| Data types |
14 |
§6.5 数据类型 |
| System management |
32 |
§8.1 System Management |
| Robot control / motion |
170 |
§6.18 + §8.3 运动命令 |
| Torque |
14 |
§8.2 转矩 |
| Input / Output |
24 |
§6.20 IO |
| Point management |
12 |
§6.19 点 |
| Coordinate change |
31 |
§6.16 坐标系 |
| Task |
15 |
§6.23 任务 |
| File / database |
34 |
§6.9 文件 |
| Numeric functions |
24 |
§6.10 数值 |
| String functions |
22 |
§6.8 字符串 |
| Logical / bitwise |
7 |
§6.11 逻辑运算 |
| Pseudo statements |
9 |
§6.13 伪指令 |
| Variable scope |
4 |
§6.7 变量 |
| Constants |
11 |
§6.5 |
| Conveyor / force / PG / collision |
30 |
§6.21–6.22 |
| Total |
481 |
|
Hover doc, completion, signature help and snippets are all generated
from this single source of truth.
License
MIT.
EPSON SPEL+ 语言支持(中文说明)
VS Code 扩展,把 .prg 文件识别为 EPSON SPEL+ 机器人程序(EPSON
RC+ 7.x 使用的语言),并提供:
- 语法高亮:关键字、运动指令、IO、任务、点管理、坐标变换、
转矩、文件管理、内置函数、类型、常量、字符串(
"..." 和 [...])、
数字(&H、&B、&O、十进制)、预处理器伪指令、注释,共 17 个
语义类。
- 自动补全:基于 EPSON RC+ 7.0 (Ver.7.1) SPEL+ 语言参考
的 481 条目,涵盖全部关键字、运动指令、IO、任务、点/坐标/文件管理、
类型、常量和内置函数。每次按键(A–Z / a–z)、
$(字符串后缀)、
常用运算符和括号都会触发;结果按光标前的标识符前缀过滤(如输入
Str 只剩 String 和 Str$)。
- 悬停文档:中英双语,每种数据类型附 §6.5 官方表里的精确字节数
和值域,字符串函数附 §6.8 表的完整描述,命令附完整签名。
- 跳转定义:
Function / Sub 声明、点标签(pickPnt = XY(...))、
行标签(errHandler:)和局部变量(Integer i、Real x、String msg$ 等)。
Ctrl+点击 或 F12 触发,光标会精确落在标识符上。
- 大纲 / 符号:资源管理器里显示 Function / Sub / 标签的树状结构。
- 代码片段:125 条覆盖 14 种数据类型、22 个字符串函数、
运动/IO/任务/坐标/文件管理命令、预处理器伪指令。
- 轻量级验证:未关闭的
If / For / While / Select /
Function / Sub 块和孤立结束符的告警。
- 文档格式化:按可配置大小规范化缩进。
- 签名帮助:在
Mid$(...)、InStr(...)、Sin(...) 等调用处
弹出参数提示,参数直接从知识库 signature 字符串解析。
项目结构
.
├─ package.json # 扩展清单
├─ tsconfig.json
├─ language-configuration.json
├─ syntaxes/
│ └─ spel.tmLanguage.json # TextMate 语法
├─ snippets/
│ └─ spel.json # 125 个代码片段
├─ src/
│ ├─ extension.ts # 扩展入口
│ ├─ definitionProvider.ts # 客户端跳转定义
│ ├─ common/
│ │ ├─ spelKnowledge.ts # 481 条 SPEL+ 知识库
│ │ └─ spelIndex.ts # 纯索引器(不依赖 vscode)
│ └─ providers/ # 所有客户端能力
│ ├─ completionProvider.ts
│ ├─ hoverProvider.ts
│ ├─ documentSymbolProvider.ts
│ ├─ documentFormatter.ts
│ ├─ diagnostics.ts
│ └─ signatureHelpProvider.ts
├─ examples/
│ └─ demo.prg # 示例 SPEL+ 程序
└─ out/ # 编译产物
└─ extension.js # 单文件扩展入口
知识库
所有 481 条都在 src/common/spelKnowledge.ts,按 17 个类别组织:
| 类别 |
条目数 |
来源 |
| 关键字(程序控制) |
59 |
§6.3 命令和语句 |
| 数据类型 |
14 |
§6.5 数据类型 |
| 系统管理 |
32 |
§8.1 System Management |
| 机器人控制 / 运动 |
170 |
§6.18 + §8.3 运动命令 |
| 转矩 |
14 |
§8.2 转矩 |
| 输入输出 |
24 |
§6.20 IO |
| 点管理 |
12 |
§6.19 点 |
| 坐标变换 |
31 |
§6.16 坐标系 |
| 任务 |
15 |
§6.23 任务 |
| 文件 / 数据库 |
34 |
§6.9 文件 |
| 数值函数 |
24 |
§6.10 数值 |
| 字符串函数 |
22 |
§6.8 字符串 |
| 逻辑 / 位运算 |
7 |
§6.11 逻辑运算 |
| 伪指令 |
9 |
§6.13 伪指令 |
| 变量作用域 |
4 |
§6.7 变量 |
| 常量 |
11 |
§6.5 |
| 输送带 / 力传感 / PG / 碰撞 |
30 |
§6.21–6.22 |
| 合计 |
481 |
|
悬停文档、补全、签名帮助、snippet 都从这个单一数据源自动生成。
常见问题
Q: 输入 Str 不出 String?
检查扩展是否被 VSCode 加载、.prg 文件是否被识别成 SPEL+ 语言
(右下角状态栏应显示 "SPEL+")。开发者工具 Console 应该看到
[spel-plus] activated (all features client-side)。
Q: 升级后看不到新功能?
先 code --uninstall-extension spel-plus-publisher.spel-plus 再
装新版,完整重启 VSCode(不是 reload window)。
捐赠一杯咖啡
如果这个扩展帮到你了,欢迎扫码请我喝杯咖啡 ☕
协议
MIT。
| |