Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,10 @@
"require": "clike",
"owner": "just-boris"
},
"psl": {
"title": "PSL",
"owner": "bertysentry"
},
"pug": {
"title": "Pug",
"require": ["markup", "javascript"],
Expand Down
28 changes: 28 additions & 0 deletions components/prism-psl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Prism.languages.psl = {
'comment': [
{
pattern: /#.*/,
greedy: true
}
],
'string': [{
pattern: /"(?:\\"|[^"\r\n]|[\r\n])*"/,
greedy: true,
inside: {
'symbol': /\\[ntrbA-Z"\\]/
}
},
{
pattern: /<<<([a-zA-Z_]\w*)[\r\n](?:.*[\r\n])*?\1\b/,
alias: 'heredoc-string',
greedy: true
}],

'keyword': /\b(?:export|function|local|exit|last|next|requires|return|until|case|default|do|elsif|else|for|foreach|if|switch|while|line|word|__single|__multi)\b/,
'constant': /\b(?:ALARM|CHART_ADD_GRAPH|CHART_DELETE_GRAPH|CHART_DESTROY|CHART_LOAD|CHART_PRINT|EOF|FALSE|False|false|NO|No|no|OK|OFFLINE|PSL_PROF_LOG|R_CHECK_HORIZ|R_CHECK_VERT|R_CLICKER|R_COLUMN|R_FRAME|R_ICON|R_LABEL|R_LABEL_CENTER|R_LIST_MULTIPLE|R_LIST_MULTIPLE_ND|R_LIST_SINGLE|R_LIST_SINGLE_ND|R_MENU|R_POPUP|R_POPUP_SCROLLED|R_RADIO_HORIZ|R_RADIO_VERT|R_ROW|R_SCALE_HORIZ|R_SCALE_VERT|R_SPINNER|R_TEXT_FIELD|R_TEXT_FIELD_LABEL|R_TOGGLE|TRUE|True|true|TRIM_LEADING|TRIM_TRAILING|TRIM_REDUNDANT|TRIM_LEADING_AND_TRAILING|VOID|WARN)\b/,
'variable': /\b(?:errno|exit_status|PslDebug)\b/,
'function': /\b(?:acos|add_diary|annotate|annotate_get|asctime|asin|atan|atexit|ascii_to_ebcdic|batch_set|blackout|cat|ceil|chan_exists|change_state|close|code_cvt|cond_signal|cond_wait|console_type|convert_base|convert_date|convert_locale_date|cos|cosh|create|destroy_lock|dump_hist|date|destroy|difference|dget_text|dcget_text|ebcdic_to_ascii|encrypt|event_archive|event_catalog_get|event_check|event_query|event_range_manage|event_range_query|event_report|event_schedule|event_trigger|event_trigger2|execute|exists|exp|fabs|floor|fmod|full_discovery|file|fopen|ftell|fseek|grep|get_vars|getenv|get|get_chan_info|get_ranges|get_text|gethostinfo|getpid|getpname|history_get_retention|history|index|int|is_var|intersection|isnumber|internal|in_transition|join|kill|length|lines|lock|lock_info|log|loge|log10|matchline|msg_check|msg_get_format|msg_get_severity|msg_printf|msg_sprintf|ntharg|num_consoles|nthargf|nthline|nthlinef|num_bytes|print|proc_exists|process|popen|printf|pconfig|poplines|pow|PslExecute|PslFunctionCall|PslFunctionExists|PslSetOptions|random|read|readln|refresh_parameters|remote_check|remote_close|remote_event_query|remote_event_trigger|remote_file_send|remote_open|remove|replace|rindex|sec_check_priv|sec_store_get|sec_store_set|set_alarm_ranges|set_locale|share|sin|sinh|sleep|sopen|sqrt|srandom|subset|set|substr|system|sprintf|sort|subset|snmp_agent_config|_snmp_debug|snmp_agent_stop|snmp_agent_start|snmp_h_set|snmp_h_get_next|snmp_h_get|snmp_set|snmp_walk|snmp_get_next|snmp_get|snmp_config|snmp_close|snmp_open|snmp_trap_receive|snmp_trap_ignore|snmp_trap_listen|snmp_trap_send|snmp_trap_raise_std_trap|snmp_trap_register_im|splitline|strcasecmp|str_repeat|trim|tail|tan|tanh|time|tmpnam|tolower|toupper|trace_psl_process|text_domain|unlock|unique|union|unset|va_arg|va_start|write)\b/,
'number': /\b(?:(?:0[xX][0-9a-fA-F]*)|(?:[0-9]+\.[0-9]+)|[0-9]+)\b/,
'operator': /[+\-~=\/*%&><\^!|\.]/,
'punctuation': /[\(\){}\[\]:;,?]/
};
1 change: 1 addition & 0 deletions components/prism-psl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions examples/prism-psl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<h2>Strings</h2>
<pre><code># PSL Strings are properly rendered
print("Hello, World!");

# Escaped sequences are highlighted too
print("Goodbye \H\H\H\H\H\H\H\HHello, World!\n");

# Multi-line strings are supported
print("multi
line");
</code></pre>

<h2>Numbers</h2>
<pre><code>a = 1;
b = 2.5;
c = 0xff;
</code></pre>

<h2>PSL Built-in Functions</h2>
<pre><code>p = nthargf(process(".*"), 1, " \t", "\n");
lock("test");
execute("OS", "pwd");
</code></pre>

<h2>PSL Keywords</h2>
<pre><code>foreach entry (["aaa", "bbb", "ccc"]) {
if (grep("[bc]", entry)) {
last;
}
}
</code></pre>

<h2>PSL Constants</h2>
<pre><code>set("/CLASS/inst/paramA/state", WARN);
if (true) {
PslDebug = -1;
}
output = execute("OS", "echo test");
if (errno) {
print(ALARM." with errno=".errno."\n");
}
print(trim(output, "\n\r\t ", TRIM_LEADING_AND_TRAILING));
</code></pre>
1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"promql": "PromQL",
"properties": ".properties",
"protobuf": "Protocol Buffers",
"psl": "PSL",
"purebasic": "PureBasic",
"pbfasm": "PureBasic",
"purs": "PureScript",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions tests/languages/psl/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Comment
# This is not a "string"
# This is not a <<<HERE_DOC document HERE_DOC
### Comment
"string # with hash"#comment
# Indented comment
# Tab-indented comment

----------------------------------------------------

[
["comment", "# Comment"],
["comment", "# This is not a \"string\""],
["comment", "# This is not a <<<HERE_DOC document HERE_DOC"],
["comment", "### Comment"],
["string", ["\"string # with hash\""]], ["comment", "#comment"],
["comment", "# Indented comment"],
["comment", "# Tab-indented comment"]
]

----------------------------------------------------

Test for comments
21 changes: 21 additions & 0 deletions tests/languages/psl/heredoc_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<<<ABC_1
Text "string"
# comment "string"
ABC_1;

<<<ABC_2
2nd here_doc \n\t
ABC_2;

----------------------------------------------------

[
["string", "<<<ABC_1\r\nText \"string\"\r\n# comment \"string\"\r\nABC_1"],
["punctuation", ";"],

["string", "<<<ABC_2\r\n2nd here_doc \\n\\t\r\nABC_2"], ["punctuation", ";"]
]

----------------------------------------------------

Test for "here_documents"
23 changes: 23 additions & 0 deletions tests/languages/psl/number_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
1
1.3
1.0
01.2
0xF0
0xbcde0
0XA390

----------------------------------------------------

[
["number", "1"],
["number", "1.3"],
["number", "1.0"],
["number", "01.2"],
["number", "0xF0"],
["number", "0xbcde0"],
["number", "0XA390"]
]

----------------------------------------------------

Test for numbers
61 changes: 61 additions & 0 deletions tests/languages/psl/overall_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function test(limit) {
for (i = 0 ; i < limit ; i++) {
s = s + i; # s has not been initialized!
}
print(s."\n");
}

----------------------------------------------------

[
["keyword", "function"],
" test",
["punctuation", "("],
"limit",
["punctuation", ")"],
["punctuation", "{"],

["keyword", "for"],
["punctuation", "("],
"i ",
["operator", "="],
["number", "0"],
["punctuation", ";"],
" i ",
["operator", "<"],
" limit ",
["punctuation", ";"],
" i",
["operator", "+"],
["operator", "+"],
["punctuation", ")"],
["punctuation", "{"],

"\r\n\t\ts ",
["operator", "="],
" s ",
["operator", "+"],
" i",
["punctuation", ";"],
["comment", "# s has not been initialized!"],

["punctuation", "}"],

["function", "print"],
["punctuation", "("],
"s",
["operator", "."],
["string", [
"\"",
["symbol", "\\n"],
"\""
]],
["punctuation", ")"],
["punctuation", ";"],

["punctuation", "}"]
]

----------------------------------------------------

General test for the most common PSL statements, all mixed together
32 changes: 32 additions & 0 deletions tests/languages/psl/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"abc"
"a \"bc\""
"a\nbc"
"a\invalid"
"a # comment"
"multi
line string"

----------------------------------------------------

[
["string", ["\"abc\""]],
["string", [
"\"a ",
["symbol", "\\\""],
"bc",
["symbol", "\\\""],
"\""
]],
["string", [
"\"a",
["symbol", "\\n"],
"bc\""
]],
["string", ["\"a\\invalid\""]],
["string", ["\"a # comment\""]],
["string", ["\"multi\r\nline string\""]]
]

----------------------------------------------------

Test for strings