dos.js 1.5 KB

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