PageRenderTime 209ms CodeModel.GetById 112ms RepoModel.GetById 1ms app.codeStats 1ms

/admin/assets/js/ace/worker-css.js

https://gitlab.com/nakome/admin-panel-morfy
JavaScript | 8682 lines | 8159 code | 515 blank | 8 comment | 599 complexity | a2bc13beff0a1ae8bdc1100b44522414 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. "no use strict";
  2. ;(function(window) {
  3. if (typeof window.window != "undefined" && window.document) {
  4. return;
  5. }
  6. window.console = function() {
  7. var msgs = Array.prototype.slice.call(arguments, 0);
  8. postMessage({type: "log", data: msgs});
  9. };
  10. window.console.error =
  11. window.console.warn =
  12. window.console.log =
  13. window.console.trace = window.console;
  14. window.window = window;
  15. window.ace = window;
  16. window.onerror = function(message, file, line, col, err) {
  17. postMessage({type: "error", data: {
  18. message: message,
  19. file: file,
  20. line: line,
  21. col: col,
  22. stack: err.stack
  23. }});
  24. };
  25. window.normalizeModule = function(parentId, moduleName) {
  26. // normalize plugin requires
  27. if (moduleName.indexOf("!") !== -1) {
  28. var chunks = moduleName.split("!");
  29. return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
  30. }
  31. // normalize relative requires
  32. if (moduleName.charAt(0) == ".") {
  33. var base = parentId.split("/").slice(0, -1).join("/");
  34. moduleName = (base ? base + "/" : "") + moduleName;
  35. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  36. var previous = moduleName;
  37. moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  38. }
  39. }
  40. return moduleName;
  41. };
  42. window.require = function(parentId, id) {
  43. if (!id) {
  44. id = parentId;
  45. parentId = null;
  46. }
  47. if (!id.charAt)
  48. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  49. id = window.normalizeModule(parentId, id);
  50. var module = window.require.modules[id];
  51. if (module) {
  52. if (!module.initialized) {
  53. module.initialized = true;
  54. module.exports = module.factory().exports;
  55. }
  56. return module.exports;
  57. }
  58. var chunks = id.split("/");
  59. if (!window.require.tlns)
  60. return console.log("unable to load " + id);
  61. chunks[0] = window.require.tlns[chunks[0]] || chunks[0];
  62. var path = chunks.join("/") + ".js";
  63. window.require.id = id;
  64. importScripts(path);
  65. return window.require(parentId, id);
  66. };
  67. window.require.modules = {};
  68. window.require.tlns = {};
  69. window.define = function(id, deps, factory) {
  70. if (arguments.length == 2) {
  71. factory = deps;
  72. if (typeof id != "string") {
  73. deps = id;
  74. id = window.require.id;
  75. }
  76. } else if (arguments.length == 1) {
  77. factory = id;
  78. deps = [];
  79. id = window.require.id;
  80. }
  81. if (typeof factory != "function") {
  82. window.require.modules[id] = {
  83. exports: factory,
  84. initialized: true
  85. };
  86. return;
  87. }
  88. if (!deps.length)
  89. // If there is no dependencies, we inject 'require', 'exports' and
  90. // 'module' as dependencies, to provide CommonJS compatibility.
  91. deps = ['require', 'exports', 'module'];
  92. var req = function(childId) {
  93. return window.require(id, childId);
  94. };
  95. window.require.modules[id] = {
  96. exports: {},
  97. factory: function() {
  98. var module = this;
  99. var returnExports = factory.apply(this, deps.map(function(dep) {
  100. switch(dep) {
  101. // Because 'require', 'exports' and 'module' aren't actual
  102. // dependencies, we must handle them seperately.
  103. case 'require': return req;
  104. case 'exports': return module.exports;
  105. case 'module': return module;
  106. // But for all other dependencies, we can just go ahead and
  107. // require them.
  108. default: return req(dep);
  109. }
  110. }));
  111. if (returnExports)
  112. module.exports = returnExports;
  113. return module;
  114. }
  115. };
  116. };
  117. window.define.amd = {};
  118. window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
  119. require.tlns = topLevelNamespaces;
  120. };
  121. window.initSender = function initSender() {
  122. var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
  123. var oop = window.require("ace/lib/oop");
  124. var Sender = function() {};
  125. (function() {
  126. oop.implement(this, EventEmitter);
  127. this.callback = function(data, callbackId) {
  128. postMessage({
  129. type: "call",
  130. id: callbackId,
  131. data: data
  132. });
  133. };
  134. this.emit = function(name, data) {
  135. postMessage({
  136. type: "event",
  137. name: name,
  138. data: data
  139. });
  140. };
  141. }).call(Sender.prototype);
  142. return new Sender();
  143. };
  144. var main = window.main = null;
  145. var sender = window.sender = null;
  146. window.onmessage = function(e) {
  147. var msg = e.data;
  148. if (msg.command) {
  149. if (main[msg.command])
  150. main[msg.command].apply(main, msg.args);
  151. else
  152. throw new Error("Unknown command:" + msg.command);
  153. }
  154. else if (msg.init) {
  155. initBaseUrls(msg.tlns);
  156. require("ace/lib/es5-shim");
  157. sender = window.sender = initSender();
  158. var clazz = require(msg.module)[msg.classname];
  159. main = window.main = new clazz(sender);
  160. }
  161. else if (msg.event && sender) {
  162. sender._signal(msg.event, msg.data);
  163. }
  164. };
  165. })(this);
  166. ace.define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
  167. "use strict";
  168. exports.inherits = function(ctor, superCtor) {
  169. ctor.super_ = superCtor;
  170. ctor.prototype = Object.create(superCtor.prototype, {
  171. constructor: {
  172. value: ctor,
  173. enumerable: false,
  174. writable: true,
  175. configurable: true
  176. }
  177. });
  178. };
  179. exports.mixin = function(obj, mixin) {
  180. for (var key in mixin) {
  181. obj[key] = mixin[key];
  182. }
  183. return obj;
  184. };
  185. exports.implement = function(proto, mixin) {
  186. exports.mixin(proto, mixin);
  187. };
  188. });
  189. ace.define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  190. "use strict";
  191. exports.last = function(a) {
  192. return a[a.length - 1];
  193. };
  194. exports.stringReverse = function(string) {
  195. return string.split("").reverse().join("");
  196. };
  197. exports.stringRepeat = function (string, count) {
  198. var result = '';
  199. while (count > 0) {
  200. if (count & 1)
  201. result += string;
  202. if (count >>= 1)
  203. string += string;
  204. }
  205. return result;
  206. };
  207. var trimBeginRegexp = /^\s\s*/;
  208. var trimEndRegexp = /\s\s*$/;
  209. exports.stringTrimLeft = function (string) {
  210. return string.replace(trimBeginRegexp, '');
  211. };
  212. exports.stringTrimRight = function (string) {
  213. return string.replace(trimEndRegexp, '');
  214. };
  215. exports.copyObject = function(obj) {
  216. var copy = {};
  217. for (var key in obj) {
  218. copy[key] = obj[key];
  219. }
  220. return copy;
  221. };
  222. exports.copyArray = function(array){
  223. var copy = [];
  224. for (var i=0, l=array.length; i<l; i++) {
  225. if (array[i] && typeof array[i] == "object")
  226. copy[i] = this.copyObject( array[i] );
  227. else
  228. copy[i] = array[i];
  229. }
  230. return copy;
  231. };
  232. exports.deepCopy = function (obj) {
  233. if (typeof obj !== "object" || !obj)
  234. return obj;
  235. var cons = obj.constructor;
  236. if (cons === RegExp)
  237. return obj;
  238. var copy = cons();
  239. for (var key in obj) {
  240. if (typeof obj[key] === "object") {
  241. copy[key] = exports.deepCopy(obj[key]);
  242. } else {
  243. copy[key] = obj[key];
  244. }
  245. }
  246. return copy;
  247. };
  248. exports.arrayToMap = function(arr) {
  249. var map = {};
  250. for (var i=0; i<arr.length; i++) {
  251. map[arr[i]] = 1;
  252. }
  253. return map;
  254. };
  255. exports.createMap = function(props) {
  256. var map = Object.create(null);
  257. for (var i in props) {
  258. map[i] = props[i];
  259. }
  260. return map;
  261. };
  262. exports.arrayRemove = function(array, value) {
  263. for (var i = 0; i <= array.length; i++) {
  264. if (value === array[i]) {
  265. array.splice(i, 1);
  266. }
  267. }
  268. };
  269. exports.escapeRegExp = function(str) {
  270. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  271. };
  272. exports.escapeHTML = function(str) {
  273. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  274. };
  275. exports.getMatchOffsets = function(string, regExp) {
  276. var matches = [];
  277. string.replace(regExp, function(str) {
  278. matches.push({
  279. offset: arguments[arguments.length-2],
  280. length: str.length
  281. });
  282. });
  283. return matches;
  284. };
  285. exports.deferredCall = function(fcn) {
  286. var timer = null;
  287. var callback = function() {
  288. timer = null;
  289. fcn();
  290. };
  291. var deferred = function(timeout) {
  292. deferred.cancel();
  293. timer = setTimeout(callback, timeout || 0);
  294. return deferred;
  295. };
  296. deferred.schedule = deferred;
  297. deferred.call = function() {
  298. this.cancel();
  299. fcn();
  300. return deferred;
  301. };
  302. deferred.cancel = function() {
  303. clearTimeout(timer);
  304. timer = null;
  305. return deferred;
  306. };
  307. deferred.isPending = function() {
  308. return timer;
  309. };
  310. return deferred;
  311. };
  312. exports.delayedCall = function(fcn, defaultTimeout) {
  313. var timer = null;
  314. var callback = function() {
  315. timer = null;
  316. fcn();
  317. };
  318. var _self = function(timeout) {
  319. if (timer == null)
  320. timer = setTimeout(callback, timeout || defaultTimeout);
  321. };
  322. _self.delay = function(timeout) {
  323. timer && clearTimeout(timer);
  324. timer = setTimeout(callback, timeout || defaultTimeout);
  325. };
  326. _self.schedule = _self;
  327. _self.call = function() {
  328. this.cancel();
  329. fcn();
  330. };
  331. _self.cancel = function() {
  332. timer && clearTimeout(timer);
  333. timer = null;
  334. };
  335. _self.isPending = function() {
  336. return timer;
  337. };
  338. return _self;
  339. };
  340. });
  341. ace.define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  342. "use strict";
  343. var EventEmitter = {};
  344. var stopPropagation = function() { this.propagationStopped = true; };
  345. var preventDefault = function() { this.defaultPrevented = true; };
  346. EventEmitter._emit =
  347. EventEmitter._dispatchEvent = function(eventName, e) {
  348. this._eventRegistry || (this._eventRegistry = {});
  349. this._defaultHandlers || (this._defaultHandlers = {});
  350. var listeners = this._eventRegistry[eventName] || [];
  351. var defaultHandler = this._defaultHandlers[eventName];
  352. if (!listeners.length && !defaultHandler)
  353. return;
  354. if (typeof e != "object" || !e)
  355. e = {};
  356. if (!e.type)
  357. e.type = eventName;
  358. if (!e.stopPropagation)
  359. e.stopPropagation = stopPropagation;
  360. if (!e.preventDefault)
  361. e.preventDefault = preventDefault;
  362. listeners = listeners.slice();
  363. for (var i=0; i<listeners.length; i++) {
  364. listeners[i](e, this);
  365. if (e.propagationStopped)
  366. break;
  367. }
  368. if (defaultHandler && !e.defaultPrevented)
  369. return defaultHandler(e, this);
  370. };
  371. EventEmitter._signal = function(eventName, e) {
  372. var listeners = (this._eventRegistry || {})[eventName];
  373. if (!listeners)
  374. return;
  375. listeners = listeners.slice();
  376. for (var i=0; i<listeners.length; i++)
  377. listeners[i](e, this);
  378. };
  379. EventEmitter.once = function(eventName, callback) {
  380. var _self = this;
  381. callback && this.addEventListener(eventName, function newCallback() {
  382. _self.removeEventListener(eventName, newCallback);
  383. callback.apply(null, arguments);
  384. });
  385. };
  386. EventEmitter.setDefaultHandler = function(eventName, callback) {
  387. var handlers = this._defaultHandlers
  388. if (!handlers)
  389. handlers = this._defaultHandlers = {_disabled_: {}};
  390. if (handlers[eventName]) {
  391. var old = handlers[eventName];
  392. var disabled = handlers._disabled_[eventName];
  393. if (!disabled)
  394. handlers._disabled_[eventName] = disabled = [];
  395. disabled.push(old);
  396. var i = disabled.indexOf(callback);
  397. if (i != -1)
  398. disabled.splice(i, 1);
  399. }
  400. handlers[eventName] = callback;
  401. };
  402. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  403. var handlers = this._defaultHandlers
  404. if (!handlers)
  405. return;
  406. var disabled = handlers._disabled_[eventName];
  407. if (handlers[eventName] == callback) {
  408. var old = handlers[eventName];
  409. if (disabled)
  410. this.setDefaultHandler(eventName, disabled.pop());
  411. } else if (disabled) {
  412. var i = disabled.indexOf(callback);
  413. if (i != -1)
  414. disabled.splice(i, 1);
  415. }
  416. };
  417. EventEmitter.on =
  418. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  419. this._eventRegistry = this._eventRegistry || {};
  420. var listeners = this._eventRegistry[eventName];
  421. if (!listeners)
  422. listeners = this._eventRegistry[eventName] = [];
  423. if (listeners.indexOf(callback) == -1)
  424. listeners[capturing ? "unshift" : "push"](callback);
  425. return callback;
  426. };
  427. EventEmitter.off =
  428. EventEmitter.removeListener =
  429. EventEmitter.removeEventListener = function(eventName, callback) {
  430. this._eventRegistry = this._eventRegistry || {};
  431. var listeners = this._eventRegistry[eventName];
  432. if (!listeners)
  433. return;
  434. var index = listeners.indexOf(callback);
  435. if (index !== -1)
  436. listeners.splice(index, 1);
  437. };
  438. EventEmitter.removeAllListeners = function(eventName) {
  439. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  440. };
  441. exports.EventEmitter = EventEmitter;
  442. });
  443. ace.define("ace/range",["require","exports","module"], function(require, exports, module) {
  444. "use strict";
  445. var comparePoints = function(p1, p2) {
  446. return p1.row - p2.row || p1.column - p2.column;
  447. };
  448. var Range = function(startRow, startColumn, endRow, endColumn) {
  449. this.start = {
  450. row: startRow,
  451. column: startColumn
  452. };
  453. this.end = {
  454. row: endRow,
  455. column: endColumn
  456. };
  457. };
  458. (function() {
  459. this.isEqual = function(range) {
  460. return this.start.row === range.start.row &&
  461. this.end.row === range.end.row &&
  462. this.start.column === range.start.column &&
  463. this.end.column === range.end.column;
  464. };
  465. this.toString = function() {
  466. return ("Range: [" + this.start.row + "/" + this.start.column +
  467. "] -> [" + this.end.row + "/" + this.end.column + "]");
  468. };
  469. this.contains = function(row, column) {
  470. return this.compare(row, column) == 0;
  471. };
  472. this.compareRange = function(range) {
  473. var cmp,
  474. end = range.end,
  475. start = range.start;
  476. cmp = this.compare(end.row, end.column);
  477. if (cmp == 1) {
  478. cmp = this.compare(start.row, start.column);
  479. if (cmp == 1) {
  480. return 2;
  481. } else if (cmp == 0) {
  482. return 1;
  483. } else {
  484. return 0;
  485. }
  486. } else if (cmp == -1) {
  487. return -2;
  488. } else {
  489. cmp = this.compare(start.row, start.column);
  490. if (cmp == -1) {
  491. return -1;
  492. } else if (cmp == 1) {
  493. return 42;
  494. } else {
  495. return 0;
  496. }
  497. }
  498. };
  499. this.comparePoint = function(p) {
  500. return this.compare(p.row, p.column);
  501. };
  502. this.containsRange = function(range) {
  503. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  504. };
  505. this.intersects = function(range) {
  506. var cmp = this.compareRange(range);
  507. return (cmp == -1 || cmp == 0 || cmp == 1);
  508. };
  509. this.isEnd = function(row, column) {
  510. return this.end.row == row && this.end.column == column;
  511. };
  512. this.isStart = function(row, column) {
  513. return this.start.row == row && this.start.column == column;
  514. };
  515. this.setStart = function(row, column) {
  516. if (typeof row == "object") {
  517. this.start.column = row.column;
  518. this.start.row = row.row;
  519. } else {
  520. this.start.row = row;
  521. this.start.column = column;
  522. }
  523. };
  524. this.setEnd = function(row, column) {
  525. if (typeof row == "object") {
  526. this.end.column = row.column;
  527. this.end.row = row.row;
  528. } else {
  529. this.end.row = row;
  530. this.end.column = column;
  531. }
  532. };
  533. this.inside = function(row, column) {
  534. if (this.compare(row, column) == 0) {
  535. if (this.isEnd(row, column) || this.isStart(row, column)) {
  536. return false;
  537. } else {
  538. return true;
  539. }
  540. }
  541. return false;
  542. };
  543. this.insideStart = function(row, column) {
  544. if (this.compare(row, column) == 0) {
  545. if (this.isEnd(row, column)) {
  546. return false;
  547. } else {
  548. return true;
  549. }
  550. }
  551. return false;
  552. };
  553. this.insideEnd = function(row, column) {
  554. if (this.compare(row, column) == 0) {
  555. if (this.isStart(row, column)) {
  556. return false;
  557. } else {
  558. return true;
  559. }
  560. }
  561. return false;
  562. };
  563. this.compare = function(row, column) {
  564. if (!this.isMultiLine()) {
  565. if (row === this.start.row) {
  566. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  567. };
  568. }
  569. if (row < this.start.row)
  570. return -1;
  571. if (row > this.end.row)
  572. return 1;
  573. if (this.start.row === row)
  574. return column >= this.start.column ? 0 : -1;
  575. if (this.end.row === row)
  576. return column <= this.end.column ? 0 : 1;
  577. return 0;
  578. };
  579. this.compareStart = function(row, column) {
  580. if (this.start.row == row && this.start.column == column) {
  581. return -1;
  582. } else {
  583. return this.compare(row, column);
  584. }
  585. };
  586. this.compareEnd = function(row, column) {
  587. if (this.end.row == row && this.end.column == column) {
  588. return 1;
  589. } else {
  590. return this.compare(row, column);
  591. }
  592. };
  593. this.compareInside = function(row, column) {
  594. if (this.end.row == row && this.end.column == column) {
  595. return 1;
  596. } else if (this.start.row == row && this.start.column == column) {
  597. return -1;
  598. } else {
  599. return this.compare(row, column);
  600. }
  601. };
  602. this.clipRows = function(firstRow, lastRow) {
  603. if (this.end.row > lastRow)
  604. var end = {row: lastRow + 1, column: 0};
  605. else if (this.end.row < firstRow)
  606. var end = {row: firstRow, column: 0};
  607. if (this.start.row > lastRow)
  608. var start = {row: lastRow + 1, column: 0};
  609. else if (this.start.row < firstRow)
  610. var start = {row: firstRow, column: 0};
  611. return Range.fromPoints(start || this.start, end || this.end);
  612. };
  613. this.extend = function(row, column) {
  614. var cmp = this.compare(row, column);
  615. if (cmp == 0)
  616. return this;
  617. else if (cmp == -1)
  618. var start = {row: row, column: column};
  619. else
  620. var end = {row: row, column: column};
  621. return Range.fromPoints(start || this.start, end || this.end);
  622. };
  623. this.isEmpty = function() {
  624. return (this.start.row === this.end.row && this.start.column === this.end.column);
  625. };
  626. this.isMultiLine = function() {
  627. return (this.start.row !== this.end.row);
  628. };
  629. this.clone = function() {
  630. return Range.fromPoints(this.start, this.end);
  631. };
  632. this.collapseRows = function() {
  633. if (this.end.column == 0)
  634. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  635. else
  636. return new Range(this.start.row, 0, this.end.row, 0)
  637. };
  638. this.toScreenRange = function(session) {
  639. var screenPosStart = session.documentToScreenPosition(this.start);
  640. var screenPosEnd = session.documentToScreenPosition(this.end);
  641. return new Range(
  642. screenPosStart.row, screenPosStart.column,
  643. screenPosEnd.row, screenPosEnd.column
  644. );
  645. };
  646. this.moveBy = function(row, column) {
  647. this.start.row += row;
  648. this.start.column += column;
  649. this.end.row += row;
  650. this.end.column += column;
  651. };
  652. }).call(Range.prototype);
  653. Range.fromPoints = function(start, end) {
  654. return new Range(start.row, start.column, end.row, end.column);
  655. };
  656. Range.comparePoints = comparePoints;
  657. Range.comparePoints = function(p1, p2) {
  658. return p1.row - p2.row || p1.column - p2.column;
  659. };
  660. exports.Range = Range;
  661. });
  662. ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  663. "use strict";
  664. var oop = require("./lib/oop");
  665. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  666. var Anchor = exports.Anchor = function(doc, row, column) {
  667. this.$onChange = this.onChange.bind(this);
  668. this.attach(doc);
  669. if (typeof column == "undefined")
  670. this.setPosition(row.row, row.column);
  671. else
  672. this.setPosition(row, column);
  673. };
  674. (function() {
  675. oop.implement(this, EventEmitter);
  676. this.getPosition = function() {
  677. return this.$clipPositionToDocument(this.row, this.column);
  678. };
  679. this.getDocument = function() {
  680. return this.document;
  681. };
  682. this.$insertRight = false;
  683. this.onChange = function(e) {
  684. var delta = e.data;
  685. var range = delta.range;
  686. if (range.start.row == range.end.row && range.start.row != this.row)
  687. return;
  688. if (range.start.row > this.row)
  689. return;
  690. if (range.start.row == this.row && range.start.column > this.column)
  691. return;
  692. var row = this.row;
  693. var column = this.column;
  694. var start = range.start;
  695. var end = range.end;
  696. if (delta.action === "insertText") {
  697. if (start.row === row && start.column <= column) {
  698. if (start.column === column && this.$insertRight) {
  699. } else if (start.row === end.row) {
  700. column += end.column - start.column;
  701. } else {
  702. column -= start.column;
  703. row += end.row - start.row;
  704. }
  705. } else if (start.row !== end.row && start.row < row) {
  706. row += end.row - start.row;
  707. }
  708. } else if (delta.action === "insertLines") {
  709. if (start.row === row && column === 0 && this.$insertRight) {
  710. }
  711. else if (start.row <= row) {
  712. row += end.row - start.row;
  713. }
  714. } else if (delta.action === "removeText") {
  715. if (start.row === row && start.column < column) {
  716. if (end.column >= column)
  717. column = start.column;
  718. else
  719. column = Math.max(0, column - (end.column - start.column));
  720. } else if (start.row !== end.row && start.row < row) {
  721. if (end.row === row)
  722. column = Math.max(0, column - end.column) + start.column;
  723. row -= (end.row - start.row);
  724. } else if (end.row === row) {
  725. row -= end.row - start.row;
  726. column = Math.max(0, column - end.column) + start.column;
  727. }
  728. } else if (delta.action == "removeLines") {
  729. if (start.row <= row) {
  730. if (end.row <= row)
  731. row -= end.row - start.row;
  732. else {
  733. row = start.row;
  734. column = 0;
  735. }
  736. }
  737. }
  738. this.setPosition(row, column, true);
  739. };
  740. this.setPosition = function(row, column, noClip) {
  741. var pos;
  742. if (noClip) {
  743. pos = {
  744. row: row,
  745. column: column
  746. };
  747. } else {
  748. pos = this.$clipPositionToDocument(row, column);
  749. }
  750. if (this.row == pos.row && this.column == pos.column)
  751. return;
  752. var old = {
  753. row: this.row,
  754. column: this.column
  755. };
  756. this.row = pos.row;
  757. this.column = pos.column;
  758. this._signal("change", {
  759. old: old,
  760. value: pos
  761. });
  762. };
  763. this.detach = function() {
  764. this.document.removeEventListener("change", this.$onChange);
  765. };
  766. this.attach = function(doc) {
  767. this.document = doc || this.document;
  768. this.document.on("change", this.$onChange);
  769. };
  770. this.$clipPositionToDocument = function(row, column) {
  771. var pos = {};
  772. if (row >= this.document.getLength()) {
  773. pos.row = Math.max(0, this.document.getLength() - 1);
  774. pos.column = this.document.getLine(pos.row).length;
  775. }
  776. else if (row < 0) {
  777. pos.row = 0;
  778. pos.column = 0;
  779. }
  780. else {
  781. pos.row = row;
  782. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  783. }
  784. if (column < 0)
  785. pos.column = 0;
  786. return pos;
  787. };
  788. }).call(Anchor.prototype);
  789. });
  790. ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  791. "use strict";
  792. var oop = require("./lib/oop");
  793. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  794. var Range = require("./range").Range;
  795. var Anchor = require("./anchor").Anchor;
  796. var Document = function(text) {
  797. this.$lines = [];
  798. if (text.length === 0) {
  799. this.$lines = [""];
  800. } else if (Array.isArray(text)) {
  801. this._insertLines(0, text);
  802. } else {
  803. this.insert({row: 0, column:0}, text);
  804. }
  805. };
  806. (function() {
  807. oop.implement(this, EventEmitter);
  808. this.setValue = function(text) {
  809. var len = this.getLength();
  810. this.remove(new Range(0, 0, len, this.getLine(len-1).length));
  811. this.insert({row: 0, column:0}, text);
  812. };
  813. this.getValue = function() {
  814. return this.getAllLines().join(this.getNewLineCharacter());
  815. };
  816. this.createAnchor = function(row, column) {
  817. return new Anchor(this, row, column);
  818. };
  819. if ("aaa".split(/a/).length === 0)
  820. this.$split = function(text) {
  821. return text.replace(/\r\n|\r/g, "\n").split("\n");
  822. };
  823. else
  824. this.$split = function(text) {
  825. return text.split(/\r\n|\r|\n/);
  826. };
  827. this.$detectNewLine = function(text) {
  828. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  829. this.$autoNewLine = match ? match[1] : "\n";
  830. this._signal("changeNewLineMode");
  831. };
  832. this.getNewLineCharacter = function() {
  833. switch (this.$newLineMode) {
  834. case "windows":
  835. return "\r\n";
  836. case "unix":
  837. return "\n";
  838. default:
  839. return this.$autoNewLine || "\n";
  840. }
  841. };
  842. this.$autoNewLine = "";
  843. this.$newLineMode = "auto";
  844. this.setNewLineMode = function(newLineMode) {
  845. if (this.$newLineMode === newLineMode)
  846. return;
  847. this.$newLineMode = newLineMode;
  848. this._signal("changeNewLineMode");
  849. };
  850. this.getNewLineMode = function() {
  851. return this.$newLineMode;
  852. };
  853. this.isNewLine = function(text) {
  854. return (text == "\r\n" || text == "\r" || text == "\n");
  855. };
  856. this.getLine = function(row) {
  857. return this.$lines[row] || "";
  858. };
  859. this.getLines = function(firstRow, lastRow) {
  860. return this.$lines.slice(firstRow, lastRow + 1);
  861. };
  862. this.getAllLines = function() {
  863. return this.getLines(0, this.getLength());
  864. };
  865. this.getLength = function() {
  866. return this.$lines.length;
  867. };
  868. this.getTextRange = function(range) {
  869. if (range.start.row == range.end.row) {
  870. return this.getLine(range.start.row)
  871. .substring(range.start.column, range.end.column);
  872. }
  873. var lines = this.getLines(range.start.row, range.end.row);
  874. lines[0] = (lines[0] || "").substring(range.start.column);
  875. var l = lines.length - 1;
  876. if (range.end.row - range.start.row == l)
  877. lines[l] = lines[l].substring(0, range.end.column);
  878. return lines.join(this.getNewLineCharacter());
  879. };
  880. this.$clipPosition = function(position) {
  881. var length = this.getLength();
  882. if (position.row >= length) {
  883. position.row = Math.max(0, length - 1);
  884. position.column = this.getLine(length-1).length;
  885. } else if (position.row < 0)
  886. position.row = 0;
  887. return position;
  888. };
  889. this.insert = function(position, text) {
  890. if (!text || text.length === 0)
  891. return position;
  892. position = this.$clipPosition(position);
  893. if (this.getLength() <= 1)
  894. this.$detectNewLine(text);
  895. var lines = this.$split(text);
  896. var firstLine = lines.splice(0, 1)[0];
  897. var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
  898. position = this.insertInLine(position, firstLine);
  899. if (lastLine !== null) {
  900. position = this.insertNewLine(position); // terminate first line
  901. position = this._insertLines(position.row, lines);
  902. position = this.insertInLine(position, lastLine || "");
  903. }
  904. return position;
  905. };
  906. this.insertLines = function(row, lines) {
  907. if (row >= this.getLength())
  908. return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
  909. return this._insertLines(Math.max(row, 0), lines);
  910. };
  911. this._insertLines = function(row, lines) {
  912. if (lines.length == 0)
  913. return {row: row, column: 0};
  914. while (lines.length > 0xF000) {
  915. var end = this._insertLines(row, lines.slice(0, 0xF000));
  916. lines = lines.slice(0xF000);
  917. row = end.row;
  918. }
  919. var args = [row, 0];
  920. args.push.apply(args, lines);
  921. this.$lines.splice.apply(this.$lines, args);
  922. var range = new Range(row, 0, row + lines.length, 0);
  923. var delta = {
  924. action: "insertLines",
  925. range: range,
  926. lines: lines
  927. };
  928. this._signal("change", { data: delta });
  929. return range.end;
  930. };
  931. this.insertNewLine = function(position) {
  932. position = this.$clipPosition(position);
  933. var line = this.$lines[position.row] || "";
  934. this.$lines[position.row] = line.substring(0, position.column);
  935. this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
  936. var end = {
  937. row : position.row + 1,
  938. column : 0
  939. };
  940. var delta = {
  941. action: "insertText",
  942. range: Range.fromPoints(position, end),
  943. text: this.getNewLineCharacter()
  944. };
  945. this._signal("change", { data: delta });
  946. return end;
  947. };
  948. this.insertInLine = function(position, text) {
  949. if (text.length == 0)
  950. return position;
  951. var line = this.$lines[position.row] || "";
  952. this.$lines[position.row] = line.substring(0, position.column) + text
  953. + line.substring(position.column);
  954. var end = {
  955. row : position.row,
  956. column : position.column + text.length
  957. };
  958. var delta = {
  959. action: "insertText",
  960. range: Range.fromPoints(position, end),
  961. text: text
  962. };
  963. this._signal("change", { data: delta });
  964. return end;
  965. };
  966. this.remove = function(range) {
  967. if (!(range instanceof Range))
  968. range = Range.fromPoints(range.start, range.end);
  969. range.start = this.$clipPosition(range.start);
  970. range.end = this.$clipPosition(range.end);
  971. if (range.isEmpty())
  972. return range.start;
  973. var firstRow = range.start.row;
  974. var lastRow = range.end.row;
  975. if (range.isMultiLine()) {
  976. var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
  977. var lastFullRow = lastRow - 1;
  978. if (range.end.column > 0)
  979. this.removeInLine(lastRow, 0, range.end.column);
  980. if (lastFullRow >= firstFullRow)
  981. this._removeLines(firstFullRow, lastFullRow);
  982. if (firstFullRow != firstRow) {
  983. this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
  984. this.removeNewLine(range.start.row);
  985. }
  986. }
  987. else {
  988. this.removeInLine(firstRow, range.start.column, range.end.column);
  989. }
  990. return range.start;
  991. };
  992. this.removeInLine = function(row, startColumn, endColumn) {
  993. if (startColumn == endColumn)
  994. return;
  995. var range = new Range(row, startColumn, row, endColumn);
  996. var line = this.getLine(row);
  997. var removed = line.substring(startColumn, endColumn);
  998. var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
  999. this.$lines.splice(row, 1, newLine);
  1000. var delta = {
  1001. action: "removeText",
  1002. range: range,
  1003. text: removed
  1004. };
  1005. this._signal("change", { data: delta });
  1006. return range.start;
  1007. };
  1008. this.removeLines = function(firstRow, lastRow) {
  1009. if (firstRow < 0 || lastRow >= this.getLength())
  1010. return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
  1011. return this._removeLines(firstRow, lastRow);
  1012. };
  1013. this._removeLines = function(firstRow, lastRow) {
  1014. var range = new Range(firstRow, 0, lastRow + 1, 0);
  1015. var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
  1016. var delta = {
  1017. action: "removeLines",
  1018. range: range,
  1019. nl: this.getNewLineCharacter(),
  1020. lines: removed
  1021. };
  1022. this._signal("change", { data: delta });
  1023. return removed;
  1024. };
  1025. this.removeNewLine = function(row) {
  1026. var firstLine = this.getLine(row);
  1027. var secondLine = this.getLine(row+1);
  1028. var range = new Range(row, firstLine.length, row+1, 0);
  1029. var line = firstLine + secondLine;
  1030. this.$lines.splice(row, 2, line);
  1031. var delta = {
  1032. action: "removeText",
  1033. range: range,
  1034. text: this.getNewLineCharacter()
  1035. };
  1036. this._signal("change", { data: delta });
  1037. };
  1038. this.replace = function(range, text) {
  1039. if (!(range instanceof Range))
  1040. range = Range.fromPoints(range.start, range.end);
  1041. if (text.length == 0 && range.isEmpty())
  1042. return range.start;
  1043. if (text == this.getTextRange(range))
  1044. return range.end;
  1045. this.remove(range);
  1046. if (text) {
  1047. var end = this.insert(range.start, text);
  1048. }
  1049. else {
  1050. end = range.start;
  1051. }
  1052. return end;
  1053. };
  1054. this.applyDeltas = function(deltas) {
  1055. for (var i=0; i<deltas.length; i++) {
  1056. var delta = deltas[i];
  1057. var range = Range.fromPoints(delta.range.start, delta.range.end);
  1058. if (delta.action == "insertLines")
  1059. this.insertLines(range.start.row, delta.lines);
  1060. else if (delta.action == "insertText")
  1061. this.insert(range.start, delta.text);
  1062. else if (delta.action == "removeLines")
  1063. this._removeLines(range.start.row, range.end.row - 1);
  1064. else if (delta.action == "removeText")
  1065. this.remove(range);
  1066. }
  1067. };
  1068. this.revertDeltas = function(deltas) {
  1069. for (var i=deltas.length-1; i>=0; i--) {
  1070. var delta = deltas[i];
  1071. var range = Range.fromPoints(delta.range.start, delta.range.end);
  1072. if (delta.action == "insertLines")
  1073. this._removeLines(range.start.row, range.end.row - 1);
  1074. else if (delta.action == "insertText")
  1075. this.remove(range);
  1076. else if (delta.action == "removeLines")
  1077. this._insertLines(range.start.row, delta.lines);
  1078. else if (delta.action == "removeText")
  1079. this.insert(range.start, delta.text);
  1080. }
  1081. };
  1082. this.indexToPosition = function(index, startRow) {
  1083. var lines = this.$lines || this.getAllLines();
  1084. var newlineLength = this.getNewLineCharacter().length;
  1085. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1086. index -= lines[i].length + newlineLength;
  1087. if (index < 0)
  1088. return {row: i, column: index + lines[i].length + newlineLength};
  1089. }
  1090. return {row: l-1, column: lines[l-1].length};
  1091. };
  1092. this.positionToIndex = function(pos, startRow) {
  1093. var lines = this.$lines || this.getAllLines();
  1094. var newlineLength = this.getNewLineCharacter().length;
  1095. var index = 0;
  1096. var row = Math.min(pos.row, lines.length);
  1097. for (var i = startRow || 0; i < row; ++i)
  1098. index += lines[i].length + newlineLength;
  1099. return index + pos.column;
  1100. };
  1101. }).call(Document.prototype);
  1102. exports.Document = Document;
  1103. });
  1104. ace.define("ace/worker/mirror",["require","exports","module","ace/document","ace/lib/lang"], function(require, exports, module) {
  1105. "use strict";
  1106. var Document = require("../document").Document;
  1107. var lang = require("../lib/lang");
  1108. var Mirror = exports.Mirror = function(sender) {
  1109. this.sender = sender;
  1110. var doc = this.doc = new Document("");
  1111. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1112. var _self = this;
  1113. sender.on("change", function(e) {
  1114. doc.applyDeltas(e.data);
  1115. if (_self.$timeout)
  1116. return deferredUpdate.schedule(_self.$timeout);
  1117. _self.onUpdate();
  1118. });
  1119. };
  1120. (function() {
  1121. this.$timeout = 500;
  1122. this.setTimeout = function(timeout) {
  1123. this.$timeout = timeout;
  1124. };
  1125. this.setValue = function(value) {
  1126. this.doc.setValue(value);
  1127. this.deferredUpdate.schedule(this.$timeout);
  1128. };
  1129. this.getValue = function(callbackId) {
  1130. this.sender.callback(this.doc.getValue(), callbackId);
  1131. };
  1132. this.onUpdate = function() {
  1133. };
  1134. this.isPending = function() {
  1135. return this.deferredUpdate.isPending();
  1136. };
  1137. }).call(Mirror.prototype);
  1138. });
  1139. ace.define("ace/mode/css/csslint",["require","exports","module"], function(require, exports, module) {
  1140. var parserlib = {};
  1141. (function(){
  1142. function EventTarget(){
  1143. this._listeners = {};
  1144. }
  1145. EventTarget.prototype = {
  1146. constructor: EventTarget,
  1147. addListener: function(type, listener){
  1148. if (!this._listeners[type]){
  1149. this._listeners[type] = [];
  1150. }
  1151. this._listeners[type].push(listener);
  1152. },
  1153. fire: function(event){
  1154. if (typeof event == "string"){
  1155. event = { type: event };
  1156. }
  1157. if (typeof event.target != "undefined"){
  1158. event.target = this;
  1159. }
  1160. if (typeof event.type == "undefined"){
  1161. throw new Error("Event object missing 'type' property.");
  1162. }
  1163. if (this._listeners[event.type]){
  1164. var listeners = this._listeners[event.type].concat();
  1165. for (var i=0, len=listeners.length; i < len; i++){
  1166. listeners[i].call(this, event);
  1167. }
  1168. }
  1169. },
  1170. removeListener: function(type, listener){
  1171. if (this._listeners[type]){
  1172. var listeners = this._listeners[type];
  1173. for (var i=0, len=listeners.length; i < len; i++){
  1174. if (listeners[i] === listener){
  1175. listeners.splice(i, 1);
  1176. break;
  1177. }
  1178. }
  1179. }
  1180. }
  1181. };
  1182. function StringReader(text){
  1183. this._input = text.replace(/\n\r?/g, "\n");
  1184. this._line = 1;
  1185. this._col = 1;
  1186. this._cursor = 0;
  1187. }
  1188. StringReader.prototype = {
  1189. constructor: StringReader,
  1190. getCol: function(){
  1191. return this._col;
  1192. },
  1193. getLine: function(){
  1194. return this._line ;
  1195. },
  1196. eof: function(){
  1197. return (this._cursor == this._input.length);
  1198. },
  1199. peek: function(count){
  1200. var c = null;
  1201. count = (typeof count == "undefined" ? 1 : count);
  1202. if (this._cursor < this._input.length){
  1203. c = this._input.charAt(this._cursor + count - 1);
  1204. }
  1205. return c;
  1206. },
  1207. read: function(){
  1208. var c = null;
  1209. if (this._cursor < this._input.length){
  1210. if (this._input.charAt(this._cursor) == "\n"){
  1211. this._line++;
  1212. this._col=1;
  1213. } else {
  1214. this._col++;
  1215. }
  1216. c = this._input.charAt(this._cursor++);
  1217. }
  1218. return c;
  1219. },
  1220. mark: function(){
  1221. this._bookmark = {
  1222. cursor: this._cursor,
  1223. line: this._line,
  1224. col: this._col
  1225. };
  1226. },
  1227. reset: function(){
  1228. if (this._bookmark){
  1229. this._cursor = this._bookmark.cursor;
  1230. this._line = this._bookmark.line;
  1231. this._col = this._bookmark.col;
  1232. delete this._bookmark;
  1233. }
  1234. },
  1235. readTo: function(pattern){
  1236. var buffer = "",
  1237. c;
  1238. while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) != buffer.length - pattern.length){
  1239. c = this.read();
  1240. if (c){
  1241. buffer += c;
  1242. } else {
  1243. throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
  1244. }
  1245. }
  1246. return buffer;
  1247. },
  1248. readWhile: function(filter){
  1249. var buffer = "",
  1250. c = this.read();
  1251. while(c !== null && filter(c)){
  1252. buffer += c;
  1253. c = this.read();
  1254. }
  1255. return buffer;
  1256. },
  1257. readMatch: function(matcher){
  1258. var source = this._input.substring(this._cursor),
  1259. value = null;
  1260. if (typeof matcher == "string"){
  1261. if (source.indexOf(matcher) === 0){
  1262. value = this.readCount(matcher.length);
  1263. }
  1264. } else if (matcher instanceof RegExp){
  1265. if (matcher.test(source)){
  1266. value = this.readCount(RegExp.lastMatch.length);
  1267. }
  1268. }
  1269. return value;
  1270. },
  1271. readCount: function(count){
  1272. var buffer = "";
  1273. while(count--){
  1274. buffer += this.read();
  1275. }
  1276. return buffer;
  1277. }
  1278. };
  1279. function SyntaxError(message, line, col){
  1280. this.col = col;
  1281. this.line = line;
  1282. this.message = message;
  1283. }
  1284. SyntaxError.prototype = new Error();
  1285. function SyntaxUnit(text, line, col, type){
  1286. this.col = col;
  1287. this.line = line;
  1288. this.text = text;
  1289. this.type = type;
  1290. }
  1291. SyntaxUnit.fromToken = function(token){
  1292. return new SyntaxUnit(token.value, token.startLine, token.startCol);
  1293. };
  1294. SyntaxUnit.prototype = {
  1295. constructor: SyntaxUnit,
  1296. valueOf: function(){
  1297. return this.text;
  1298. },
  1299. toString: function(){
  1300. return this.text;
  1301. }
  1302. };
  1303. function TokenStreamBase(input, tokenData){
  1304. this._reader = input ? new StringReader(input.toString()) : null;
  1305. this._token = null;
  1306. this._tokenData = tokenData;
  1307. this._lt = [];
  1308. this._ltIndex = 0;
  1309. this._ltIndexCache = [];
  1310. }
  1311. TokenStreamBase.createTokenData = function(tokens){
  1312. var nameMap = [],
  1313. typeMap = {},
  1314. tokenData = tokens.concat([]),
  1315. i = 0,
  1316. len = tokenData.length+1;
  1317. tokenData.UNKNOWN = -1;
  1318. tokenData.unshift({name:"EOF"});
  1319. for (; i < len; i++){
  1320. nameMap.push(tokenData[i].name);
  1321. tokenData[tokenData[i].name] = i;
  1322. if (tokenData[i].text){
  1323. typeMap[tokenData[i].text] = i;
  1324. }
  1325. }
  1326. tokenData.name = function(tt){
  1327. return nameMap[tt];
  1328. };
  1329. tokenData.type = function(c){
  1330. return typeMap[c];
  1331. };
  1332. return tokenData;
  1333. };
  1334. TokenStreamBase.prototype = {
  1335. constructor: TokenStreamBase,
  1336. match: function(tokenTypes, channel){
  1337. if (!(tokenTypes instanceof Array)){
  1338. tokenTypes = [tokenTypes];
  1339. }
  1340. var tt = this.get(channel),
  1341. i = 0,
  1342. len = tokenTypes.length;
  1343. while(i < len){
  1344. if (tt == tokenTypes[i++]){
  1345. return true;
  1346. }
  1347. }
  1348. this.unget();
  1349. return false;
  1350. },
  1351. mustMatch: function(tokenTypes, channel){
  1352. var token;
  1353. if (!(tokenTypes instanceof Array)){
  1354. tokenTypes = [tokenTypes];
  1355. }
  1356. if (!this.match.apply(this, arguments)){
  1357. token = this.LT(1);
  1358. throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
  1359. " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  1360. }
  1361. },
  1362. advance: function(tokenTypes, channel){
  1363. while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){
  1364. this.get();
  1365. }
  1366. return this.LA(0);
  1367. },
  1368. get: function(channel){
  1369. var tokenInfo = this._tokenData,
  1370. reader = this._reader,
  1371. value,
  1372. i =0,
  1373. len = tokenInfo.length,
  1374. found = false,
  1375. token,
  1376. info;
  1377. if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){
  1378. i++;
  1379. this._token = this._lt[this._ltIndex++];
  1380. info = tokenInfo[this._token.type];
  1381. while((info.channel !== undefined && channel !== info.channel) &&
  1382. this._ltIndex < this._lt.length){
  1383. this._token = this._lt[this._ltIndex++];
  1384. info = tokenInfo[this._token.type];
  1385. i++;
  1386. }
  1387. if ((info.channel === undefined || channel === info.channel) &&
  1388. this._ltIndex <= this._lt.length){
  1389. this._ltIndexCache.push(i);
  1390. return this._token.type;
  1391. }
  1392. }
  1393. token = this._getToken();
  1394. if (token.type > -1 && !tokenInfo[token.type].hide){
  1395. token.channel = tokenInfo[token.type].channel;
  1396. this._token = token;
  1397. this._lt.push(token);
  1398. this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
  1399. if (this._lt.length > 5){
  1400. this._lt.shift();
  1401. }
  1402. if (this._ltIndexCache.length > 5){
  1403. this._ltIndexCache.shift();
  1404. }
  1405. this._ltIndex = this._lt.length;
  1406. }
  1407. info = tokenInfo[token.type];
  1408. if (info &&
  1409. (info.hide ||
  1410. (info.channel !== undefined && channel !== info.channel))){
  1411. return this.get(channel);
  1412. } else {
  1413. return token.type;
  1414. }
  1415. },
  1416. LA: function(index){
  1417. var total = index,
  1418. tt;
  1419. if (index > 0){
  1420. if (index > 5){
  1421. throw new Error("Too much lookahead.");
  1422. }
  1423. while(total){
  1424. tt = this.get();
  1425. total--;
  1426. }
  1427. while(total < index){
  1428. this.unget();
  1429. total++;
  1430. }
  1431. } else if (index < 0){
  1432. if(this._lt[this._ltIndex+index]){
  1433. tt = this._lt[this._ltIndex+index].type;
  1434. } else {
  1435. throw new Error("Too much lookbehind.");
  1436. }
  1437. } else {
  1438. tt = this._token.type;
  1439. }
  1440. return tt;
  1441. },
  1442. LT: function(index){
  1443. this.LA(index);
  1444. return this._lt[this._ltIndex+index-1];
  1445. },
  1446. peek: function(){
  1447. return this.LA(1);
  1448. },
  1449. token: function(){
  1450. return this._token;
  1451. },
  1452. tokenName: function(tokenType){
  1453. if (tokenType < 0 || tokenType > this._tokenData.length){
  1454. return "UNKNOWN_TOKEN";
  1455. } else {
  1456. return this._tokenData[tokenType].name;
  1457. }
  1458. },
  1459. tokenType: function(tokenName){
  1460. return this._tokenData[tokenName] || -1;
  1461. },
  1462. unget: function(){
  1463. if (this._ltIndexCache.length){
  1464. this._ltIndex -= this._ltIndexCache.pop();//--;
  1465. this._token = this._lt[this._ltIndex - 1];
  1466. } else {
  1467. throw new Error("Too much lookahead.");
  1468. }
  1469. }
  1470. };
  1471. parserlib.util = {
  1472. StringReader: StringReader,
  1473. SyntaxError : SyntaxError,
  1474. SyntaxUnit : SyntaxUnit,
  1475. EventTarget : EventTarget,
  1476. TokenStreamBase : TokenStreamBase
  1477. };
  1478. })();
  1479. (function(){
  1480. var EventTarget = parserlib.util.EventTarget,
  1481. TokenStreamBase = parserlib.util.TokenStreamBase,
  1482. StringReader = parserlib.util.StringReader,
  1483. SyntaxError = parserlib.util.SyntaxError,
  1484. SyntaxUnit = parserlib.util.SyntaxUnit;
  1485. var Colors = {
  1486. aliceblue :"#f0f8ff",
  1487. antiquewhite :"#faebd7",
  1488. aqua :"#00ffff",
  1489. aquamarine :"#7fffd4",
  1490. azure :"#f0ffff",
  1491. beige :"#f5f5dc",
  1492. bisque :"#ffe4c4",
  1493. black :"#000000",
  1494. blanchedalmond :"#ffebcd",
  1495. blue :"#0000ff",
  1496. blueviolet :"#8a2be2",
  1497. brown :"#a52a2a",
  1498. burlywood :"#deb887",
  1499. cadetblue :"#5f9ea0",
  1500. chartreuse :"#7fff00",
  1501. chocolate :"#d2691e",
  1502. coral :"#ff7f50",
  1503. cornflowerblue :"#6495ed",
  1504. cornsilk :"#fff8dc",
  1505. crimson :"#dc143c",
  1506. cyan

Large files files are truncated, but you can click here to view the full file