Skip to content
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

Add support for PSL, PATROL Scripting Language (#2735) #2739

Merged
merged 4 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -843,6 +843,10 @@
"title": "Pascaligo",
"owner": "DefinitelyNotAGoat"
},
"psl": {
"title": "PATROL Scripting Language",
"owner": "bertysentry"
},
"pcaxis": {
"title": "PC-Axis",
"alias": "px",
Expand Down
36 changes: 36 additions & 0 deletions components/prism-psl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Prism.languages.psl = {
'comment': {
pattern: /#.*/,
greedy: true
},
'string': {
pattern: /"(?:\\.|[^\\"])*"/,
greedy: true,
inside: {
'symbol': /\\[ntrbA-Z"\\]/
}
},
'heredoc-string': {
pattern: /<<<([a-zA-Z_]\w*)[\r\n](?:.*[\r\n])*?\1\b/,
alias: 'string',
greedy: true
},
'keyword': /\b(?:__multi|__single|case|default|do|else|elsif|exit|export|for|foreach|function|if|last|line|local|next|requires|return|switch|until|while|word)\b/,
'constant': /\b(?:ALARM|CHART_ADD_GRAPH|CHART_DELETE_GRAPH|CHART_DESTROY|CHART_LOAD|CHART_PRINT|EOF|FALSE|False|false|NO|No|no|OFFLINE|OK|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|TRIM_LEADING|TRIM_LEADING_AND_TRAILING|TRIM_REDUNDANT|TRIM_TRAILING|TRUE|True|true|VOID|WARN)\b/,
'variable': /\b(?:errno|exit_status|PslDebug)\b/,
'builtin': {
pattern: /\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/,
bertysentry marked this conversation as resolved.
Show resolved Hide resolved
alias: 'builtin-function'
},
'foreach-variable': {
pattern: /(\bforeach\s+(?:(?:\w+\b|"(?:\\.|[^\\"])*")\s+){0,2})[_a-zA-Z]\w*(?=\s*\()/,
lookbehind: true,
greedy: true
},
'function': {
pattern: /\b[_a-z]\w*\b(?=\s*\()/i,
},
'number': /\b(?:0x[0-9a-f]+|[0-9]+(?:\.[0-9]+)?)\b/i,
'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 @@ -138,6 +138,7 @@
"opencl": "OpenCL",
"parigp": "PARI/GP",
"objectpascal": "Object Pascal",
"psl": "PATROL Scripting Language",
"pcaxis": "PC-Axis",
"px": "PC-Axis",
"peoplecode": "PeopleCode",
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.

Loading