erlang_highlight_rules.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  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 tm bundles\erlang.tmbundle\Syntaxes\Erlang.plist (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 ErlangHighlightRules = function() {
  40. // regexp must not have capturing parentheses. Use (?:) instead.
  41. // regexps are ordered -> the first match is used
  42. this.$rules = { start:
  43. [ { include: '#module-directive' },
  44. { include: '#import-export-directive' },
  45. { include: '#behaviour-directive' },
  46. { include: '#record-directive' },
  47. { include: '#define-directive' },
  48. { include: '#macro-directive' },
  49. { include: '#directive' },
  50. { include: '#function' },
  51. { include: '#everything-else' } ],
  52. '#atom':
  53. [ { token: 'punctuation.definition.symbol.begin.erlang',
  54. regex: '\'',
  55. push:
  56. [ { token: 'punctuation.definition.symbol.end.erlang',
  57. regex: '\'',
  58. next: 'pop' },
  59. { token:
  60. [ 'punctuation.definition.escape.erlang',
  61. 'constant.other.symbol.escape.erlang',
  62. 'punctuation.definition.escape.erlang',
  63. 'constant.other.symbol.escape.erlang',
  64. 'constant.other.symbol.escape.erlang' ],
  65. regex: '(\\\\)(?:([bdefnrstv\\\\\'"])|(\\^)([@-_])|([0-7]{1,3}))' },
  66. { token: 'invalid.illegal.atom.erlang', regex: '\\\\\\^?.?' },
  67. { defaultToken: 'constant.other.symbol.quoted.single.erlang' } ] },
  68. { token: 'constant.other.symbol.unquoted.erlang',
  69. regex: '[a-z][a-zA-Z\\d@_]*' } ],
  70. '#behaviour-directive':
  71. [ { token:
  72. [ 'meta.directive.behaviour.erlang',
  73. 'punctuation.section.directive.begin.erlang',
  74. 'meta.directive.behaviour.erlang',
  75. 'keyword.control.directive.behaviour.erlang',
  76. 'meta.directive.behaviour.erlang',
  77. 'punctuation.definition.parameters.begin.erlang',
  78. 'meta.directive.behaviour.erlang',
  79. 'entity.name.type.class.behaviour.definition.erlang',
  80. 'meta.directive.behaviour.erlang',
  81. 'punctuation.definition.parameters.end.erlang',
  82. 'meta.directive.behaviour.erlang',
  83. 'punctuation.section.directive.end.erlang' ],
  84. regex: '^(\\s*)(-)(\\s*)(behaviour)(\\s*)(\\()(\\s*)([a-z][a-zA-Z\\d@_]*)(\\s*)(\\))(\\s*)(\\.)' } ],
  85. '#binary':
  86. [ { token: 'punctuation.definition.binary.begin.erlang',
  87. regex: '<<',
  88. push:
  89. [ { token: 'punctuation.definition.binary.end.erlang',
  90. regex: '>>',
  91. next: 'pop' },
  92. { token:
  93. [ 'punctuation.separator.binary.erlang',
  94. 'punctuation.separator.value-size.erlang' ],
  95. regex: '(,)|(:)' },
  96. { include: '#internal-type-specifiers' },
  97. { include: '#everything-else' },
  98. { defaultToken: 'meta.structure.binary.erlang' } ] } ],
  99. '#character':
  100. [ { token:
  101. [ 'punctuation.definition.character.erlang',
  102. 'punctuation.definition.escape.erlang',
  103. 'constant.character.escape.erlang',
  104. 'punctuation.definition.escape.erlang',
  105. 'constant.character.escape.erlang',
  106. 'constant.character.escape.erlang' ],
  107. regex: '(\\$)(\\\\)(?:([bdefnrstv\\\\\'"])|(\\^)([@-_])|([0-7]{1,3}))' },
  108. { token: 'invalid.illegal.character.erlang',
  109. regex: '\\$\\\\\\^?.?' },
  110. { token:
  111. [ 'punctuation.definition.character.erlang',
  112. 'constant.character.erlang' ],
  113. regex: '(\\$)(\\S)' },
  114. { token: 'invalid.illegal.character.erlang', regex: '\\$.?' } ],
  115. '#comment':
  116. [ { token: 'punctuation.definition.comment.erlang',
  117. regex: '%.*$',
  118. push_:
  119. [ { token: 'comment.line.percentage.erlang',
  120. regex: '$',
  121. next: 'pop' },
  122. { defaultToken: 'comment.line.percentage.erlang' } ] } ],
  123. '#define-directive':
  124. [ { token:
  125. [ 'meta.directive.define.erlang',
  126. 'punctuation.section.directive.begin.erlang',
  127. 'meta.directive.define.erlang',
  128. 'keyword.control.directive.define.erlang',
  129. 'meta.directive.define.erlang',
  130. 'punctuation.definition.parameters.begin.erlang',
  131. 'meta.directive.define.erlang',
  132. 'entity.name.function.macro.definition.erlang',
  133. 'meta.directive.define.erlang',
  134. 'punctuation.separator.parameters.erlang' ],
  135. regex: '^(\\s*)(-)(\\s*)(define)(\\s*)(\\()(\\s*)([a-zA-Z\\d@_]+)(\\s*)(,)',
  136. push:
  137. [ { token:
  138. [ 'punctuation.definition.parameters.end.erlang',
  139. 'meta.directive.define.erlang',
  140. 'punctuation.section.directive.end.erlang' ],
  141. regex: '(\\))(\\s*)(\\.)',
  142. next: 'pop' },
  143. { include: '#everything-else' },
  144. { defaultToken: 'meta.directive.define.erlang' } ] },
  145. { token: 'meta.directive.define.erlang',
  146. regex: '(?=^\\s*-\\s*define\\s*\\(\\s*[a-zA-Z\\d@_]+\\s*\\()',
  147. push:
  148. [ { token:
  149. [ 'punctuation.definition.parameters.end.erlang',
  150. 'meta.directive.define.erlang',
  151. 'punctuation.section.directive.end.erlang' ],
  152. regex: '(\\))(\\s*)(\\.)',
  153. next: 'pop' },
  154. { token:
  155. [ 'text',
  156. 'punctuation.section.directive.begin.erlang',
  157. 'text',
  158. 'keyword.control.directive.define.erlang',
  159. 'text',
  160. 'punctuation.definition.parameters.begin.erlang',
  161. 'text',
  162. 'entity.name.function.macro.definition.erlang',
  163. 'text',
  164. 'punctuation.definition.parameters.begin.erlang' ],
  165. regex: '^(\\s*)(-)(\\s*)(define)(\\s*)(\\()(\\s*)([a-zA-Z\\d@_]+)(\\s*)(\\()',
  166. push:
  167. [ { token:
  168. [ 'punctuation.definition.parameters.end.erlang',
  169. 'text',
  170. 'punctuation.separator.parameters.erlang' ],
  171. regex: '(\\))(\\s*)(,)',
  172. next: 'pop' },
  173. { token: 'punctuation.separator.parameters.erlang', regex: ',' },
  174. { include: '#everything-else' } ] },
  175. { token: 'punctuation.separator.define.erlang',
  176. regex: '\\|\\||\\||:|;|,|\\.|->' },
  177. { include: '#everything-else' },
  178. { defaultToken: 'meta.directive.define.erlang' } ] } ],
  179. '#directive':
  180. [ { token:
  181. [ 'meta.directive.erlang',
  182. 'punctuation.section.directive.begin.erlang',
  183. 'meta.directive.erlang',
  184. 'keyword.control.directive.erlang',
  185. 'meta.directive.erlang',
  186. 'punctuation.definition.parameters.begin.erlang' ],
  187. regex: '^(\\s*)(-)(\\s*)([a-z][a-zA-Z\\d@_]*)(\\s*)(\\(?)',
  188. push:
  189. [ { token:
  190. [ 'punctuation.definition.parameters.end.erlang',
  191. 'meta.directive.erlang',
  192. 'punctuation.section.directive.end.erlang' ],
  193. regex: '(\\)?)(\\s*)(\\.)',
  194. next: 'pop' },
  195. { include: '#everything-else' },
  196. { defaultToken: 'meta.directive.erlang' } ] },
  197. { token:
  198. [ 'meta.directive.erlang',
  199. 'punctuation.section.directive.begin.erlang',
  200. 'meta.directive.erlang',
  201. 'keyword.control.directive.erlang',
  202. 'meta.directive.erlang',
  203. 'punctuation.section.directive.end.erlang' ],
  204. regex: '^(\\s*)(-)(\\s*)([a-z][a-zA-Z\\d@_]*)(\\s*)(\\.)' } ],
  205. '#everything-else':
  206. [ { include: '#comment' },
  207. { include: '#record-usage' },
  208. { include: '#macro-usage' },
  209. { include: '#expression' },
  210. { include: '#keyword' },
  211. { include: '#textual-operator' },
  212. { include: '#function-call' },
  213. { include: '#tuple' },
  214. { include: '#list' },
  215. { include: '#binary' },
  216. { include: '#parenthesized-expression' },
  217. { include: '#character' },
  218. { include: '#number' },
  219. { include: '#atom' },
  220. { include: '#string' },
  221. { include: '#symbolic-operator' },
  222. { include: '#variable' } ],
  223. '#expression':
  224. [ { token: 'keyword.control.if.erlang',
  225. regex: '\\bif\\b',
  226. push:
  227. [ { token: 'keyword.control.end.erlang',
  228. regex: '\\bend\\b',
  229. next: 'pop' },
  230. { include: '#internal-expression-punctuation' },
  231. { include: '#everything-else' },
  232. { defaultToken: 'meta.expression.if.erlang' } ] },
  233. { token: 'keyword.control.case.erlang',
  234. regex: '\\bcase\\b',
  235. push:
  236. [ { token: 'keyword.control.end.erlang',
  237. regex: '\\bend\\b',
  238. next: 'pop' },
  239. { include: '#internal-expression-punctuation' },
  240. { include: '#everything-else' },
  241. { defaultToken: 'meta.expression.case.erlang' } ] },
  242. { token: 'keyword.control.receive.erlang',
  243. regex: '\\breceive\\b',
  244. push:
  245. [ { token: 'keyword.control.end.erlang',
  246. regex: '\\bend\\b',
  247. next: 'pop' },
  248. { include: '#internal-expression-punctuation' },
  249. { include: '#everything-else' },
  250. { defaultToken: 'meta.expression.receive.erlang' } ] },
  251. { token:
  252. [ 'keyword.control.fun.erlang',
  253. 'text',
  254. 'entity.name.type.class.module.erlang',
  255. 'text',
  256. 'punctuation.separator.module-function.erlang',
  257. 'text',
  258. 'entity.name.function.erlang',
  259. 'text',
  260. 'punctuation.separator.function-arity.erlang' ],
  261. regex: '\\b(fun)(\\s*)(?:([a-z][a-zA-Z\\d@_]*)(\\s*)(:)(\\s*))?([a-z][a-zA-Z\\d@_]*)(\\s*)(/)' },
  262. { token: 'keyword.control.fun.erlang',
  263. regex: '\\bfun\\b',
  264. push:
  265. [ { token: 'keyword.control.end.erlang',
  266. regex: '\\bend\\b',
  267. next: 'pop' },
  268. { token: 'text',
  269. regex: '(?=\\()',
  270. push:
  271. [ { token: 'punctuation.separator.clauses.erlang',
  272. regex: ';|(?=\\bend\\b)',
  273. next: 'pop' },
  274. { include: '#internal-function-parts' } ] },
  275. { include: '#everything-else' },
  276. { defaultToken: 'meta.expression.fun.erlang' } ] },
  277. { token: 'keyword.control.try.erlang',
  278. regex: '\\btry\\b',
  279. push:
  280. [ { token: 'keyword.control.end.erlang',
  281. regex: '\\bend\\b',
  282. next: 'pop' },
  283. { include: '#internal-expression-punctuation' },
  284. { include: '#everything-else' },
  285. { defaultToken: 'meta.expression.try.erlang' } ] },
  286. { token: 'keyword.control.begin.erlang',
  287. regex: '\\bbegin\\b',
  288. push:
  289. [ { token: 'keyword.control.end.erlang',
  290. regex: '\\bend\\b',
  291. next: 'pop' },
  292. { include: '#internal-expression-punctuation' },
  293. { include: '#everything-else' },
  294. { defaultToken: 'meta.expression.begin.erlang' } ] },
  295. { token: 'keyword.control.query.erlang',
  296. regex: '\\bquery\\b',
  297. push:
  298. [ { token: 'keyword.control.end.erlang',
  299. regex: '\\bend\\b',
  300. next: 'pop' },
  301. { include: '#everything-else' },
  302. { defaultToken: 'meta.expression.query.erlang' } ] } ],
  303. '#function':
  304. [ { token:
  305. [ 'meta.function.erlang',
  306. 'entity.name.function.definition.erlang',
  307. 'meta.function.erlang' ],
  308. regex: '^(\\s*)([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(?=\\()',
  309. push:
  310. [ { token: 'punctuation.terminator.function.erlang',
  311. regex: '\\.',
  312. next: 'pop' },
  313. { token: [ 'text', 'entity.name.function.erlang', 'text' ],
  314. regex: '^(\\s*)([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(?=\\()' },
  315. { token: 'text',
  316. regex: '(?=\\()',
  317. push:
  318. [ { token: 'punctuation.separator.clauses.erlang',
  319. regex: ';|(?=\\.)',
  320. next: 'pop' },
  321. { include: '#parenthesized-expression' },
  322. { include: '#internal-function-parts' } ] },
  323. { include: '#everything-else' },
  324. { defaultToken: 'meta.function.erlang' } ] } ],
  325. '#function-call':
  326. [ { token: 'meta.function-call.erlang',
  327. regex: '(?=(?:[a-z][a-zA-Z\\d@_]*|\'[^\']*\')\\s*(?:\\(|:\\s*(?:[a-z][a-zA-Z\\d@_]*|\'[^\']*\')\\s*\\())',
  328. push:
  329. [ { token: 'punctuation.definition.parameters.end.erlang',
  330. regex: '\\)',
  331. next: 'pop' },
  332. { token:
  333. [ 'entity.name.type.class.module.erlang',
  334. 'text',
  335. 'punctuation.separator.module-function.erlang',
  336. 'text',
  337. 'entity.name.function.guard.erlang',
  338. 'text',
  339. 'punctuation.definition.parameters.begin.erlang' ],
  340. regex: '(?:(erlang)(\\s*)(:)(\\s*))?(is_atom|is_binary|is_constant|is_float|is_function|is_integer|is_list|is_number|is_pid|is_port|is_reference|is_tuple|is_record|abs|element|hd|length|node|round|self|size|tl|trunc)(\\s*)(\\()',
  341. push:
  342. [ { token: 'text', regex: '(?=\\))', next: 'pop' },
  343. { token: 'punctuation.separator.parameters.erlang', regex: ',' },
  344. { include: '#everything-else' } ] },
  345. { token:
  346. [ 'entity.name.type.class.module.erlang',
  347. 'text',
  348. 'punctuation.separator.module-function.erlang',
  349. 'text',
  350. 'entity.name.function.erlang',
  351. 'text',
  352. 'punctuation.definition.parameters.begin.erlang' ],
  353. regex: '(?:([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(:)(\\s*))?([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(\\()',
  354. push:
  355. [ { token: 'text', regex: '(?=\\))', next: 'pop' },
  356. { token: 'punctuation.separator.parameters.erlang', regex: ',' },
  357. { include: '#everything-else' } ] },
  358. { defaultToken: 'meta.function-call.erlang' } ] } ],
  359. '#import-export-directive':
  360. [ { token:
  361. [ 'meta.directive.import.erlang',
  362. 'punctuation.section.directive.begin.erlang',
  363. 'meta.directive.import.erlang',
  364. 'keyword.control.directive.import.erlang',
  365. 'meta.directive.import.erlang',
  366. 'punctuation.definition.parameters.begin.erlang',
  367. 'meta.directive.import.erlang',
  368. 'entity.name.type.class.module.erlang',
  369. 'meta.directive.import.erlang',
  370. 'punctuation.separator.parameters.erlang' ],
  371. regex: '^(\\s*)(-)(\\s*)(import)(\\s*)(\\()(\\s*)([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(,)',
  372. push:
  373. [ { token:
  374. [ 'punctuation.definition.parameters.end.erlang',
  375. 'meta.directive.import.erlang',
  376. 'punctuation.section.directive.end.erlang' ],
  377. regex: '(\\))(\\s*)(\\.)',
  378. next: 'pop' },
  379. { include: '#internal-function-list' },
  380. { defaultToken: 'meta.directive.import.erlang' } ] },
  381. { token:
  382. [ 'meta.directive.export.erlang',
  383. 'punctuation.section.directive.begin.erlang',
  384. 'meta.directive.export.erlang',
  385. 'keyword.control.directive.export.erlang',
  386. 'meta.directive.export.erlang',
  387. 'punctuation.definition.parameters.begin.erlang' ],
  388. regex: '^(\\s*)(-)(\\s*)(export)(\\s*)(\\()',
  389. push:
  390. [ { token:
  391. [ 'punctuation.definition.parameters.end.erlang',
  392. 'meta.directive.export.erlang',
  393. 'punctuation.section.directive.end.erlang' ],
  394. regex: '(\\))(\\s*)(\\.)',
  395. next: 'pop' },
  396. { include: '#internal-function-list' },
  397. { defaultToken: 'meta.directive.export.erlang' } ] } ],
  398. '#internal-expression-punctuation':
  399. [ { token:
  400. [ 'punctuation.separator.clause-head-body.erlang',
  401. 'punctuation.separator.clauses.erlang',
  402. 'punctuation.separator.expressions.erlang' ],
  403. regex: '(->)|(;)|(,)' } ],
  404. '#internal-function-list':
  405. [ { token: 'punctuation.definition.list.begin.erlang',
  406. regex: '\\[',
  407. push:
  408. [ { token: 'punctuation.definition.list.end.erlang',
  409. regex: '\\]',
  410. next: 'pop' },
  411. { token:
  412. [ 'entity.name.function.erlang',
  413. 'text',
  414. 'punctuation.separator.function-arity.erlang' ],
  415. regex: '([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(/)',
  416. push:
  417. [ { token: 'punctuation.separator.list.erlang',
  418. regex: ',|(?=\\])',
  419. next: 'pop' },
  420. { include: '#everything-else' } ] },
  421. { include: '#everything-else' },
  422. { defaultToken: 'meta.structure.list.function.erlang' } ] } ],
  423. '#internal-function-parts':
  424. [ { token: 'text',
  425. regex: '(?=\\()',
  426. push:
  427. [ { token: 'punctuation.separator.clause-head-body.erlang',
  428. regex: '->',
  429. next: 'pop' },
  430. { token: 'punctuation.definition.parameters.begin.erlang',
  431. regex: '\\(',
  432. push:
  433. [ { token: 'punctuation.definition.parameters.end.erlang',
  434. regex: '\\)',
  435. next: 'pop' },
  436. { token: 'punctuation.separator.parameters.erlang', regex: ',' },
  437. { include: '#everything-else' } ] },
  438. { token: 'punctuation.separator.guards.erlang', regex: ',|;' },
  439. { include: '#everything-else' } ] },
  440. { token: 'punctuation.separator.expressions.erlang',
  441. regex: ',' },
  442. { include: '#everything-else' } ],
  443. '#internal-record-body':
  444. [ { token: 'punctuation.definition.class.record.begin.erlang',
  445. regex: '\\{',
  446. push:
  447. [ { token: 'meta.structure.record.erlang',
  448. regex: '(?=\\})',
  449. next: 'pop' },
  450. { token:
  451. [ 'variable.other.field.erlang',
  452. 'variable.language.omitted.field.erlang',
  453. 'text',
  454. 'keyword.operator.assignment.erlang' ],
  455. regex: '(?:([a-z][a-zA-Z\\d@_]*|\'[^\']*\')|(_))(\\s*)(=|::)',
  456. push:
  457. [ { token: 'punctuation.separator.class.record.erlang',
  458. regex: ',|(?=\\})',
  459. next: 'pop' },
  460. { include: '#everything-else' } ] },
  461. { token:
  462. [ 'variable.other.field.erlang',
  463. 'text',
  464. 'punctuation.separator.class.record.erlang' ],
  465. regex: '([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)((?:,)?)' },
  466. { include: '#everything-else' },
  467. { defaultToken: 'meta.structure.record.erlang' } ] } ],
  468. '#internal-type-specifiers':
  469. [ { token: 'punctuation.separator.value-type.erlang',
  470. regex: '/',
  471. push:
  472. [ { token: 'text', regex: '(?=,|:|>>)', next: 'pop' },
  473. { token:
  474. [ 'storage.type.erlang',
  475. 'storage.modifier.signedness.erlang',
  476. 'storage.modifier.endianness.erlang',
  477. 'storage.modifier.unit.erlang',
  478. 'punctuation.separator.type-specifiers.erlang' ],
  479. regex: '(integer|float|binary|bytes|bitstring|bits)|(signed|unsigned)|(big|little|native)|(unit)|(-)' } ] } ],
  480. '#keyword':
  481. [ { token: 'keyword.control.erlang',
  482. regex: '\\b(?:after|begin|case|catch|cond|end|fun|if|let|of|query|try|receive|when)\\b' } ],
  483. '#list':
  484. [ { token: 'punctuation.definition.list.begin.erlang',
  485. regex: '\\[',
  486. push:
  487. [ { token: 'punctuation.definition.list.end.erlang',
  488. regex: '\\]',
  489. next: 'pop' },
  490. { token: 'punctuation.separator.list.erlang',
  491. regex: '\\||\\|\\||,' },
  492. { include: '#everything-else' },
  493. { defaultToken: 'meta.structure.list.erlang' } ] } ],
  494. '#macro-directive':
  495. [ { token:
  496. [ 'meta.directive.ifdef.erlang',
  497. 'punctuation.section.directive.begin.erlang',
  498. 'meta.directive.ifdef.erlang',
  499. 'keyword.control.directive.ifdef.erlang',
  500. 'meta.directive.ifdef.erlang',
  501. 'punctuation.definition.parameters.begin.erlang',
  502. 'meta.directive.ifdef.erlang',
  503. 'entity.name.function.macro.erlang',
  504. 'meta.directive.ifdef.erlang',
  505. 'punctuation.definition.parameters.end.erlang',
  506. 'meta.directive.ifdef.erlang',
  507. 'punctuation.section.directive.end.erlang' ],
  508. regex: '^(\\s*)(-)(\\s*)(ifdef)(\\s*)(\\()(\\s*)([a-zA-z\\d@_]+)(\\s*)(\\))(\\s*)(\\.)' },
  509. { token:
  510. [ 'meta.directive.ifndef.erlang',
  511. 'punctuation.section.directive.begin.erlang',
  512. 'meta.directive.ifndef.erlang',
  513. 'keyword.control.directive.ifndef.erlang',
  514. 'meta.directive.ifndef.erlang',
  515. 'punctuation.definition.parameters.begin.erlang',
  516. 'meta.directive.ifndef.erlang',
  517. 'entity.name.function.macro.erlang',
  518. 'meta.directive.ifndef.erlang',
  519. 'punctuation.definition.parameters.end.erlang',
  520. 'meta.directive.ifndef.erlang',
  521. 'punctuation.section.directive.end.erlang' ],
  522. regex: '^(\\s*)(-)(\\s*)(ifndef)(\\s*)(\\()(\\s*)([a-zA-z\\d@_]+)(\\s*)(\\))(\\s*)(\\.)' },
  523. { token:
  524. [ 'meta.directive.undef.erlang',
  525. 'punctuation.section.directive.begin.erlang',
  526. 'meta.directive.undef.erlang',
  527. 'keyword.control.directive.undef.erlang',
  528. 'meta.directive.undef.erlang',
  529. 'punctuation.definition.parameters.begin.erlang',
  530. 'meta.directive.undef.erlang',
  531. 'entity.name.function.macro.erlang',
  532. 'meta.directive.undef.erlang',
  533. 'punctuation.definition.parameters.end.erlang',
  534. 'meta.directive.undef.erlang',
  535. 'punctuation.section.directive.end.erlang' ],
  536. regex: '^(\\s*)(-)(\\s*)(undef)(\\s*)(\\()(\\s*)([a-zA-z\\d@_]+)(\\s*)(\\))(\\s*)(\\.)' } ],
  537. '#macro-usage':
  538. [ { token:
  539. [ 'keyword.operator.macro.erlang',
  540. 'meta.macro-usage.erlang',
  541. 'entity.name.function.macro.erlang' ],
  542. regex: '(\\?\\??)(\\s*)([a-zA-Z\\d@_]+)' } ],
  543. '#module-directive':
  544. [ { token:
  545. [ 'meta.directive.module.erlang',
  546. 'punctuation.section.directive.begin.erlang',
  547. 'meta.directive.module.erlang',
  548. 'keyword.control.directive.module.erlang',
  549. 'meta.directive.module.erlang',
  550. 'punctuation.definition.parameters.begin.erlang',
  551. 'meta.directive.module.erlang',
  552. 'entity.name.type.class.module.definition.erlang',
  553. 'meta.directive.module.erlang',
  554. 'punctuation.definition.parameters.end.erlang',
  555. 'meta.directive.module.erlang',
  556. 'punctuation.section.directive.end.erlang' ],
  557. regex: '^(\\s*)(-)(\\s*)(module)(\\s*)(\\()(\\s*)([a-z][a-zA-Z\\d@_]*)(\\s*)(\\))(\\s*)(\\.)' } ],
  558. '#number':
  559. [ { token: 'text',
  560. regex: '(?=\\d)',
  561. push:
  562. [ { token: 'text', regex: '(?!\\d)', next: 'pop' },
  563. { token:
  564. [ 'constant.numeric.float.erlang',
  565. 'punctuation.separator.integer-float.erlang',
  566. 'constant.numeric.float.erlang',
  567. 'punctuation.separator.float-exponent.erlang' ],
  568. regex: '(\\d+)(\\.)(\\d+)((?:[eE][\\+\\-]?\\d+)?)' },
  569. { token:
  570. [ 'constant.numeric.integer.binary.erlang',
  571. 'punctuation.separator.base-integer.erlang',
  572. 'constant.numeric.integer.binary.erlang' ],
  573. regex: '(2)(#)([0-1]+)' },
  574. { token:
  575. [ 'constant.numeric.integer.base-3.erlang',
  576. 'punctuation.separator.base-integer.erlang',
  577. 'constant.numeric.integer.base-3.erlang' ],
  578. regex: '(3)(#)([0-2]+)' },
  579. { token:
  580. [ 'constant.numeric.integer.base-4.erlang',
  581. 'punctuation.separator.base-integer.erlang',
  582. 'constant.numeric.integer.base-4.erlang' ],
  583. regex: '(4)(#)([0-3]+)' },
  584. { token:
  585. [ 'constant.numeric.integer.base-5.erlang',
  586. 'punctuation.separator.base-integer.erlang',
  587. 'constant.numeric.integer.base-5.erlang' ],
  588. regex: '(5)(#)([0-4]+)' },
  589. { token:
  590. [ 'constant.numeric.integer.base-6.erlang',
  591. 'punctuation.separator.base-integer.erlang',
  592. 'constant.numeric.integer.base-6.erlang' ],
  593. regex: '(6)(#)([0-5]+)' },
  594. { token:
  595. [ 'constant.numeric.integer.base-7.erlang',
  596. 'punctuation.separator.base-integer.erlang',
  597. 'constant.numeric.integer.base-7.erlang' ],
  598. regex: '(7)(#)([0-6]+)' },
  599. { token:
  600. [ 'constant.numeric.integer.octal.erlang',
  601. 'punctuation.separator.base-integer.erlang',
  602. 'constant.numeric.integer.octal.erlang' ],
  603. regex: '(8)(#)([0-7]+)' },
  604. { token:
  605. [ 'constant.numeric.integer.base-9.erlang',
  606. 'punctuation.separator.base-integer.erlang',
  607. 'constant.numeric.integer.base-9.erlang' ],
  608. regex: '(9)(#)([0-8]+)' },
  609. { token:
  610. [ 'constant.numeric.integer.decimal.erlang',
  611. 'punctuation.separator.base-integer.erlang',
  612. 'constant.numeric.integer.decimal.erlang' ],
  613. regex: '(10)(#)(\\d+)' },
  614. { token:
  615. [ 'constant.numeric.integer.base-11.erlang',
  616. 'punctuation.separator.base-integer.erlang',
  617. 'constant.numeric.integer.base-11.erlang' ],
  618. regex: '(11)(#)([\\daA]+)' },
  619. { token:
  620. [ 'constant.numeric.integer.base-12.erlang',
  621. 'punctuation.separator.base-integer.erlang',
  622. 'constant.numeric.integer.base-12.erlang' ],
  623. regex: '(12)(#)([\\da-bA-B]+)' },
  624. { token:
  625. [ 'constant.numeric.integer.base-13.erlang',
  626. 'punctuation.separator.base-integer.erlang',
  627. 'constant.numeric.integer.base-13.erlang' ],
  628. regex: '(13)(#)([\\da-cA-C]+)' },
  629. { token:
  630. [ 'constant.numeric.integer.base-14.erlang',
  631. 'punctuation.separator.base-integer.erlang',
  632. 'constant.numeric.integer.base-14.erlang' ],
  633. regex: '(14)(#)([\\da-dA-D]+)' },
  634. { token:
  635. [ 'constant.numeric.integer.base-15.erlang',
  636. 'punctuation.separator.base-integer.erlang',
  637. 'constant.numeric.integer.base-15.erlang' ],
  638. regex: '(15)(#)([\\da-eA-E]+)' },
  639. { token:
  640. [ 'constant.numeric.integer.hexadecimal.erlang',
  641. 'punctuation.separator.base-integer.erlang',
  642. 'constant.numeric.integer.hexadecimal.erlang' ],
  643. regex: '(16)(#)([\\da-fA-F]+)' },
  644. { token:
  645. [ 'constant.numeric.integer.base-17.erlang',
  646. 'punctuation.separator.base-integer.erlang',
  647. 'constant.numeric.integer.base-17.erlang' ],
  648. regex: '(17)(#)([\\da-gA-G]+)' },
  649. { token:
  650. [ 'constant.numeric.integer.base-18.erlang',
  651. 'punctuation.separator.base-integer.erlang',
  652. 'constant.numeric.integer.base-18.erlang' ],
  653. regex: '(18)(#)([\\da-hA-H]+)' },
  654. { token:
  655. [ 'constant.numeric.integer.base-19.erlang',
  656. 'punctuation.separator.base-integer.erlang',
  657. 'constant.numeric.integer.base-19.erlang' ],
  658. regex: '(19)(#)([\\da-iA-I]+)' },
  659. { token:
  660. [ 'constant.numeric.integer.base-20.erlang',
  661. 'punctuation.separator.base-integer.erlang',
  662. 'constant.numeric.integer.base-20.erlang' ],
  663. regex: '(20)(#)([\\da-jA-J]+)' },
  664. { token:
  665. [ 'constant.numeric.integer.base-21.erlang',
  666. 'punctuation.separator.base-integer.erlang',
  667. 'constant.numeric.integer.base-21.erlang' ],
  668. regex: '(21)(#)([\\da-kA-K]+)' },
  669. { token:
  670. [ 'constant.numeric.integer.base-22.erlang',
  671. 'punctuation.separator.base-integer.erlang',
  672. 'constant.numeric.integer.base-22.erlang' ],
  673. regex: '(22)(#)([\\da-lA-L]+)' },
  674. { token:
  675. [ 'constant.numeric.integer.base-23.erlang',
  676. 'punctuation.separator.base-integer.erlang',
  677. 'constant.numeric.integer.base-23.erlang' ],
  678. regex: '(23)(#)([\\da-mA-M]+)' },
  679. { token:
  680. [ 'constant.numeric.integer.base-24.erlang',
  681. 'punctuation.separator.base-integer.erlang',
  682. 'constant.numeric.integer.base-24.erlang' ],
  683. regex: '(24)(#)([\\da-nA-N]+)' },
  684. { token:
  685. [ 'constant.numeric.integer.base-25.erlang',
  686. 'punctuation.separator.base-integer.erlang',
  687. 'constant.numeric.integer.base-25.erlang' ],
  688. regex: '(25)(#)([\\da-oA-O]+)' },
  689. { token:
  690. [ 'constant.numeric.integer.base-26.erlang',
  691. 'punctuation.separator.base-integer.erlang',
  692. 'constant.numeric.integer.base-26.erlang' ],
  693. regex: '(26)(#)([\\da-pA-P]+)' },
  694. { token:
  695. [ 'constant.numeric.integer.base-27.erlang',
  696. 'punctuation.separator.base-integer.erlang',
  697. 'constant.numeric.integer.base-27.erlang' ],
  698. regex: '(27)(#)([\\da-qA-Q]+)' },
  699. { token:
  700. [ 'constant.numeric.integer.base-28.erlang',
  701. 'punctuation.separator.base-integer.erlang',
  702. 'constant.numeric.integer.base-28.erlang' ],
  703. regex: '(28)(#)([\\da-rA-R]+)' },
  704. { token:
  705. [ 'constant.numeric.integer.base-29.erlang',
  706. 'punctuation.separator.base-integer.erlang',
  707. 'constant.numeric.integer.base-29.erlang' ],
  708. regex: '(29)(#)([\\da-sA-S]+)' },
  709. { token:
  710. [ 'constant.numeric.integer.base-30.erlang',
  711. 'punctuation.separator.base-integer.erlang',
  712. 'constant.numeric.integer.base-30.erlang' ],
  713. regex: '(30)(#)([\\da-tA-T]+)' },
  714. { token:
  715. [ 'constant.numeric.integer.base-31.erlang',
  716. 'punctuation.separator.base-integer.erlang',
  717. 'constant.numeric.integer.base-31.erlang' ],
  718. regex: '(31)(#)([\\da-uA-U]+)' },
  719. { token:
  720. [ 'constant.numeric.integer.base-32.erlang',
  721. 'punctuation.separator.base-integer.erlang',
  722. 'constant.numeric.integer.base-32.erlang' ],
  723. regex: '(32)(#)([\\da-vA-V]+)' },
  724. { token:
  725. [ 'constant.numeric.integer.base-33.erlang',
  726. 'punctuation.separator.base-integer.erlang',
  727. 'constant.numeric.integer.base-33.erlang' ],
  728. regex: '(33)(#)([\\da-wA-W]+)' },
  729. { token:
  730. [ 'constant.numeric.integer.base-34.erlang',
  731. 'punctuation.separator.base-integer.erlang',
  732. 'constant.numeric.integer.base-34.erlang' ],
  733. regex: '(34)(#)([\\da-xA-X]+)' },
  734. { token:
  735. [ 'constant.numeric.integer.base-35.erlang',
  736. 'punctuation.separator.base-integer.erlang',
  737. 'constant.numeric.integer.base-35.erlang' ],
  738. regex: '(35)(#)([\\da-yA-Y]+)' },
  739. { token:
  740. [ 'constant.numeric.integer.base-36.erlang',
  741. 'punctuation.separator.base-integer.erlang',
  742. 'constant.numeric.integer.base-36.erlang' ],
  743. regex: '(36)(#)([\\da-zA-Z]+)' },
  744. { token: 'invalid.illegal.integer.erlang',
  745. regex: '\\d+#[\\da-zA-Z]+' },
  746. { token: 'constant.numeric.integer.decimal.erlang',
  747. regex: '\\d+' } ] } ],
  748. '#parenthesized-expression':
  749. [ { token: 'punctuation.section.expression.begin.erlang',
  750. regex: '\\(',
  751. push:
  752. [ { token: 'punctuation.section.expression.end.erlang',
  753. regex: '\\)',
  754. next: 'pop' },
  755. { include: '#everything-else' },
  756. { defaultToken: 'meta.expression.parenthesized' } ] } ],
  757. '#record-directive':
  758. [ { token:
  759. [ 'meta.directive.record.erlang',
  760. 'punctuation.section.directive.begin.erlang',
  761. 'meta.directive.record.erlang',
  762. 'keyword.control.directive.import.erlang',
  763. 'meta.directive.record.erlang',
  764. 'punctuation.definition.parameters.begin.erlang',
  765. 'meta.directive.record.erlang',
  766. 'entity.name.type.class.record.definition.erlang',
  767. 'meta.directive.record.erlang',
  768. 'punctuation.separator.parameters.erlang' ],
  769. regex: '^(\\s*)(-)(\\s*)(record)(\\s*)(\\()(\\s*)([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(,)',
  770. push:
  771. [ { token:
  772. [ 'punctuation.definition.class.record.end.erlang',
  773. 'meta.directive.record.erlang',
  774. 'punctuation.definition.parameters.end.erlang',
  775. 'meta.directive.record.erlang',
  776. 'punctuation.section.directive.end.erlang' ],
  777. regex: '(\\})(\\s*)(\\))(\\s*)(\\.)',
  778. next: 'pop' },
  779. { include: '#internal-record-body' },
  780. { defaultToken: 'meta.directive.record.erlang' } ] } ],
  781. '#record-usage':
  782. [ { token:
  783. [ 'keyword.operator.record.erlang',
  784. 'meta.record-usage.erlang',
  785. 'entity.name.type.class.record.erlang',
  786. 'meta.record-usage.erlang',
  787. 'punctuation.separator.record-field.erlang',
  788. 'meta.record-usage.erlang',
  789. 'variable.other.field.erlang' ],
  790. regex: '(#)(\\s*)([a-z][a-zA-Z\\d@_]*|\'[^\']*\')(\\s*)(\\.)(\\s*)([a-z][a-zA-Z\\d@_]*|\'[^\']*\')' },
  791. { token:
  792. [ 'keyword.operator.record.erlang',
  793. 'meta.record-usage.erlang',
  794. 'entity.name.type.class.record.erlang' ],
  795. regex: '(#)(\\s*)([a-z][a-zA-Z\\d@_]*|\'[^\']*\')',
  796. push:
  797. [ { token: 'punctuation.definition.class.record.end.erlang',
  798. regex: '\\}',
  799. next: 'pop' },
  800. { include: '#internal-record-body' },
  801. { defaultToken: 'meta.record-usage.erlang' } ] } ],
  802. '#string':
  803. [ { token: 'punctuation.definition.string.begin.erlang',
  804. regex: '"',
  805. push:
  806. [ { token: 'punctuation.definition.string.end.erlang',
  807. regex: '"',
  808. next: 'pop' },
  809. { token:
  810. [ 'punctuation.definition.escape.erlang',
  811. 'constant.character.escape.erlang',
  812. 'punctuation.definition.escape.erlang',
  813. 'constant.character.escape.erlang',
  814. 'constant.character.escape.erlang' ],
  815. regex: '(\\\\)(?:([bdefnrstv\\\\\'"])|(\\^)([@-_])|([0-7]{1,3}))' },
  816. { token: 'invalid.illegal.string.erlang', regex: '\\\\\\^?.?' },
  817. { token:
  818. [ 'punctuation.definition.placeholder.erlang',
  819. 'punctuation.separator.placeholder-parts.erlang',
  820. 'constant.other.placeholder.erlang',
  821. 'punctuation.separator.placeholder-parts.erlang',
  822. 'punctuation.separator.placeholder-parts.erlang',
  823. 'constant.other.placeholder.erlang',
  824. 'punctuation.separator.placeholder-parts.erlang',
  825. 'punctuation.separator.placeholder-parts.erlang',
  826. 'punctuation.separator.placeholder-parts.erlang',
  827. 'constant.other.placeholder.erlang',
  828. 'constant.other.placeholder.erlang' ],
  829. regex: '(~)(?:((?:\\-)?)(\\d+)|(\\*))?(?:(\\.)(?:(\\d+)|(\\*)))?(?:(\\.)(?:(\\*)|(.)))?([~cfegswpWPBX#bx\\+ni])' },
  830. { token:
  831. [ 'punctuation.definition.placeholder.erlang',
  832. 'punctuation.separator.placeholder-parts.erlang',
  833. 'constant.other.placeholder.erlang',
  834. 'constant.other.placeholder.erlang' ],
  835. regex: '(~)((?:\\*)?)((?:\\d+)?)([~du\\-#fsacl])' },
  836. { token: 'invalid.illegal.string.erlang', regex: '~.?' },
  837. { defaultToken: 'string.quoted.double.erlang' } ] } ],
  838. '#symbolic-operator':
  839. [ { token: 'keyword.operator.symbolic.erlang',
  840. regex: '\\+\\+|\\+|--|-|\\*|/=|/|=/=|=:=|==|=<|=|<-|<|>=|>|!|::' } ],
  841. '#textual-operator':
  842. [ { token: 'keyword.operator.textual.erlang',
  843. regex: '\\b(?:andalso|band|and|bxor|xor|bor|orelse|or|bnot|not|bsl|bsr|div|rem)\\b' } ],
  844. '#tuple':
  845. [ { token: 'punctuation.definition.tuple.begin.erlang',
  846. regex: '\\{',
  847. push:
  848. [ { token: 'punctuation.definition.tuple.end.erlang',
  849. regex: '\\}',
  850. next: 'pop' },
  851. { token: 'punctuation.separator.tuple.erlang', regex: ',' },
  852. { include: '#everything-else' },
  853. { defaultToken: 'meta.structure.tuple.erlang' } ] } ],
  854. '#variable':
  855. [ { token: [ 'variable.other.erlang', 'variable.language.omitted.erlang' ],
  856. regex: '(_[a-zA-Z\\d@_]+|[A-Z][a-zA-Z\\d@_]*)|(_)' } ] }
  857. this.normalizeRules();
  858. };
  859. ErlangHighlightRules.metaData = { comment: 'The recognition of function definitions and compiler directives (such as module, record and macro definitions) requires that each of the aforementioned constructs must be the first string inside a line (except for whitespace). Also, the function/module/record/macro names must be given unquoted. -- desp',
  860. fileTypes: [ 'erl', 'hrl' ],
  861. keyEquivalent: '^~E',
  862. name: 'Erlang',
  863. scopeName: 'source.erlang' }
  864. oop.inherits(ErlangHighlightRules, TextHighlightRules);
  865. exports.ErlangHighlightRules = ErlangHighlightRules;
  866. });