makefile_highlight_rules.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. define(function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var ShHighlightFile = require("./sh_highlight_rules");
  6. var MakefileHighlightRules = function() {
  7. // regexp must not have capturing parentheses. Use (?:) instead.
  8. // regexps are ordered -> the first match is used
  9. var keywordMapper = this.createKeywordMapper({
  10. "keyword": ShHighlightFile.reservedKeywords,
  11. "support.function.builtin": ShHighlightFile.languageConstructs,
  12. "invalid.deprecated": "debugger"
  13. }, "string");
  14. this.$rules =
  15. {
  16. "start": [
  17. {
  18. token: "string.interpolated.backtick.makefile",
  19. regex: "`",
  20. next: "shell-start"
  21. },
  22. {
  23. token: "punctuation.definition.comment.makefile",
  24. regex: /#(?=.)/,
  25. next: "comment"
  26. },
  27. {
  28. token: [ "keyword.control.makefile"],
  29. regex: "^(?:\\s*\\b)(\\-??include|ifeq|ifneq|ifdef|ifndef|else|endif|vpath|export|unexport|define|endef|override)(?:\\b)"
  30. },
  31. {// ^([^\t ]+(\s[^\t ]+)*:(?!\=))\s*.*
  32. token: ["entity.name.function.makefile", "text"],
  33. regex: "^([^\\t ]+(?:\\s[^\\t ]+)*:)(\\s*.*)"
  34. }
  35. ],
  36. "comment": [
  37. {
  38. token : "punctuation.definition.comment.makefile",
  39. regex : /.+\\/
  40. },
  41. {
  42. token : "punctuation.definition.comment.makefile",
  43. regex : ".+",
  44. next : "start"
  45. }
  46. ],
  47. "shell-start": [
  48. {
  49. token: keywordMapper,
  50. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  51. },
  52. {
  53. token: "string",
  54. regex : "\\w+"
  55. },
  56. {
  57. token : "string.interpolated.backtick.makefile",
  58. regex : "`",
  59. next : "start"
  60. }
  61. ]
  62. }
  63. };
  64. oop.inherits(MakefileHighlightRules, TextHighlightRules);
  65. exports.MakefileHighlightRules = MakefileHighlightRules;
  66. });