Transpilation and semantic analysis
The 2ot compiler combines a lossless IEC 61131-3 syntax pipeline with semantic analysis, target-aware lowering and independently routed diagnostic and protocol surfaces.
Lossless CST fidelity
Standard PLC compilers can discard whitespace, formatting and comments as they parse. For a bi-directional source workflow that is not good enough. 2ot parses into a lossless Concrete Syntax Tree so source structure can survive analysis and target-aware transformations without treating formatting as disposable noise.
Target-aware normalization passes
The mutation pipeline applies localized rewriting, polyfilling and normalization across divergent IEC dialects. Passes are isolated so target quirks can be handled without turning the parser into a vendor-specific code path.
| Pass / Folder | Target | Impact |
|---|---|---|
| HoistInlineVarDeclarationsPass | Variable hoisting | Extracts inline VAR blocks into the preamble for stricter target formatting. |
| StripBeginMarkersPass | Syntax pruning | Removes legacy BEGIN markers while preserving the surrounding source structure. |
| LowerUnsupportedRuntimeCallsPass | Call substitution | Maps unsupported runtime calls to deterministic target strategies. |
| DomainCallRewriteFolder | Native spelling | Rewrites domain functions to the spelling expected by the selected target provider. |
| NormalizeElseIfFolder | Conditional logic | Normalizes conditional syntax when a target requires a different IEC spelling. |
Fast compiler feedback
Use 2ot check --fast for the low-latency compiler loop, with vendor-aligned diagnostic mapping and structured enrichments for repair workflows.
Language Server Protocol
Expose the same compiler-backed diagnostics, symbols and semantic language operations over the standard LSP surface.
Multi-vendor verification
Keep target behavior honest with shared suites, runtime-equivalence checks and vendor-specific execution paths.
HIR, OOP lowering and semantic passes
2ot resolves scopes, types, call relationships and target semantics before lowering features such as inheritance, interfaces and unsupported runtime constructs into forms that the target environment can accept. The compiler can therefore reason about source meaning before it chooses the vendor-specific representation.
Transpilation is a first-class route
2ot transpile enters the compiler pipeline directly for CST/HIR/TIR analysis, lowering and target emission. The gateway keeps that compiler work separate from vendor automation so source transformation does not depend on an IDE process being available.