How c-li/estun_robot_highlighting works
Purpose and host integration
This repository is a TypeScript VS Code extension for ESTUN RCS2 robot-language source files: .erd data definitions and .erp executable robot programs. VS Code supplies document lifecycle, grammar tokenization, and hover UI; the extension does not execute or validate robot programs. Key integration metadata is in package.json, with activation/runtime code in src/extension.ts.
Extension activation and registration
The extension entry point activates in the VS Code extension host and registers a hover provider for the RCS2 language. The provider is responsible only for contextual documentation at the cursor; grammar-based highlighting remains declarative and is handled by VS Code. Paths: src/extension.ts, src/hoverProvider.ts, package.json.
Language definition and syntax-tokenization boundary
A TextMate grammar defines recognition and scopes for RCS2 keywords, types, motion and I/O instructions, operators, variables, labels, strings, numbers, and the three comment forms. VS Code’s TextMate engine consumes this JSON grammar for highlighting, separating lexical display from TypeScript hover behavior. Paths: syntaxes/robot-language.tmLanguage.json, language-configuration.json, package.json.
Hover resolution pipeline
On hover, the provider identifies the relevant token or variable form from the current document position, then resolves documentation for recognized language elements. It supports both direct keyword documentation and special forms such as labels and prefixed variables (t_p., t_s., t_l., t_g.), including full-variable contextual descriptions. Paths: src/hoverProvider.ts, src/hoverData.ts.
Documentation knowledge base
The extension embeds RCS2 reference content as structured TypeScript data rather than retrieving it from a controller, network API, or language server. This catalog covers data types, motion/control/IO/system instructions, math functions, velocity and zone constants, and usage syntax/examples/parameters. Adding supported hover content primarily means extending this data catalog. Path: src/hoverData.ts.
File-type workflow and examples
Users open RCS2 source files in VS Code; VS Code maps them to the contributed language, applies the grammar, and invokes hover handling on demand. The sample .erd and .erp files represent the two-file RCS2 model and serve as representative inputs for manual verification. Paths: examples/sample.erd, examples/sample.erp, package.json.
Runtime, packaging, and boundaries
Runtime is Node.js/TypeScript compiled for the VS Code extension host, using the VS Code API. Distribution is a VSIX package; package scripts drive compilation and prepublish packaging. No backend, database, robot controller connection, or external service is present. Paths: package.json, tsconfig.json, build.bat.
Components 15
VS Code Host
- RCS2 source files · Robot data definitions and executable programs opened by users.
- Document lifecycle
- TextMate tokenization
- Hover UI
Extension Runtime
- Extension manifest · Contributes language wiring, activation, and packaging scripts.
package.json - Activation entry · Activates in the extension host and registers hover support.
src/extension.ts - Hover provider · Finds the token or variable form at the cursor.
src/hoverProvider.ts - Hover documentation catalog · Embedded RCS2 reference data for keywords, variables, constants, and instructions.
src/hoverData.ts - TypeScript build · Compiles Node.js extension-host runtime code.
tsconfig.json - VSIX distribution · Built and prepublished through package scripts.
package.json - Windows build script
build.bat
Language Assets
- RCS2 TextMate grammar · Defines scopes for keywords, types, instructions, literals, labels, and comments.
syntaxes/robot-language.tmLanguage.json - Language configuration
language-configuration.json - Sample data definition · Representative manual-verification input.
examples/sample.erd - Sample robot program · Representative manual-verification input.
examples/sample.erp
Connections 17
- Extension manifest → Activation entry: declares entry and activation
- Extension manifest → RCS2 TextMate grammar: contributes grammar
- Extension manifest → Language configuration: contributes settings
- RCS2 source files → Document lifecycle: opened as
- Document lifecycle → TextMate tokenization: tokenized for highlighting
- RCS2 TextMate grammar → TextMate tokenization: defines lexical scopes
- Language configuration → Document lifecycle: configures language behavior
- Activation entry → Hover provider: registers
- Document lifecycle → Hover provider: hover request and cursor position
- Hover provider → Hover documentation catalog: resolves documentation from
- Hover provider → Hover UI: returns contextual content
- Sample data definition → RCS2 source files: representative input
- Sample robot program → RCS2 source files: representative input
- TypeScript build → Activation entry: compiles
- Windows build script → TypeScript build: drives
- TypeScript build → VSIX distribution: builds runtime for
- Extension manifest → VSIX distribution: packages as