mode-scrypt.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. define("ace/mode/doc_comment_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 DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. };
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. define("ace/mode/scrypt_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function (require, exports, module) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  46. var scryptHighlightRules = function () {
  47. var keywords = (
  48. "contract|library|loop|new|private|" +
  49. "public|if|else|struct|type|" +
  50. "require|static|const|import|exit|return|asm"
  51. );
  52. var buildinConstants = ("true|false");
  53. var langClasses = (
  54. "function|auto|constructor|bytes|int|bool|SigHashPreimage|PrivKey|PubKey|Sig|Ripemd160|Sha1|Sha256|" +
  55. "SigHashType|SigHashPreimage|OpCodeType"
  56. );
  57. var keywordMapper = this.createKeywordMapper({
  58. "variable.language": "this",
  59. "keyword": keywords,
  60. "constant.language": buildinConstants,
  61. "support.function": langClasses
  62. }, "identifier");
  63. this.$rules = {
  64. "start": [
  65. {
  66. token: "comment",
  67. regex: "\\/\\/.*$"
  68. },
  69. DocCommentHighlightRules.getStartRule("doc-start"),
  70. {
  71. token: "comment", // multi line comment
  72. regex: "\\/\\*",
  73. next: "comment"
  74. }, {
  75. token: "string", // single line
  76. regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  77. }, {
  78. token: "string", // single line
  79. regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  80. }, {
  81. token: "constant.numeric", // hex
  82. regex: /0(?:[xX][0-9a-fA-F][0-9a-fA-F_]*|[bB][01][01_]*)[LlSsDdFfYy]?\b/
  83. }, {
  84. token: "constant.numeric", // float
  85. regex: /[+-]?\d[\d_]*(?:(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?)?[LlSsDdFfYy]?\b/
  86. }, {
  87. token: "constant.language.boolean",
  88. regex: "(?:true|false)\\b"
  89. },
  90. {
  91. token: ["support.function.math.scrypt", "text", "text"],
  92. regex: /\b(abs|min|max|within|ripemd160|sha1|sha256|hash160|hash256|checkSig|checkMultiSig|num2bin|pack|unpack|len|reverseBytes|repeat)(\s*)(\()/
  93. }, {
  94. token: [
  95. "entity.name.type.scrypt",
  96. "text",
  97. "text",
  98. "text",
  99. "variable.object.property.scrypt"
  100. ],
  101. regex: /\b(SigHash)(\s*)(\.)(\s*)(ANYONECANPAY|ALL|FORKID|NONE|SINGLE)\b/
  102. },
  103. {
  104. token: [
  105. "entity.name.type.scrypt",
  106. "text",
  107. "text",
  108. "text",
  109. "variable.object.property.scrypt"
  110. ],
  111. regex: /\b(OpCode)(\s*)(\.)(\s*)(OP_PUSHDATA1|OP_PUSHDATA2|OP_PUSHDATA4|OP_0|OP_FALSE|OP_1NEGATE|OP_1|OP_TRUE|OP_2|OP_3|OP_4|OP_5|OP_6|OP_7|OP_8|OP_9|OP_10|OP_11|OP_12|OP_13|OP_14|OP_15|OP_16|OP_1ADD|OP_1SUB|OP_NEGATE|OP_ABS|OP_NOT|OP_0NOTEQUAL|OP_ADD|OP_SUB|OP_MUL|OP_DIV|OP_MOD|OP_LSHIFT|OP_RSHIFT|OP_BOOLAND|OP_BOOLOR|OP_NUMEQUAL|OP_NUMEQUALVERIFY|OP_NUMNOTEQUAL|OP_LESSTHAN|OP_GREATERTHAN|OP_LESSTHANOREQUAL|OP_GREATERTHANOREQUAL|OP_MIN|OP_MAX|OP_WITHIN|OP_CAT|OP_SPLIT|OP_BIN2NUM|OP_NUM2BIN|OP_SIZE|OP_NOP|OP_IF|OP_NOTIF|OP_ELSE|OP_ENDIF|OP_VERIFY|OP_RETURN|OP_TOALTSTACK|OP_FROMALTSTACK|OP_IFDUP|OP_DEPTH|OP_DROP|OP_DUP|OP_NIP|OP_OVER|OP_PICK|OP_ROLL|OP_ROT|OP_SWAP|OP_TUCK|OP_2DROP|OP_2DUP|OP_3DUP|OP_2OVER|OP_2ROT|OP_2SWAP|OP_RIPEMD160|OP_SHA1|OP_SHA256|OP_HASH160|OP_HASH256|OP_CODESEPARATOR|OP_CHECKSIG|OP_CHECKSIGVERIFY|OP_CHECKMULTISIG|OP_CHECKMULTISIGVERIFY|OP_INVERT|OP_AND|OP_OR|OP_XOR|OP_EQUAL|OP_EQUALVERIFY)\b/
  112. }, {
  113. token: "entity.name.type.scrypt",
  114. regex: /\b(?:P2PKH|P2PK|Tx|HashPuzzleRipemd160|HashPuzzleSha1|HashPuzzleSha256|HashPuzzleHash160|OpCode|SigHash)\b/
  115. }, {
  116. token: [
  117. "punctuation.separator.period.scrypt",
  118. 'text',
  119. "entity.name.function.scrypt",
  120. "text",
  121. "punctuation.definition.parameters.begin.bracket.round.scrypt"
  122. ],
  123. regex: /(\.)([^\S$\r]*)([\w][\w\d]*)(\s*)(\()/,
  124. push: [{
  125. token: "punctuation.definition.parameters.end.bracket.round.scrypt",
  126. regex: /\)/,
  127. next: "pop"
  128. }, {
  129. defaultToken: "start"
  130. }]
  131. }, {
  132. token: keywordMapper,
  133. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  134. }, {
  135. token: "keyword.operator",
  136. regex: "!|\\$|%|&|\\||\\^|\\*|\\/|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\*=|\\/=|%=|\\+=|\\-=|&=|\\|=|\\^="
  137. }, {
  138. token: "lparen",
  139. regex: "[[({]"
  140. }, {
  141. token: "rparen",
  142. regex: "[\\])}]"
  143. }, {
  144. token: "text",
  145. regex: "\\s+"
  146. }
  147. ],
  148. "comment": [
  149. {
  150. token: "comment", // closing comment
  151. regex: "\\*\\/",
  152. next: "start"
  153. }, {
  154. defaultToken: "comment"
  155. }
  156. ]
  157. };
  158. this.embedRules(DocCommentHighlightRules, "doc-",
  159. [DocCommentHighlightRules.getEndRule("start")]);
  160. this.normalizeRules();
  161. };
  162. oop.inherits(scryptHighlightRules, TextHighlightRules);
  163. exports.scryptHighlightRules = scryptHighlightRules;
  164. });
  165. define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  166. "use strict";
  167. var oop = require("../../lib/oop");
  168. var Range = require("../../range").Range;
  169. var BaseFoldMode = require("./fold_mode").FoldMode;
  170. var FoldMode = exports.FoldMode = function(commentRegex) {
  171. if (commentRegex) {
  172. this.foldingStartMarker = new RegExp(
  173. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  174. );
  175. this.foldingStopMarker = new RegExp(
  176. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  177. );
  178. }
  179. };
  180. oop.inherits(FoldMode, BaseFoldMode);
  181. (function() {
  182. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  183. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  184. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  185. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  186. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  187. this._getFoldWidgetBase = this.getFoldWidget;
  188. this.getFoldWidget = function(session, foldStyle, row) {
  189. var line = session.getLine(row);
  190. if (this.singleLineBlockCommentRe.test(line)) {
  191. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  192. return "";
  193. }
  194. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  195. if (!fw && this.startRegionRe.test(line))
  196. return "start"; // lineCommentRegionStart
  197. return fw;
  198. };
  199. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  200. var line = session.getLine(row);
  201. if (this.startRegionRe.test(line))
  202. return this.getCommentRegionBlock(session, line, row);
  203. var match = line.match(this.foldingStartMarker);
  204. if (match) {
  205. var i = match.index;
  206. if (match[1])
  207. return this.openingBracketBlock(session, match[1], row, i);
  208. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  209. if (range && !range.isMultiLine()) {
  210. if (forceMultiline) {
  211. range = this.getSectionRange(session, row);
  212. } else if (foldStyle != "all")
  213. range = null;
  214. }
  215. return range;
  216. }
  217. if (foldStyle === "markbegin")
  218. return;
  219. var match = line.match(this.foldingStopMarker);
  220. if (match) {
  221. var i = match.index + match[0].length;
  222. if (match[1])
  223. return this.closingBracketBlock(session, match[1], row, i);
  224. return session.getCommentFoldRange(row, i, -1);
  225. }
  226. };
  227. this.getSectionRange = function(session, row) {
  228. var line = session.getLine(row);
  229. var startIndent = line.search(/\S/);
  230. var startRow = row;
  231. var startColumn = line.length;
  232. row = row + 1;
  233. var endRow = row;
  234. var maxRow = session.getLength();
  235. while (++row < maxRow) {
  236. line = session.getLine(row);
  237. var indent = line.search(/\S/);
  238. if (indent === -1)
  239. continue;
  240. if (startIndent > indent)
  241. break;
  242. var subRange = this.getFoldWidgetRange(session, "all", row);
  243. if (subRange) {
  244. if (subRange.start.row <= startRow) {
  245. break;
  246. } else if (subRange.isMultiLine()) {
  247. row = subRange.end.row;
  248. } else if (startIndent == indent) {
  249. break;
  250. }
  251. }
  252. endRow = row;
  253. }
  254. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  255. };
  256. this.getCommentRegionBlock = function(session, line, row) {
  257. var startColumn = line.search(/\s*$/);
  258. var maxRow = session.getLength();
  259. var startRow = row;
  260. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  261. var depth = 1;
  262. while (++row < maxRow) {
  263. line = session.getLine(row);
  264. var m = re.exec(line);
  265. if (!m) continue;
  266. if (m[1]) depth--;
  267. else depth++;
  268. if (!depth) break;
  269. }
  270. var endRow = row;
  271. if (endRow > startRow) {
  272. return new Range(startRow, startColumn, endRow, line.length);
  273. }
  274. };
  275. }).call(FoldMode.prototype);
  276. });
  277. define("ace/mode/scrypt",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/scrypt_highlight_rules","ace/mode/folding/cstyle"], function (require, exports, module) {
  278. "use strict";
  279. var oop = require("../lib/oop");
  280. var TextMode = require("./text").Mode;
  281. var scryptHighlightRules = require("./scrypt_highlight_rules").scryptHighlightRules;
  282. var FoldMode = require("./folding/cstyle").FoldMode;
  283. var Mode = function () {
  284. this.HighlightRules = scryptHighlightRules;
  285. this.foldingRules = new FoldMode();
  286. };
  287. oop.inherits(Mode, TextMode);
  288. (function () {
  289. this.lineCommentStart = "//";
  290. this.blockComment = { start: "/*", end: "*/" };
  291. this.$quotes = { '"': '"', "'": "'" };
  292. this.createWorker = function (session) {
  293. return null;
  294. };
  295. this.$id = "ace/mode/scrypt";
  296. }).call(Mode.prototype);
  297. exports.Mode = Mode;
  298. }); (function() {
  299. window.require(["ace/mode/scrypt"], function(m) {
  300. if (typeof module == "object" && typeof exports == "object" && module) {
  301. module.exports = m;
  302. }
  303. });
  304. })();