makefile.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. module.exports = function(hljs) {
  2. /* Variables: simple (eg $(var)) and special (eg $@) */
  3. var VARIABLE = {
  4. className: 'variable',
  5. variants: [
  6. {
  7. begin: '\\$\\(' + hljs.UNDERSCORE_IDENT_RE + '\\)',
  8. contains: [hljs.BACKSLASH_ESCAPE],
  9. },
  10. {
  11. begin: /\$[@%<?\^\+\*]/
  12. },
  13. ]
  14. };
  15. /* Quoted string with variables inside */
  16. var QUOTE_STRING = {
  17. className: 'string',
  18. begin: /"/, end: /"/,
  19. contains: [
  20. hljs.BACKSLASH_ESCAPE,
  21. VARIABLE,
  22. ]
  23. };
  24. /* Function: $(func arg,...) */
  25. var FUNC = {
  26. className: 'variable',
  27. begin: /\$\([\w-]+\s/, end: /\)/,
  28. keywords: {
  29. built_in:
  30. 'subst patsubst strip findstring filter filter-out sort ' +
  31. 'word wordlist firstword lastword dir notdir suffix basename ' +
  32. 'addsuffix addprefix join wildcard realpath abspath error warning ' +
  33. 'shell origin flavor foreach if or and call eval file value',
  34. },
  35. contains: [
  36. VARIABLE,
  37. ]
  38. };
  39. /* Variable assignment */
  40. var ASSIGNMENT = {
  41. begin: '^' + hljs.UNDERSCORE_IDENT_RE + '\\s*(?=[:+?]?=)'
  42. };
  43. /* Meta targets (.PHONY) */
  44. var META = {
  45. className: 'meta',
  46. begin: /^\.PHONY:/, end: /$/,
  47. keywords: {'meta-keyword': '.PHONY'},
  48. lexemes: /[\.\w]+/
  49. };
  50. /* Targets */
  51. var TARGET = {
  52. className: 'section',
  53. begin: /^[^\s]+:/, end: /$/,
  54. contains: [VARIABLE,]
  55. };
  56. return {
  57. aliases: ['mk', 'mak'],
  58. keywords:
  59. 'define endef undefine ifdef ifndef ifeq ifneq else endif ' +
  60. 'include -include sinclude override export unexport private vpath',
  61. lexemes: /[\w-]+/,
  62. contains: [
  63. hljs.HASH_COMMENT_MODE,
  64. VARIABLE,
  65. QUOTE_STRING,
  66. FUNC,
  67. ASSIGNMENT,
  68. META,
  69. TARGET,
  70. ]
  71. };
  72. };