18b9a42de70da52144b223be58bb65c3.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. ace.define("ace/mode/zeek_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var ZeekHighlightRules = function () {
  5. this.$rules = {
  6. "start": [
  7. {
  8. token: "comment.line",
  9. regex: "#.*$"
  10. },
  11. {
  12. token: "string.double",
  13. regex: /"/,
  14. next: "string-state"
  15. },
  16. {
  17. token: "string.regexp",
  18. regex: "(/)(?=.*/)",
  19. next: "pattern-state"
  20. },
  21. {
  22. token: ["keyword.other", "meta.preprocessor"],
  23. regex: /(@(?:load-plugin|load-sigs|load|unload))(.*$)/
  24. },
  25. {
  26. token: "keyword.other",
  27. regex: /@(?:DEBUG|DIR|FILENAME|deprecated|if|ifdef|ifndef|else|endif)/
  28. },
  29. {
  30. token: [
  31. "keyword.other",
  32. "meta.preprocessor",
  33. "keyword.operator",
  34. "meta.preprocessor"
  35. ],
  36. regex: /(@prefixes)(\s*)(\+?=)(.*$)/
  37. },
  38. {
  39. token: "storage.modifier.attribute",
  40. regex: /\&\b(?:redef|priority|log|optional|default|add_func|delete_func|expire_func|read_expire|write_expire|create_expire|synchronized|persistent|rotate_interval|rotate_size|encrypt|raw_output|mergeable|error_handler|type_column|deprecated)\b/
  41. },
  42. {
  43. token: "constant.language",
  44. regex: /\b(?:T|F)\b/
  45. },
  46. {
  47. token: "constant.numeric.port",
  48. regex: /\b\d{1,5}\/(?:udp|tcp|icmp|unknown)\b/
  49. },
  50. {
  51. token: "constant.numeric.addr",
  52. regex: /\b(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\b/,
  53. comment: "IPv4 address"
  54. },
  55. {
  56. token: "constant.numeric.addr",
  57. regex: /\[(?:[0-9a-fA-F]{0,4}:){2,7}(?:[0-9a-fA-F]{0,4})?(?:(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2}))?\]/,
  58. comment: "IPv6 address"
  59. },
  60. {
  61. token: "constant.numeric.float.decimal.interval",
  62. regex: /(?:(?:\d*\.\d*(?:[eE][+-]?\d+)?|\d*[eE][+-]?\d+|\d*\.\d*)|\d+)\s*(?:day|hr|min|msec|usec|sec)s?/
  63. },
  64. {
  65. token: "constant.numeric.float.decimal",
  66. regex: /\d*\.\d*(?:[eE][+-]?\d+)?|\d*[eE][+-]?\d+|\d*\.\d*/
  67. },
  68. {
  69. token: "constant.numeric.hostname",
  70. regex: /\b[A-Za-z0-9][A-Za-z0-9\-]*(?:\.[A-Za-z0-9][A-Za-z0-9\-]*)+\b/
  71. },
  72. {
  73. token: "constant.numeric.integer.hexadecimal",
  74. regex: /\b0x[0-9a-fA-F]+\b/
  75. },
  76. {
  77. token: "constant.numeric.integer.decimal",
  78. regex: /\b\d+\b/
  79. },
  80. {
  81. token: "keyword.operator",
  82. regex: /==|!=|<=|<|>=|>/
  83. },
  84. {
  85. token: "keyword.operator",
  86. regex: /(&&)|(\|\|)|(!)/
  87. },
  88. {
  89. token: "keyword.operator",
  90. regex: /=|\+=|-=/
  91. },
  92. {
  93. token: "keyword.operator",
  94. regex: /\+\+|\+|--|-|\*|\/|%/
  95. },
  96. {
  97. token: "keyword.operator",
  98. regex: /&|\||\^|~/
  99. },
  100. {
  101. token: "keyword.operator",
  102. regex: /\b(?:in|as|is)\b/
  103. },
  104. {
  105. token: "punctuation.terminator",
  106. regex: /;/
  107. },
  108. {
  109. token: "punctuation.accessor",
  110. regex: /\??\$/
  111. },
  112. {
  113. token: "punctuation.accessor",
  114. regex: /::/
  115. },
  116. {
  117. token: "keyword.operator",
  118. regex: /\?/
  119. },
  120. {
  121. token: "punctuation.separator",
  122. regex: /:/
  123. },
  124. {
  125. token: "punctuation.separator",
  126. regex: /,/
  127. },
  128. {
  129. token: [
  130. "keyword.other",
  131. "meta.namespace",
  132. "entity.name.namespace"
  133. ],
  134. regex: /(module)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)/
  135. },
  136. {
  137. token: "keyword.other",
  138. regex: /\bexport\b/
  139. },
  140. {
  141. token: "keyword.control.conditional",
  142. regex: /\b(?:if|else)\b/
  143. },
  144. {
  145. token: "keyword.control",
  146. regex: /\b(?:for|while)\b/
  147. },
  148. {
  149. token: "keyword.control",
  150. regex: /\b(?:return|break|next|continue|fallthrough)\b/
  151. },
  152. {
  153. token: "keyword.control",
  154. regex: /\b(?:switch|default|case)\b/
  155. },
  156. {
  157. token: "keyword.other",
  158. regex: /\b(?:add|delete)\b/
  159. },
  160. {
  161. token: "keyword.other",
  162. regex: /\bprint\b/
  163. },
  164. {
  165. token: "keyword.control",
  166. regex: /\b(?:when|timeout|schedule)\b/
  167. },
  168. {
  169. token: [
  170. "keyword.other",
  171. "meta.struct.record",
  172. "entity.name.struct.record",
  173. "meta.struct.record",
  174. "punctuation.separator",
  175. "meta.struct.record",
  176. "storage.type.struct.record"
  177. ],
  178. regex: /\b(type)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(\s*)(:)(\s*\b)(record)\b/
  179. },
  180. {
  181. token: [
  182. "keyword.other",
  183. "meta.enum",
  184. "entity.name.enum",
  185. "meta.enum",
  186. "punctuation.separator",
  187. "meta.enum",
  188. "storage.type.enum"
  189. ],
  190. regex: /\b(type)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(\s*)(:)(\s*\b)(enum)\b/
  191. },
  192. {
  193. token: [
  194. "keyword.other",
  195. "meta.type",
  196. "entity.name.type",
  197. "meta.type",
  198. "punctuation.separator"
  199. ],
  200. regex: /\b(type)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(\s*)(:)/
  201. },
  202. {
  203. token: [
  204. "keyword.other",
  205. "meta.struct.record",
  206. "storage.type.struct.record",
  207. "meta.struct.record",
  208. "entity.name.struct.record"
  209. ],
  210. regex: /\b(redef)(\s+)(record)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\b/
  211. },
  212. {
  213. token: [
  214. "keyword.other",
  215. "meta.enum",
  216. "storage.type.enum",
  217. "meta.enum",
  218. "entity.name.enum"
  219. ],
  220. regex: /\b(redef)(\s+)(enum)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\b/
  221. },
  222. {
  223. token: [
  224. "storage.type",
  225. "text",
  226. "entity.name.function.event"
  227. ],
  228. regex: /\b(event)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(?=s*\()/
  229. },
  230. {
  231. token: [
  232. "storage.type",
  233. "text",
  234. "entity.name.function.hook"
  235. ],
  236. regex: /\b(hook)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(?=s*\()/
  237. },
  238. {
  239. token: [
  240. "storage.type",
  241. "text",
  242. "entity.name.function"
  243. ],
  244. regex: /\b(function)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(?=s*\()/
  245. },
  246. {
  247. token: "keyword.other",
  248. regex: /\bredef\b/
  249. },
  250. {
  251. token: "storage.type",
  252. regex: /\bany\b/
  253. },
  254. {
  255. token: "storage.type",
  256. regex: /\b(?:enum|record|set|table|vector)\b/
  257. },
  258. {
  259. token: [
  260. "storage.type",
  261. "text",
  262. "keyword.operator",
  263. "text",
  264. "storage.type"
  265. ],
  266. regex: /\b(opaque)(\s+)(of)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\b/
  267. },
  268. {
  269. token: "keyword.operator",
  270. regex: /\bof\b/
  271. },
  272. {
  273. token: "storage.type",
  274. regex: /\b(?:addr|bool|count|double|file|int|interval|pattern|port|string|subnet|time)\b/
  275. },
  276. {
  277. token: "storage.type",
  278. regex: /\b(?:function|hook|event)\b/
  279. },
  280. {
  281. token: "storage.modifier",
  282. regex: /\b(?:global|local|const|option)\b/
  283. },
  284. {
  285. token: "entity.name.function.call",
  286. regex: /\b[A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*(?=s*\()/
  287. },
  288. {
  289. token: "punctuation.section.block.begin",
  290. regex: /\{/
  291. },
  292. {
  293. token: "punctuation.section.block.end",
  294. regex: /\}/
  295. },
  296. {
  297. token: "punctuation.section.brackets.begin",
  298. regex: /\[/
  299. },
  300. {
  301. token: "punctuation.section.brackets.end",
  302. regex: /\]/
  303. },
  304. {
  305. token: "punctuation.section.parens.begin",
  306. regex: /\(/
  307. },
  308. {
  309. token: "punctuation.section.parens.end",
  310. regex: /\)/
  311. }
  312. ],
  313. "string-state": [
  314. {
  315. token: "constant.character.escape",
  316. regex: /\\./
  317. },
  318. {
  319. token: "string.double",
  320. regex: /"/,
  321. next: "start"
  322. },
  323. {
  324. token: "constant.other.placeholder",
  325. regex: /%-?[0-9]*(\.[0-9]+)?[DTdxsefg]/
  326. },
  327. {
  328. token: "string.double",
  329. regex: "."
  330. }
  331. ],
  332. "pattern-state": [
  333. {
  334. token: "constant.character.escape",
  335. regex: /\\./
  336. },
  337. {
  338. token: "string.regexp",
  339. regex: "/",
  340. next: "start"
  341. },
  342. {
  343. token: "string.regexp",
  344. regex: "."
  345. }
  346. ] // state: pattern-state
  347. };
  348. this.normalizeRules();
  349. };
  350. ZeekHighlightRules.metaData = {
  351. fileTypes: ["bro", "zeek"],
  352. name: "Zeek",
  353. scopeName: "source.zeek"
  354. };
  355. oop.inherits(ZeekHighlightRules, TextHighlightRules);
  356. exports.ZeekHighlightRules = ZeekHighlightRules;
  357. });
  358. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  359. var oop = require("../../lib/oop");
  360. var Range = require("../../range").Range;
  361. var BaseFoldMode = require("./fold_mode").FoldMode;
  362. var FoldMode = exports.FoldMode = function (commentRegex) {
  363. if (commentRegex) {
  364. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  365. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  366. }
  367. };
  368. oop.inherits(FoldMode, BaseFoldMode);
  369. (function () {
  370. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  371. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  372. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  373. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  374. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  375. this._getFoldWidgetBase = this.getFoldWidget;
  376. this.getFoldWidget = function (session, foldStyle, row) {
  377. var line = session.getLine(row);
  378. if (this.singleLineBlockCommentRe.test(line)) {
  379. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  380. return "";
  381. }
  382. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  383. if (!fw && this.startRegionRe.test(line))
  384. return "start"; // lineCommentRegionStart
  385. return fw;
  386. };
  387. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  388. var line = session.getLine(row);
  389. if (this.startRegionRe.test(line))
  390. return this.getCommentRegionBlock(session, line, row);
  391. var match = line.match(this.foldingStartMarker);
  392. if (match) {
  393. var i = match.index;
  394. if (match[1])
  395. return this.openingBracketBlock(session, match[1], row, i);
  396. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  397. if (range && !range.isMultiLine()) {
  398. if (forceMultiline) {
  399. range = this.getSectionRange(session, row);
  400. }
  401. else if (foldStyle != "all")
  402. range = null;
  403. }
  404. return range;
  405. }
  406. if (foldStyle === "markbegin")
  407. return;
  408. var match = line.match(this.foldingStopMarker);
  409. if (match) {
  410. var i = match.index + match[0].length;
  411. if (match[1])
  412. return this.closingBracketBlock(session, match[1], row, i);
  413. return session.getCommentFoldRange(row, i, -1);
  414. }
  415. };
  416. this.getSectionRange = function (session, row) {
  417. var line = session.getLine(row);
  418. var startIndent = line.search(/\S/);
  419. var startRow = row;
  420. var startColumn = line.length;
  421. row = row + 1;
  422. var endRow = row;
  423. var maxRow = session.getLength();
  424. while (++row < maxRow) {
  425. line = session.getLine(row);
  426. var indent = line.search(/\S/);
  427. if (indent === -1)
  428. continue;
  429. if (startIndent > indent)
  430. break;
  431. var subRange = this.getFoldWidgetRange(session, "all", row);
  432. if (subRange) {
  433. if (subRange.start.row <= startRow) {
  434. break;
  435. }
  436. else if (subRange.isMultiLine()) {
  437. row = subRange.end.row;
  438. }
  439. else if (startIndent == indent) {
  440. break;
  441. }
  442. }
  443. endRow = row;
  444. }
  445. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  446. };
  447. this.getCommentRegionBlock = function (session, line, row) {
  448. var startColumn = line.search(/\s*$/);
  449. var maxRow = session.getLength();
  450. var startRow = row;
  451. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  452. var depth = 1;
  453. while (++row < maxRow) {
  454. line = session.getLine(row);
  455. var m = re.exec(line);
  456. if (!m)
  457. continue;
  458. if (m[1])
  459. depth--;
  460. else
  461. depth++;
  462. if (!depth)
  463. break;
  464. }
  465. var endRow = row;
  466. if (endRow > startRow) {
  467. return new Range(startRow, startColumn, endRow, line.length);
  468. }
  469. };
  470. }).call(FoldMode.prototype);
  471. });
  472. ace.define("ace/mode/zeek",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/zeek_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
  473. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  474. */
  475. "use strict";
  476. var oop = require("../lib/oop");
  477. var TextMode = require("./text").Mode;
  478. var ZeekHighlightRules = require("./zeek_highlight_rules").ZeekHighlightRules;
  479. var FoldMode = require("./folding/cstyle").FoldMode;
  480. var Mode = function () {
  481. this.HighlightRules = ZeekHighlightRules;
  482. this.foldingRules = new FoldMode();
  483. };
  484. oop.inherits(Mode, TextMode);
  485. (function () {
  486. this.lineCommentStart = "#";
  487. this.$id = "ace/mode/zeek";
  488. }).call(Mode.prototype);
  489. exports.Mode = Mode;
  490. }); (function() {
  491. ace.require(["ace/mode/zeek"], function(m) {
  492. if (typeof module == "object" && typeof exports == "object" && module) {
  493. module.exports = m;
  494. }
  495. });
  496. })();