Skip to content

5250ng/5250script-syntax-highlighting-plugin

Repository files navigation

A VSCode extension for syntax highlighting, autocompletion, and linting of the 5250script DSL.
GitHub release (latest by date) YouTube Channel Subscribers

Features

  • 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
  • Context-aware autocompletion:
    • Top-level commands and AID keys on empty lines
    • Sub-keywords after commands (PRESS suggests keys, MOVE suggests CURSOR, etc.)
    • Label names after GOTO and ON ... 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)
    • ELSE without IF / duplicate ELSE detection
    • DEF inside another block detection
    • Duplicate label and function name detection
    • Undefined GOTO target and CALL target detection
    • Argument count mismatch on function calls
    • Unused variable warnings
    • Unreachable code warnings after ABORT or GOTO
  • Parse error reporting (Chevrotain-based parser)
  • Auto-formatting on save (indentation and trailing whitespace removal)
  • Right-click "Format file" context menu for .5250script files
  • Support for bare function calls (login($user, $pass) without CALL)
  • Optional THEN keyword after IF conditions

Installation

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
    

Usage

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 .5250script file and select "Format file", or save the file to auto-format.

Example

# 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

Contributing

Pull requests are welcome. Feel free to open an issue if you want to add other features.

About

A VSCode extension for syntax highlighting, autocompletion, and linting of the 5250script DSL.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors