]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/makefile.js
Initial commit.
[flow-web.git] / static / highlight / languages / makefile.js
1 /*! `makefile` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Makefile
8 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
9 Contributors: Joël Porquet <joel@porquet.org>
10 Website: https://www.gnu.org/software/make/manual/html_node/Introduction.html
11 Category: common, build-system
12 */
13
14 function makefile(hljs) {
15 /* Variables: simple (eg $(var)) and special (eg $@) */
16 const VARIABLE = {
17 className: 'variable',
18 variants: [
19 {
20 begin: '\\$\\(' + hljs.UNDERSCORE_IDENT_RE + '\\)',
21 contains: [ hljs.BACKSLASH_ESCAPE ]
22 },
23 { begin: /\$[@%<?\^\+\*]/ }
24 ]
25 };
26 /* Quoted string with variables inside */
27 const QUOTE_STRING = {
28 className: 'string',
29 begin: /"/,
30 end: /"/,
31 contains: [
32 hljs.BACKSLASH_ESCAPE,
33 VARIABLE
34 ]
35 };
36 /* Function: $(func arg,...) */
37 const FUNC = {
38 className: 'variable',
39 begin: /\$\([\w-]+\s/,
40 end: /\)/,
41 keywords: { built_in:
42 'subst patsubst strip findstring filter filter-out sort '
43 + 'word wordlist firstword lastword dir notdir suffix basename '
44 + 'addsuffix addprefix join wildcard realpath abspath error warning '
45 + 'shell origin flavor foreach if or and call eval file value' },
46 contains: [
47 VARIABLE,
48 QUOTE_STRING // Added QUOTE_STRING as they can be a part of functions
49 ]
50 };
51 /* Variable assignment */
52 const ASSIGNMENT = { begin: '^' + hljs.UNDERSCORE_IDENT_RE + '\\s*(?=[:+?]?=)' };
53 /* Meta targets (.PHONY) */
54 const META = {
55 className: 'meta',
56 begin: /^\.PHONY:/,
57 end: /$/,
58 keywords: {
59 $pattern: /[\.\w]+/,
60 keyword: '.PHONY'
61 }
62 };
63 /* Targets */
64 const TARGET = {
65 className: 'section',
66 begin: /^[^\s]+:/,
67 end: /$/,
68 contains: [ VARIABLE ]
69 };
70 return {
71 name: 'Makefile',
72 aliases: [
73 'mk',
74 'mak',
75 'make',
76 ],
77 keywords: {
78 $pattern: /[\w-]+/,
79 keyword: 'define endef undefine ifdef ifndef ifeq ifneq else endif '
80 + 'include -include sinclude override export unexport private vpath'
81 },
82 contains: [
83 hljs.HASH_COMMENT_MODE,
84 VARIABLE,
85 QUOTE_STRING,
86 FUNC,
87 ASSIGNMENT,
88 META,
89 TARGET
90 ]
91 };
92 }
93
94 return makefile;
95
96 })();
97
98 hljs.registerLanguage('makefile', hljsGrammar);
99 })();