1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function makefile(hljs) {
|
10 |
|
11 | const VARIABLE = {
|
12 | className: 'variable',
|
13 | variants: [
|
14 | {
|
15 | begin: '\\$\\(' + hljs.UNDERSCORE_IDENT_RE + '\\)',
|
16 | contains: [ hljs.BACKSLASH_ESCAPE ]
|
17 | },
|
18 | {
|
19 | begin: /\$[@%<?\^\+\*]/
|
20 | }
|
21 | ]
|
22 | };
|
23 |
|
24 | const QUOTE_STRING = {
|
25 | className: 'string',
|
26 | begin: /"/,
|
27 | end: /"/,
|
28 | contains: [
|
29 | hljs.BACKSLASH_ESCAPE,
|
30 | VARIABLE
|
31 | ]
|
32 | };
|
33 |
|
34 | const FUNC = {
|
35 | className: 'variable',
|
36 | begin: /\$\([\w-]+\s/,
|
37 | end: /\)/,
|
38 | keywords: {
|
39 | built_in:
|
40 | 'subst patsubst strip findstring filter filter-out sort ' +
|
41 | 'word wordlist firstword lastword dir notdir suffix basename ' +
|
42 | 'addsuffix addprefix join wildcard realpath abspath error warning ' +
|
43 | 'shell origin flavor foreach if or and call eval file value'
|
44 | },
|
45 | contains: [ VARIABLE ]
|
46 | };
|
47 |
|
48 | const ASSIGNMENT = {
|
49 | begin: '^' + hljs.UNDERSCORE_IDENT_RE + '\\s*(?=[:+?]?=)'
|
50 | };
|
51 |
|
52 | const META = {
|
53 | className: 'meta',
|
54 | begin: /^\.PHONY:/,
|
55 | end: /$/,
|
56 | keywords: {
|
57 | $pattern: /[\.\w]+/,
|
58 | keyword: '.PHONY'
|
59 | }
|
60 | };
|
61 |
|
62 | const TARGET = {
|
63 | className: 'section',
|
64 | begin: /^[^\s]+:/,
|
65 | end: /$/,
|
66 | contains: [ VARIABLE ]
|
67 | };
|
68 | return {
|
69 | name: 'Makefile',
|
70 | aliases: [
|
71 | 'mk',
|
72 | 'mak',
|
73 | 'make',
|
74 | ],
|
75 | keywords: {
|
76 | $pattern: /[\w-]+/,
|
77 | keyword: 'define endef undefine ifdef ifndef ifeq ifneq else endif ' +
|
78 | 'include -include sinclude override export unexport private vpath'
|
79 | },
|
80 | contains: [
|
81 | hljs.HASH_COMMENT_MODE,
|
82 | VARIABLE,
|
83 | QUOTE_STRING,
|
84 | FUNC,
|
85 | ASSIGNMENT,
|
86 | META,
|
87 | TARGET
|
88 | ]
|
89 | };
|
90 | }
|
91 |
|
92 | export { makefile as default };
|