dos.js (1800B)
1 /* 2 Language: Batch file (DOS) 3 Author: Alexander Makarov <sam@rmcreative.ru> 4 Contributors: Anton Kochkov <anton.kochkov@gmail.com> 5 Website: https://en.wikipedia.org/wiki/Batch_file 6 */ 7 8 function dos(hljs) { 9 var COMMENT = hljs.COMMENT( 10 /^\s*@?rem\b/, /$/, 11 { 12 relevance: 10 13 } 14 ); 15 var LABEL = { 16 className: 'symbol', 17 begin: '^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)', 18 relevance: 0 19 }; 20 return { 21 name: 'Batch file (DOS)', 22 aliases: ['bat', 'cmd'], 23 case_insensitive: true, 24 illegal: /\/\*/, 25 keywords: { 26 keyword: 27 'if else goto for in do call exit not exist errorlevel defined ' + 28 'equ neq lss leq gtr geq', 29 built_in: 30 'prn nul lpt3 lpt2 lpt1 con com4 com3 com2 com1 aux ' + 31 'shift cd dir echo setlocal endlocal set pause copy ' + 32 'append assoc at attrib break cacls cd chcp chdir chkdsk chkntfs cls cmd color ' + 33 'comp compact convert date dir diskcomp diskcopy doskey erase fs ' + 34 'find findstr format ftype graftabl help keyb label md mkdir mode more move path ' + 35 'pause print popd pushd promt rd recover rem rename replace restore rmdir shift ' + 36 'sort start subst time title tree type ver verify vol ' + 37 // winutils 38 'ping net ipconfig taskkill xcopy ren del' 39 }, 40 contains: [ 41 { 42 className: 'variable', begin: /%%[^ ]|%[^ ]+?%|![^ ]+?!/ 43 }, 44 { 45 className: 'function', 46 begin: LABEL.begin, end: 'goto:eof', 47 contains: [ 48 hljs.inherit(hljs.TITLE_MODE, {begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*'}), 49 COMMENT 50 ] 51 }, 52 { 53 className: 'number', begin: '\\b\\d+', 54 relevance: 0 55 }, 56 COMMENT 57 ] 58 }; 59 } 60 61 module.exports = dos;