dos.js 1.8 KB

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