mode-live_script.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. ace.define("ace/mode/live_script_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var LiveScriptHighlightRules = function() {
  6. this.$rules = { start:
  7. [ { token: 'punctuation.definition.comment.livescript',
  8. regex: '\\/\\*',
  9. push:
  10. [ { token: 'punctuation.definition.comment.livescript',
  11. regex: '\\*\\/',
  12. next: 'pop' },
  13. { token: 'storage.type.annotation.livescriptscript',
  14. regex: '@\\w*' },
  15. { defaultToken: 'comment.block.livescript' } ] },
  16. { token:
  17. [ 'punctuation.definition.comment.livescript',
  18. 'comment.line.number-sign.livescript' ],
  19. regex: '(#)(?!\\{)(.*$)' },
  20. { token:
  21. [ 'variable.parameter.function.livescript',
  22. 'meta.inline.function.livescript',
  23. 'storage.type.function.livescript',
  24. 'meta.inline.function.livescript',
  25. 'variable.parameter.function.livescript',
  26. 'meta.inline.function.livescript',
  27. 'storage.type.function.livescript' ],
  28. regex: '(\\s*\\!?\\(\\s*[^()]*?\\))(\\s*)(!?[~-]{1,2}>)|(\\s*\\!?)(\\(?[^()]*?\\)?)(\\s*)(<[~-]{1,2}!?)',
  29. comment: 'match stuff like: a -> … ' },
  30. { token:
  31. [ 'keyword.operator.new.livescript',
  32. 'meta.class.instance.constructor',
  33. 'entity.name.type.instance.livescript' ],
  34. regex: '(new)(\\s+)(\\w+(?:\\.\\w*)*)' },
  35. { token: 'keyword.illegal.livescript',
  36. regex: '\\bp(?:ackage|r(?:ivate|otected)|ublic)|interface|enum|static|yield\\b' },
  37. { token: 'punctuation.definition.string.begin.livescript',
  38. regex: '\'\'\'',
  39. push:
  40. [ { token: 'punctuation.definition.string.end.livescript',
  41. regex: '\'\'\'',
  42. next: 'pop' },
  43. { defaultToken: 'string.quoted.heredoc.livescript' } ] },
  44. { token: 'punctuation.definition.string.begin.livescript',
  45. regex: '"""',
  46. push:
  47. [ { token: 'punctuation.definition.string.end.livescript',
  48. regex: '"""',
  49. next: 'pop' },
  50. { token: 'constant.character.escape.livescript',
  51. regex: '\\\\.' },
  52. { include: '#interpolated_livescript' },
  53. { defaultToken: 'string.quoted.double.heredoc.livescript' } ] },
  54. { token: 'punctuation.definition.string.begin.livescript',
  55. regex: '``',
  56. push:
  57. [ { token: 'punctuation.definition.string.end.livescript',
  58. regex: '``',
  59. next: 'pop' },
  60. { token: 'constant.character.escape.livescript',
  61. regex: '\\\\(?:x[\\da-fA-F]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)' },
  62. { defaultToken: 'string.quoted.script.livescript' } ] },
  63. { token: 'string.array-literal.livescript',
  64. regex: '<\\[',
  65. push:
  66. [ { token: 'string.array-literal.livescript',
  67. regex: '\\]>',
  68. next: 'pop' },
  69. { defaultToken: 'string.array-literal.livescript' } ] },
  70. { token: 'string.regexp.livescript',
  71. regex: '/{2}(?![\\s=/*+{}?]).*?[^\\\\]/[igmy]{0,4}(?![a-zA-Z0-9])/{2}' },
  72. { token: 'string.regexp.livescript',
  73. regex: '/{2}$',
  74. push:
  75. [ { token: 'string.regexp.livescript',
  76. regex: '/{2}[imgy]{0,4}',
  77. next: 'pop' },
  78. { include: '#embedded_spaced_comment' },
  79. { include: '#interpolated_livescript' },
  80. { defaultToken: 'string.regexp.livescript' } ] },
  81. { token: 'string.regexp.livescript',
  82. regex: '/{2}',
  83. push:
  84. [ { token: 'string.regexp.livescript',
  85. regex: '/{2}[imgy]{0,4}',
  86. next: 'pop' },
  87. { token: 'constant.character.escape.livescript',
  88. regex: '\\\\(?:x[\\da-fA-F]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)' },
  89. { include: '#interpolated_livescript' },
  90. { defaultToken: 'string.regexp.livescript' } ] },
  91. { token: 'string.regexp.livescript',
  92. regex: '/(?![\\s=/*+{}?]).*?[^\\\\]/[igmy]{0,4}(?![a-zA-Z0-9])' },
  93. { token: 'keyword.control.livescript',
  94. regex: '\\b(?<![\\.\\$\\-])(?:t(?:h(?:is|row|en)|ry|ypeof!?|il|o)|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|rom|allthrough)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith|hen)|o(?:f|r|therwise)|return|break|let|var|loop|match|by)(?!\\-|\\s*:)\\b',
  95. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  96. originalRegex: '(?x)\n\t\t\t\t\\b(?<![\\.\\$\\-])(?:\n\t\t t(?:h(?:is|row|en)|ry|ypeof!?|il|o)\n\t\t |c(?:on(?:tinue|st)|a(?:se|tch)|lass)\n\t\t |i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])\n\t\t |d(?:e(?:fault|lete|bugger)|o)\n\t\t |f(?:or(?:\\s+own)?|inally|unction|rom|allthrough)\n\t\t |s(?:uper|witch)\n\t\t |e(?:lse|x(?:tends|port)|val)\n\t\t |a(?:nd|rguments)\n\t\t |n(?:ew|ot)\n\t\t |un(?:less|til)\n\t\t |w(?:hile|ith|hen)\n\t\t |o(?:f|r|therwise)\n\t\t |return|break|let|var|loop\n\t\t |match\n\t\t |by\n\t\t\t\t)(?!\\-|\\s*:)\\b\n\t\t\t' },
  97. { token: 'keyword.operator.livescript',
  98. regex: '\\b(?<![\\.\\$\\-])(?:instanceof|new|delete|typeof|and|or|is|isnt|not)(?!\\-|\\s*:)\\b',
  99. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  100. originalRegex: '(?x)\n\t\t\t\t\\b(?<![\\.\\$\\-])(\n\t\t\t\t\tinstanceof|new|delete|typeof|and|or|is|isnt|not\n\t\t\t\t)(?!\\-|\\s*:)\\b\n\t\t\t' },
  101. { token: 'keyword.operator.livescript',
  102. regex: 'and=|or=|%|&|\\^|\\*|\\/|(?<![a-zA-Z$_])(?:\\-)?\\-(?!\\-?>)|\\+\\+|\\+|~(?!~?>)|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<(?!\\[)|(?<!\\])>|(?<!\\w)!(?!(?:[~\\-]+)?>)|&&|\\.\\.(?:\\.)?|\\s\\.\\s|\\?|\\||\\|\\||\\:|\\*=|(?<!\\()/=|%=|\\+=|\\-=|\\.=|&=|\\(\\.|\\.\\)|\\^=',
  103. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  104. originalRegex: '(?x)\n\t\t\t\tand=|or=|%|&|\\^|\\*|\\/|(?<![a-zA-Z$_])(\\-)?\\-(?!\\-?>)|\\+\\+|\\+|\n\t\t\t\t~(?!~?>)|==|=|!=|<=|>=|<<=|>>=|\n\t\t\t\t>>>=|<>|<(?!\\[)|(?<!\\])>|(?<!\\w)!(?!([~\\-]+)?>)|&&|\\.\\.(\\.)?|\\s\\.\\s|\\?|\\||\\|\\||\\:|\\*=|(?<!\\()/=|%=|\\+=|\\-=|\\.=|&=|\\(\\.|\\.\\)|\n\t\t\t\t\\^=\n\t\t\t' },
  105. { token:
  106. [ 'variable.assignment.livescript',
  107. 'variable.assignment.livescript',
  108. 'variable.assignment.livescript',
  109. 'punctuation.separator.key-value',
  110. 'keyword.operator.livescript',
  111. 'variable.assignment.livescript' ],
  112. regex: '([a-zA-Z\\$_])((?:[\\w$.-])*)(\\s*)(?!\\::)(?:(:)|(=))(\\s*)(?!(?:\\s*!?\\s*\\(.*\\))?\\s*!?[~-]{1,2}>)' },
  113. { token: 'keyword.operator.livescript',
  114. regex: '(?<=\\s|^)[\\[\\{](?=.*?[\\]\\}]\\s+[:=])',
  115. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  116. originalRegex: '(?<=\\s|^)([\\[\\{])(?=.*?[\\]\\}]\\s+[:=])',
  117. push:
  118. [ { token: 'keyword.operator.livescript',
  119. regex: '[\\]\\}]\\s*[:=]',
  120. next: 'pop' },
  121. { include: '#variable_name' },
  122. { include: '#instance_variable' },
  123. { include: '#single_quoted_string' },
  124. { include: '#double_quoted_string' },
  125. { include: '#numeric' },
  126. { defaultToken: 'meta.variable.assignment.destructured.livescript' } ] },
  127. { token:
  128. [ 'meta.function.livescript',
  129. 'entity.name.function.livescript',
  130. 'entity.name.function.livescript',
  131. 'entity.name.function.livescript',
  132. 'entity.name.function.livescript',
  133. 'variable.parameter.function.livescript',
  134. 'entity.name.function.livescript',
  135. 'storage.type.function.livescript' ],
  136. regex: '(\\s*)(?=[a-zA-Z\\$_])([a-zA-Z\\$_])((?:[\\w$.:-])*)(\\s*)([:=])((?:\\s*!?\\s*\\(.*\\))?)(\\s*)(!?[~-]{1,2}>)' },
  137. { token: 'storage.type.function.livescript',
  138. regex: '!?[~-]{1,2}>' },
  139. { token: 'constant.language.boolean.true.livescript',
  140. regex: '\\b(?<!\\.)(?:true|on|yes)(?!\\s*[:=])\\b',
  141. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  142. originalRegex: '\\b(?<!\\.)(true|on|yes)(?!\\s*[:=])\\b' },
  143. { token: 'constant.language.boolean.false.livescript',
  144. regex: '\\b(?<!\\.)(?:false|off|no)(?!\\s*[:=])\\b',
  145. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  146. originalRegex: '\\b(?<!\\.)(false|off|no)(?!\\s*[:=])\\b' },
  147. { token: 'constant.language.null.livescript',
  148. regex: '\\b(?<!\\.)(?:null|void)(?!\\s*[:=])\\b',
  149. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  150. originalRegex: '\\b(?<!\\.)(null|void)(?!\\s*[:=])\\b' },
  151. { token: 'variable.language.livescript',
  152. regex: '\\b(?<!\\.)(?:super|this|extends)(?!\\s*[:=])\\b',
  153. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  154. originalRegex: '\\b(?<!\\.)(super|this|extends)(?!\\s*[:=])\\b' },
  155. { token:
  156. [ 'storage.type.class.livescript',
  157. 'meta.class.livescript',
  158. 'entity.name.type.class.livescript',
  159. 'meta.class.livescript',
  160. 'keyword.control.inheritance.livescript',
  161. 'meta.class.livescript',
  162. 'entity.other.inherited-class.livescript' ],
  163. regex: '(class\\b)(\\s+)((?:@?[a-zA-Z$_][\\w$.-]*)?)(?:(\\s+)(extends)(\\s+)(@?[a-zA-Z$_][\\w$.-]*))?' },
  164. { token: 'keyword.other.livescript',
  165. regex: '\\b(?:debugger|\\\\)\\b' },
  166. { token: 'support.class.livescript',
  167. regex: '\\b(?:Array|ArrayBuffer|Blob|Boolean|Date|document|event|Function|Int(?:8|16|32|64)Array|Math|Map|Number|Object|Proxy|RegExp|Set|String|WeakMap|window|Uint(?:8|16|32|64)Array|XMLHttpRequest)\\b' },
  168. { token: 'entity.name.type.object.livescript',
  169. regex: '\\bconsole\\b' },
  170. { token: 'support.function.console.livescript',
  171. regex: '(?<=console\\.)(?:debug|warn|info|log|error|time(?:End|-end)|assert)\\b',
  172. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  173. originalRegex: '((?<=console\\.)(debug|warn|info|log|error|time(End|-end)|assert))\\b' },
  174. { token: 'support.function.livescript',
  175. regex: '\\b(?:decodeURI(?:Component)?|encodeURI(?:Component)?|eval|parse(?:Float|Int)|require)\\b' },
  176. { token: 'support.function.prelude.livescript',
  177. regex: '(?<![.-])\\b(?:map|filter|reject|partition|find|each|head|tail|last|initial|empty|values|keys|length|cons|append|join|reverse|fold(?:l|r)?1?|unfoldr|and(?:List|-list)|or(?:List|-list)|any|all|unique|sum|product|mean|compact|concat(?:Map|-map)?|maximum|minimum|scan(?:l|r)?1?|replicate|slice|apply|split(?:At|-at)?|take(?:While|-while)?|drop(?:While|-while)?|span|first|break(?:It|-it)|list(?:ToObj|-to-obj)|obj(?:ToFunc|-to-func)|pairs(?:ToObj|-to-obj)|obj(?:ToPairs|-to-pairs|ToLists|-to-lists)|zip(?:All|-all)?(?:With|-with)?|compose|curry|partial|flip|fix|sort(?:With|-with|By|-by)?|group(?:By|-by)|break(?:List|-list|Str|-str)|difference|intersection|union|average|flatten|chars|unchars|repeat|lines|unlines|words|unwords|max|min|negate|abs|signum|quot|rem|div|mod|recip|pi|tau|exp|sqrt|ln|pow|sin|cos|tan|asin|acos|atan|atan2|truncate|round|ceiling|floor|is(?:It|-it)NaN|even|odd|gcd|lcm|disabled__id)\\b(?![.-])',
  178. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  179. originalRegex: '(?x)(?<![.-])\\b(\n\t\t\t\tmap|filter|reject|partition|find|each|head|tail|last|initial|empty|\n\t\t\t\tvalues|keys|length|cons|append|join|reverse|fold(l|r)?1?|unfoldr|\n\t\t\t\tand(List|-list)|or(List|-list)|any|all|unique|sum|product|mean|compact|\n\t\t\t\tconcat(Map|-map)?|maximum|minimum|scan(l|r)?1?|replicate|slice|apply|\n\t\t\t\tsplit(At|-at)?|take(While|-while)?|drop(While|-while)?|span|first|\n\t\t\t\tbreak(It|-it)|list(ToObj|-to-obj)|obj(ToFunc|-to-func)|\n\t\t\t\tpairs(ToObj|-to-obj)|obj(ToPairs|-to-pairs|ToLists|-to-lists)|\n\t\t\t\tzip(All|-all)?(With|-with)?|compose|curry|partial|flip|fix|\n\t\t\t\tsort(With|-with|By|-by)?|group(By|-by)|break(List|-list|Str|-str)|\n\t\t\t\tdifference|intersection|union|average|flatten|chars|unchars|repeat|\n\t\t\t\tlines|unlines|words|unwords|max|min|negate|abs|signum|quot|rem|div|mod|\n\t\t\t\trecip|pi|tau|exp|sqrt|ln|pow|sin|cos|tan|asin|acos|atan|atan2|truncate|\n\t\t\t\tround|ceiling|floor|is(It|-it)NaN|even|odd|gcd|lcm|disabled__id\n\t\t\t)\\b(?![.-])',
  180. comment: 'Generated by DOM query from http://gkz.github.com/prelude-ls/:\n\t [].slice\n\t .call(document.querySelectorAll(".nav-pills li a"))\n\t .map(function(_) {return _.innerText})\n\t .filter(function(_) {return _.trim() !== \'})\n\t .slice(2)\n\t .join("|")\n \t\t' },
  181. { token: 'support.function.semireserved.livescript',
  182. regex: '(?<![.-])\\b(?:that|it|e)\\b',
  183. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  184. originalRegex: '(?x)(?<![.-])\\b(that|it|e)\\b' },
  185. { token: 'support.function.method.array.livescript',
  186. regex: '(?<=(?:\\.|\\]|\\)))(?:apply|call|concat|every|filter|for(?:Each|-each)|from|has(?:Own|-own)(?:Property|-property)|index(?:Of|-of)|is(?:Prototype|-prototype)(?:Of|-of)|join|last(?:Index|-index)(?:Of|-of)|map|of|pop|property(?:Is|-is)(?:Enumerable|-enumerable)|push|reduce(?:Right|-right)?|reverse|shift|slice|some|sort|splice|to(?:Locale|-locale)?(?:String|-string)|unshift|valueOf)\\b(?!-)',
  187. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  188. originalRegex: '(?x)((?<=(\\.|\\]|\\)))(\n\t\t\t\tapply|call|concat|every|filter|for(Each|-each)|\n\t\t\t\tfrom|has(Own|-own)(Property|-property)|index(Of|-of)|\n\t\t\t\tis(Prototype|-prototype)(Of|-of)|join|last(Index|-index)(Of|-of)|\n\t\t\t\tmap|of|pop|property(Is|-is)(Enumerable|-enumerable)|push|\n\t\t\t\treduce(Right|-right)?|reverse|shift|slice|some|sort|\n\t\t\t\tsplice|to(Locale|-locale)?(String|-string)|unshift|valueOf\n\t\t\t))\\b(?!-) ' },
  189. { token: 'support.function.static.array.livescript',
  190. regex: '(?<=Array\\.)isArray\\b',
  191. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  192. originalRegex: '(?x)((?<=Array\\.)(\n\t\t\t\tisArray\n\t\t\t))\\b' },
  193. { token: 'support.function.static.object.livescript',
  194. regex: '(?<=Object\\.)(?:create|ace.define(?:Propert|-propert)(?:ies|y)|freeze|get(?:Own|-own)(?:Property|-property)(?:Descriptors?|Names)|get(?:Property|-property)(?:Descriptor|Names)|getPrototypeOf|is(?:(?:Extensible|-extensible)|(?:Frozen|-frozen)|(?:Sealed|-sealed))?|keys|prevent(?:Extensions|-extensions)|seal)\\b',
  195. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  196. originalRegex: '(?x)((?<=Object\\.)(\n\t\t\t\tcreate|ace.define(Propert|-propert)(ies|y)|freeze|\n\t\t\t\tget(Own|-own)(Property|-property)(Descriptors?|Names)|\n\t\t\t\tget(Property|-property)(Descriptor|Names)|getPrototypeOf|\n\t\t\t\tis((Extensible|-extensible)|(Frozen|-frozen)|(Sealed|-sealed))?|\n\t\t\t\tkeys|prevent(Extensions|-extensions)|seal\n\t\t\t))\\b' },
  197. { token: 'support.function.static.math.livescript',
  198. regex: '(?<=Math\\.)(?:abs|acos|acosh|asin|asinh|atan|atan2|atanh|ceil|cos|cosh|exp|expm1|floor|hypot|log|log10|log1p|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc)\\b',
  199. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  200. originalRegex: '(?x)((?<=Math\\.)(\n\t\t\t\tabs|acos|acosh|asin|asinh|atan|atan2|atanh|ceil|cos|cosh|exp|expm1|floor|\n\t\t\t\thypot|log|log10|log1p|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|\n\t\t\t\ttan|tanh|trunc\n\t\t\t))\\b' },
  201. { token: 'support.function.static.number.livescript',
  202. regex: '(?<=Number\\.)(?:is(?:Finite|Integer|NaN)|to(?:Integer|-integer))\\b',
  203. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  204. originalRegex: '(?x)((?<=Number\\.)(\n\t\t\t\tis(Finite|Integer|NaN)|to(Integer|-integer)\n\t\t\t))\\b' },
  205. { token: 'constant.language.livescript',
  206. regex: '\\b(?:Infinity|NaN|undefined)\\b' },
  207. { token: 'punctuation.terminator.statement.livescript',
  208. regex: '\\;' },
  209. { token: 'meta.delimiter.object.comma.livescript',
  210. regex: ',[ |\\t]*' },
  211. { token: 'meta.delimiter.method.period.livescript',
  212. regex: '\\.' },
  213. { token: 'meta.brace.curly.livescript', regex: '\\{|\\}' },
  214. { token: 'meta.brace.round.livescript', regex: '\\(|\\)' },
  215. { token: 'meta.brace.square.livescript', regex: '\\[|\\]\\s*' },
  216. { include: '#instance_variable' },
  217. { include: '#backslash_string' },
  218. { include: '#single_quoted_string' },
  219. { include: '#double_quoted_string' },
  220. { include: '#numeric' } ],
  221. '#backslash_string':
  222. [ { token: 'string.quoted.single.livescript',
  223. regex: '\\\\(?:[\\\\)\\s,\\};\\]])?',
  224. push:
  225. [ { token: 'punctuation.definition.string.end.livescript',
  226. regex: '[\\\\)\\s,\\};\\]]',
  227. next: 'pop' },
  228. { defaultToken: 'string.quoted.single.livescript' } ] } ],
  229. '#double_quoted_string':
  230. [ { token: 'punctuation.definition.string.begin.livescript',
  231. regex: '"',
  232. push:
  233. [ { token: 'punctuation.definition.string.end.livescript',
  234. regex: '"',
  235. next: 'pop' },
  236. { token: 'constant.character.escape.livescript',
  237. regex: '\\\\(?:x[\\da-fA-F]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)' },
  238. { include: '#interpolated_livescript' },
  239. { defaultToken: 'string.quoted.double.livescript' } ] } ],
  240. '#embedded_comment':
  241. [ { token:
  242. [ 'punctuation.definition.comment.livescript',
  243. 'comment.line.number-sign.livescript' ],
  244. regex: '(?<!\\\\)(#)(.*$)',
  245. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  246. originalRegex: '(?<!\\\\)(#).*$\\n' } ],
  247. '#embedded_spaced_comment':
  248. [ { token:
  249. [ 'punctuation.definition.comment.livescript',
  250. 'comment.line.number-sign.livescript' ],
  251. regex: '(?<!\\\\)(#\\s)(.*$)',
  252. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  253. originalRegex: '(?<!\\\\)(#\\s).*$\\n' } ],
  254. '#constructor_variable':
  255. [ { token: 'variable.other.readwrite.constructor.livescript',
  256. regex: '[a-zA-Z$_][\\w$-]*@{2}(?:[a-zA-Z$_][\\w$-]*)?' } ],
  257. '#instance_variable':
  258. [ { token: 'variable.other.readwrite.instance.livescript',
  259. regex: '(?<!\\S)@(?:[a-zA-Z$_][\\w$-]*)?',
  260. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  261. originalRegex: '(?<!\\S)(@)([a-zA-Z$_][\\w$-]*)?' } ],
  262. '#interpolated_livescript':
  263. [ { todo:
  264. { token: 'punctuation.section.embedded.livescript',
  265. regex: '\\#\\{',
  266. push:
  267. [ { token: 'punctuation.section.embedded.livescript',
  268. regex: '\\}',
  269. next: 'pop' },
  270. { include: '$self' },
  271. { defaultToken: 'source.livescript.embedded.source' } ] } },
  272. { todo:
  273. { token: 'source.livescript.embedded.source.simple',
  274. regex: '\\#',
  275. push:
  276. [ { token: 'source.livescript.embedded.source.simple',
  277. regex: '',
  278. next: 'pop' },
  279. { include: '$self' },
  280. { defaultToken: 'source.livescript.embedded.source.simple' } ] } } ],
  281. '#numeric':
  282. [ { token: 'constant.numeric.livescript',
  283. regex: '(?<![\\$@a-zA-Z_])(?:[0-9]+r[0-9_]+|(?:16r|0[xX])[0-9a-fA-F_]+|[0-9]+(?:\\.[0-9_]+)?(?:e[+\\-]?[0-9_]+)?[_a-zA-Z]*)',
  284. TODO: 'FIXME: regexp doesn\'t have js equivalent',
  285. originalRegex: '(?<![\\$@a-zA-Z_])(([0-9]+r[0-9_]+)|((16r|0[xX])[0-9a-fA-F_]+)|([0-9]+(\\.[0-9_]+)?(e[+\\-]?[0-9_]+)?)[_a-zA-Z]*)' } ],
  286. '#single_quoted_string':
  287. [ { token: 'punctuation.definition.string.begin.livescript',
  288. regex: '\'',
  289. push:
  290. [ { token: 'punctuation.definition.string.end.livescript',
  291. regex: '\'',
  292. next: 'pop' },
  293. { token: 'constant.character.escape.livescript',
  294. regex: '\\\\(?:x[\\da-fA-F]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' },
  295. { defaultToken: 'string.quoted.single.livescript' } ] } ],
  296. '#variable_name':
  297. [ { token: 'variable.assignment.livescript',
  298. regex: '[a-zA-Z\\$_][\\w$-]*(?:\\.\\w+)*(?!\\-)' } ] }
  299. this.normalizeRules();
  300. };
  301. LiveScriptHighlightRules.metaData = { comment: 'LiveScript Syntax: version 1',
  302. fileTypes: [ 'ls', 'Slakefile', 'ls.erb' ],
  303. firstLineMatch: '^#!.*\\bls',
  304. foldingStartMarker: '^\\s*class\\s+\\S.*$|.*(->|=>)\\s*$|.*[\\[{]\\s*$',
  305. foldingStopMarker: '^\\s*$|^\\s*[}\\]]\\s*$',
  306. keyEquivalent: '^~C',
  307. name: 'LiveScript',
  308. scopeName: 'source.livescript' }
  309. oop.inherits(LiveScriptHighlightRules, TextHighlightRules);
  310. exports.LiveScriptHighlightRules = LiveScriptHighlightRules;
  311. });
  312. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  313. "use strict";
  314. var oop = require("../../lib/oop");
  315. var Range = require("../../range").Range;
  316. var BaseFoldMode = require("./fold_mode").FoldMode;
  317. var FoldMode = exports.FoldMode = function(commentRegex) {
  318. if (commentRegex) {
  319. this.foldingStartMarker = new RegExp(
  320. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  321. );
  322. this.foldingStopMarker = new RegExp(
  323. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  324. );
  325. }
  326. };
  327. oop.inherits(FoldMode, BaseFoldMode);
  328. (function() {
  329. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  330. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  331. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  332. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  333. this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
  334. this._getFoldWidgetBase = this.getFoldWidget;
  335. this.getFoldWidget = function(session, foldStyle, row) {
  336. var line = session.getLine(row);
  337. if (this.singleLineBlockCommentRe.test(line)) {
  338. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  339. return "";
  340. }
  341. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  342. if (!fw && this.startRegionRe.test(line))
  343. return "start"; // lineCommentRegionStart
  344. return fw;
  345. };
  346. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  347. var line = session.getLine(row);
  348. if (this.startRegionRe.test(line))
  349. return this.getCommentRegionBlock(session, line, row);
  350. var match = line.match(this.foldingStartMarker);
  351. if (match) {
  352. var i = match.index;
  353. if (match[1])
  354. return this.openingBracketBlock(session, match[1], row, i);
  355. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  356. if (range && !range.isMultiLine()) {
  357. if (forceMultiline) {
  358. range = this.getSectionRange(session, row);
  359. } else if (foldStyle != "all")
  360. range = null;
  361. }
  362. return range;
  363. }
  364. if (foldStyle === "markbegin")
  365. return;
  366. var match = line.match(this.foldingStopMarker);
  367. if (match) {
  368. var i = match.index + match[0].length;
  369. if (match[1])
  370. return this.closingBracketBlock(session, match[1], row, i);
  371. return session.getCommentFoldRange(row, i, -1);
  372. }
  373. };
  374. this.getSectionRange = function(session, row) {
  375. var line = session.getLine(row);
  376. var startIndent = line.search(/\S/);
  377. var startRow = row;
  378. var startColumn = line.length;
  379. row = row + 1;
  380. var endRow = row;
  381. var maxRow = session.getLength();
  382. while (++row < maxRow) {
  383. line = session.getLine(row);
  384. var indent = line.search(/\S/);
  385. if (indent === -1)
  386. continue;
  387. if (startIndent > indent)
  388. break;
  389. var subRange = this.getFoldWidgetRange(session, "all", row);
  390. if (subRange) {
  391. if (subRange.start.row <= startRow) {
  392. break;
  393. } else if (subRange.isMultiLine()) {
  394. row = subRange.end.row;
  395. } else if (startIndent == indent) {
  396. break;
  397. }
  398. }
  399. endRow = row;
  400. }
  401. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  402. };
  403. this.getCommentRegionBlock = function(session, line, row) {
  404. var startColumn = line.search(/\s*$/);
  405. var maxRow = session.getLength();
  406. var startRow = row;
  407. var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
  408. var depth = 1;
  409. while (++row < maxRow) {
  410. line = session.getLine(row);
  411. var m = re.exec(line);
  412. if (!m) continue;
  413. if (m[1]) depth--;
  414. else depth++;
  415. if (!depth) break;
  416. }
  417. var endRow = row;
  418. if (endRow > startRow) {
  419. return new Range(startRow, startColumn, endRow, line.length);
  420. }
  421. };
  422. }).call(FoldMode.prototype);
  423. });
  424. ace.define("ace/mode/live_script",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/live_script_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
  425. "use strict";
  426. var oop = require("../lib/oop");
  427. var TextMode = require("./text").Mode;
  428. var LiveScriptHighlightRules = require("./live_script_highlight_rules").LiveScriptHighlightRules;
  429. var FoldMode = require("./folding/cstyle").FoldMode;
  430. var Mode = function() {
  431. this.HighlightRules = LiveScriptHighlightRules;
  432. this.foldingRules = new FoldMode();
  433. };
  434. oop.inherits(Mode, TextMode);
  435. (function() {
  436. this.$id = "ace/mode/live_script"
  437. }).call(Mode.prototype);
  438. exports.Mode = Mode;
  439. });