You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

271 lines
7.9 KiB

12 months ago
  1. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(acequire, exports, module) {
  2. "use strict";
  3. var Range = acequire("../range").Range;
  4. var MatchingBraceOutdent = function() {};
  5. (function() {
  6. this.checkOutdent = function(line, input) {
  7. if (! /^\s+$/.test(line))
  8. return false;
  9. return /^\s*\}/.test(input);
  10. };
  11. this.autoOutdent = function(doc, row) {
  12. var line = doc.getLine(row);
  13. var match = line.match(/^(\s*\})/);
  14. if (!match) return 0;
  15. var column = match[1].length;
  16. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  17. if (!openBracePos || openBracePos.row == row) return 0;
  18. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  19. doc.replace(new Range(row, 0, row, column-1), indent);
  20. };
  21. this.$getIndent = function(line) {
  22. return line.match(/^\s*/)[0];
  23. };
  24. }).call(MatchingBraceOutdent.prototype);
  25. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  26. });
  27. ace.define("ace/mode/livescript",["require","exports","module","ace/tokenizer","ace/mode/matching_brace_outdent","ace/mode/text"], function(acequire, exports, module){
  28. var identifier, LiveScriptMode, keywordend, stringfill;
  29. identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
  30. exports.Mode = LiveScriptMode = (function(superclass){
  31. var indenter, prototype = extend$((import$(LiveScriptMode, superclass).displayName = 'LiveScriptMode', LiveScriptMode), superclass).prototype, constructor = LiveScriptMode;
  32. function LiveScriptMode(){
  33. var that;
  34. this.$tokenizer = new (acequire('../tokenizer')).Tokenizer(LiveScriptMode.Rules);
  35. if (that = acequire('../mode/matching_brace_outdent')) {
  36. this.$outdent = new that.MatchingBraceOutdent;
  37. }
  38. this.$id = "ace/mode/livescript";
  39. }
  40. indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
  41. prototype.getNextLineIndent = function(state, line, tab){
  42. var indent, tokens;
  43. indent = this.$getIndent(line);
  44. tokens = this.$tokenizer.getLineTokens(line, state).tokens;
  45. if (!(tokens.length && tokens[tokens.length - 1].type === 'comment')) {
  46. if (state === 'start' && indenter.test(line)) {
  47. indent += tab;
  48. }
  49. }
  50. return indent;
  51. };
  52. prototype.lineCommentStart = "#";
  53. prototype.blockComment = {start: "###", end: "###"};
  54. prototype.checkOutdent = function(state, line, input){
  55. var ref$;
  56. return (ref$ = this.$outdent) != null ? ref$.checkOutdent(line, input) : void 8;
  57. };
  58. prototype.autoOutdent = function(state, doc, row){
  59. var ref$;
  60. return (ref$ = this.$outdent) != null ? ref$.autoOutdent(doc, row) : void 8;
  61. };
  62. return LiveScriptMode;
  63. }(acequire('../mode/text').Mode));
  64. keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
  65. stringfill = {
  66. defaultToken: 'string'
  67. };
  68. LiveScriptMode.Rules = {
  69. start: [
  70. {
  71. token: 'keyword',
  72. regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
  73. }, {
  74. token: 'constant.language',
  75. regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
  76. }, {
  77. token: 'invalid.illegal',
  78. regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
  79. }, {
  80. token: 'language.support.class',
  81. regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
  82. }, {
  83. token: 'language.support.function',
  84. regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
  85. }, {
  86. token: 'variable.language',
  87. regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
  88. }, {
  89. token: 'identifier',
  90. regex: identifier + '\\s*:(?![:=])'
  91. }, {
  92. token: 'variable',
  93. regex: identifier
  94. }, {
  95. token: 'keyword.operator',
  96. regex: '(?:\\.{3}|\\s+\\?)'
  97. }, {
  98. token: 'keyword.variable',
  99. regex: '(?:@+|::|\\.\\.)',
  100. next: 'key'
  101. }, {
  102. token: 'keyword.operator',
  103. regex: '\\.\\s*',
  104. next: 'key'
  105. }, {
  106. token: 'string',
  107. regex: '\\\\\\S[^\\s,;)}\\]]*'
  108. }, {
  109. token: 'string.doc',
  110. regex: '\'\'\'',
  111. next: 'qdoc'
  112. }, {
  113. token: 'string.doc',
  114. regex: '"""',
  115. next: 'qqdoc'
  116. }, {
  117. token: 'string',
  118. regex: '\'',
  119. next: 'qstring'
  120. }, {
  121. token: 'string',
  122. regex: '"',
  123. next: 'qqstring'
  124. }, {
  125. token: 'string',
  126. regex: '`',
  127. next: 'js'
  128. }, {
  129. token: 'string',
  130. regex: '<\\[',
  131. next: 'words'
  132. }, {
  133. token: 'string.regex',
  134. regex: '//',
  135. next: 'heregex'
  136. }, {
  137. token: 'comment.doc',
  138. regex: '/\\*',
  139. next: 'comment'
  140. }, {
  141. token: 'comment',
  142. regex: '#.*'
  143. }, {
  144. token: 'string.regex',
  145. regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
  146. next: 'key'
  147. }, {
  148. token: 'constant.numeric',
  149. regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
  150. }, {
  151. token: 'lparen',
  152. regex: '[({[]'
  153. }, {
  154. token: 'rparen',
  155. regex: '[)}\\]]',
  156. next: 'key'
  157. }, {
  158. token: 'keyword.operator',
  159. regex: '[\\^!|&%+\\-]+'
  160. }, {
  161. token: 'text',
  162. regex: '\\s+'
  163. }
  164. ],
  165. heregex: [
  166. {
  167. token: 'string.regex',
  168. regex: '.*?//[gimy$?]{0,4}',
  169. next: 'start'
  170. }, {
  171. token: 'string.regex',
  172. regex: '\\s*#{'
  173. }, {
  174. token: 'comment.regex',
  175. regex: '\\s+(?:#.*)?'
  176. }, {
  177. defaultToken: 'string.regex'
  178. }
  179. ],
  180. key: [
  181. {
  182. token: 'keyword.operator',
  183. regex: '[.?@!]+'
  184. }, {
  185. token: 'identifier',
  186. regex: identifier,
  187. next: 'start'
  188. }, {
  189. token: 'text',
  190. regex: '',
  191. next: 'start'
  192. }
  193. ],
  194. comment: [
  195. {
  196. token: 'comment.doc',
  197. regex: '.*?\\*/',
  198. next: 'start'
  199. }, {
  200. defaultToken: 'comment.doc'
  201. }
  202. ],
  203. qdoc: [
  204. {
  205. token: 'string',
  206. regex: ".*?'''",
  207. next: 'key'
  208. }, stringfill
  209. ],
  210. qqdoc: [
  211. {
  212. token: 'string',
  213. regex: '.*?"""',
  214. next: 'key'
  215. }, stringfill
  216. ],
  217. qstring: [
  218. {
  219. token: 'string',
  220. regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
  221. next: 'key'
  222. }, stringfill
  223. ],
  224. qqstring: [
  225. {
  226. token: 'string',
  227. regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
  228. next: 'key'
  229. }, stringfill
  230. ],
  231. js: [
  232. {
  233. token: 'string',
  234. regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
  235. next: 'key'
  236. }, stringfill
  237. ],
  238. words: [
  239. {
  240. token: 'string',
  241. regex: '.*?\\]>',
  242. next: 'key'
  243. }, stringfill
  244. ]
  245. };
  246. function extend$(sub, sup){
  247. function fun(){} fun.prototype = (sub.superclass = sup).prototype;
  248. (sub.prototype = new fun).constructor = sub;
  249. if (typeof sup.extended == 'function') sup.extended(sub);
  250. return sub;
  251. }
  252. function import$(obj, src){
  253. var own = {}.hasOwnProperty;
  254. for (var key in src) if (own.call(src, key)) obj[key] = src[key];
  255. return obj;
  256. }
  257. });