Overview of Phio Highlighter architecture
highlightCode function to perform highlighting without requiring the full CodeMirror editor.website·Indexed 30 days ago
https://docs.phioautomation.com/Documentation for a PLC and automation programming playground, featuring guides on IEC 61131-3 structured text, elementary types (BOOL, POINTER, integers), function blocks (TON, TOF, CTU, CTD, R_TRIG, F_TRIG), and core library functions. Includes syntax references for declarations, conditional statements, loops, and the Phio Highlighter.
highlightCode function to perform highlighting without requiring the full CodeMirror editor.print function is a non-standard extension (not defined by IEC 61131-3) provided by Phio Automation to allow developers to trace code execution and inspect the results of operations for debugging and educational purposes.Properties are special members available to Programs and Function Blocks used to encapsulate local variables and control access to the internal state. They provide a mechanism to validate or transform data through getter and setter methods.
Access levels for properties include:
print function is a non-standard utility (not defined by IEC 61131-3) provided by Phio Automation to allow developers to trace code execution and understand the results of operations. It is primarily used as a debugging and educational tool to monitor the internal state and flow of the program.RETURN statement is used to immediately exit the scope of a call expression, such as a Function, Function Block, Method, or Property. Any code following the RETURN statement within that scope will not be executed.FUNCTION F_EarlyReturn : INT
F_EarlyReturn := 10;
// End the function early
RETURN;
F_EarlyReturn := 20; // This line will never be reached
END_FUNCTION
print(F_EarlyReturn());To use the highlighter in a standard HTML document, three requirements must be met:
language-phioiecst to the pre and code elements that require syntax highlighting.<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- 1. Prism CSS Theme -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-vsc-dark-plus.min.css" />
</head>
<body>
<!-- 2. Highlighter Script -->
<script src="https://highlighter.phioautomation.com/iecst.js"></script>
<!-- 3. Highlighted Block -->
<pre class="language-phioiecst"><code class="language-phioiecst">// Your code here!</code></pre>
<!-- 3. Highlighted Inline Code -->
<p>
This is an inline piece of code: <code class="language-phioiecst">VAR</code> or <code class="language-phioiecst">END_VAR</code>
</p>
</body>
</html>ELSIF clause allows for additional conditions to be tested in sequential order if the preceding IF or ELSIF conditions evaluate to false. Only the first block that evaluates to true is executed.a : BOOL := TRUE;
b : INT := 0;
IF b > 0 THEN
b := 1; // Not executed, b is not greater than 0
ELSIF a THEN
b := 2; // a is true, b is assigned to 2
END_IF;FOR statement executes a block of code a specific number of times based on a lower bound, an upper bound, and an increment value. The loop continues to execute until the iterator variable exceeds the defined upper bound.i : INT;
a : INT;
FOR i := 1 TO 10 BY 1 DO
a := i;
END_FOR;
print(a); // a is 10
print(i); // i is 10Floating point literals can be defined using decimal or scientific notation. Underscores (_) are supported as digit separators to improve readability.
Constraints:
1,000,000.0) are not supported.1,123) are not supported; use a period (.) instead.a : REAL;
// Decimal notation
a := -1.0;
a := +205.3;
a := 100.856;
// Scientific notation (case-insensitive 'e')
a := 1.0e2;
a := 6.45e+5;
a := 2.11e-7;
a := 1.0E2;
// Using underscores for readability
a := 0.123_456;
a := 123_456.0;