Makefile: Use standard token names correctly (#3227)

This commit is contained in:
Michael Schmidt 2021-12-07 12:48:48 +01:00 committed by GitHub
parent b58cd7227f
commit 21a3c2d755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 313 additions and 112 deletions

View File

@ -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': /[:;(){}]/
};

View File

@ -1 +1 @@
Prism.languages.makefile={comment:{pattern:/(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,lookbehind:!0},string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},builtin:/\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,symbol:{pattern:/^(?:[^:=\s]|[ \t]+(?![\s:]))+(?=\s*:(?!=))/m,inside:{variable:/\$+(?:(?!\$)[^(){}:#=\s]+|(?=[({]))/}},variable:/\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,keyword:[/-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,{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:!0}],operator:/(?:::|[?:+!])?=|[|@]/,punctuation:/[:;(){}]/};
Prism.languages.makefile={comment:{pattern:/(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,lookbehind:!0},string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"builtin-target":{pattern:/\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,alias:"builtin"},target:{pattern:/^(?:[^:=\s]|[ \t]+(?![\s:]))+(?=\s*:(?!=))/m,alias:"symbol",inside:{variable:/\$+(?:(?!\$)[^(){}:#=\s]+|(?=[({]))/}},variable:/\$+(?:(?!\$)[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,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:!0},operator:/(?:::|[?:+!])?=|[|@]/,punctuation:/[:;(){}]/};

View File

@ -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.

View File

@ -1,15 +0,0 @@
.PHONY:
.DELETE_ON_ERROR:
.SECONDEXPANSION:
----------------------------------------------------
[
["builtin", ".PHONY"], ["punctuation", ":"],
["builtin", ".DELETE_ON_ERROR"], ["punctuation", ":"],
["builtin", ".SECONDEXPANSION"], ["punctuation", ":"]
]
----------------------------------------------------
Checks for built-in target names.

View File

@ -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", ")"]
]

View File

@ -1,73 +1,43 @@
define else endef endif
export ifdef ifndef ifeq
ifneq -include include
override private sinclude
undefine unexport vpath
(addsuffix foo) (abspath 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) (words foo) (wordlist foo)
-include
define
else
endef
endif
export
ifdef
ifeq
ifndef
ifneq
include
override
private
sinclude
undefine
unexport
vpath
----------------------------------------------------
[
["keyword", "define"], ["keyword", "else"], ["keyword", "endef"], ["keyword", "endif"],
["keyword", "export"], ["keyword", "ifdef"], ["keyword", "ifndef"], ["keyword", "ifeq"],
["keyword", "ifneq"], ["keyword", "-include"], ["keyword", "include"],
["keyword", "override"], ["keyword", "private"], ["keyword", "sinclude"],
["keyword", "undefine"], ["keyword", "unexport"], ["keyword", "vpath"],
["punctuation", "("], ["keyword", "addsuffix"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "abspath"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "and"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "basename"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "call"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "dir"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "error"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "eval"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "file"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "filter"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "filter-out"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "findstring"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "firstword"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "flavor"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "foreach"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "guile"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "if"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "info"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "join"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "lastword"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "load"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "notdir"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "or"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "origin"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "patsubst"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "realpath"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "shell"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "sort"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "strip"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "subst"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "suffix"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "value"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "warning"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "wildcard"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "word"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "words"], " foo", ["punctuation", ")"],
["punctuation", "("], ["keyword", "wordlist"], " foo", ["punctuation", ")"]
["keyword", "-include"],
["keyword", "define"],
["keyword", "else"],
["keyword", "endef"],
["keyword", "endif"],
["keyword", "export"],
["keyword", "ifdef"],
["keyword", "ifeq"],
["keyword", "ifndef"],
["keyword", "ifneq"],
["keyword", "include"],
["keyword", "override"],
["keyword", "private"],
["keyword", "sinclude"],
["keyword", "undefine"],
["keyword", "unexport"],
["keyword", "vpath"]
]
----------------------------------------------------
Checks for keywords and functions.
Checks for keywords.

View File

@ -1,18 +0,0 @@
edit :
%oo:
$(foo):
----------------------------------------------------
[
["symbol", ["edit"]], ["punctuation", ":"],
["symbol", ["%oo"]], ["punctuation", ":"],
["symbol", [
["variable", "$"],
"(foo)"
]], ["punctuation", ":"]
]
----------------------------------------------------
Checks for targets, optionally containing interpolation.

View File

@ -0,0 +1,23 @@
edit :
%oo:
$(foo):
----------------------------------------------------
[
["target", ["edit"]],
["punctuation", ":"],
["target", ["%oo"]],
["punctuation", ":"],
["target", [
["variable", "$"],
"(foo)"
]],
["punctuation", ":"]
]
----------------------------------------------------
Checks for targets, optionally containing interpolation.