dos.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /** @type LanguageFn */
  8. function dos(hljs) {
  9. const COMMENT = hljs.COMMENT(
  10. /^\s*@?rem\b/, /$/,
  11. {
  12. relevance: 10
  13. }
  14. );
  15. const 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: [
  23. 'bat',
  24. 'cmd'
  25. ],
  26. case_insensitive: true,
  27. illegal: /\/\*/,
  28. keywords: {
  29. keyword:
  30. 'if else goto for in do call exit not exist errorlevel defined ' +
  31. 'equ neq lss leq gtr geq',
  32. built_in:
  33. 'prn nul lpt3 lpt2 lpt1 con com4 com3 com2 com1 aux ' +
  34. 'shift cd dir echo setlocal endlocal set pause copy ' +
  35. 'append assoc at attrib break cacls cd chcp chdir chkdsk chkntfs cls cmd color ' +
  36. 'comp compact convert date dir diskcomp diskcopy doskey erase fs ' +
  37. 'find findstr format ftype graftabl help keyb label md mkdir mode more move path ' +
  38. 'pause print popd pushd promt rd recover rem rename replace restore rmdir shift ' +
  39. 'sort start subst time title tree type ver verify vol ' +
  40. // winutils
  41. 'ping net ipconfig taskkill xcopy ren del'
  42. },
  43. contains: [
  44. {
  45. className: 'variable',
  46. begin: /%%[^ ]|%[^ ]+?%|![^ ]+?!/
  47. },
  48. {
  49. className: 'function',
  50. begin: LABEL.begin,
  51. end: 'goto:eof',
  52. contains: [
  53. hljs.inherit(hljs.TITLE_MODE, {
  54. begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*'
  55. }),
  56. COMMENT
  57. ]
  58. },
  59. {
  60. className: 'number',
  61. begin: '\\b\\d+',
  62. relevance: 0
  63. },
  64. COMMENT
  65. ]
  66. };
  67. }
  68. module.exports = dos;