highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.66k stars 3.59k forks source link

PLC Structured text language support IEC61131 #3120

Closed iAnyKey closed 3 years ago

iAnyKey commented 3 years ago

Pleas add support of the syntax hihglighting for Structured text languages used in programmable logic controllers (PLC) as defined in IEC 61131-3 (for example CoDeSys or Siemens SCL) s. Wikipedia Article with references for more detailed information.

They are basically wery similar to PASCAL and it is possible to use this language definition for highlighting. But as you can see below, some specific constructions remain not parsed:

// PLC configuration
CONFIGURATION DefaultCfg
    VAR_GLOBAL
        b_Start_Stop  : BOOL;         // Global variable to represent a boolean.
        b_ON_OFF      : BOOL;         // Global variable to represent a boolean.
        Start_Stop AT %IX0.0:BOOL;    // Digital   input of the PLC (Address 0.0)
        ON_OFF     AT %QX0.0:BOOL;    // Digital output of the PLC (Address 0.0). (Coil)
    END_VAR

    // Schedule the main program to be executed every 20 ms
    TASK Tick(INTERVAL := t#20ms);

    PROGRAM Main WITH Tick : Monitor_Start_Stop;
END_CONFIGURATION

PROGRAM Monitor_Start_Stop          // Actual Program
    VAR_EXTERNAL
        Start_Stop  : BOOL;
        ON_OFF      : BOOL;
    END_VAR
    VAR                             // Temporary variables for logic handling
        ONS_Trig    : BOOL;
        Rising_ONS  : BOOL;
    END_VAR

    // Start of Logic
    // Catch the Rising Edge One Shot of the Start_Stop input
    ONS_Trig    := Start_Stop AND NOT Rising_ONS;

    // Main Logic for Run_Contact -- Toggle ON / Toggle OFF ---
    ON_OFF := (ONS_Trig AND NOT ON_OFF) OR (ON_OFF AND NOT ONS_Trig);

    // Rising One Shot logic   
    Rising_ONS := Start_Stop;
END_PROGRAM
joshgoebel commented 3 years ago

Closing per our policy on language requests. https://highlightjs.readthedocs.io/en/latest/language-requests.html

You're welcome to add your request to the wiki (with a link to this issue), but generally nothing comes of doing so. https://github.com/highlightjs/highlight.js/wiki/Grammar-Requests

If you'd be interested in working on this yourself and contributing a 3rd party grammar we'd be happy to have it! Looks like it might be a pretty simple grammar as far as such things go.