Skip to content

A Python-based compiler that parses IEC 61131-3 Structured Text (ST) source files and outputs a corresponding Abstract Syntax Tree (AST) in XML format. It utilizes a custom recursive descent parser (pyPEG-like) for grammar matching and supports advanced features like EPAS pragmas for nested comments.

Notifications You must be signed in to change notification settings

LaBackDoor/iec_st_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

IEC-ST-Analyzer

A Python tool for static analysis of IEC 61131-3 Structured Text (ST) code. It parses PLC logic into an XML Abstract Syntax Tree (AST) and generates Program Dependency Graphs (PDGs) and Invariant Templates for safety verification.

๐Ÿš€ Capabilities

  • ST Parser: Converts Structured Text source code into a standardized XML AST.
  • Static Analysis: Builds Program Dependency Graphs (PDG) mapping control and data flow.
  • Invariant Extraction: Automatically identifies safety invariant templates:
    • Single-Variable: H_Sensor > 100 -> Valve = FALSE
    • Multi-Variable: IF Sensor + Offset > Limit THEN Actuate
    • Inter-State: Logic governing valid state transitions.
  • Variable Classification: Automatically detects Sensing, Actuation, and Configuration variables.

๐Ÿ“ฆ Installation

Requires Python 3.13+.

Using uv (Recommended):

uv venv
source .venv/bin/activate
uv sync

About

A Python-based compiler that parses IEC 61131-3 Structured Text (ST) source files and outputs a corresponding Abstract Syntax Tree (AST) in XML format. It utilizes a custom recursive descent parser (pyPEG-like) for grammar matching and supports advanced features like EPAS pragmas for nested comments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages