mode-ada.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ace.define("ace/mode/ada_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 AdaHighlightRules = function() {
  6. var keywords = "abort|else|new|return|abs|elsif|not|reverse|abstract|end|null|accept|entry|select|" +
  7. "access|exception|of|separate|aliased|exit|or|some|all|others|subtype|and|for|out|synchronized|" +
  8. "array|function|overriding|at|tagged|generic|package|task|begin|goto|pragma|terminate|" +
  9. "body|private|then|if|procedure|type|case|in|protected|constant|interface|until|" +
  10. "|is|raise|use|declare|range|delay|limited|record|when|delta|loop|rem|while|digits|renames|with|do|mod|requeue|xor";
  11. var builtinConstants = (
  12. "true|false|null"
  13. );
  14. var builtinFunctions = (
  15. "count|min|max|avg|sum|rank|now|coalesce|main"
  16. );
  17. var keywordMapper = this.createKeywordMapper({
  18. "support.function": builtinFunctions,
  19. "keyword": keywords,
  20. "constant.language": builtinConstants
  21. }, "identifier", true);
  22. this.$rules = {
  23. "start" : [ {
  24. token : "comment",
  25. regex : "--.*$"
  26. }, {
  27. token : "string", // " string
  28. regex : '".*?"'
  29. }, {
  30. token : "string", // character
  31. regex : "'.'"
  32. }, {
  33. token : "constant.numeric", // float
  34. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  35. }, {
  36. token : keywordMapper,
  37. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  38. }, {
  39. token : "keyword.operator",
  40. regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  41. }, {
  42. token : "paren.lparen",
  43. regex : "[\\(]"
  44. }, {
  45. token : "paren.rparen",
  46. regex : "[\\)]"
  47. }, {
  48. token : "text",
  49. regex : "\\s+"
  50. } ]
  51. };
  52. };
  53. oop.inherits(AdaHighlightRules, TextHighlightRules);
  54. exports.AdaHighlightRules = AdaHighlightRules;
  55. });
  56. ace.define("ace/mode/ada",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ada_highlight_rules","ace/range"], function(require, exports, module) {
  57. "use strict";
  58. var oop = require("../lib/oop");
  59. var TextMode = require("./text").Mode;
  60. var AdaHighlightRules = require("./ada_highlight_rules").AdaHighlightRules;
  61. var Range = require("../range").Range;
  62. var Mode = function() {
  63. this.HighlightRules = AdaHighlightRules;
  64. this.$behaviour = this.$defaultBehaviour;
  65. };
  66. oop.inherits(Mode, TextMode);
  67. (function() {
  68. this.lineCommentStart = "--";
  69. this.getNextLineIndent = function(state, line, tab) {
  70. var indent = this.$getIndent(line);
  71. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  72. var tokens = tokenizedLine.tokens;
  73. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  74. return indent;
  75. }
  76. if (state == "start") {
  77. var match = line.match(/^.*(begin|loop|then|is|do)\s*$/);
  78. if (match) {
  79. indent += tab;
  80. }
  81. }
  82. return indent;
  83. };
  84. this.checkOutdent = function(state, line, input) {
  85. var complete_line = line + input;
  86. if (complete_line.match(/^\s*(begin|end)$/)) {
  87. return true;
  88. }
  89. return false;
  90. };
  91. this.autoOutdent = function(state, session, row) {
  92. var line = session.getLine(row);
  93. var prevLine = session.getLine(row - 1);
  94. var prevIndent = this.$getIndent(prevLine).length;
  95. var indent = this.$getIndent(line).length;
  96. if (indent <= prevIndent) {
  97. return;
  98. }
  99. session.outdentRows(new Range(row, 0, row + 2, 0));
  100. };
  101. this.$id = "ace/mode/ada";
  102. }).call(Mode.prototype);
  103. exports.Mode = Mode;
  104. }); (function() {
  105. ace.require(["ace/mode/ada"], function(m) {
  106. if (typeof module == "object" && typeof exports == "object" && module) {
  107. module.exports = m;
  108. }
  109. });
  110. })();