batchfile_highlight_rules.js 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2012, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /* This file was autogenerated from C:\Users\LED\AppData\Roaming\Sublime Text 2\Packages\Batch File\Batch File.tmLanguage (uuid: ) */
  31. /****************************************************************************************
  32. * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. *
  33. * fileTypes *
  34. ****************************************************************************************/
  35. define(function(require, exports, module) {
  36. "use strict";
  37. var oop = require("../lib/oop");
  38. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  39. var BatchFileHighlightRules = function() {
  40. // regexp must not have capturing parentheses. Use (?:) instead.
  41. // regexps are ordered -> the first match is used
  42. this.$rules = { start:
  43. [ { token: 'keyword.command.dosbatch',
  44. regex: '\\b(?:append|assoc|at|attrib|break|cacls|cd|chcp|chdir|chkdsk|chkntfs|cls|cmd|color|comp|compact|convert|copy|date|del|dir|diskcomp|diskcopy|doskey|echo|endlocal|erase|fc|find|findstr|format|ftype|graftabl|help|keyb|label|md|mkdir|mode|more|move|path|pause|popd|print|prompt|pushd|rd|recover|ren|rename|replace|restore|rmdir|set|setlocal|shift|sort|start|subst|time|title|tree|type|ver|verify|vol|xcopy)\\b',
  45. caseInsensitive: true },
  46. { token: 'keyword.control.statement.dosbatch',
  47. regex: '\\b(?:goto|call|exit)\\b',
  48. caseInsensitive: true },
  49. { token: 'keyword.control.conditional.if.dosbatch',
  50. regex: '\\bif\\s+not\\s+(?:exist|defined|errorlevel|cmdextversion)\\b',
  51. caseInsensitive: true },
  52. { token: 'keyword.control.conditional.dosbatch',
  53. regex: '\\b(?:if|else)\\b',
  54. caseInsensitive: true },
  55. { token: 'keyword.control.repeat.dosbatch',
  56. regex: '\\bfor\\b',
  57. caseInsensitive: true },
  58. { token: 'keyword.operator.dosbatch',
  59. regex: '\\b(?:EQU|NEQ|LSS|LEQ|GTR|GEQ)\\b' },
  60. { token: ['doc.comment', 'comment'],
  61. regex: '(?:^|\\b)(rem)($|\\s.*$)',
  62. caseInsensitive: true },
  63. { token: 'comment.line.colons.dosbatch',
  64. regex: '::.*$' },
  65. { include: 'variable' },
  66. { token: 'punctuation.definition.string.begin.shell',
  67. regex: '"',
  68. push: [
  69. { token: 'punctuation.definition.string.end.shell', regex: '"', next: 'pop' },
  70. { include: 'variable' },
  71. { defaultToken: 'string.quoted.double.dosbatch' } ] },
  72. { token: 'keyword.operator.pipe.dosbatch', regex: '[|]' },
  73. { token: 'keyword.operator.redirect.shell',
  74. regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ],
  75. variable: [
  76. { token: 'constant.numeric', regex: '%%\\w+|%[*\\d]|%\\w+%'},
  77. { token: 'constant.numeric', regex: '%~\\d+'},
  78. { token: ['markup.list', 'constant.other', 'markup.list'],
  79. regex: '(%)(\\w+)(%?)' }]}
  80. this.normalizeRules();
  81. };
  82. BatchFileHighlightRules.metaData = { name: 'Batch File',
  83. scopeName: 'source.dosbatch',
  84. fileTypes: [ 'bat' ] }
  85. oop.inherits(BatchFileHighlightRules, TextHighlightRules);
  86. exports.BatchFileHighlightRules = BatchFileHighlightRules;
  87. });