mode-verilog.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ace.define("ace/mode/verilog_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 VerilogHighlightRules = function() {
  6. var keywords = "always|and|assign|automatic|begin|buf|bufif0|bufif1|case|casex|casez|cell|cmos|config|" +
  7. "deassign|default|defparam|design|disable|edge|else|end|endcase|endconfig|endfunction|endgenerate|endmodule|" +
  8. "endprimitive|endspecify|endtable|endtask|event|for|force|forever|fork|function|generate|genvar|highz0|" +
  9. "highz1|if|ifnone|incdir|include|initial|inout|input|instance|integer|join|large|liblist|library|localparam|" +
  10. "macromodule|medium|module|nand|negedge|nmos|nor|noshowcancelled|not|notif0|notif1|or|output|parameter|pmos|" +
  11. "posedge|primitive|pull0|pull1|pulldown|pullup|pulsestyle_onevent|pulsestyle_ondetect|rcmos|real|realtime|" +
  12. "reg|release|repeat|rnmos|rpmos|rtran|rtranif0|rtranif1|scalared|showcancelled|signed|small|specify|specparam|" +
  13. "strong0|strong1|supply0|supply1|table|task|time|tran|tranif0|tranif1|tri|tri0|tri1|triand|trior|trireg|" +
  14. "unsigned|use|vectored|wait|wand|weak0|weak1|while|wire|wor|xnor|xor" +
  15. "begin|bufif0|bufif1|case|casex|casez|config|else|end|endcase|endconfig|endfunction|" +
  16. "endgenerate|endmodule|endprimitive|endspecify|endtable|endtask|for|forever|function|generate|if|ifnone|" +
  17. "macromodule|module|primitive|repeat|specify|table|task|while";
  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 : "comment.start",
  35. regex : "/\\*",
  36. next : [
  37. { token : "comment.end", regex : "\\*/", next: "start" },
  38. { defaultToken : "comment" }
  39. ]
  40. }, {
  41. token : "string.start",
  42. regex : '"',
  43. next : [
  44. { token : "constant.language.escape", regex : /\\(?:[ntvfa\\"]|[0-7]{1,3}|\x[a-fA-F\d]{1,2}|)/, consumeLineEnd : true },
  45. { token : "string.end", regex : '"|$', next: "start" },
  46. { defaultToken : "string" }
  47. ]
  48. }, {
  49. token : "string",
  50. regex : "'^[']'"
  51. }, {
  52. token : "constant.numeric", // float
  53. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  54. }, {
  55. token : keywordMapper,
  56. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  57. }, {
  58. token : "keyword.operator",
  59. regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  60. }, {
  61. token : "paren.lparen",
  62. regex : "[\\(]"
  63. }, {
  64. token : "paren.rparen",
  65. regex : "[\\)]"
  66. }, {
  67. token : "text",
  68. regex : "\\s+"
  69. } ]
  70. };
  71. this.normalizeRules();
  72. };
  73. oop.inherits(VerilogHighlightRules, TextHighlightRules);
  74. exports.VerilogHighlightRules = VerilogHighlightRules;
  75. });
  76. ace.define("ace/mode/verilog",[], function(require, exports, module) {
  77. "use strict";
  78. var oop = require("../lib/oop");
  79. var TextMode = require("./text").Mode;
  80. var VerilogHighlightRules = require("./verilog_highlight_rules").VerilogHighlightRules;
  81. var Range = require("../range").Range;
  82. var Mode = function() {
  83. this.HighlightRules = VerilogHighlightRules;
  84. this.$behaviour = this.$defaultBehaviour;
  85. };
  86. oop.inherits(Mode, TextMode);
  87. (function() {
  88. this.lineCommentStart = "//";
  89. this.blockComment = {start: "/*", end: "*/"};
  90. this.$quotes = { '"': '"' };
  91. this.$id = "ace/mode/verilog";
  92. }).call(Mode.prototype);
  93. exports.Mode = Mode;
  94. });
  95. (function() {
  96. ace.require(["ace/mode/verilog"], function(m) {
  97. if (typeof module == "object" && typeof exports == "object" && module) {
  98. module.exports = m;
  99. }
  100. });
  101. })();