elixir_highlight_rules.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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 https://raw.githubusercontent.com/elixir-lang/elixir-tmbundle/master/Syntaxes/Elixir.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 ElixirHighlightRules = 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:
  44. [ 'meta.module.elixir',
  45. 'keyword.control.module.elixir',
  46. 'meta.module.elixir',
  47. 'entity.name.type.module.elixir' ],
  48. regex: '^(\\s*)(defmodule)(\\s+)((?:[A-Z]\\w*\\s*\\.\\s*)*[A-Z]\\w*)' },
  49. { token: 'comment.documentation.heredoc',
  50. regex: '@(?:module|type)?doc (?:~[a-z])?"""',
  51. push:
  52. [ { token: 'comment.documentation.heredoc',
  53. regex: '\\s*"""',
  54. next: 'pop' },
  55. { include: '#interpolated_elixir' },
  56. { include: '#escaped_char' },
  57. { defaultToken: 'comment.documentation.heredoc' } ],
  58. comment: '@doc with heredocs is treated as documentation' },
  59. { token: 'comment.documentation.heredoc',
  60. regex: '@(?:module|type)?doc ~[A-Z]"""',
  61. push:
  62. [ { token: 'comment.documentation.heredoc',
  63. regex: '\\s*"""',
  64. next: 'pop' },
  65. { defaultToken: 'comment.documentation.heredoc' } ],
  66. comment: '@doc with heredocs is treated as documentation' },
  67. { token: 'comment.documentation.heredoc',
  68. regex: '@(?:module|type)?doc (?:~[a-z])?\'\'\'',
  69. push:
  70. [ { token: 'comment.documentation.heredoc',
  71. regex: '\\s*\'\'\'',
  72. next: 'pop' },
  73. { include: '#interpolated_elixir' },
  74. { include: '#escaped_char' },
  75. { defaultToken: 'comment.documentation.heredoc' } ],
  76. comment: '@doc with heredocs is treated as documentation' },
  77. { token: 'comment.documentation.heredoc',
  78. regex: '@(?:module|type)?doc ~[A-Z]\'\'\'',
  79. push:
  80. [ { token: 'comment.documentation.heredoc',
  81. regex: '\\s*\'\'\'',
  82. next: 'pop' },
  83. { defaultToken: 'comment.documentation.heredoc' } ],
  84. comment: '@doc with heredocs is treated as documentation' },
  85. { token: 'comment.documentation.false',
  86. regex: '@(?:module|type)?doc false',
  87. comment: '@doc false is treated as documentation' },
  88. { token: 'comment.documentation.string',
  89. regex: '@(?:module|type)?doc "',
  90. push:
  91. [ { token: 'comment.documentation.string',
  92. regex: '"',
  93. next: 'pop' },
  94. { include: '#interpolated_elixir' },
  95. { include: '#escaped_char' },
  96. { defaultToken: 'comment.documentation.string' } ],
  97. comment: '@doc with string is treated as documentation' },
  98. { token: 'keyword.control.elixir',
  99. regex: '\\b(?:do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])',
  100. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  101. originalRegex: '(?<!\\.)\\b(do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])' },
  102. { token: 'keyword.operator.elixir',
  103. regex: '\\b(?:and|not|or|when|xor|in|inlist|inbits)\\b',
  104. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  105. originalRegex: '(?<!\\.)\\b(and|not|or|when|xor|in|inlist|inbits)\\b',
  106. comment: ' as above, just doesn\'t need a \'end\' and does a logic operation' },
  107. { token: 'constant.language.elixir',
  108. regex: '\\b(?:nil|true|false)\\b(?![?!])' },
  109. { token: 'variable.language.elixir',
  110. regex: '\\b__(?:CALLER|ENV|MODULE|DIR)__\\b(?![?!])' },
  111. { token:
  112. [ 'punctuation.definition.variable.elixir',
  113. 'variable.other.readwrite.module.elixir' ],
  114. regex: '(@)([a-zA-Z_]\\w*)' },
  115. { token:
  116. [ 'punctuation.definition.variable.elixir',
  117. 'variable.other.anonymous.elixir' ],
  118. regex: '(&)(\\d*)' },
  119. { token: 'variable.other.constant.elixir',
  120. regex: '\\b[A-Z]\\w*\\b' },
  121. { token: 'constant.numeric.elixir',
  122. regex: '\\b(?:0x[\\da-fA-F](?:_?[\\da-fA-F])*|\\d(?:_?\\d)*(?:\\.(?![^[:space:][:digit:]])(?:_?\\d)*)?(?:[eE][-+]?\\d(?:_?\\d)*)?|0b[01]+|0o[0-7]+)\\b',
  123. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  124. originalRegex: '\\b(0x\\h(?>_?\\h)*|\\d(?>_?\\d)*(\\.(?![^[:space:][:digit:]])(?>_?\\d)*)?([eE][-+]?\\d(?>_?\\d)*)?|0b[01]+|0o[0-7]+)\\b' },
  125. { token: 'punctuation.definition.constant.elixir',
  126. regex: ':\'',
  127. push:
  128. [ { token: 'punctuation.definition.constant.elixir',
  129. regex: '\'',
  130. next: 'pop' },
  131. { include: '#interpolated_elixir' },
  132. { include: '#escaped_char' },
  133. { defaultToken: 'constant.other.symbol.single-quoted.elixir' } ] },
  134. { token: 'punctuation.definition.constant.elixir',
  135. regex: ':"',
  136. push:
  137. [ { token: 'punctuation.definition.constant.elixir',
  138. regex: '"',
  139. next: 'pop' },
  140. { include: '#interpolated_elixir' },
  141. { include: '#escaped_char' },
  142. { defaultToken: 'constant.other.symbol.double-quoted.elixir' } ] },
  143. { token: 'punctuation.definition.string.begin.elixir',
  144. regex: '(?:\'\'\')',
  145. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  146. originalRegex: '(?>\'\'\')',
  147. push:
  148. [ { token: 'punctuation.definition.string.end.elixir',
  149. regex: '^\\s*\'\'\'',
  150. next: 'pop' },
  151. { include: '#interpolated_elixir' },
  152. { include: '#escaped_char' },
  153. { defaultToken: 'support.function.variable.quoted.single.heredoc.elixir' } ],
  154. comment: 'Single-quoted heredocs' },
  155. { token: 'punctuation.definition.string.begin.elixir',
  156. regex: '\'',
  157. push:
  158. [ { token: 'punctuation.definition.string.end.elixir',
  159. regex: '\'',
  160. next: 'pop' },
  161. { include: '#interpolated_elixir' },
  162. { include: '#escaped_char' },
  163. { defaultToken: 'support.function.variable.quoted.single.elixir' } ],
  164. comment: 'single quoted string (allows for interpolation)' },
  165. { token: 'punctuation.definition.string.begin.elixir',
  166. regex: '(?:""")',
  167. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  168. originalRegex: '(?>""")',
  169. push:
  170. [ { token: 'punctuation.definition.string.end.elixir',
  171. regex: '^\\s*"""',
  172. next: 'pop' },
  173. { include: '#interpolated_elixir' },
  174. { include: '#escaped_char' },
  175. { defaultToken: 'string.quoted.double.heredoc.elixir' } ],
  176. comment: 'Double-quoted heredocs' },
  177. { token: 'punctuation.definition.string.begin.elixir',
  178. regex: '"',
  179. push:
  180. [ { token: 'punctuation.definition.string.end.elixir',
  181. regex: '"',
  182. next: 'pop' },
  183. { include: '#interpolated_elixir' },
  184. { include: '#escaped_char' },
  185. { defaultToken: 'string.quoted.double.elixir' } ],
  186. comment: 'double quoted string (allows for interpolation)' },
  187. { token: 'punctuation.definition.string.begin.elixir',
  188. regex: '~[a-z](?:""")',
  189. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  190. originalRegex: '~[a-z](?>""")',
  191. push:
  192. [ { token: 'punctuation.definition.string.end.elixir',
  193. regex: '^\\s*"""',
  194. next: 'pop' },
  195. { include: '#interpolated_elixir' },
  196. { include: '#escaped_char' },
  197. { defaultToken: 'string.quoted.double.heredoc.elixir' } ],
  198. comment: 'Double-quoted heredocs sigils' },
  199. { token: 'punctuation.definition.string.begin.elixir',
  200. regex: '~[a-z]\\{',
  201. push:
  202. [ { token: 'punctuation.definition.string.end.elixir',
  203. regex: '\\}[a-z]*',
  204. next: 'pop' },
  205. { include: '#interpolated_elixir' },
  206. { include: '#escaped_char' },
  207. { defaultToken: 'string.interpolated.elixir' } ],
  208. comment: 'sigil (allow for interpolation)' },
  209. { token: 'punctuation.definition.string.begin.elixir',
  210. regex: '~[a-z]\\[',
  211. push:
  212. [ { token: 'punctuation.definition.string.end.elixir',
  213. regex: '\\][a-z]*',
  214. next: 'pop' },
  215. { include: '#interpolated_elixir' },
  216. { include: '#escaped_char' },
  217. { defaultToken: 'string.interpolated.elixir' } ],
  218. comment: 'sigil (allow for interpolation)' },
  219. { token: 'punctuation.definition.string.begin.elixir',
  220. regex: '~[a-z]\\<',
  221. push:
  222. [ { token: 'punctuation.definition.string.end.elixir',
  223. regex: '\\>[a-z]*',
  224. next: 'pop' },
  225. { include: '#interpolated_elixir' },
  226. { include: '#escaped_char' },
  227. { defaultToken: 'string.interpolated.elixir' } ],
  228. comment: 'sigil (allow for interpolation)' },
  229. { token: 'punctuation.definition.string.begin.elixir',
  230. regex: '~[a-z]\\(',
  231. push:
  232. [ { token: 'punctuation.definition.string.end.elixir',
  233. regex: '\\)[a-z]*',
  234. next: 'pop' },
  235. { include: '#interpolated_elixir' },
  236. { include: '#escaped_char' },
  237. { defaultToken: 'string.interpolated.elixir' } ],
  238. comment: 'sigil (allow for interpolation)' },
  239. { token: 'punctuation.definition.string.begin.elixir',
  240. regex: '~[a-z][^\\w]',
  241. push:
  242. [ { token: 'punctuation.definition.string.end.elixir',
  243. regex: '[^\\w][a-z]*',
  244. next: 'pop' },
  245. { include: '#interpolated_elixir' },
  246. { include: '#escaped_char' },
  247. { include: '#escaped_char' },
  248. { defaultToken: 'string.interpolated.elixir' } ],
  249. comment: 'sigil (allow for interpolation)' },
  250. { token: 'punctuation.definition.string.begin.elixir',
  251. regex: '~[A-Z](?:""")',
  252. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  253. originalRegex: '~[A-Z](?>""")',
  254. push:
  255. [ { token: 'punctuation.definition.string.end.elixir',
  256. regex: '^\\s*"""',
  257. next: 'pop' },
  258. { defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
  259. comment: 'Double-quoted heredocs sigils' },
  260. { token: 'punctuation.definition.string.begin.elixir',
  261. regex: '~[A-Z]\\{',
  262. push:
  263. [ { token: 'punctuation.definition.string.end.elixir',
  264. regex: '\\}[a-z]*',
  265. next: 'pop' },
  266. { defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
  267. comment: 'sigil (without interpolation)' },
  268. { token: 'punctuation.definition.string.begin.elixir',
  269. regex: '~[A-Z]\\[',
  270. push:
  271. [ { token: 'punctuation.definition.string.end.elixir',
  272. regex: '\\][a-z]*',
  273. next: 'pop' },
  274. { defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
  275. comment: 'sigil (without interpolation)' },
  276. { token: 'punctuation.definition.string.begin.elixir',
  277. regex: '~[A-Z]\\<',
  278. push:
  279. [ { token: 'punctuation.definition.string.end.elixir',
  280. regex: '\\>[a-z]*',
  281. next: 'pop' },
  282. { defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
  283. comment: 'sigil (without interpolation)' },
  284. { token: 'punctuation.definition.string.begin.elixir',
  285. regex: '~[A-Z]\\(',
  286. push:
  287. [ { token: 'punctuation.definition.string.end.elixir',
  288. regex: '\\)[a-z]*',
  289. next: 'pop' },
  290. { defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
  291. comment: 'sigil (without interpolation)' },
  292. { token: 'punctuation.definition.string.begin.elixir',
  293. regex: '~[A-Z][^\\w]',
  294. push:
  295. [ { token: 'punctuation.definition.string.end.elixir',
  296. regex: '[^\\w][a-z]*',
  297. next: 'pop' },
  298. { defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
  299. comment: 'sigil (without interpolation)' },
  300. { token: ['punctuation.definition.constant.elixir', 'constant.other.symbol.elixir'],
  301. regex: '(:)([a-zA-Z_][\\w@]*(?:[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(?:\\^\\^)?)',
  302. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  303. originalRegex: '(?<!:)(:)(?>[a-zA-Z_][\\w@]*(?>[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(\\^\\^)?)',
  304. comment: 'symbols' },
  305. { token: 'punctuation.definition.constant.elixir',
  306. regex: '(?:[a-zA-Z_][\\w@]*(?:[?!])?):(?!:)',
  307. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  308. originalRegex: '(?>[a-zA-Z_][\\w@]*(?>[?!])?)(:)(?!:)',
  309. comment: 'symbols' },
  310. { token:
  311. [ 'punctuation.definition.comment.elixir',
  312. 'comment.line.number-sign.elixir' ],
  313. regex: '(#)(.*)' },
  314. { token: 'constant.numeric.elixir',
  315. regex: '\\?(?:\\\\(?:x[\\da-fA-F]{1,2}(?![\\da-fA-F])\\b|[^xMC])|[^\\s\\\\])',
  316. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  317. originalRegex: '(?<!\\w)\\?(\\\\(x\\h{1,2}(?!\\h)\\b|[^xMC])|[^\\s\\\\])',
  318. comment: '\n\t\t\tmatches questionmark-letters.\n\n\t\t\texamples (1st alternation = hex):\n\t\t\t?\\x1 ?\\x61\n\n\t\t\texamples (2rd alternation = escaped):\n\t\t\t?\\n ?\\b\n\n\t\t\texamples (3rd alternation = normal):\n\t\t\t?a ?A ?0 \n\t\t\t?* ?" ?( \n\t\t\t?. ?#\n\t\t\t\n\t\t\tthe negative lookbehind prevents against matching\n\t\t\tp(42.tainted?)\n\t\t\t' },
  319. /* { token: 'punctuation.separator.variable.elixir',
  320. regex: '(?<=\\{|do|\\{\\s|do\\s)\\|',
  321. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  322. originalRegex: '(?<=\\{|do|\\{\\s|do\\s)(\\|)',
  323. push:
  324. [ { token: 'punctuation.separator.variable.elixir',
  325. regex: '\\|',
  326. next: 'pop' },
  327. { token: 'variable.other.block.elixir',
  328. regex: '[_a-zA-Z][_a-zA-Z0-9]*' },
  329. { token: 'punctuation.separator.variable.elixir', regex: ',' } ] },*/
  330. { token: 'keyword.operator.assignment.augmented.elixir',
  331. regex: '\\+=|\\-=|\\|\\|=|~=|&&=' },
  332. { token: 'keyword.operator.comparison.elixir',
  333. regex: '===?|!==?|<=?|>=?' },
  334. { token: 'keyword.operator.bitwise.elixir',
  335. regex: '\\|{3}|&{3}|\\^{3}|<{3}|>{3}|~{3}' },
  336. { token: 'keyword.operator.logical.elixir',
  337. regex: '!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b',
  338. originalRegex: '(?<=[ \\t])!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b' },
  339. { token: 'keyword.operator.arithmetic.elixir',
  340. regex: '\\*|\\+|\\-|/' },
  341. { token: 'keyword.operator.other.elixir',
  342. regex: '\\||\\+\\+|\\-\\-|\\*\\*|\\\\\\\\|\\<\\-|\\<\\>|\\<\\<|\\>\\>|\\:\\:|\\.\\.|\\|>|~|=>' },
  343. { token: 'keyword.operator.assignment.elixir', regex: '=' },
  344. { token: 'punctuation.separator.other.elixir', regex: ':' },
  345. { token: 'punctuation.separator.statement.elixir',
  346. regex: '\\;' },
  347. { token: 'punctuation.separator.object.elixir', regex: ',' },
  348. { token: 'punctuation.separator.method.elixir', regex: '\\.' },
  349. { token: 'punctuation.section.scope.elixir', regex: '\\{|\\}' },
  350. { token: 'punctuation.section.array.elixir', regex: '\\[|\\]' },
  351. { token: 'punctuation.section.function.elixir',
  352. regex: '\\(|\\)' } ],
  353. '#escaped_char':
  354. [ { token: 'constant.character.escape.elixir',
  355. regex: '\\\\(?:x[\\da-fA-F]{1,2}|.)' } ],
  356. '#interpolated_elixir':
  357. [ { token:
  358. [ 'source.elixir.embedded.source',
  359. 'source.elixir.embedded.source.empty' ],
  360. regex: '(#\\{)(\\})' },
  361. { todo:
  362. { token: 'punctuation.section.embedded.elixir',
  363. regex: '#\\{',
  364. push:
  365. [ { token: 'punctuation.section.embedded.elixir',
  366. regex: '\\}',
  367. next: 'pop' },
  368. { include: '#nest_curly_and_self' },
  369. { include: '$self' },
  370. { defaultToken: 'source.elixir.embedded.source' } ] } } ],
  371. '#nest_curly_and_self':
  372. [ { token: 'punctuation.section.scope.elixir',
  373. regex: '\\{',
  374. push:
  375. [ { token: 'punctuation.section.scope.elixir',
  376. regex: '\\}',
  377. next: 'pop' },
  378. { include: '#nest_curly_and_self' } ] },
  379. { include: '$self' } ],
  380. '#regex_sub':
  381. [ { include: '#interpolated_elixir' },
  382. { include: '#escaped_char' },
  383. { token:
  384. [ 'punctuation.definition.arbitrary-repitition.elixir',
  385. 'string.regexp.arbitrary-repitition.elixir',
  386. 'string.regexp.arbitrary-repitition.elixir',
  387. 'punctuation.definition.arbitrary-repitition.elixir' ],
  388. regex: '(\\{)(\\d+)((?:,\\d+)?)(\\})' },
  389. { token: 'punctuation.definition.character-class.elixir',
  390. regex: '\\[(?:\\^?\\])?',
  391. push:
  392. [ { token: 'punctuation.definition.character-class.elixir',
  393. regex: '\\]',
  394. next: 'pop' },
  395. { include: '#escaped_char' },
  396. { defaultToken: 'string.regexp.character-class.elixir' } ] },
  397. { token: 'punctuation.definition.group.elixir',
  398. regex: '\\(',
  399. push:
  400. [ { token: 'punctuation.definition.group.elixir',
  401. regex: '\\)',
  402. next: 'pop' },
  403. { include: '#regex_sub' },
  404. { defaultToken: 'string.regexp.group.elixir' } ] },
  405. { token:
  406. [ 'punctuation.definition.comment.elixir',
  407. 'comment.line.number-sign.elixir' ],
  408. regex: '(?:^|\\s)(#)(\\s[[a-zA-Z0-9,. \\t?!-][^\\x00-\\x7F]]*$)',
  409. originalRegex: '(?<=^|\\s)(#)\\s[[a-zA-Z0-9,. \\t?!-][^\\x{00}-\\x{7F}]]*$',
  410. comment: 'We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags.' } ] }
  411. this.normalizeRules();
  412. };
  413. ElixirHighlightRules.metaData = { comment: 'Textmate bundle for Elixir Programming Language.',
  414. fileTypes: [ 'ex', 'exs' ],
  415. firstLineMatch: '^#!/.*\\belixir',
  416. foldingStartMarker: '(after|else|catch|rescue|\\-\\>|\\{|\\[|do)\\s*$',
  417. foldingStopMarker: '^\\s*((\\}|\\]|after|else|catch|rescue)\\s*$|end\\b)',
  418. keyEquivalent: '^~E',
  419. name: 'Elixir',
  420. scopeName: 'source.elixir' }
  421. oop.inherits(ElixirHighlightRules, TextHighlightRules);
  422. exports.ElixirHighlightRules = ElixirHighlightRules;
  423. });