maze_highlight_rules.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. define(function(require, exports, module) {
  31. "use strict";
  32. var oop = require("../lib/oop");
  33. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  34. var MazeHighlightRules = function() {
  35. // regexp must not have capturing parentheses. Use (?:) instead.
  36. // regexps are ordered -> the first match is used
  37. this.$rules = {
  38. start: [{
  39. token: "keyword.control",
  40. regex: /##|``/,
  41. comment: "Wall"
  42. }, {
  43. token: "entity.name.tag",
  44. regex: /\.\./,
  45. comment: "Path"
  46. }, {
  47. token: "keyword.control",
  48. regex: /<>/,
  49. comment: "Splitter"
  50. }, {
  51. token: "entity.name.tag",
  52. regex: /\*[\*A-Za-z0-9]/,
  53. comment: "Signal"
  54. }, {
  55. token: "constant.numeric",
  56. regex: /[0-9]{2}/,
  57. comment: "Pause"
  58. }, {
  59. token: "keyword.control",
  60. regex: /\^\^/,
  61. comment: "Start"
  62. }, {
  63. token: "keyword.control",
  64. regex: /\(\)/,
  65. comment: "Hole"
  66. }, {
  67. token: "support.function",
  68. regex: />>/,
  69. comment: "Out"
  70. }, {
  71. token: "support.function",
  72. regex: />\//,
  73. comment: "Ln Out"
  74. }, {
  75. token: "support.function",
  76. regex: /<</,
  77. comment: "In"
  78. }, {
  79. token: "keyword.control",
  80. regex: /--/,
  81. comment: "One use"
  82. }, {
  83. token: "constant.language",
  84. regex: /%[LRUDNlrudn]/,
  85. comment: "Direction"
  86. }, {
  87. token: [
  88. "entity.name.function",
  89. "keyword.other",
  90. "keyword.operator",
  91. "keyword.other",
  92. "keyword.operator",
  93. "constant.numeric",
  94. "keyword.operator",
  95. "keyword.other",
  96. "keyword.operator",
  97. "constant.numeric",
  98. "string.quoted.double",
  99. "string.quoted.single"
  100. ],
  101. regex: /([A-Za-z][A-Za-z0-9])( *-> *)(?:([-+*\/]=)( *)((?:-)?)([0-9]+)|(=)( *)(?:((?:-)?)([0-9]+)|("[^"]*")|('[^']*')))/,
  102. comment: "Assignment function"
  103. }, {
  104. token: [
  105. "entity.name.function",
  106. "keyword.other",
  107. "keyword.control",
  108. "keyword.other",
  109. "keyword.operator",
  110. "keyword.other",
  111. "keyword.operator",
  112. "constant.numeric",
  113. "entity.name.tag",
  114. "keyword.other",
  115. "keyword.control",
  116. "keyword.other",
  117. "constant.language",
  118. "keyword.other",
  119. "keyword.control",
  120. "keyword.other",
  121. "constant.language"
  122. ],
  123. regex: /([A-Za-z][A-Za-z0-9])( *-> *)(IF|if)( *)(?:([<>]=?|==)( *)((?:-)?)([0-9]+)|(\*[\*A-Za-z0-9]))( *)(THEN|then)( *)(%[LRUDNlrudn])(?:( *)(ELSE|else)( *)(%[LRUDNlrudn]))?/,
  124. comment: "Equality Function"
  125. }, {
  126. token: "entity.name.function",
  127. regex: /[A-Za-z][A-Za-z0-9]/,
  128. comment: "Function cell"
  129. }, {
  130. token: "comment.line.double-slash",
  131. regex: / *\/\/.*/,
  132. comment: "Comment"
  133. }]
  134. };
  135. this.normalizeRules();
  136. };
  137. MazeHighlightRules.metaData = {
  138. fileTypes: ["mz"],
  139. name: "Maze",
  140. scopeName: "source.maze"
  141. };
  142. oop.inherits(MazeHighlightRules, TextHighlightRules);
  143. exports.MazeHighlightRules = MazeHighlightRules;
  144. });