mode-edifact.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. };
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. ace.define("ace/mode/edifact_highlight_rules",[], function(require, exports, module) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  46. var EdifactHighlightRules = function() {
  47. var header = (
  48. "UNH"
  49. );
  50. var segment = (
  51. "ADR|AGR|AJT|ALC|ALI|APP|APR|ARD|ARR|ASI|ATT|AUT|"+
  52. "BAS|BGM|BII|BUS|"+
  53. "CAV|CCD|CCI|CDI|CDS|CDV|CED|CIN|CLA|CLI|CMP|CNI|CNT|COD|COM|COT|CPI|CPS|CPT|CST|CTA|CUX|"+
  54. "DAM|DFN|DGS|DII|DIM|DLI|DLM|DMS|DOC|DRD|DSG|DSI|DTM|"+
  55. "EDT|EFI|ELM|ELU|ELV|EMP|EQA|EQD|EQN|ERC|ERP|EVE|FCA|FII|FNS|FNT|FOR|FSQ|FTX|"+
  56. "GDS|GEI|GID|GIN|GIR|GOR|GPO|GRU|HAN|HYN|ICD|IDE|IFD|IHC|IMD|IND|INP|INV|IRQ|"+
  57. "LAN|LIN|LOC|MEA|MEM|MKS|MOA|MSG|MTD|NAD|NAT|"+
  58. "PAC|PAI|PAS|PCC|PCD|PCI|PDI|PER|PGI|PIA|PNA|POC|PRC|PRI|PRV|PSD|PTY|PYT|"+
  59. "QRS|QTY|QUA|QVR|"+
  60. "RCS|REL|RFF|RJL|RNG|ROD|RSL|RTE|"+
  61. "SAL|SCC|SCD|SEG|SEL|SEQ|SFI|SGP|SGU|SPR|SPS|STA|STC|STG|STS|"+
  62. "TAX|TCC|TDT|TEM|TMD|TMP|TOD|TPL|TRU|TSR|"+
  63. "UNB|UNZ|UNT|UGH|UGT|UNS|"+
  64. "VLI"
  65. );
  66. var header = (
  67. "UNH"
  68. );
  69. var buildinConstants = ("null|Infinity|NaN|undefined");
  70. var langClasses = (
  71. ""
  72. );
  73. var keywords = (
  74. "BY|SE|ON|INV|JP|UNOA"
  75. );
  76. var keywordMapper = this.createKeywordMapper({
  77. "variable.language": "this",
  78. "keyword": keywords,
  79. "entity.name.segment":segment,
  80. "entity.name.header":header,
  81. "constant.language": buildinConstants,
  82. "support.function": langClasses
  83. }, "identifier");
  84. this.$rules = {
  85. "start" : [
  86. {
  87. token : "punctuation.operator",
  88. regex : "\\+.\\+"
  89. }, {
  90. token : "constant.language.boolean",
  91. regex : "(?:true|false)\\b"
  92. }, {
  93. token : keywordMapper,
  94. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  95. }, {
  96. token : "keyword.operator",
  97. regex : "\\+"
  98. }, {
  99. token : "punctuation.operator",
  100. regex : "\\:|'"
  101. },{
  102. token : "identifier",
  103. regex : "\\:D\\:"
  104. }
  105. ]
  106. };
  107. this.embedRules(DocCommentHighlightRules, "doc-",
  108. [ DocCommentHighlightRules.getEndRule("start") ]);
  109. };
  110. EdifactHighlightRules.metaData = { fileTypes: [ 'edi' ],
  111. keyEquivalent: '^~E',
  112. name: 'Edifact',
  113. scopeName: 'source.edifact' };
  114. oop.inherits(EdifactHighlightRules, TextHighlightRules);
  115. exports.EdifactHighlightRules = EdifactHighlightRules;
  116. });
  117. ace.define("ace/mode/edifact",[], function(require, exports, module) {
  118. "use strict";
  119. var oop = require("../lib/oop");
  120. var TextMode = require("./text").Mode;
  121. var EdifactHighlightRules = require("./edifact_highlight_rules").EdifactHighlightRules;
  122. var Mode = function() {
  123. this.HighlightRules = EdifactHighlightRules;
  124. };
  125. oop.inherits(Mode, TextMode);
  126. (function() {
  127. this.$id = "ace/mode/edifact";
  128. }).call(Mode.prototype);
  129. exports.Mode = Mode;
  130. });
  131. (function() {
  132. ace.require(["ace/mode/edifact"], function(m) {
  133. if (typeof module == "object" && typeof exports == "object" && module) {
  134. module.exports = m;
  135. }
  136. });
  137. })();