l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

makefile.js (2085B)


      1 /*
      2 Language: Makefile
      3 Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
      4 Contributors: Joël Porquet <joel@porquet.org>
      5 Website: https://www.gnu.org/software/make/manual/html_node/Introduction.html
      6 Category: common
      7 */
      8 
      9 function makefile(hljs) {
     10   /* Variables: simple (eg $(var)) and special (eg $@) */
     11   var 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   /* Quoted string with variables inside */
     24   var QUOTE_STRING = {
     25     className: 'string',
     26     begin: /"/, end: /"/,
     27     contains: [
     28       hljs.BACKSLASH_ESCAPE,
     29       VARIABLE,
     30     ]
     31   };
     32   /* Function: $(func arg,...) */
     33   var FUNC = {
     34     className: 'variable',
     35     begin: /\$\([\w-]+\s/, end: /\)/,
     36     keywords: {
     37       built_in:
     38         'subst patsubst strip findstring filter filter-out sort ' +
     39         'word wordlist firstword lastword dir notdir suffix basename ' +
     40         'addsuffix addprefix join wildcard realpath abspath error warning ' +
     41         'shell origin flavor foreach if or and call eval file value',
     42     },
     43     contains: [
     44       VARIABLE,
     45     ]
     46   };
     47   /* Variable assignment */
     48   var ASSIGNMENT = {
     49     begin: '^' + hljs.UNDERSCORE_IDENT_RE + '\\s*(?=[:+?]?=)'
     50   };
     51   /* Meta targets (.PHONY) */
     52   var META = {
     53     className: 'meta',
     54     begin: /^\.PHONY:/, end: /$/,
     55     keywords: {
     56       $pattern: /[\.\w]+/,
     57       'meta-keyword': '.PHONY'
     58     }
     59   };
     60   /* Targets */
     61   var TARGET = {
     62     className: 'section',
     63     begin: /^[^\s]+:/, end: /$/,
     64     contains: [VARIABLE,]
     65   };
     66   return {
     67     name: 'Makefile',
     68     aliases: ['mk', 'mak'],
     69     keywords: {
     70       $pattern: /[\w-]+/,
     71       keyword: 'define endef undefine ifdef ifndef ifeq ifneq else endif ' +
     72       'include -include sinclude override export unexport private vpath'
     73     },
     74     contains: [
     75       hljs.HASH_COMMENT_MODE,
     76       VARIABLE,
     77       QUOTE_STRING,
     78       FUNC,
     79       ASSIGNMENT,
     80       META,
     81       TARGET,
     82     ]
     83   };
     84 }
     85 
     86 module.exports = makefile;