makefile.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 VAR_ASSIG = {
  41. begin: '^' + hljs.UNDERSCORE_IDENT_RE + '\\s*[:+?]?=',
  42. illegal: '\\n',
  43. returnBegin: true,
  44. contains: [
  45. {
  46. begin: '^' + hljs.UNDERSCORE_IDENT_RE, end: '[:+?]?=',
  47. excludeEnd: true,
  48. }
  49. ]
  50. };
  51. /* Meta targets (.PHONY) */
  52. var META = {
  53. className: 'meta',
  54. begin: /^\.PHONY:/, end: /$/,
  55. keywords: {'meta-keyword': '.PHONY'},
  56. lexemes: /[\.\w]+/
  57. };
  58. /* Targets */
  59. var TARGET = {
  60. className: 'section',
  61. begin: /^[^\s]+:/, end: /$/,
  62. contains: [VARIABLE,]
  63. };
  64. return {
  65. aliases: ['mk', 'mak'],
  66. keywords:
  67. 'define endef undefine ifdef ifndef ifeq ifneq else endif ' +
  68. 'include -include sinclude override export unexport private vpath',
  69. lexemes: /[\w-]+/,
  70. contains: [
  71. hljs.HASH_COMMENT_MODE,
  72. VARIABLE,
  73. QUOTE_STRING,
  74. FUNC,
  75. VAR_ASSIG,
  76. META,
  77. TARGET,
  78. ]
  79. };
  80. };