mode-mixal.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ace.define("ace/mode/mixal_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 MixalHighlightRules = function() {
  6. var isValidSymbol = function(string) {
  7. return string && string.search(/^[A-Z\u0394\u03a0\u03a30-9]{1,10}$/) > -1 && string.search(/[A-Z\u0394\u03a0\u03a3]/) > -1;
  8. };
  9. var isValidOp = function(op) {
  10. return op && [
  11. 'NOP', 'ADD', 'FADD', 'SUB', 'FSUB', 'MUL', 'FMUL', 'DIV', 'FDIV', 'NUM', 'CHAR', 'HLT',
  12. 'SLA', 'SRA', 'SLAX', 'SRAX', 'SLC', 'SRC', 'MOVE', 'LDA', 'LD1', 'LD2', 'LD3', 'LD4',
  13. 'LD5', 'LD6', 'LDX', 'LDAN', 'LD1N', 'LD2N', 'LD3N', 'LD4N', 'LD5N', 'LD6N', 'LDXN',
  14. 'STA', 'ST1', 'ST2', 'ST3', 'ST4', 'ST5', 'ST6', 'STX', 'STJ', 'STZ', 'JBUS', 'IOC',
  15. 'IN', 'OUT', 'JRED', 'JMP', 'JSJ', 'JOV', 'JNOV', 'JL', 'JE', 'JG', 'JGE', 'JNE', 'JLE',
  16. 'JAN', 'JAZ', 'JAP', 'JANN', 'JANZ', 'JANP', 'J1N', 'J1Z', 'J1P', 'J1NN', 'J1NZ',
  17. 'J1NP', 'J2N', 'J2Z', 'J2P', 'J2NN', 'J2NZ', 'J2NP','J3N', 'J3Z', 'J3P', 'J3NN', 'J3NZ',
  18. 'J3NP', 'J4N', 'J4Z', 'J4P', 'J4NN', 'J4NZ', 'J4NP', 'J5N', 'J5Z', 'J5P', 'J5NN',
  19. 'J5NZ', 'J5NP','J6N', 'J6Z', 'J6P', 'J6NN', 'J6NZ', 'J6NP', 'JXAN', 'JXZ', 'JXP',
  20. 'JXNN', 'JXNZ', 'JXNP', 'INCA', 'DECA', 'ENTA', 'ENNA', 'INC1', 'DEC1', 'ENT1', 'ENN1',
  21. 'INC2', 'DEC2', 'ENT2', 'ENN2', 'INC3', 'DEC3', 'ENT3', 'ENN3', 'INC4', 'DEC4', 'ENT4',
  22. 'ENN4', 'INC5', 'DEC5', 'ENT5', 'ENN5', 'INC6', 'DEC6', 'ENT6', 'ENN6', 'INCX', 'DECX',
  23. 'ENTX', 'ENNX', 'CMPA', 'FCMP', 'CMP1', 'CMP2', 'CMP3', 'CMP4', 'CMP5', 'CMP6', 'CMPX',
  24. 'EQU', 'ORIG', 'CON', 'ALF', 'END'
  25. ].indexOf(op) > -1;
  26. };
  27. var containsOnlySupportedCharacters = function(string) {
  28. return string && string.search(/[^ A-Z\u0394\u03a0\u03a30-9.,()+*/=$<>@;:'-]/) == -1;
  29. };
  30. this.$rules = {
  31. "start" : [{
  32. token: "comment.line.character",
  33. regex: /^ *\*.*$/
  34. }, {
  35. token: function(label, space0, keyword, space1, literal, comment) {
  36. return [
  37. isValidSymbol(label) ? "variable.other" : "invalid.illegal",
  38. "text",
  39. "keyword.control",
  40. "text",
  41. containsOnlySupportedCharacters(literal) ? "text" : "invalid.illegal",
  42. "comment.line.character"
  43. ];
  44. },
  45. regex: /^(\S+)?( +)(ALF)( )(.{5})(\s+.*)?$/
  46. }, {
  47. token: function(label, space0, keyword, space1, literal, comment) {
  48. return [
  49. isValidSymbol(label) ? "variable.other" : "invalid.illegal",
  50. "text",
  51. "keyword.control",
  52. "text",
  53. containsOnlySupportedCharacters(literal) ? "text" : "invalid.illegal",
  54. "comment.line.character"
  55. ];
  56. },
  57. regex: /^(\S+)?( +)(ALF)( )(\S.{4})(\s+.*)?$/
  58. }, {
  59. token: function(label, space0, op, comment) {
  60. return [
  61. isValidSymbol(label) ? "variable.other" : "invalid.illegal",
  62. "text",
  63. isValidOp(op) ? "keyword.control" : "invalid.illegal",
  64. "comment.line.character"
  65. ];
  66. },
  67. regex: /^(\S+)?( +)(\S+)(?:\s*)$/
  68. }, {
  69. token: function(label, space0, op, space1, address, comment) {
  70. return [
  71. isValidSymbol(label) ? "variable.other" : "invalid.illegal",
  72. "text",
  73. isValidOp(op) ? "keyword.control" : "invalid.illegal",
  74. "text",
  75. containsOnlySupportedCharacters(address) ? "text" : "invalid.illegal",
  76. "comment.line.character"
  77. ];
  78. },
  79. regex: /^(\S+)?( +)(\S+)( +)(\S+)(\s+.*)?$/
  80. }, {
  81. defaultToken: "text"
  82. }]
  83. };
  84. };
  85. oop.inherits(MixalHighlightRules, TextHighlightRules);
  86. exports.MixalHighlightRules = MixalHighlightRules;
  87. });
  88. ace.define("ace/mode/mixal",[], function(require, exports, module) {
  89. "use strict";
  90. var oop = require("../lib/oop");
  91. var TextMode = require("./text").Mode;
  92. var MixalHighlightRules = require("./mixal_highlight_rules").MixalHighlightRules;
  93. var Mode = function() {
  94. this.HighlightRules = MixalHighlightRules;
  95. };
  96. oop.inherits(Mode, TextMode);
  97. (function() {
  98. this.$id = "ace/mode/mixal";
  99. this.lineCommentStart = "*";
  100. }).call(Mode.prototype);
  101. exports.Mode = Mode;
  102. });
  103. (function() {
  104. ace.require(["ace/mode/mixal"], function(m) {
  105. if (typeof module == "object" && typeof exports == "object" && module) {
  106. module.exports = m;
  107. }
  108. });
  109. })();