Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: Use standard token names correctly #3227

Merged
merged 1 commit into from Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions components/prism-makefile.js
Expand Up @@ -8,27 +8,27 @@ Prism.languages.makefile = {
greedy: true
},

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

// Targets
'symbol': {
'target': {
pattern: /^(?:[^:=\s]|[ \t]+(?![\s:]))+(?=\s*:(?!=))/m,
alias: 'symbol',
inside: {
'variable': /\$+(?:(?!\$)[^(){}:#=\s]+|(?=[({]))/
}
},
'variable': /\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,

'keyword': [
// Directives
/-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,
// Functions
{
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])/,
lookbehind: true
}
],
// Directives
'keyword': /-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,

'function': {
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])/,
lookbehind: true
},
'operator': /(?:::|[?:+!])?=|[|@]/,
'punctuation': /[:;(){}]/
};
2 changes: 1 addition & 1 deletion components/prism-makefile.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/languages/makefile/builtin-target_feature.test
@@ -0,0 +1,15 @@
.PHONY:
.DELETE_ON_ERROR:
.SECONDEXPANSION:

----------------------------------------------------

[
["builtin-target", ".PHONY"], ["punctuation", ":"],
["builtin-target", ".DELETE_ON_ERROR"], ["punctuation", ":"],
["builtin-target", ".SECONDEXPANSION"], ["punctuation", ":"]
]

----------------------------------------------------

Checks for built-in target names.
15 changes: 0 additions & 15 deletions tests/languages/makefile/builtin_feature.test

This file was deleted.

226 changes: 226 additions & 0 deletions tests/languages/makefile/function_feature.test
@@ -0,0 +1,226 @@
(abspath foo)
(addsuffix foo)
(and foo)
(basename foo)
(call foo)
(dir foo)
(error foo)
(eval foo)
(file foo)
(filter foo)
(filter-out foo)
(findstring foo)
(firstword foo)
(flavor foo)
(foreach foo)
(guile foo)
(if foo)
(info foo)
(join foo)
(lastword foo)
(load foo)
(notdir foo)
(or foo)
(origin foo)
(patsubst foo)
(realpath foo)
(shell foo)
(sort foo)
(strip foo)
(subst foo)
(suffix foo)
(value foo)
(warning foo)
(wildcard foo)
(word foo)
(wordlist foo)
(words foo)

----------------------------------------------------

[
["punctuation", "("],
["function", "abspath"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "addsuffix"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "and"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "basename"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "call"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "dir"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "error"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "eval"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "file"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "filter"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "filter-out"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "findstring"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "firstword"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "flavor"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "foreach"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "guile"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "if"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "info"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "join"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "lastword"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "load"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "notdir"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "or"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "origin"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "patsubst"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "realpath"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "shell"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "sort"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "strip"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "subst"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "suffix"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "value"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "warning"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "wildcard"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "word"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "wordlist"],
" foo",
["punctuation", ")"],

["punctuation", "("],
["function", "words"],
" foo",
["punctuation", ")"]
]