mode-mushcode.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. ace.define("ace/mode/mushcode_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 MushCodeRules = function() {
  6. var keywords = (
  7. "@if|"+
  8. "@ifelse|"+
  9. "@switch|"+
  10. "@halt|"+
  11. "@dolist|"+
  12. "@create|"+
  13. "@scent|"+
  14. "@sound|"+
  15. "@touch|"+
  16. "@ataste|"+
  17. "@osound|"+
  18. "@ahear|"+
  19. "@aahear|"+
  20. "@amhear|"+
  21. "@otouch|"+
  22. "@otaste|"+
  23. "@drop|"+
  24. "@odrop|"+
  25. "@adrop|"+
  26. "@dropfail|"+
  27. "@odropfail|"+
  28. "@smell|"+
  29. "@oemit|"+
  30. "@emit|"+
  31. "@pemit|"+
  32. "@parent|"+
  33. "@clone|"+
  34. "@taste|"+
  35. "whisper|"+
  36. "page|"+
  37. "say|"+
  38. "pose|"+
  39. "semipose|"+
  40. "teach|"+
  41. "touch|"+
  42. "taste|"+
  43. "smell|"+
  44. "listen|"+
  45. "look|"+
  46. "move|"+
  47. "go|"+
  48. "home|"+
  49. "follow|"+
  50. "unfollow|"+
  51. "desert|"+
  52. "dismiss|"+
  53. "@tel"
  54. );
  55. var builtinConstants = (
  56. "=#0"
  57. );
  58. var builtinFunctions = (
  59. "default|"+
  60. "edefault|"+
  61. "eval|"+
  62. "get_eval|"+
  63. "get|"+
  64. "grep|"+
  65. "grepi|"+
  66. "hasattr|"+
  67. "hasattrp|"+
  68. "hasattrval|"+
  69. "hasattrpval|"+
  70. "lattr|"+
  71. "nattr|"+
  72. "poss|"+
  73. "udefault|"+
  74. "ufun|"+
  75. "u|"+
  76. "v|"+
  77. "uldefault|"+
  78. "xget|"+
  79. "zfun|"+
  80. "band|"+
  81. "bnand|"+
  82. "bnot|"+
  83. "bor|"+
  84. "bxor|"+
  85. "shl|"+
  86. "shr|"+
  87. "and|"+
  88. "cand|"+
  89. "cor|"+
  90. "eq|"+
  91. "gt|"+
  92. "gte|"+
  93. "lt|"+
  94. "lte|"+
  95. "nand|"+
  96. "neq|"+
  97. "nor|"+
  98. "not|"+
  99. "or|"+
  100. "t|"+
  101. "xor|"+
  102. "con|"+
  103. "entrances|"+
  104. "exit|"+
  105. "followers|"+
  106. "home|"+
  107. "lcon|"+
  108. "lexits|"+
  109. "loc|"+
  110. "locate|"+
  111. "lparent|"+
  112. "lsearch|"+
  113. "next|"+
  114. "num|"+
  115. "owner|"+
  116. "parent|"+
  117. "pmatch|"+
  118. "rloc|"+
  119. "rnum|"+
  120. "room|"+
  121. "where|"+
  122. "zone|"+
  123. "worn|"+
  124. "held|"+
  125. "carried|"+
  126. "acos|"+
  127. "asin|"+
  128. "atan|"+
  129. "ceil|"+
  130. "cos|"+
  131. "e|"+
  132. "exp|"+
  133. "fdiv|"+
  134. "fmod|"+
  135. "floor|"+
  136. "log|"+
  137. "ln|"+
  138. "pi|"+
  139. "power|"+
  140. "round|"+
  141. "sin|"+
  142. "sqrt|"+
  143. "tan|"+
  144. "aposs|"+
  145. "andflags|"+
  146. "conn|"+
  147. "commandssent|"+
  148. "controls|"+
  149. "doing|"+
  150. "elock|"+
  151. "findable|"+
  152. "flags|"+
  153. "fullname|"+
  154. "hasflag|"+
  155. "haspower|"+
  156. "hastype|"+
  157. "hidden|"+
  158. "idle|"+
  159. "isbaker|"+
  160. "lock|"+
  161. "lstats|"+
  162. "money|"+
  163. "who|"+
  164. "name|"+
  165. "nearby|"+
  166. "obj|"+
  167. "objflags|"+
  168. "photo|"+
  169. "poll|"+
  170. "powers|"+
  171. "pendingtext|"+
  172. "receivedtext|"+
  173. "restarts|"+
  174. "restarttime|"+
  175. "subj|"+
  176. "shortestpath|"+
  177. "tmoney|"+
  178. "type|"+
  179. "visible|"+
  180. "cat|"+
  181. "element|"+
  182. "elements|"+
  183. "extract|"+
  184. "filter|"+
  185. "filterbool|"+
  186. "first|"+
  187. "foreach|"+
  188. "fold|"+
  189. "grab|"+
  190. "graball|"+
  191. "index|"+
  192. "insert|"+
  193. "itemize|"+
  194. "items|"+
  195. "iter|"+
  196. "last|"+
  197. "ldelete|"+
  198. "map|"+
  199. "match|"+
  200. "matchall|"+
  201. "member|"+
  202. "mix|"+
  203. "munge|"+
  204. "pick|"+
  205. "remove|"+
  206. "replace|"+
  207. "rest|"+
  208. "revwords|"+
  209. "setdiff|"+
  210. "setinter|"+
  211. "setunion|"+
  212. "shuffle|"+
  213. "sort|"+
  214. "sortby|"+
  215. "splice|"+
  216. "step|"+
  217. "wordpos|"+
  218. "words|"+
  219. "add|"+
  220. "lmath|"+
  221. "max|"+
  222. "mean|"+
  223. "median|"+
  224. "min|"+
  225. "mul|"+
  226. "percent|"+
  227. "sign|"+
  228. "stddev|"+
  229. "sub|"+
  230. "val|"+
  231. "bound|"+
  232. "abs|"+
  233. "inc|"+
  234. "dec|"+
  235. "dist2d|"+
  236. "dist3d|"+
  237. "div|"+
  238. "floordiv|"+
  239. "mod|"+
  240. "modulo|"+
  241. "remainder|"+
  242. "vadd|"+
  243. "vdim|"+
  244. "vdot|"+
  245. "vmag|"+
  246. "vmax|"+
  247. "vmin|"+
  248. "vmul|"+
  249. "vsub|"+
  250. "vunit|"+
  251. "regedit|"+
  252. "regeditall|"+
  253. "regeditalli|"+
  254. "regediti|"+
  255. "regmatch|"+
  256. "regmatchi|"+
  257. "regrab|"+
  258. "regraball|"+
  259. "regraballi|"+
  260. "regrabi|"+
  261. "regrep|"+
  262. "regrepi|"+
  263. "after|"+
  264. "alphamin|"+
  265. "alphamax|"+
  266. "art|"+
  267. "before|"+
  268. "brackets|"+
  269. "capstr|"+
  270. "case|"+
  271. "caseall|"+
  272. "center|"+
  273. "containsfansi|"+
  274. "comp|"+
  275. "decompose|"+
  276. "decrypt|"+
  277. "delete|"+
  278. "edit|"+
  279. "encrypt|"+
  280. "escape|"+
  281. "if|"+
  282. "ifelse|"+
  283. "lcstr|"+
  284. "left|"+
  285. "lit|"+
  286. "ljust|"+
  287. "merge|"+
  288. "mid|"+
  289. "ostrlen|"+
  290. "pos|"+
  291. "repeat|"+
  292. "reverse|"+
  293. "right|"+
  294. "rjust|"+
  295. "scramble|"+
  296. "secure|"+
  297. "space|"+
  298. "spellnum|"+
  299. "squish|"+
  300. "strcat|"+
  301. "strmatch|"+
  302. "strinsert|"+
  303. "stripansi|"+
  304. "stripfansi|"+
  305. "strlen|"+
  306. "switch|"+
  307. "switchall|"+
  308. "table|"+
  309. "tr|"+
  310. "trim|"+
  311. "ucstr|"+
  312. "unsafe|"+
  313. "wrap|"+
  314. "ctitle|"+
  315. "cwho|"+
  316. "channels|"+
  317. "clock|"+
  318. "cflags|"+
  319. "ilev|"+
  320. "itext|"+
  321. "inum|"+
  322. "convsecs|"+
  323. "convutcsecs|"+
  324. "convtime|"+
  325. "ctime|"+
  326. "etimefmt|"+
  327. "isdaylight|"+
  328. "mtime|"+
  329. "secs|"+
  330. "msecs|"+
  331. "starttime|"+
  332. "time|"+
  333. "timefmt|"+
  334. "timestring|"+
  335. "utctime|"+
  336. "atrlock|"+
  337. "clone|"+
  338. "create|"+
  339. "cook|"+
  340. "dig|"+
  341. "emit|"+
  342. "lemit|"+
  343. "link|"+
  344. "oemit|"+
  345. "open|"+
  346. "pemit|"+
  347. "remit|"+
  348. "set|"+
  349. "tel|"+
  350. "wipe|"+
  351. "zemit|"+
  352. "fbcreate|"+
  353. "fbdestroy|"+
  354. "fbwrite|"+
  355. "fbclear|"+
  356. "fbcopy|"+
  357. "fbcopyto|"+
  358. "fbclip|"+
  359. "fbdump|"+
  360. "fbflush|"+
  361. "fbhset|"+
  362. "fblist|"+
  363. "fbstats|"+
  364. "qentries|"+
  365. "qentry|"+
  366. "play|"+
  367. "ansi|"+
  368. "break|"+
  369. "c|"+
  370. "asc|"+
  371. "die|"+
  372. "isdbref|"+
  373. "isint|"+
  374. "isnum|"+
  375. "isletters|"+
  376. "linecoords|"+
  377. "localize|"+
  378. "lnum|"+
  379. "nameshort|"+
  380. "null|"+
  381. "objeval|"+
  382. "r|"+
  383. "rand|"+
  384. "s|"+
  385. "setq|"+
  386. "setr|"+
  387. "soundex|"+
  388. "soundslike|"+
  389. "valid|"+
  390. "vchart|"+
  391. "vchart2|"+
  392. "vlabel|"+
  393. "@@|"+
  394. "bakerdays|"+
  395. "bodybuild|"+
  396. "box|"+
  397. "capall|"+
  398. "catalog|"+
  399. "children|"+
  400. "ctrailer|"+
  401. "darttime|"+
  402. "debt|"+
  403. "detailbar|"+
  404. "exploredroom|"+
  405. "fansitoansi|"+
  406. "fansitoxansi|"+
  407. "fullbar|"+
  408. "halfbar|"+
  409. "isdarted|"+
  410. "isnewbie|"+
  411. "isword|"+
  412. "lambda|"+
  413. "lobjects|"+
  414. "lplayers|"+
  415. "lthings|"+
  416. "lvexits|"+
  417. "lvobjects|"+
  418. "lvplayers|"+
  419. "lvthings|"+
  420. "newswrap|"+
  421. "numsuffix|"+
  422. "playerson|"+
  423. "playersthisweek|"+
  424. "randomad|"+
  425. "randword|"+
  426. "realrandword|"+
  427. "replacechr|"+
  428. "second|"+
  429. "splitamount|"+
  430. "strlenall|"+
  431. "text|"+
  432. "third|"+
  433. "tofansi|"+
  434. "totalac|"+
  435. "unique|"+
  436. "getaddressroom|"+
  437. "listpropertycomm|"+
  438. "listpropertyres|"+
  439. "lotowner|"+
  440. "lotrating|"+
  441. "lotratingcount|"+
  442. "lotvalue|"+
  443. "boughtproduct|"+
  444. "companyabb|"+
  445. "companyicon|"+
  446. "companylist|"+
  447. "companyname|"+
  448. "companyowners|"+
  449. "companyvalue|"+
  450. "employees|"+
  451. "invested|"+
  452. "productlist|"+
  453. "productname|"+
  454. "productowners|"+
  455. "productrating|"+
  456. "productratingcount|"+
  457. "productsoldat|"+
  458. "producttype|"+
  459. "ratedproduct|"+
  460. "soldproduct|"+
  461. "topproducts|"+
  462. "totalspentonproduct|"+
  463. "totalstock|"+
  464. "transfermoney|"+
  465. "uniquebuyercount|"+
  466. "uniqueproductsbought|"+
  467. "validcompany|"+
  468. "deletepicture|"+
  469. "fbsave|"+
  470. "getpicturesecurity|"+
  471. "haspicture|"+
  472. "listpictures|"+
  473. "picturesize|"+
  474. "replacecolor|"+
  475. "rgbtocolor|"+
  476. "savepicture|"+
  477. "setpicturesecurity|"+
  478. "showpicture|"+
  479. "piechart|"+
  480. "piechartlabel|"+
  481. "createmaze|"+
  482. "drawmaze|"+
  483. "drawwireframe"
  484. );
  485. var keywordMapper = this.createKeywordMapper({
  486. "invalid.deprecated": "debugger",
  487. "support.function": builtinFunctions,
  488. "constant.language": builtinConstants,
  489. "keyword": keywords
  490. }, "identifier");
  491. var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?";
  492. var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
  493. var octInteger = "(?:0[oO]?[0-7]+)";
  494. var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
  495. var binInteger = "(?:0[bB][01]+)";
  496. var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")";
  497. var exponent = "(?:[eE][+-]?\\d+)";
  498. var fraction = "(?:\\.\\d+)";
  499. var intPart = "(?:\\d+)";
  500. var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
  501. var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")";
  502. var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
  503. this.$rules = {
  504. "start" : [
  505. {
  506. token : "variable", // mush substitution register
  507. regex : "%[0-9]{1}"
  508. },
  509. {
  510. token : "variable", // mush substitution register
  511. regex : "%q[0-9A-Za-z]{1}"
  512. },
  513. {
  514. token : "variable", // mush special character register
  515. regex : "%[a-zA-Z]{1}"
  516. },
  517. {
  518. token: "variable.language",
  519. regex: "%[a-z0-9-_]+"
  520. },
  521. {
  522. token : "constant.numeric", // imaginary
  523. regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b"
  524. }, {
  525. token : "constant.numeric", // float
  526. regex : floatNumber
  527. }, {
  528. token : "constant.numeric", // long integer
  529. regex : integer + "[lL]\\b"
  530. }, {
  531. token : "constant.numeric", // integer
  532. regex : integer + "\\b"
  533. }, {
  534. token : keywordMapper,
  535. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  536. }, {
  537. token : "keyword.operator",
  538. regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|#|%|<<|>>|\\||\\^|~|<|>|<=|=>|==|!=|<>|="
  539. }, {
  540. token : "paren.lparen",
  541. regex : "[\\[\\(\\{]"
  542. }, {
  543. token : "paren.rparen",
  544. regex : "[\\]\\)\\}]"
  545. }, {
  546. token : "text",
  547. regex : "\\s+"
  548. } ]
  549. };
  550. };
  551. oop.inherits(MushCodeRules, TextHighlightRules);
  552. exports.MushCodeRules = MushCodeRules;
  553. });
  554. ace.define("ace/mode/folding/pythonic",[], function(require, exports, module) {
  555. "use strict";
  556. var oop = require("../../lib/oop");
  557. var BaseFoldMode = require("./fold_mode").FoldMode;
  558. var FoldMode = exports.FoldMode = function(markers) {
  559. this.foldingStartMarker = new RegExp("([\\[{])(?:\\s*)$|(" + markers + ")(?:\\s*)(?:#.*)?$");
  560. };
  561. oop.inherits(FoldMode, BaseFoldMode);
  562. (function() {
  563. this.getFoldWidgetRange = function(session, foldStyle, row) {
  564. var line = session.getLine(row);
  565. var match = line.match(this.foldingStartMarker);
  566. if (match) {
  567. if (match[1])
  568. return this.openingBracketBlock(session, match[1], row, match.index);
  569. if (match[2])
  570. return this.indentationBlock(session, row, match.index + match[2].length);
  571. return this.indentationBlock(session, row);
  572. }
  573. };
  574. }).call(FoldMode.prototype);
  575. });
  576. ace.define("ace/mode/mushcode",[], function(require, exports, module) {
  577. "use strict";
  578. var oop = require("../lib/oop");
  579. var TextMode = require("./text").Mode;
  580. var MushCodeRules = require("./mushcode_highlight_rules").MushCodeRules;
  581. var PythonFoldMode = require("./folding/pythonic").FoldMode;
  582. var Range = require("../range").Range;
  583. var Mode = function() {
  584. this.HighlightRules = MushCodeRules;
  585. this.foldingRules = new PythonFoldMode("\\:");
  586. this.$behaviour = this.$defaultBehaviour;
  587. };
  588. oop.inherits(Mode, TextMode);
  589. (function() {
  590. this.getNextLineIndent = function(state, line, tab) {
  591. var indent = this.$getIndent(line);
  592. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  593. var tokens = tokenizedLine.tokens;
  594. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  595. return indent;
  596. }
  597. if (state == "start") {
  598. var match = line.match(/^.*[\{\(\[:]\s*$/);
  599. if (match) {
  600. indent += tab;
  601. }
  602. }
  603. return indent;
  604. };
  605. var outdents = {
  606. "pass": 1,
  607. "return": 1,
  608. "raise": 1,
  609. "break": 1,
  610. "continue": 1
  611. };
  612. this.checkOutdent = function(state, line, input) {
  613. if (input !== "\r\n" && input !== "\r" && input !== "\n")
  614. return false;
  615. var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens;
  616. if (!tokens)
  617. return false;
  618. do {
  619. var last = tokens.pop();
  620. } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/))));
  621. if (!last)
  622. return false;
  623. return (last.type == "keyword" && outdents[last.value]);
  624. };
  625. this.autoOutdent = function(state, doc, row) {
  626. row += 1;
  627. var indent = this.$getIndent(doc.getLine(row));
  628. var tab = doc.getTabString();
  629. if (indent.slice(-tab.length) == tab)
  630. doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
  631. };
  632. this.$id = "ace/mode/mushcode";
  633. }).call(Mode.prototype);
  634. exports.Mode = Mode;
  635. });
  636. (function() {
  637. ace.require(["ace/mode/mushcode"], function(m) {
  638. if (typeof module == "object" && typeof exports == "object" && module) {
  639. module.exports = m;
  640. }
  641. });
  642. })();