mode-cobol.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ace.define("ace/mode/cobol_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 CobolHighlightRules = function() {
  6. var keywords = "ACCEPT|MERGE|SUM|ADD||MESSAGE|TABLE|ADVANCING|MODE|TAPE|" +
  7. "AFTER|MULTIPLY|TEST|ALL|NEGATIVE|TEXT|ALPHABET|NEXT|THAN|" +
  8. "ALSO|NO|THEN|ALTERNATE|NOT|THROUGH|AND|NUMBER|THRU|ANY|OCCURS|" +
  9. "TIME|ARE|OF|TO|AREA|OFF|TOP||ASCENDING|OMITTED|TRUE|ASSIGN|ON|TYPE|AT|OPEN|" +
  10. "UNIT|AUTHOR|OR|UNTIL|BEFORE|OTHER|UP|BLANK|OUTPUT|USE|BLOCK|PAGE|USING|BOTTOM|" +
  11. "PERFORM|VALUE|BY|PIC|VALUES|CALL|PICTURE|WHEN|CANCEL|PLUS|WITH|CD|POINTER|WRITE|" +
  12. "CHARACTER|POSITION||ZERO|CLOSE|POSITIVE|ZEROS|COLUMN|PROCEDURE|ZEROES|COMMA|PROGRAM|" +
  13. "COMMON|PROGRAM-ID|COMMUNICATION|QUOTE|COMP|RANDOM|COMPUTE|READ|CONTAINS|RECEIVE|CONFIGURATION|" +
  14. "RECORD|CONTINUE|REDEFINES|CONTROL|REFERENCE|COPY|REMAINDER|COUNT|REPLACE|DATA|REPORT|DATE|RESERVE|" +
  15. "DAY|RESET|DELETE|RETURN|DESTINATION|REWIND|DISABLE|REWRITE|DISPLAY|RIGHT|DIVIDE|RUN|DOWN|SAME|" +
  16. "ELSE|SEARCH|ENABLE|SECTION|END|SELECT|ENVIRONMENT|SENTENCE|EQUAL|SET|ERROR|SIGN|EXIT|SEQUENTIAL|" +
  17. "EXTERNAL|SIZE|FLASE|SORT|FILE|SOURCE|LENGTH|SPACE|LESS|STANDARD|LIMIT|START|LINE|STOP|LOCK|STRING|LOW-VALUE|SUBTRACT";
  18. var builtinConstants = (
  19. "true|false|null"
  20. );
  21. var builtinFunctions = (
  22. "count|min|max|avg|sum|rank|now|coalesce|main"
  23. );
  24. var keywordMapper = this.createKeywordMapper({
  25. "support.function": builtinFunctions,
  26. "keyword": keywords,
  27. "constant.language": builtinConstants
  28. }, "identifier", true);
  29. this.$rules = {
  30. "start" : [ {
  31. token : "comment",
  32. regex : "\\*.*$"
  33. }, {
  34. token : "string", // " string
  35. regex : '".*?"'
  36. }, {
  37. token : "string", // ' string
  38. regex : "'.*?'"
  39. }, {
  40. token : "constant.numeric", // float
  41. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  42. }, {
  43. token : keywordMapper,
  44. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  45. }, {
  46. token : "keyword.operator",
  47. regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  48. }, {
  49. token : "paren.lparen",
  50. regex : "[\\(]"
  51. }, {
  52. token : "paren.rparen",
  53. regex : "[\\)]"
  54. }, {
  55. token : "text",
  56. regex : "\\s+"
  57. } ]
  58. };
  59. };
  60. oop.inherits(CobolHighlightRules, TextHighlightRules);
  61. exports.CobolHighlightRules = CobolHighlightRules;
  62. });
  63. ace.define("ace/mode/cobol",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/cobol_highlight_rules"], function(require, exports, module) {
  64. "use strict";
  65. var oop = require("../lib/oop");
  66. var TextMode = require("./text").Mode;
  67. var CobolHighlightRules = require("./cobol_highlight_rules").CobolHighlightRules;
  68. var Mode = function() {
  69. this.HighlightRules = CobolHighlightRules;
  70. this.$behaviour = this.$defaultBehaviour;
  71. };
  72. oop.inherits(Mode, TextMode);
  73. (function() {
  74. this.lineCommentStart = "*";
  75. this.$id = "ace/mode/cobol";
  76. }).call(Mode.prototype);
  77. exports.Mode = Mode;
  78. });