Skip to content

Commit 21a3c2d

Browse files
authoredDec 7, 2021
Makefile: Use standard token names correctly (#3227)
1 parent b58cd72 commit 21a3c2d

8 files changed

+313
-112
lines changed
 

‎components/prism-makefile.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ Prism.languages.makefile = {
88
greedy: true
99
},
1010

11-
// Built-in target names
12-
'builtin': /\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,
11+
'builtin-target': {
12+
pattern: /\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,
13+
alias: 'builtin'
14+
},
1315

14-
// Targets
15-
'symbol': {
16+
'target': {
1617
pattern: /^(?:[^:=\s]|[ \t]+(?![\s:]))+(?=\s*:(?!=))/m,
18+
alias: 'symbol',
1719
inside: {
1820
'variable': /\$+(?:(?!\$)[^(){}:#=\s]+|(?=[({]))/
1921
}
2022
},
2123
'variable': /\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,
2224

23-
'keyword': [
24-
// Directives
25-
/-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,
26-
// Functions
27-
{
28-
pattern: /(\()(?:abspath|addsuffix|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:list|s)?)(?=[ \t])/,
29-
lookbehind: true
30-
}
31-
],
25+
// Directives
26+
'keyword': /-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,
27+
28+
'function': {
29+
pattern: /(\()(?:abspath|addsuffix|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:list|s)?)(?=[ \t])/,
30+
lookbehind: true
31+
},
3232
'operator': /(?:::|[?:+!])?=|[|@]/,
3333
'punctuation': /[:;(){}]/
3434
};

‎components/prism-makefile.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.PHONY:
2+
.DELETE_ON_ERROR:
3+
.SECONDEXPANSION:
4+
5+
----------------------------------------------------
6+
7+
[
8+
["builtin-target", ".PHONY"], ["punctuation", ":"],
9+
["builtin-target", ".DELETE_ON_ERROR"], ["punctuation", ":"],
10+
["builtin-target", ".SECONDEXPANSION"], ["punctuation", ":"]
11+
]
12+
13+
----------------------------------------------------
14+
15+
Checks for built-in target names.

‎tests/languages/makefile/builtin_feature.test

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
(abspath foo)
2+
(addsuffix foo)
3+
(and foo)
4+
(basename foo)
5+
(call foo)
6+
(dir foo)
7+
(error foo)
8+
(eval foo)
9+
(file foo)
10+
(filter foo)
11+
(filter-out foo)
12+
(findstring foo)
13+
(firstword foo)
14+
(flavor foo)
15+
(foreach foo)
16+
(guile foo)
17+
(if foo)
18+
(info foo)
19+
(join foo)
20+
(lastword foo)
21+
(load foo)
22+
(notdir foo)
23+
(or foo)
24+
(origin foo)
25+
(patsubst foo)
26+
(realpath foo)
27+
(shell foo)
28+
(sort foo)
29+
(strip foo)
30+
(subst foo)
31+
(suffix foo)
32+
(value foo)
33+
(warning foo)
34+
(wildcard foo)
35+
(word foo)
36+
(wordlist foo)
37+
(words foo)
38+
39+
----------------------------------------------------
40+
41+
[
42+
["punctuation", "("],
43+
["function", "abspath"],
44+
" foo",
45+
["punctuation", ")"],
46+
47+
["punctuation", "("],
48+
["function", "addsuffix"],
49+
" foo",
50+
["punctuation", ")"],
51+
52+
["punctuation", "("],
53+
["function", "and"],
54+
" foo",
55+
["punctuation", ")"],
56+
57+
["punctuation", "("],
58+
["function", "basename"],
59+
" foo",
60+
["punctuation", ")"],
61+
62+
["punctuation", "("],
63+
["function", "call"],
64+
" foo",
65+
["punctuation", ")"],
66+
67+
["punctuation", "("],
68+
["function", "dir"],
69+
" foo",
70+
["punctuation", ")"],
71+
72+
["punctuation", "("],
73+
["function", "error"],
74+
" foo",
75+
["punctuation", ")"],
76+
77+
["punctuation", "("],
78+
["function", "eval"],
79+
" foo",
80+
["punctuation", ")"],
81+
82+
["punctuation", "("],
83+
["function", "file"],
84+
" foo",
85+
["punctuation", ")"],
86+
87+
["punctuation", "("],
88+
["function", "filter"],
89+
" foo",
90+
["punctuation", ")"],
91+
92+
["punctuation", "("],
93+
["function", "filter-out"],
94+
" foo",
95+
["punctuation", ")"],
96+
97+
["punctuation", "("],
98+
["function", "findstring"],
99+
" foo",
100+
["punctuation", ")"],
101+
102+
["punctuation", "("],
103+
["function", "firstword"],
104+
" foo",
105+
["punctuation", ")"],
106+
107+
["punctuation", "("],
108+
["function", "flavor"],
109+
" foo",
110+
["punctuation", ")"],
111+
112+
["punctuation", "("],
113+
["function", "foreach"],
114+
" foo",
115+
["punctuation", ")"],
116+
117+
["punctuation", "("],
118+
["function", "guile"],
119+
" foo",
120+
["punctuation", ")"],
121+
122+
["punctuation", "("],
123+
["function", "if"],
124+
" foo",
125+
["punctuation", ")"],
126+
127+
["punctuation", "("],
128+
["function", "info"],
129+
" foo",
130+
["punctuation", ")"],
131+
132+
["punctuation", "("],
133+
["function", "join"],
134+
" foo",
135+
["punctuation", ")"],
136+
137+
["punctuation", "("],
138+
["function", "lastword"],
139+
" foo",
140+
["punctuation", ")"],
141+
142+
["punctuation", "("],
143+
["function", "load"],
144+
" foo",
145+
["punctuation", ")"],
146+
147+
["punctuation", "("],
148+
["function", "notdir"],
149+
" foo",
150+
["punctuation", ")"],
151+
152+
["punctuation", "("],
153+
["function", "or"],
154+
" foo",
155+
["punctuation", ")"],
156+
157+
["punctuation", "("],
158+
["function", "origin"],
159+
" foo",
160+
["punctuation", ")"],
161+
162+
["punctuation", "("],
163+
["function", "patsubst"],
164+
" foo",
165+
["punctuation", ")"],
166+
167+
["punctuation", "("],
168+
["function", "realpath"],
169+
" foo",
170+
["punctuation", ")"],
171+
172+
["punctuation", "("],
173+
["function", "shell"],
174+
" foo",
175+
["punctuation", ")"],
176+
177+
["punctuation", "("],
178+
["function", "sort"],
179+
" foo",
180+
["punctuation", ")"],
181+
182+
["punctuation", "("],
183+
["function", "strip"],
184+
" foo",
185+
["punctuation", ")"],
186+
187+
["punctuation", "("],
188+
["function", "subst"],
189+
" foo",
190+
["punctuation", ")"],
191+
192+
["punctuation", "("],
193+
["function", "suffix"],
194+
" foo",
195+
["punctuation", ")"],
196+
197+
["punctuation", "("],
198+
["function", "value"],
199+
" foo",
200+
["punctuation", ")"],
201+
202+
["punctuation", "("],
203+
["function", "warning"],
204+
" foo",
205+
["punctuation", ")"],
206+
207+
["punctuation", "("],
208+
["function", "wildcard"],
209+
" foo",
210+
["punctuation", ")"],
211+
212+
["punctuation", "("],
213+
["function", "word"],
214+
" foo",
215+
["punctuation", ")"],
216+
217+
["punctuation", "("],
218+
["function", "wordlist"],
219+
" foo",
220+
["punctuation", ")"],
221+
222+
["punctuation", "("],
223+
["function", "words"],
224+
" foo",
225+
["punctuation", ")"]
226+
]

0 commit comments

Comments
 (0)
Please sign in to comment.