stylus_highlight_rules.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. THIS FILE WAS AUTOGENERATED BY Stylus.tmlanguage (UUID: 60519324-6A3A-4382-9E0B-546993A3869A) */
  3. define(function(require, exports, module) {
  4. "use strict";
  5. var oop = require("../lib/oop");
  6. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  7. var CssHighlightRules = require("./css_highlight_rules");
  8. var StylusHighlightRules = function() {
  9. // regexp must not have capturing parentheses. Use (?:) instead.
  10. // regexps are ordered -> the first match is used
  11. var keywordMapper = this.createKeywordMapper({
  12. "support.type": CssHighlightRules.supportType,
  13. "support.function": CssHighlightRules.supportFunction,
  14. "support.constant": CssHighlightRules.supportConstant,
  15. "support.constant.color": CssHighlightRules.supportConstantColor,
  16. "support.constant.fonts": CssHighlightRules.supportConstantFonts
  17. }, "text", true);
  18. this.$rules = {
  19. start: [
  20. {
  21. token : "comment",
  22. regex : /\/\/.*$/
  23. },
  24. {
  25. token : "comment", // multi line comment
  26. regex : /\/\*/,
  27. next : "comment"
  28. },
  29. {
  30. token: ["entity.name.function.stylus", "text"],
  31. regex: "^([-a-zA-Z_][-\\w]*)?(\\()"
  32. },
  33. {
  34. token: ["entity.other.attribute-name.class.stylus"],
  35. regex: "\\.-?[_a-zA-Z]+[_a-zA-Z0-9-]*"
  36. },
  37. {
  38. token: ["entity.language.stylus"],
  39. regex: "^ *&"
  40. },
  41. {
  42. token: ["variable.language.stylus"],
  43. regex: "(arguments)"
  44. },
  45. {
  46. token: ["keyword.stylus"],
  47. regex: "@[-\\w]+"
  48. },
  49. {
  50. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  51. regex : CssHighlightRules.pseudoElements
  52. }, {
  53. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  54. regex : CssHighlightRules.pseudoClasses
  55. },
  56. {
  57. token: ["entity.name.tag.stylus"],
  58. regex: "(?:\\b)(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|datalist|dd|del|details|dfn|dialog|div|dl|dt|em|eventsource|fieldset|figure|figcaption|footer|form|frame|frameset|(?:h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|label|legend|li|link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)(?:\\b)"
  59. },
  60. {
  61. token : "constant.numeric", // hex6 color
  62. regex : "#[a-f0-9]{6}"
  63. },
  64. {
  65. token : "constant.numeric", // hex3 color
  66. regex : "#[a-f0-9]{3}"
  67. },
  68. {
  69. token: ["punctuation.definition.entity.stylus", "entity.other.attribute-name.id.stylus"],
  70. regex: "(#)([a-zA-Z][a-zA-Z0-9_-]*)"
  71. },
  72. {
  73. token: "meta.vendor-prefix.stylus",
  74. regex: "-webkit-|-moz\\-|-ms-|-o-"
  75. },
  76. {
  77. token: "keyword.control.stylus",
  78. regex: "(?:!important|for|in|return|true|false|null|if|else|unless|return)\\b"
  79. },
  80. {
  81. token: "keyword.operator.stylus",
  82. regex: "!|~|\\+|-|(?:\\*)?\\*|\\/|%|(?:\\.)\\.\\.|<|>|(?:=|:|\\?|\\+|-|\\*|\\/|%|<|>)?=|!="
  83. },
  84. {
  85. token: "keyword.operator.stylus",
  86. regex: "(?:in|is(?:nt)?|not)\\b"
  87. },
  88. {
  89. token : "string",
  90. regex : "'(?=.)",
  91. next : "qstring"
  92. }, {
  93. token : "string",
  94. regex : '"(?=.)',
  95. next : "qqstring"
  96. },
  97. {
  98. token : "constant.numeric",
  99. regex : CssHighlightRules.numRe
  100. },
  101. {
  102. token : "keyword",
  103. regex : "(?:ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)\\b"
  104. },
  105. {
  106. token : keywordMapper,
  107. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  108. }
  109. ],
  110. "comment" : [
  111. {
  112. token : "comment", // closing comment
  113. regex : ".*?\\*\\/",
  114. next : "start"
  115. }, {
  116. token : "comment", // comment spanning whole line
  117. regex : ".+"
  118. }
  119. ],
  120. "qqstring" : [
  121. {
  122. token : "string",
  123. regex : '[^"\\\\]+'
  124. },
  125. {
  126. token : "string",
  127. regex : "\\\\$",
  128. next : "qqstring"
  129. },
  130. {
  131. token : "string",
  132. regex : '"|$',
  133. next : "start"
  134. }
  135. ],
  136. "qstring" : [
  137. {
  138. token : "string",
  139. regex : "[^'\\\\]+"
  140. },
  141. {
  142. token : "string",
  143. regex : "\\\\$",
  144. next : "qstring"
  145. },
  146. {
  147. token : "string",
  148. regex : "'|$",
  149. next : "start"
  150. }
  151. ]
  152. }
  153. };
  154. oop.inherits(StylusHighlightRules, TextHighlightRules);
  155. exports.StylusHighlightRules = StylusHighlightRules;
  156. });