mode-pascal.js 7.9 KB

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