aboutsummaryrefslogtreecommitdiffstats
path: root/public/prism/prism-psl.js
blob: 0d7a24ee27dcf0a6aa5c734e618ee518121a8279 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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|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/,
    alias: 'builtin-function',
  },
  'foreach-variable': {
    pattern:
      /(\bforeach\s+(?:(?:\w+\b|"(?:\\.|[^\\"])*")\s+){0,2})[_a-zA-Z]\w*(?=\s*\()/,
    lookbehind: true,
    greedy: true,
  },
  function: /\b[_a-z]\w*\b(?=\s*\()/i,
  number: /\b(?:0x[0-9a-f]+|\d+(?:\.\d+)?)\b/i,
  operator: /--|\+\+|&&=?|\|\|=?|<<=?|>>=?|[=!]~|[-+*/%&|^!=<>]=?|\.|[:?]/,
  punctuation: /[(){}\[\];,]/,
};
promise" "->" * | ( "[" [^\[\]]* "]" | "*" | "**" ) ( ALIGN | "const" \b | "volatile" \b | "allowzero" \b )* * * ALIGN = "align" "(" ( [^()] | "(" [^()]* ")" )* ")" * * IDENTIFIER = \b (?! KEYWORD ) [a-zA-Z_] \w* \b * */ Prism.languages.zig = { comment: [ { pattern: /\/\/[/!].*/, alias: 'doc-comment', }, /\/{2}.*/, ], string: [ { // "string" and c"string" pattern: /(^|[^\\@])c?"(?:[^"\\\r\n]|\\.)*"/, lookbehind: true, greedy: true, }, { // multiline strings and c-strings pattern: /([\r\n])([ \t]+c?\\{2}).*(?:(?:\r\n?|\n)\2.*)*/, lookbehind: true, greedy: true, }, ], char: { // characters 'a', '\n', '\xFF', '\u{10FFFF}' pattern: /(^|[^\\])'(?:[^'\\\r\n]|[\uD800-\uDFFF]{2}|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/, lookbehind: true, greedy: true, }, builtin: /\B@(?!\d)\w+(?=\s*\()/, label: { pattern: /(\b(?:break|continue)\s*:\s*)\w+\b|\b(?!\d)\w+\b(?=\s*:\s*(?:\{|while\b))/, lookbehind: true, }, 'class-name': [ // const Foo = struct {}; /\b(?!\d)\w+(?=\s*=\s*(?:(?:extern|packed)\s+)?(?:enum|struct|union)\s*[({])/, { // const x: i32 = 9; // var x: Bar; // fn foo(x: bool, y: f32) void {} pattern: RegExp( /(:\s*)<TYPE>(?=\s*(?:<ALIGN>\s*)?[=;,)])|<TYPE>(?=\s*(?:<ALIGN>\s*)?\{)/.source .replace(/<TYPE>/g, literal(TYPE)) .replace(/<ALIGN>/g, literal(ALIGN)) ), lookbehind: true, inside: null, // see below }, { // extern fn foo(x: f64) f64; (optional alignment) pattern: RegExp( /(\)\s*)<TYPE>(?=\s*(?:<ALIGN>\s*)?;)/.source .replace(/<TYPE>/g, literal(TYPE)) .replace(/<ALIGN>/g, literal(ALIGN)) ), lookbehind: true, inside: null, // see below }, ], 'builtin-type': { pattern: /\b(?:anyerror|bool|c_u?(?:int|long|longlong|short)|c_longdouble|c_void|comptime_(?:float|int)|f(?:16|32|64|128)|[iu](?:8|16|32|64|128|size)|noreturn|type|void)\b/, alias: 'keyword', }, keyword: keyword, function: /\b(?!\d)\w+(?=\s*\()/, number: /\b(?:0b[01]+|0o[0-7]+|0x[a-fA-F\d]+(?:\.[a-fA-F\d]*)?(?:[pP][+-]?[a-fA-F\d]+)?|\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)\b/, boolean: /\b(?:false|true)\b/, operator: /\.[*?]|\.{2,3}|[-=]>|\*\*|\+\+|\|\||(?:<<|>>|[-+*]%|[-+*/%^&|<>!=])=?|[?~]/, punctuation: /[.:,;(){}[\]]/, }; Prism.languages.zig['class-name'].forEach(function (obj) { if (obj.inside === null) { obj.inside = Prism.languages.zig; } }); })(Prism);