dart_highlight_rules.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. THIS FILE WAS AUTOGENERATED BY mode_highlight_rules.tmpl.js (UUID: 958518BC-799F-477A-99F9-5B28EBF230F6) */
  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 DartHighlightRules = function() {
  8. var constantLanguage = "true|false|null";
  9. var variableLanguage = "this|super";
  10. var keywordControl = "try|catch|finally|throw|break|case|continue|default|do|else|for|if|in|return|switch|while|new";
  11. var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef";
  12. var storageModifier = "static|final|const";
  13. var storageType = "void|bool|num|int|double|dynamic|var|String";
  14. var keywordMapper = this.createKeywordMapper({
  15. "constant.language.dart": constantLanguage,
  16. "variable.language.dart": variableLanguage,
  17. "keyword.control.dart": keywordControl,
  18. "keyword.declaration.dart": keywordDeclaration,
  19. "storage.modifier.dart": storageModifier,
  20. "storage.type.primitive.dart": storageType
  21. }, "identifier");
  22. var stringfill = {
  23. token : "string",
  24. regex : ".+"
  25. };
  26. // regexp must not have capturing parentheses. Use (?:) instead.
  27. // regexps are ordered -> the first match is used
  28. this.$rules =
  29. {
  30. "start": [
  31. {
  32. token : "comment",
  33. regex : /\/\/.*$/
  34. },
  35. {
  36. token : "comment", // multi line comment
  37. regex : /\/\*/,
  38. next : "comment"
  39. },
  40. {
  41. token: ["meta.preprocessor.script.dart"],
  42. regex: "^(#!.*)$"
  43. },
  44. {
  45. token: "keyword.other.import.dart",
  46. regex: "(?:\\b)(?:library|import|part|of)(?:\\b)"
  47. },
  48. {
  49. token : ["keyword.other.import.dart", "text"],
  50. regex : "(?:\\b)(prefix)(\\s*:)"
  51. },
  52. {
  53. regex: "\\bas\\b",
  54. token: "keyword.cast.dart"
  55. },
  56. {
  57. regex: "\\?|:",
  58. token: "keyword.control.ternary.dart"
  59. },
  60. {
  61. regex: "(?:\\b)(is\\!?)(?:\\b)",
  62. token: ["keyword.operator.dart"]
  63. },
  64. {
  65. regex: "(<<|>>>?|~|\\^|\\||&)",
  66. token: ["keyword.operator.bitwise.dart"]
  67. },
  68. {
  69. regex: "((?:&|\\^|\\||<<|>>>?)=)",
  70. token: ["keyword.operator.assignment.bitwise.dart"]
  71. },
  72. {
  73. regex: "(===?|!==?|<=?|>=?)",
  74. token: ["keyword.operator.comparison.dart"]
  75. },
  76. {
  77. regex: "((?:[+*/%-]|\\~)=)",
  78. token: ["keyword.operator.assignment.arithmetic.dart"]
  79. },
  80. {
  81. regex: "=",
  82. token: "keyword.operator.assignment.dart"
  83. },
  84. {
  85. token : "string",
  86. regex : "'''",
  87. next : "qdoc"
  88. },
  89. {
  90. token : "string",
  91. regex : '"""',
  92. next : "qqdoc"
  93. },
  94. {
  95. token : "string",
  96. regex : "'",
  97. next : "qstring"
  98. },
  99. {
  100. token : "string",
  101. regex : '"',
  102. next : "qqstring"
  103. },
  104. {
  105. regex: "(\\-\\-|\\+\\+)",
  106. token: ["keyword.operator.increment-decrement.dart"]
  107. },
  108. {
  109. regex: "(\\-|\\+|\\*|\\/|\\~\\/|%)",
  110. token: ["keyword.operator.arithmetic.dart"]
  111. },
  112. {
  113. regex: "(!|&&|\\|\\|)",
  114. token: ["keyword.operator.logical.dart"]
  115. },
  116. {
  117. token : "constant.numeric", // hex
  118. regex : "0[xX][0-9a-fA-F]+\\b"
  119. },
  120. {
  121. token : "constant.numeric", // float
  122. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  123. },
  124. {
  125. token : keywordMapper,
  126. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  127. }
  128. ],
  129. "comment" : [
  130. {
  131. token : "comment", // closing comment
  132. regex : ".*?\\*\\/",
  133. next : "start"
  134. }, {
  135. token : "comment", // comment spanning whole line
  136. regex : ".+"
  137. }
  138. ],
  139. "qdoc" : [
  140. {
  141. token : "string",
  142. regex : ".*?'''",
  143. next : "start"
  144. }, stringfill],
  145. "qqdoc" : [
  146. {
  147. token : "string",
  148. regex : '.*?"""',
  149. next : "start"
  150. }, stringfill],
  151. "qstring" : [
  152. {
  153. token : "string",
  154. regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'",
  155. next : "start"
  156. }, stringfill],
  157. "qqstring" : [
  158. {
  159. token : "string",
  160. regex : '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
  161. next : "start"
  162. }, stringfill]
  163. }
  164. };
  165. oop.inherits(DartHighlightRules, TextHighlightRules);
  166. exports.DartHighlightRules = DartHighlightRules;
  167. });