io_highlight_rules.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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\io.tmbundle/Syntaxes/io.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 IoHighlightRules = 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: [ 'text', 'meta.empty-parenthesis.io' ],
  44. regex: '(\\()(\\))',
  45. comment: 'we match this to overload return inside () --Allan; scoping rules for what gets the scope have changed, so we now group the ) instead of the ( -- Rob' },
  46. { token: [ 'text', 'meta.comma-parenthesis.io' ],
  47. regex: '(\\,)(\\))',
  48. comment: 'We want to do the same for ,) -- Seckar; same as above -- Rob' },
  49. { token: 'keyword.control.io',
  50. regex: '\\b(?:if|ifTrue|ifFalse|ifTrueIfFalse|for|loop|reverseForeach|foreach|map|continue|break|while|do|return)\\b' },
  51. { token: 'punctuation.definition.comment.io',
  52. regex: '/\\*',
  53. push:
  54. [ { token: 'punctuation.definition.comment.io',
  55. regex: '\\*/',
  56. next: 'pop' },
  57. { defaultToken: 'comment.block.io' } ] },
  58. { token: 'punctuation.definition.comment.io',
  59. regex: '//',
  60. push:
  61. [ { token: 'comment.line.double-slash.io',
  62. regex: '$',
  63. next: 'pop' },
  64. { defaultToken: 'comment.line.double-slash.io' } ] },
  65. { token: 'punctuation.definition.comment.io',
  66. regex: '#',
  67. push:
  68. [ { token: 'comment.line.number-sign.io', regex: '$', next: 'pop' },
  69. { defaultToken: 'comment.line.number-sign.io' } ] },
  70. { token: 'variable.language.io',
  71. regex: '\\b(?:self|sender|target|proto|protos|parent)\\b',
  72. comment: 'I wonder if some of this isn\'t variable.other.language? --Allan; scoping this as variable.language to match Objective-C\'s handling of \'self\', which is inconsistent with C++\'s handling of \'this\' but perhaps intentionally so -- Rob' },
  73. { token: 'keyword.operator.io',
  74. regex: '<=|>=|=|:=|\\*|\\||\\|\\||\\+|-|/|&|&&|>|<|\\?|@|@@|\\b(?:and|or)\\b' },
  75. { token: 'constant.other.io', regex: '\\bGL[\\w_]+\\b' },
  76. { token: 'support.class.io', regex: '\\b[A-Z](?:\\w+)?\\b' },
  77. { token: 'support.function.io',
  78. regex: '\\b(?:clone|call|init|method|list|vector|block|\\w+(?=\\s*\\())\\b' },
  79. { token: 'support.function.open-gl.io',
  80. regex: '\\bgl(?:u|ut)?[A-Z]\\w+\\b' },
  81. { token: 'punctuation.definition.string.begin.io',
  82. regex: '"""',
  83. push:
  84. [ { token: 'punctuation.definition.string.end.io',
  85. regex: '"""',
  86. next: 'pop' },
  87. { token: 'constant.character.escape.io', regex: '\\\\.' },
  88. { defaultToken: 'string.quoted.triple.io' } ] },
  89. { token: 'punctuation.definition.string.begin.io',
  90. regex: '"',
  91. push:
  92. [ { token: 'punctuation.definition.string.end.io',
  93. regex: '"',
  94. next: 'pop' },
  95. { token: 'constant.character.escape.io', regex: '\\\\.' },
  96. { defaultToken: 'string.quoted.double.io' } ] },
  97. { token: 'constant.numeric.io',
  98. regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?\\b' },
  99. { token: 'variable.other.global.io', regex: 'Lobby\\b' },
  100. { token: 'constant.language.io',
  101. regex: '\\b(?:TRUE|true|FALSE|false|NULL|null|Null|Nil|nil|YES|NO)\\b' } ] }
  102. this.normalizeRules();
  103. };
  104. IoHighlightRules.metaData = { fileTypes: [ 'io' ],
  105. keyEquivalent: '^~I',
  106. name: 'Io',
  107. scopeName: 'source.io' }
  108. oop.inherits(IoHighlightRules, TextHighlightRules);
  109. exports.IoHighlightRules = IoHighlightRules;
  110. });