1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/tcl.js

116 lines
3.0 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/**
* @param {string} value
* @returns {RegExp}
* */
/**
* @param {RegExp | string } re
* @returns {string}
*/
function source(re) {
if (!re) return null;
if (typeof re === "string") return re;
return re.source;
}
/**
* @param {RegExp | string } re
* @returns {string}
*/
function optional(re) {
return concat('(', re, ')?');
}
/**
* @param {...(RegExp | string) } args
* @returns {string}
*/
function concat(...args) {
const joined = args.map((x) => source(x)).join("");
return joined;
}
/*
Language: Tcl
Description: Tcl is a very simple programming language.
Author: Radek Liska <radekliska@gmail.com>
Website: https://www.tcl.tk/about/language.html
*/
function tcl(hljs) {
const TCL_IDENT = /[a-zA-Z_][a-zA-Z0-9_]*/;
const NUMBER = {
className: 'number',
variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]
};
2023-12-18 13:12:25 +08:00
return {
2024-01-16 21:26:16 +08:00
name: 'Tcl',
2023-12-18 13:12:25 +08:00
aliases: ['tk'],
keywords: 'after append apply array auto_execok auto_import auto_load auto_mkindex ' +
'auto_mkindex_old auto_qualify auto_reset bgerror binary break catch cd chan clock ' +
'close concat continue dde dict encoding eof error eval exec exit expr fblocked ' +
'fconfigure fcopy file fileevent filename flush for foreach format gets glob global ' +
'history http if incr info interp join lappend|10 lassign|10 lindex|10 linsert|10 list ' +
'llength|10 load lrange|10 lrepeat|10 lreplace|10 lreverse|10 lsearch|10 lset|10 lsort|10 '+
'mathfunc mathop memory msgcat namespace open package parray pid pkg::create pkg_mkIndex '+
'platform platform::shell proc puts pwd read refchan regexp registry regsub|10 rename '+
'return safe scan seek set socket source split string subst switch tcl_endOfWord '+
'tcl_findLibrary tcl_startOfNextWord tcl_startOfPreviousWord tcl_wordBreakAfter '+
'tcl_wordBreakBefore tcltest tclvars tell time tm trace unknown unload unset update '+
'uplevel upvar variable vwait while',
contains: [
hljs.COMMENT(';[ \\t]*#', '$'),
hljs.COMMENT('^[ \\t]*#', '$'),
{
beginKeywords: 'proc',
end: '[\\{]',
excludeEnd: true,
contains: [
{
className: 'title',
begin: '[ \\t\\n\\r]+(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*',
end: '[ \\t\\n\\r]',
endsWithParent: true,
excludeEnd: true
}
]
},
{
2024-01-16 21:26:16 +08:00
className: "variable",
2023-12-18 13:12:25 +08:00
variants: [
{
2024-01-16 21:26:16 +08:00
begin: concat(
/\$/,
optional(/::/),
TCL_IDENT,
'(::',
TCL_IDENT,
')*'
)
2023-12-18 13:12:25 +08:00
},
{
2024-01-16 21:26:16 +08:00
begin: '\\$\\{(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*',
end: '\\}',
contains: [
NUMBER
]
2023-12-18 13:12:25 +08:00
}
]
},
{
className: 'string',
contains: [hljs.BACKSLASH_ESCAPE],
variants: [
hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null})
]
},
2024-01-16 21:26:16 +08:00
NUMBER
2023-12-18 13:12:25 +08:00
]
}
2024-01-16 21:26:16 +08:00
}
module.exports = tcl;