mode-pascal.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. ace.define("ace/mode/pascal_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 PascalHighlightRules = function() {
  6. this.$rules = { start:
  7. [ { caseInsensitive: true,
  8. token: 'keyword.control.pascal',
  9. regex: '\\b(?:(absolute|abstract|all|and|and_then|array|as|asm|attribute|begin|bindable|case|class|const|constructor|destructor|div|do|do|else|end|except|export|exports|external|far|file|finalization|finally|for|forward|goto|if|implementation|import|in|inherited|initialization|interface|interrupt|is|label|library|mod|module|name|near|nil|not|object|of|only|operator|or|or_else|otherwise|packed|pow|private|program|property|protected|public|published|qualified|record|repeat|resident|restricted|segment|set|shl|shr|then|to|try|type|unit|until|uses|value|var|view|virtual|while|with|xor))\\b' },
  10. { caseInsensitive: true,
  11. token:
  12. [ 'variable.pascal', "text",
  13. 'storage.type.prototype.pascal',
  14. 'entity.name.function.prototype.pascal' ],
  15. regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
  16. { caseInsensitive: true,
  17. token:
  18. [ 'variable.pascal', "text",
  19. 'storage.type.function.pascal',
  20. 'entity.name.function.pascal' ],
  21. regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?' },
  22. { token: 'constant.numeric.pascal',
  23. regex: '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b' },
  24. { token: 'punctuation.definition.comment.pascal',
  25. regex: '--.*$',
  26. push_:
  27. [ { token: 'comment.line.double-dash.pascal.one',
  28. regex: '$',
  29. next: 'pop' },
  30. { defaultToken: 'comment.line.double-dash.pascal.one' } ] },
  31. { token: 'punctuation.definition.comment.pascal',
  32. regex: '//.*$',
  33. push_:
  34. [ { token: 'comment.line.double-slash.pascal.two',
  35. regex: '$',
  36. next: 'pop' },
  37. { defaultToken: 'comment.line.double-slash.pascal.two' } ] },
  38. { token: 'punctuation.definition.comment.pascal',
  39. regex: '\\(\\*',
  40. push:
  41. [ { token: 'punctuation.definition.comment.pascal',
  42. regex: '\\*\\)',
  43. next: 'pop' },
  44. { defaultToken: 'comment.block.pascal.one' } ] },
  45. { token: 'punctuation.definition.comment.pascal',
  46. regex: '\\{',
  47. push:
  48. [ { token: 'punctuation.definition.comment.pascal',
  49. regex: '\\}',
  50. next: 'pop' },
  51. { defaultToken: 'comment.block.pascal.two' } ] },
  52. { token: 'punctuation.definition.string.begin.pascal',
  53. regex: '"',
  54. push:
  55. [ { token: 'constant.character.escape.pascal', regex: '\\\\.' },
  56. { token: 'punctuation.definition.string.end.pascal',
  57. regex: '"',
  58. next: 'pop' },
  59. { defaultToken: 'string.quoted.double.pascal' } ]
  60. },
  61. { token: 'punctuation.definition.string.begin.pascal',
  62. regex: '\'',
  63. push:
  64. [ { token: 'constant.character.escape.apostrophe.pascal',
  65. regex: '\'\'' },
  66. { token: 'punctuation.definition.string.end.pascal',
  67. regex: '\'',
  68. next: 'pop' },
  69. { defaultToken: 'string.quoted.single.pascal' } ] },
  70. { token: 'keyword.operator',
  71. regex: '[+\\-;,/*%]|:=|=' } ] };
  72. this.normalizeRules();
  73. };
  74. oop.inherits(PascalHighlightRules, TextHighlightRules);
  75. exports.PascalHighlightRules = PascalHighlightRules;
  76. });
  77. ace.define("ace/mode/folding/coffee",[], function(require, exports, module) {
  78. "use strict";
  79. var oop = require("../../lib/oop");
  80. var BaseFoldMode = require("./fold_mode").FoldMode;
  81. var Range = require("../../range").Range;
  82. var FoldMode = exports.FoldMode = function() {};
  83. oop.inherits(FoldMode, BaseFoldMode);
  84. (function() {
  85. this.getFoldWidgetRange = function(session, foldStyle, row) {
  86. var range = this.indentationBlock(session, row);
  87. if (range)
  88. return range;
  89. var re = /\S/;
  90. var line = session.getLine(row);
  91. var startLevel = line.search(re);
  92. if (startLevel == -1 || line[startLevel] != "#")
  93. return;
  94. var startColumn = line.length;
  95. var maxRow = session.getLength();
  96. var startRow = row;
  97. var endRow = row;
  98. while (++row < maxRow) {
  99. line = session.getLine(row);
  100. var level = line.search(re);
  101. if (level == -1)
  102. continue;
  103. if (line[level] != "#")
  104. break;
  105. endRow = row;
  106. }
  107. if (endRow > startRow) {
  108. var endColumn = session.getLine(endRow).length;
  109. return new Range(startRow, startColumn, endRow, endColumn);
  110. }
  111. };
  112. this.getFoldWidget = function(session, foldStyle, row) {
  113. var line = session.getLine(row);
  114. var indent = line.search(/\S/);
  115. var next = session.getLine(row + 1);
  116. var prev = session.getLine(row - 1);
  117. var prevIndent = prev.search(/\S/);
  118. var nextIndent = next.search(/\S/);
  119. if (indent == -1) {
  120. session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
  121. return "";
  122. }
  123. if (prevIndent == -1) {
  124. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  125. session.foldWidgets[row - 1] = "";
  126. session.foldWidgets[row + 1] = "";
  127. return "start";
  128. }
  129. } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  130. if (session.getLine(row - 2).search(/\S/) == -1) {
  131. session.foldWidgets[row - 1] = "start";
  132. session.foldWidgets[row + 1] = "";
  133. return "";
  134. }
  135. }
  136. if (prevIndent!= -1 && prevIndent < indent)
  137. session.foldWidgets[row - 1] = "start";
  138. else
  139. session.foldWidgets[row - 1] = "";
  140. if (indent < nextIndent)
  141. return "start";
  142. else
  143. return "";
  144. };
  145. }).call(FoldMode.prototype);
  146. });
  147. ace.define("ace/mode/pascal",[], function(require, exports, module) {
  148. "use strict";
  149. var oop = require("../lib/oop");
  150. var TextMode = require("./text").Mode;
  151. var PascalHighlightRules = require("./pascal_highlight_rules").PascalHighlightRules;
  152. var FoldMode = require("./folding/coffee").FoldMode;
  153. var Mode = function() {
  154. this.HighlightRules = PascalHighlightRules;
  155. this.foldingRules = new FoldMode();
  156. this.$behaviour = this.$defaultBehaviour;
  157. };
  158. oop.inherits(Mode, TextMode);
  159. (function() {
  160. this.lineCommentStart = ["--", "//"];
  161. this.blockComment = [
  162. {start: "(*", end: "*)"},
  163. {start: "{", end: "}"}
  164. ];
  165. this.$id = "ace/mode/pascal";
  166. }).call(Mode.prototype);
  167. exports.Mode = Mode;
  168. });
  169. (function() {
  170. ace.require(["ace/mode/pascal"], function(m) {
  171. if (typeof module == "object" && typeof exports == "object" && module) {
  172. module.exports = m;
  173. }
  174. });
  175. })();