A VSCode extension for syntax highlighting, autocompletion, and linting of the 5250script DSL.
- Syntax highlighting for the 5250script language:
- Commands (
TYPE,PRESS,MOVE,EXPECT,EXTRACT,WAIT,SET,INC,DEC,ADD,ABORT,LOG,PAUSE,GLOBAL) - Control flow keywords (
IF,ELSE,ENDIF,WHILE,ENDWHILE,REPEAT,ENDREPEAT,DEF,ENDDEF,CALL,RETURN,LABEL,GOTO,ON,THEN) - AID keys (
ENTER,F1-F24,PAGEUP,PAGEDOWN,ATTN,SYSREQ,HELP,CLEAR,PRINT) - Local keys (
TAB,BACKTAB,BACKSPACE,DELETE,INSERT,HOME,END,ESC,FIELDPLUS,FIELDMINUS,FIELDEXIT,DUP,ERASEINPUT,ERASEFIELD,ERASEEOF) - Character keys (
KEY_A-KEY_Z,KEY_0-KEY_9,KEY_SPACE,KEY_PERIOD, etc.) - Variables (
$USERNAME,$CURSOR_ROW, etc.) - Function names (definitions,
CALL, and bare calls) - Strings with variable interpolation
- Comments, numbers, operators
- Commands (
- Context-aware autocompletion:
- Top-level commands and AID keys on empty lines
- Sub-keywords after commands (
PRESSsuggests keys,MOVEsuggestsCURSOR, etc.) - Label names after
GOTOandON ... GOTO - Function names with parameter snippets after
CALL - User-defined and built-in variables when typing
$
- Semantic linting:
- Block matching (
IF/ENDIF,WHILE/ENDWHILE,REPEAT/ENDREPEAT,DEF/ENDDEF) -
ELSEwithoutIF/ duplicateELSEdetection -
DEFinside another block detection - Duplicate label and function name detection
- Undefined
GOTOtarget andCALLtarget detection - Argument count mismatch on function calls
- Unused variable warnings
- Unreachable code warnings after
ABORTorGOTO
- Block matching (
- Parse error reporting (Chevrotain-based parser)
- Auto-formatting on save (indentation and trailing whitespace removal)
- Right-click "Format file" context menu for
.5250scriptfiles - Support for bare function calls (
login($user, $pass)withoutCALL) - Optional
THENkeyword afterIFconditions
You can install this extension from a .vsix package:
-
Build the extension:
make all -
Install in VSCode:
make vscode-install -
Install in Cursor:
make cursor-install
Create a file with the .5250script extension and start writing. The extension activates automatically and provides syntax highlighting, autocompletion, and linting.
- Autocompletion: Triggered automatically when typing commands, or with
$for variables. - Linting: Errors and warnings appear in real-time as you type.
- Formatting: Right-click a
.5250scriptfile and select "Format file", or save the file to auto-format.
# Login automation script
GLOBAL EXPECT_TIMEOUT 30000
GLOBAL DELAY 100
SET $USERNAME "QSECOFR"
SET $PASSWORD "QSECOFR0"
DEF login($username, $password)
MOVE CURSOR AT NEXT INPUTFIELD
TYPE "$username"
MOVE CURSOR AT NEXT INPUTFIELD
TYPE "$password"
PRESS ENTER
ENDDEF
EXPECT TEXT "Sign On"
login($USERNAME, $PASSWORD)
IF $CURSOR_ROW == 1 THEN
LOG "Login successful"
ELSE
ABORT "Login failed"
ENDIF
Pull requests are welcome. Feel free to open an issue if you want to add other features.
