-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Structured text language support #2310
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e100a0f
Structured text language support
Serhioromano 75b8bf6
Conflict resolve
Serhioromano 6fffed7
Merge branch 'master' into iecst-lang
Serhioromano f6b3e84
Update components/prism-iecst.js
Serhioromano d421907
Update components/prism-iecst.js
Serhioromano a475d3b
Update components/prism-iecst.js
Serhioromano 25085b5
Update components/prism-iecst.js
Serhioromano 5383533
Update components/prism-iecst.js
Serhioromano 46edd17
Fix all
Serhioromano 73e1518
fixes
Serhioromano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Prism.languages.iecst = { | ||
comment: [ | ||
{ | ||
pattern: /(^|[^\\])(?:\/\*[\s\S]*?(?:\*\/|$)|\(\*[\s\S]*?(?:\*\)|$)|\{[\s\S]*?(?:\}|$))/, | ||
lookbehind: true, | ||
}, | ||
{ | ||
pattern: /(^|[^\\:])\/\/.*/, | ||
lookbehind: true, | ||
greedy: true, | ||
}, | ||
], | ||
string: { | ||
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, | ||
greedy: true, | ||
}, | ||
"class-name": /\b(?:END_)?(?:PROGRAM|CONFIGURATION|INTERFACE|FUNCTION_BLOCK|FUNCTION|ACTION|TRANSITION|TYPE|STRUCT|(?:INITIAL_)?STEP|NAMESPACE|LIBRARY|CHANNEL|FOLDER|RESOURCE|VAR_(?:GLOBAL|INPUT|PUTPUT|IN_OUT|ACCESS|TEMP|EXTERNAL|CONFIG)|VAR|METHOD|PROPERTY)\b/i, | ||
keyword: /\b(?:(?:END_)?(?:IF|WHILE|REPEAT|CASE|FOR)|ELSE|FROM|THEN|ELSIF|DO|TO|BY|PRIVATE|PUBLIC|PROTECTED|CONSTANT|RETURN|EXIT|CONTINUE|GOTO|JMP|AT|RETAIN|NON_RETAIN|TASK|WITH|UNTIL|USING|EXTENDS|IMPLEMENTS|GET|SET|__TRY|__CATCH|__FINALLY|__ENDTRY)\b/, | ||
variable: /\b(?:AT|BOOL|BYTE|(?:D|L)?WORD|U?(?:S|D|L)?INT|L?REAL|TIME(?:_OF_DAY)?|TOD|DT|DATE(?:_AND_TIME)?|STRING|ARRAY|ANY|POINTER)\b/, | ||
symbol: /%[IQM][XBWDL][\d.]*|%[IQ][\d.]*/, | ||
number: /\b(?:16#[\da-f]+|2#[01_]+|0x[\da-f]+)\b|\b(?:T|D|DT|TOD)#[\d_shmd:]*|\b[A-Z]*\#[\d.,_]*|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, | ||
boolean: /\b(?:TRUE|FALSE|NULL)\b/, | ||
function: /\w+(?=\()/, | ||
operator: /(?:\+|S?R?:?\=>?|:|\^|\-|&&?|\*\*?|\/|<=?|>=?|OR|AND|MOD|NOT|XOR|LE|GE|EQ|NE|GE|LT)/, | ||
punctuation: /[();]/, | ||
type: { | ||
pattern: /#/, | ||
alias: "selector", | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<h2>Code</h2> | ||
<pre><code> | ||
CONFIGURATION DefaultCfg | ||
VAR_GLOBAL | ||
Start_Stop AT %IX0.0: BOOL; (* This is a comment *) | ||
END_VAR | ||
TASK NewTask (INTERVAL := T#20ms); | ||
PROGRAM Main WITH NewTask : PLC_PRG; | ||
END_CONFIGURATION | ||
|
||
PROGRAM demo | ||
VAR_EXTERNAL | ||
Start_Stop: BOOL; | ||
StringVar: STRING[250] := "Test String" | ||
END_VAR | ||
VAR | ||
a : REAL; // Another comment | ||
todTest: TIME_OF_DAY := TOD#12:55; | ||
END_VAR | ||
a := csq(12.5); | ||
IF a > REAL#100 - 16#FAC0 + 2#1001_0110 THEN | ||
Start_Stop := TRUE; | ||
END_IF | ||
END_PROGRAM; | ||
|
||
FUNCTION_BLOCK PRIVATE MyName EXTENDS AnotherName | ||
|
||
END_FUNCTION_BLOCK | ||
|
||
/* Get a square of the circle */ | ||
FUNCTION csq : REAL | ||
VAR_INPUT | ||
r: REAL; | ||
END_VAR | ||
VAR CONSTANT | ||
c_pi: REAL := 3.14; | ||
END_VAR | ||
csq := ABS(c_pi * (r * 2)); | ||
END_FUNCTION | ||
</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
csq := ABS(c_pi * (r * 2)); | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
"csq ", | ||
["operator", ":="], | ||
["function", "ABS"], | ||
["punctuation", "("], | ||
"c_pi ", | ||
["operator", "*"], | ||
["punctuation", "("], | ||
"r ", | ||
["operator", "*"], | ||
["number", "2"], | ||
["punctuation", ")"], | ||
["punctuation", ")"], | ||
["punctuation", ";"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks expression. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
a := 100 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
"a ", | ||
["operator", ":="], | ||
["number", "100"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks number. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
VAR | ||
varname AT %QX1.0.0: BOOL := TRUE; | ||
END_VAR | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["class-name", "VAR"], | ||
"\n varname ", | ||
["keyword", "AT"], | ||
["symbol", "%QX1.0.0"], | ||
["operator", ":"], | ||
["variable", "BOOL"], | ||
["operator", ":="], | ||
["boolean", "TRUE"], | ||
["punctuation", ";"], | ||
["class-name", "END_VAR"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks expression. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert these changes. While the file might need a cleanup, it shouldn't be part of this PR.
The only change to this file should be this:
"ichigojam": "IchigoJam", + "iecst": "Structured Text (IEC 61131-3)", "inform7": "Inform 7",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How? when I run npx gulp it rebuild this file and make them all one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yet, I am not sure how to revert a single file change. Out of my knowledge. I'll try to google it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest way would probably to copy-paste the content of the current
prism-show-language.js
in master and runnpx gulp
.There's probably also some fancy git-way of doing it, but I'm not a git expert...