Skip to content

Commit

Permalink
PSL: Added boolean token (#3248)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Dec 8, 2021
1 parent 0390e64 commit a5b6c5e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
7 changes: 3 additions & 4 deletions components/prism-psl.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Prism.languages.psl = {
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|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|VOID|WARN|false|no|true)\b/,
'constant': /\b(?:ALARM|CHART_ADD_GRAPH|CHART_DELETE_GRAPH|CHART_DESTROY|CHART_LOAD|CHART_PRINT|EOF|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_SEP_HORIZ|R_SEP_VERT|R_SPINNER|R_TEXT_FIELD|R_TEXT_FIELD_LABEL|R_TOGGLE|TRIM_LEADING|TRIM_LEADING_AND_TRAILING|TRIM_REDUNDANT|TRIM_TRAILING|VOID|WARN)\b/,
'boolean': /\b(?:FALSE|False|NO|No|TRUE|True|YES|Yes|false|no|true|yes)\b/,
'variable': /\b(?:PslDebug|errno|exit_status)\b/,
'builtin': {
pattern: /\b(?:PslExecute|PslFunctionCall|PslFunctionExists|PslSetOptions|_snmp_debug|acos|add_diary|annotate|annotate_get|ascii_to_ebcdic|asctime|asin|atan|atexit|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|date|dcget_text|destroy|destroy_lock|dget_text|difference|dump_hist|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|file|floor|fmod|fopen|fseek|ftell|full_discovery|get|get_chan_info|get_ranges|get_text|get_vars|getenv|gethostinfo|getpid|getpname|grep|history|history_get_retention|in_transition|index|int|internal|intersection|is_var|isnumber|join|kill|length|lines|lock|lock_info|log|log10|loge|matchline|msg_check|msg_get_format|msg_get_severity|msg_printf|msg_sprintf|ntharg|nthargf|nthline|nthlinef|num_bytes|num_consoles|pconfig|popen|poplines|pow|print|printf|proc_exists|process|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|set_alarm_ranges|set_locale|share|sin|sinh|sleep|snmp_agent_config|snmp_agent_start|snmp_agent_stop|snmp_close|snmp_config|snmp_get|snmp_get_next|snmp_h_get|snmp_h_get_next|snmp_h_set|snmp_open|snmp_set|snmp_trap_ignore|snmp_trap_listen|snmp_trap_raise_std_trap|snmp_trap_receive|snmp_trap_register_im|snmp_trap_send|snmp_walk|sopen|sort|splitline|sprintf|sqrt|srandom|str_repeat|strcasecmp|subset|substr|system|tail|tan|tanh|text_domain|time|tmpnam|tolower|toupper|trace_psl_process|trim|union|unique|unlock|unset|va_arg|va_start|write)\b/,
Expand All @@ -27,9 +28,7 @@ Prism.languages.psl = {
lookbehind: true,
greedy: true
},
'function': {
pattern: /\b[_a-z]\w*\b(?=\s*\()/i,
},
'function': /\b[_a-z]\w*\b(?=\s*\()/i,
'number': /\b(?:0x[0-9a-f]+|\d+(?:\.\d+)?)\b/i,
'operator': /--|\+\+|&&=?|\|\|=?|<<=?|>>=?|[=!]~|[-+*/%&|^!=<>]=?|\.|[:?]/,
'punctuation': /[(){}\[\];,]/
Expand Down
2 changes: 1 addition & 1 deletion components/prism-psl.min.js

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

35 changes: 35 additions & 0 deletions tests/languages/psl/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FALSE
False
false

TRUE
True
true

NO
No
no

YES
Yes
yes

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

[
["boolean", "FALSE"],
["boolean", "False"],
["boolean", "false"],

["boolean", "TRUE"],
["boolean", "True"],
["boolean", "true"],

["boolean", "NO"],
["boolean", "No"],
["boolean", "no"],

["boolean", "YES"],
["boolean", "Yes"],
["boolean", "yes"]
]
24 changes: 5 additions & 19 deletions tests/languages/psl/constant_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ CHART_DESTROY
CHART_LOAD
CHART_PRINT
EOF
FALSE
False
false
NO
No
no
OFFLINE
OK
PSL_PROF_LOG
Expand All @@ -34,6 +28,8 @@ R_RADIO_VERT
R_ROW
R_SCALE_HORIZ
R_SCALE_VERT
R_SEP_HORIZ
R_SEP_VERT
R_SPINNER
R_TEXT_FIELD
R_TEXT_FIELD_LABEL
Expand All @@ -42,9 +38,6 @@ TRIM_LEADING
TRIM_LEADING_AND_TRAILING
TRIM_REDUNDANT
TRIM_TRAILING
TRUE
True
true
VOID
WARN

Expand All @@ -58,12 +51,6 @@ WARN
["constant", "CHART_LOAD"],
["constant", "CHART_PRINT"],
["constant", "EOF"],
["constant", "FALSE"],
["constant", "False"],
["constant", "false"],
["constant", "NO"],
["constant", "No"],
["constant", "no"],
["constant", "OFFLINE"],
["constant", "OK"],
["constant", "PSL_PROF_LOG"],
Expand All @@ -87,6 +74,8 @@ WARN
["constant", "R_ROW"],
["constant", "R_SCALE_HORIZ"],
["constant", "R_SCALE_VERT"],
["constant", "R_SEP_HORIZ"],
["constant", "R_SEP_VERT"],
["constant", "R_SPINNER"],
["constant", "R_TEXT_FIELD"],
["constant", "R_TEXT_FIELD_LABEL"],
Expand All @@ -95,13 +84,10 @@ WARN
["constant", "TRIM_LEADING_AND_TRAILING"],
["constant", "TRIM_REDUNDANT"],
["constant", "TRIM_TRAILING"],
["constant", "TRUE"],
["constant", "True"],
["constant", "true"],
["constant", "VOID"],
["constant", "WARN"]
]

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

Test for constants
Test for constants

0 comments on commit a5b6c5e

Please sign in to comment.