source: node_modules/highlight.js/lib/languages/tcl.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/**
2 * @param {string} value
3 * @returns {RegExp}
4 * */
5
6/**
7 * @param {RegExp | string } re
8 * @returns {string}
9 */
10function source(re) {
11 if (!re) return null;
12 if (typeof re === "string") return re;
13
14 return re.source;
15}
16
17/**
18 * @param {RegExp | string } re
19 * @returns {string}
20 */
21function optional(re) {
22 return concat('(', re, ')?');
23}
24
25/**
26 * @param {...(RegExp | string) } args
27 * @returns {string}
28 */
29function concat(...args) {
30 const joined = args.map((x) => source(x)).join("");
31 return joined;
32}
33
34/*
35Language: Tcl
36Description: Tcl is a very simple programming language.
37Author: Radek Liska <radekliska@gmail.com>
38Website: https://www.tcl.tk/about/language.html
39*/
40
41function tcl(hljs) {
42 const TCL_IDENT = /[a-zA-Z_][a-zA-Z0-9_]*/;
43
44 const NUMBER = {
45 className: 'number',
46 variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]
47 };
48
49 return {
50 name: 'Tcl',
51 aliases: ['tk'],
52 keywords: 'after append apply array auto_execok auto_import auto_load auto_mkindex ' +
53 'auto_mkindex_old auto_qualify auto_reset bgerror binary break catch cd chan clock ' +
54 'close concat continue dde dict encoding eof error eval exec exit expr fblocked ' +
55 'fconfigure fcopy file fileevent filename flush for foreach format gets glob global ' +
56 'history http if incr info interp join lappend|10 lassign|10 lindex|10 linsert|10 list ' +
57 'llength|10 load lrange|10 lrepeat|10 lreplace|10 lreverse|10 lsearch|10 lset|10 lsort|10 '+
58 'mathfunc mathop memory msgcat namespace open package parray pid pkg::create pkg_mkIndex '+
59 'platform platform::shell proc puts pwd read refchan regexp registry regsub|10 rename '+
60 'return safe scan seek set socket source split string subst switch tcl_endOfWord '+
61 'tcl_findLibrary tcl_startOfNextWord tcl_startOfPreviousWord tcl_wordBreakAfter '+
62 'tcl_wordBreakBefore tcltest tclvars tell time tm trace unknown unload unset update '+
63 'uplevel upvar variable vwait while',
64 contains: [
65 hljs.COMMENT(';[ \\t]*#', '$'),
66 hljs.COMMENT('^[ \\t]*#', '$'),
67 {
68 beginKeywords: 'proc',
69 end: '[\\{]',
70 excludeEnd: true,
71 contains: [
72 {
73 className: 'title',
74 begin: '[ \\t\\n\\r]+(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*',
75 end: '[ \\t\\n\\r]',
76 endsWithParent: true,
77 excludeEnd: true
78 }
79 ]
80 },
81 {
82 className: "variable",
83 variants: [
84 {
85 begin: concat(
86 /\$/,
87 optional(/::/),
88 TCL_IDENT,
89 '(::',
90 TCL_IDENT,
91 ')*'
92 )
93 },
94 {
95 begin: '\\$\\{(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*',
96 end: '\\}',
97 contains: [
98 NUMBER
99 ]
100 }
101 ]
102 },
103 {
104 className: 'string',
105 contains: [hljs.BACKSLASH_ESCAPE],
106 variants: [
107 hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null})
108 ]
109 },
110 NUMBER
111 ]
112 }
113}
114
115module.exports = tcl;
Note: See TracBrowser for help on using the repository browser.