mode-lisp.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ace.define("ace/mode/lisp_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 LispHighlightRules = function() {
  6. var keywordControl = "case|do|let|loop|if|else|when";
  7. var keywordOperator = "eq|neq|and|or";
  8. var constantLanguage = "null|nil";
  9. var supportFunctions = "cons|car|cdr|cond|lambda|format|setq|setf|quote|eval|append|list|listp|memberp|t|load|progn";
  10. var keywordMapper = this.createKeywordMapper({
  11. "keyword.control": keywordControl,
  12. "keyword.operator": keywordOperator,
  13. "constant.language": constantLanguage,
  14. "support.function": supportFunctions
  15. }, "identifier", true);
  16. this.$rules =
  17. {
  18. "start": [
  19. {
  20. token : "comment",
  21. regex : ";.*$"
  22. },
  23. {
  24. token: ["storage.type.function-type.lisp", "text", "entity.name.function.lisp"],
  25. regex: "(?:\\b(?:(defun|defmethod|defmacro))\\b)(\\s+)((?:\\w|\\-|\\!|\\?)*)"
  26. },
  27. {
  28. token: ["punctuation.definition.constant.character.lisp", "constant.character.lisp"],
  29. regex: "(#)((?:\\w|[\\\\+-=<>'\"&#])+)"
  30. },
  31. {
  32. token: ["punctuation.definition.variable.lisp", "variable.other.global.lisp", "punctuation.definition.variable.lisp"],
  33. regex: "(\\*)(\\S*)(\\*)"
  34. },
  35. {
  36. token : "constant.numeric", // hex
  37. regex : "0[xX][0-9a-fA-F]+(?:L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  38. },
  39. {
  40. token : "constant.numeric", // float
  41. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(?:L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  42. },
  43. {
  44. token : keywordMapper,
  45. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  46. },
  47. {
  48. token : "string",
  49. regex : '"(?=.)',
  50. next : "qqstring"
  51. }
  52. ],
  53. "qqstring": [
  54. {
  55. token: "constant.character.escape.lisp",
  56. regex: "\\\\."
  57. },
  58. {
  59. token : "string",
  60. regex : '[^"\\\\]+'
  61. }, {
  62. token : "string",
  63. regex : "\\\\$",
  64. next : "qqstring"
  65. }, {
  66. token : "string",
  67. regex : '"|$',
  68. next : "start"
  69. }
  70. ]
  71. };
  72. };
  73. oop.inherits(LispHighlightRules, TextHighlightRules);
  74. exports.LispHighlightRules = LispHighlightRules;
  75. });
  76. ace.define("ace/mode/lisp",[], function(require, exports, module) {
  77. "use strict";
  78. var oop = require("../lib/oop");
  79. var TextMode = require("./text").Mode;
  80. var LispHighlightRules = require("./lisp_highlight_rules").LispHighlightRules;
  81. var Mode = function() {
  82. this.HighlightRules = LispHighlightRules;
  83. this.$behaviour = this.$defaultBehaviour;
  84. };
  85. oop.inherits(Mode, TextMode);
  86. (function() {
  87. this.lineCommentStart = ";";
  88. this.$id = "ace/mode/lisp";
  89. }).call(Mode.prototype);
  90. exports.Mode = Mode;
  91. });
  92. (function() {
  93. ace.require(["ace/mode/lisp"], function(m) {
  94. if (typeof module == "object" && typeof exports == "object" && module) {
  95. module.exports = m;
  96. }
  97. });
  98. })();