mirror of https://github.com/Wilfred/difftastic/
Use tree-sitter-make from crates.io
parent
8bf5b90a7b
commit
dda64336e6
@ -1 +0,0 @@
|
||||
../tree-sitter-make/queries/highlights.scm
|
||||
@ -1 +0,0 @@
|
||||
tree-sitter-make/src
|
||||
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Alexandre A. Muller
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@ -1,14 +0,0 @@
|
||||
# tree-sitter-make
|
||||
Tree-sitter-make is a Make parser intended to be used for syntax highlighting.
|
||||
|
||||
## Missing features
|
||||
- [ ] Support to custom .RECIPEPREFIX
|
||||
- [ ] Load directive
|
||||
|
||||
This parser uses GNUMakefile documentation as reference. Others makefile formats
|
||||
might have features not implemented by this grammar. Feel free to open an issue
|
||||
with a feature request or do a pull request to extend this grammar to support
|
||||
other makefiles formats.
|
||||
|
||||
## Reference
|
||||
* [GNU Make manual](https://www.gnu.org/software/make/manual/html_node/index.html)
|
||||
@ -1,622 +0,0 @@
|
||||
const CHARSET = 'a-zA-Z0-9%\\+\\-\\.@_\\*\\?\\/';
|
||||
const ESCAPE_SET = 'abtnvfrE!"#\\$&\'\\(\\)\\*,;<>\\?\\[\\\\\\]^`{\\|}~'
|
||||
|
||||
const NL = token.immediate(/[\r\n]+/);
|
||||
const WS = token.immediate(/[\t ]+/);
|
||||
const SPLIT = alias(token.immediate(seq('\\', /\r?\n|\r/)), '\\');
|
||||
|
||||
const AUTOMATIC_VARS = [ '@', '%', '<', '?', '^', '+', '/', '*' ];
|
||||
|
||||
const DEFINE_OPS = ['=', ':=', '::=', '?=', '+='];
|
||||
|
||||
const FUNCTIONS = [
|
||||
'subst',
|
||||
'patsubst',
|
||||
'strip',
|
||||
'findstring',
|
||||
'filter',
|
||||
'filter-out',
|
||||
'sort',
|
||||
'word',
|
||||
'words',
|
||||
'wordlist',
|
||||
'firstword',
|
||||
'lastword',
|
||||
'dir',
|
||||
'notdir',
|
||||
'suffix',
|
||||
'basename',
|
||||
'addsuffix',
|
||||
'addprefix',
|
||||
'join',
|
||||
'wildcard',
|
||||
'realpath',
|
||||
'abspath',
|
||||
'error',
|
||||
'warning',
|
||||
'info',
|
||||
'origin',
|
||||
'flavor',
|
||||
'foreach',
|
||||
'if',
|
||||
'or',
|
||||
'and',
|
||||
'call',
|
||||
'eval',
|
||||
'file',
|
||||
'value',
|
||||
];
|
||||
|
||||
module.exports = grammar({
|
||||
name: 'make',
|
||||
|
||||
word: $ => $.word,
|
||||
|
||||
inline: $ => [
|
||||
$._targets,
|
||||
$._target_pattern,
|
||||
$._prerequisites_pattern,
|
||||
$._prerequisites,
|
||||
$._order_only_prerequisites,
|
||||
$._target_or_pattern_assignment,
|
||||
|
||||
$._primary,
|
||||
$._name,
|
||||
$._string,
|
||||
],
|
||||
|
||||
extras: $ => [
|
||||
/[\s]/,
|
||||
alias(token(seq('\\',/\r?\n|\r/)), '\\'),
|
||||
$.comment
|
||||
],
|
||||
|
||||
conflicts: $ => [],
|
||||
|
||||
precedences: $ => [],
|
||||
|
||||
rules: {
|
||||
|
||||
// 3.1
|
||||
makefile: $ => repeat($._thing),
|
||||
|
||||
_thing: $ => choice(
|
||||
$.rule,
|
||||
$._variable_definition,
|
||||
$._directive,
|
||||
seq($._function, NL)
|
||||
),
|
||||
|
||||
// Rules {{{
|
||||
// 2.1
|
||||
rule: $ => choice(
|
||||
$._ordinary_rule,
|
||||
$._static_pattern_rule,
|
||||
),
|
||||
|
||||
_ordinary_rule: $ => prec.right(seq(
|
||||
$._targets,
|
||||
choice(':', '&:', '::'),
|
||||
optional(WS),
|
||||
optional($._prerequisites),
|
||||
choice(
|
||||
$.recipe,
|
||||
NL
|
||||
)
|
||||
)),
|
||||
|
||||
// 4.12.1
|
||||
_static_pattern_rule: $ => prec.right(seq(
|
||||
$._targets,
|
||||
':',
|
||||
optional(WS),
|
||||
$._target_pattern,
|
||||
':',
|
||||
optional(WS),
|
||||
optional($._prerequisites_pattern),
|
||||
choice(
|
||||
$.recipe,
|
||||
NL
|
||||
)
|
||||
)),
|
||||
|
||||
_targets: $ => alias($.list, $.targets),
|
||||
|
||||
// LINT: List shall have length one
|
||||
_target_pattern: $ => field(
|
||||
'target',
|
||||
alias($.list, $.pattern_list)
|
||||
),
|
||||
|
||||
// 4.3
|
||||
_prerequisites: $ => choice(
|
||||
$._normal_prerequisites,
|
||||
seq(
|
||||
optional($._normal_prerequisites),
|
||||
'|',
|
||||
$._order_only_prerequisites
|
||||
),
|
||||
),
|
||||
|
||||
_normal_prerequisites: $ => field(
|
||||
'normal',
|
||||
alias($.list, $.prerequisites),
|
||||
),
|
||||
|
||||
_order_only_prerequisites: $ => field(
|
||||
'order_only',
|
||||
alias($.list, $.prerequisites)
|
||||
),
|
||||
|
||||
_prerequisites_pattern: $ => field(
|
||||
'prerequisite',
|
||||
alias($.list, $.pattern_list)
|
||||
),
|
||||
|
||||
recipe: $ => prec.right(choice(
|
||||
// the first recipe line may be attached to the
|
||||
// target-and-prerequisites line with a semicolon
|
||||
// in between
|
||||
seq(
|
||||
$._attached_recipe_line,
|
||||
NL,
|
||||
repeat(choice(
|
||||
$.conditional,
|
||||
$._prefixed_recipe_line,
|
||||
))
|
||||
),
|
||||
seq(
|
||||
NL,
|
||||
repeat1(choice(
|
||||
$.conditional,
|
||||
$._prefixed_recipe_line
|
||||
))
|
||||
),
|
||||
)),
|
||||
|
||||
_attached_recipe_line: $ => seq(
|
||||
';',
|
||||
optional($.recipe_line)
|
||||
),
|
||||
|
||||
_prefixed_recipe_line: $ => seq(
|
||||
$._recipeprefix,
|
||||
optional($.recipe_line),
|
||||
NL
|
||||
),
|
||||
|
||||
recipe_line: $ => seq(
|
||||
optional(choice(
|
||||
...['@', '-', '+'].map(c => token(prec(1,c)))
|
||||
)),
|
||||
optional(seq(
|
||||
alias($.shell_text_with_split, $.shell_text),
|
||||
repeat(seq(
|
||||
// splited recipe lines may start with .RECIPEPREFIX
|
||||
// that shall not be part of the shell_code
|
||||
optional($._recipeprefix),
|
||||
alias($.shell_text_with_split, $.shell_text),
|
||||
)),
|
||||
optional($._recipeprefix),
|
||||
)),
|
||||
alias($._shell_text_without_split, $.shell_text),
|
||||
),
|
||||
// }}}
|
||||
// Variables {{{
|
||||
_variable_definition: $ => choice(
|
||||
$.VPATH_assignment,
|
||||
$.RECIPEPREFIX_assignment,
|
||||
$.variable_assignment,
|
||||
$.shell_assignment,
|
||||
$.define_directive
|
||||
),
|
||||
|
||||
// 4.5.1
|
||||
VPATH_assignment: $ => seq(
|
||||
field('name','VPATH'),
|
||||
optional(WS),
|
||||
field('operator',choice(...DEFINE_OPS)),
|
||||
field('value',$.paths),
|
||||
NL
|
||||
),
|
||||
|
||||
RECIPEPREFIX_assignment: $ => seq(
|
||||
field('name','.RECIPEPREFIX'),
|
||||
optional(WS),
|
||||
field('operator',choice(...DEFINE_OPS)),
|
||||
field('value', $.text),
|
||||
NL
|
||||
),
|
||||
|
||||
// 6.5
|
||||
variable_assignment: $ => seq(
|
||||
optional($._target_or_pattern_assignment),
|
||||
$._name,
|
||||
optional(WS),
|
||||
field('operator',choice(...DEFINE_OPS)),
|
||||
optional(WS),
|
||||
optional(field('value', $.text)),
|
||||
NL
|
||||
),
|
||||
|
||||
_target_or_pattern_assignment: $ => seq(
|
||||
field('target_or_pattern', $.list),
|
||||
':',
|
||||
optional(WS),
|
||||
),
|
||||
|
||||
shell_assignment: $ => seq(
|
||||
field('name',$.word),
|
||||
optional(WS),
|
||||
field('operator','!='),
|
||||
optional(WS),
|
||||
field('value',$._shell_command),
|
||||
NL
|
||||
),
|
||||
|
||||
define_directive: $ => seq(
|
||||
'define',
|
||||
field('name',$.word),
|
||||
optional(WS),
|
||||
optional(field('operator',choice(...DEFINE_OPS))),
|
||||
optional(WS),
|
||||
NL,
|
||||
optional(field('value',
|
||||
alias(repeat1($._rawline), $.raw_text)
|
||||
)),
|
||||
token(prec(1,'endef')),
|
||||
NL
|
||||
),
|
||||
// }}}
|
||||
// Directives {{{
|
||||
_directive: $ => choice(
|
||||
$.include_directive,
|
||||
$.vpath_directive,
|
||||
$.export_directive,
|
||||
$.unexport_directive,
|
||||
$.override_directive,
|
||||
$.undefine_directive,
|
||||
$.private_directive,
|
||||
$.conditional
|
||||
),
|
||||
|
||||
// 3.3
|
||||
include_directive: $ => choice(
|
||||
seq( 'include', field('filenames',$.list), NL),
|
||||
seq('sinclude', field('filenames',$.list), NL),
|
||||
seq('-include', field('filenames',$.list), NL),
|
||||
),
|
||||
|
||||
// 4.5.2
|
||||
vpath_directive: $ => choice(
|
||||
seq('vpath', NL),
|
||||
seq('vpath', field('pattern', $.word), NL),
|
||||
seq('vpath', field('pattern', $.word), field('directories', $.paths), NL)
|
||||
),
|
||||
|
||||
// 5.7.2
|
||||
export_directive: $ => choice(
|
||||
seq('export', NL),
|
||||
seq('export', field('variables', $.list), NL),
|
||||
seq('export', $.variable_assignment)
|
||||
),
|
||||
|
||||
// 5.7.2
|
||||
unexport_directive: $ => choice(
|
||||
seq('unexport', NL),
|
||||
seq('unexport', field('variables', $.list), NL),
|
||||
),
|
||||
|
||||
// 6.7
|
||||
override_directive: $ => choice(
|
||||
seq('override', $.define_directive),
|
||||
seq('override', $.variable_assignment),
|
||||
seq('override', $.undefine_directive),
|
||||
),
|
||||
|
||||
// 6.9
|
||||
undefine_directive: $ => seq(
|
||||
'undefine', field('variable', $.word), NL
|
||||
),
|
||||
|
||||
// 6.13
|
||||
private_directive: $ => seq(
|
||||
'private', $.variable_assignment
|
||||
),
|
||||
// }}}
|
||||
// Conditionals {{{
|
||||
// 7
|
||||
conditional: $ => seq(
|
||||
field('condition', $._conditional_directives),
|
||||
optional(field('consequence', $._conditional_consequence)),
|
||||
repeat($.elsif_directive),
|
||||
optional($.else_directive),
|
||||
'endif',
|
||||
NL
|
||||
),
|
||||
|
||||
elsif_directive: $ => seq(
|
||||
'else',
|
||||
field('condition', $._conditional_directives),
|
||||
optional(field('consequence', $._conditional_consequence)),
|
||||
),
|
||||
|
||||
else_directive: $ => seq(
|
||||
'else',
|
||||
NL,
|
||||
optional(field('consequence', $._conditional_consequence)),
|
||||
),
|
||||
|
||||
_conditional_directives: $ => choice(
|
||||
$.ifeq_directive,
|
||||
$.ifneq_directive,
|
||||
$.ifdef_directive,
|
||||
$.ifndef_directive
|
||||
),
|
||||
|
||||
_conditional_consequence: $ => repeat1(choice(
|
||||
$._thing,
|
||||
$._prefixed_recipe_line
|
||||
)),
|
||||
|
||||
ifeq_directive: $ => seq(
|
||||
'ifeq', $._conditional_args_cmp, NL
|
||||
),
|
||||
|
||||
ifneq_directive: $ => seq(
|
||||
'ifneq', $._conditional_args_cmp, NL
|
||||
),
|
||||
|
||||
ifdef_directive: $ => seq(
|
||||
'ifdef', field('variable', $._primary), NL
|
||||
),
|
||||
|
||||
ifndef_directive: $ => seq(
|
||||
'ifndef', field('variable', $._primary), NL
|
||||
),
|
||||
|
||||
_conditional_args_cmp: $ => choice(
|
||||
seq(
|
||||
'(',
|
||||
optional(field('arg0', $._primary)),
|
||||
',',
|
||||
optional(field('arg1', $._primary)),
|
||||
')'
|
||||
),
|
||||
seq(
|
||||
field('arg0', $._primary),
|
||||
field('arg1', $._primary),
|
||||
),
|
||||
),
|
||||
|
||||
// }}}
|
||||
// Variables {{{
|
||||
_variable: $ => choice(
|
||||
$.variable_reference,
|
||||
$.substitution_reference,
|
||||
$.automatic_variable,
|
||||
),
|
||||
|
||||
variable_reference: $ => seq(
|
||||
choice('$','$$'),
|
||||
choice(
|
||||
delimitedVariable($._primary),
|
||||
// TODO are those legal? $) $$$
|
||||
alias(token.immediate(/./), $.word), // match any single digit
|
||||
//alias(token.immediate('\\\n'), $.word)
|
||||
)
|
||||
),
|
||||
|
||||
// 6.3.1
|
||||
substitution_reference: $ => seq(
|
||||
choice('$','$$'),
|
||||
delimitedVariable(seq(
|
||||
field('text',$._primary),
|
||||
':',
|
||||
field('pattern',$._primary),
|
||||
'=',
|
||||
field('replacement',$._primary),
|
||||
)),
|
||||
),
|
||||
|
||||
// 10.5.3
|
||||
automatic_variable: $ => seq(
|
||||
choice('$','$$'),
|
||||
choice(
|
||||
choice(
|
||||
...AUTOMATIC_VARS
|
||||
.map(c => token.immediate(prec(1,c)))
|
||||
),
|
||||
delimitedVariable(seq(
|
||||
choice(
|
||||
...AUTOMATIC_VARS
|
||||
.map(c => token(prec(1,c)))
|
||||
),
|
||||
optional(choice(
|
||||
token.immediate('D'),
|
||||
token.immediate('F')
|
||||
)),
|
||||
))
|
||||
)
|
||||
),
|
||||
// }}}
|
||||
// Functions {{{
|
||||
_function: $ => choice(
|
||||
$.function_call,
|
||||
$.shell_function,
|
||||
),
|
||||
|
||||
function_call: $ => seq(
|
||||
choice('$','$$'),
|
||||
token.immediate('('),
|
||||
field('function', choice(
|
||||
...FUNCTIONS.map(f => token.immediate(f))
|
||||
)),
|
||||
optional(WS),
|
||||
$.arguments,
|
||||
')'
|
||||
),
|
||||
|
||||
arguments: $ => seq(
|
||||
field('argument',$.text),
|
||||
repeat(seq(
|
||||
',',
|
||||
field('argument',$.text),
|
||||
))
|
||||
),
|
||||
|
||||
// 8.13
|
||||
shell_function: $ => seq(
|
||||
choice('$','$$'),
|
||||
token.immediate('('),
|
||||
field('function', 'shell'),
|
||||
optional(WS),
|
||||
$._shell_command,
|
||||
')'
|
||||
),
|
||||
// }}}
|
||||
// Primary and lists {{{
|
||||
list: $ => prec(1,seq(
|
||||
$._primary,
|
||||
repeat(seq(
|
||||
choice(WS, SPLIT),
|
||||
$._primary
|
||||
)),
|
||||
optional(WS)
|
||||
)),
|
||||
|
||||
paths: $ => seq(
|
||||
$._primary,
|
||||
repeat(seq(
|
||||
choice(...[':',';'].map(c=>token.immediate(c))),
|
||||
$._primary
|
||||
)),
|
||||
),
|
||||
|
||||
_primary: $ => choice(
|
||||
$.word,
|
||||
$.archive,
|
||||
$._variable,
|
||||
$._function,
|
||||
$.concatenation,
|
||||
$.string,
|
||||
),
|
||||
|
||||
concatenation: $ => prec.right(seq(
|
||||
$._primary,
|
||||
repeat1(prec.left($._primary))
|
||||
)),
|
||||
// }}}
|
||||
// Names {{{
|
||||
_name: $ => field('name',$.word),
|
||||
|
||||
string: $ => field('string',choice(
|
||||
seq('"', optional($._string), '"'),
|
||||
seq("'", optional($._string), "'"),
|
||||
)),
|
||||
|
||||
_string: $ => repeat1(choice(
|
||||
$._variable,
|
||||
$._function,
|
||||
token(prec(-1,/([^'"$\r\n\\]|\\\\|\\[^\r\n])+/)),
|
||||
)),
|
||||
|
||||
word: $ => token(repeat1(choice(
|
||||
new RegExp ('['+CHARSET+']'),
|
||||
new RegExp ('\\\\['+ESCAPE_SET+']'),
|
||||
new RegExp ('\\\\[0-9]{3}'),
|
||||
))),
|
||||
|
||||
// 11.1
|
||||
archive: $ => seq(
|
||||
field('archive', $.word),
|
||||
token.immediate('('),
|
||||
field('members', $.list),
|
||||
token.immediate(')'),
|
||||
),
|
||||
// }}}
|
||||
// Tokens {{{
|
||||
// TODO external parser for .RECIPEPREFIX
|
||||
_recipeprefix: $ => '\t',
|
||||
|
||||
// TODO prefixed line in define is recipe
|
||||
_rawline: $ => token(/.*[\r\n]+/), // any line
|
||||
|
||||
_shell_text_without_split: $ => text($,
|
||||
noneOf(...['\\$', '\\r', '\\n', '\\']),
|
||||
choice(
|
||||
$._variable,
|
||||
$._function,
|
||||
alias('$$',$.escape),
|
||||
alias('//',$.escape),
|
||||
),
|
||||
),
|
||||
|
||||
// The SPLIT chars shall be included the injected code
|
||||
shell_text_with_split: $ => seq(
|
||||
$._shell_text_without_split,
|
||||
SPLIT,
|
||||
),
|
||||
|
||||
_shell_command: $ => alias(
|
||||
$.text,
|
||||
$.shell_command
|
||||
),
|
||||
|
||||
text: $ => text($,
|
||||
choice(
|
||||
noneOf(...['\\$', '\\(', '\\)', '\\n', '\\r', '\\']),
|
||||
SPLIT
|
||||
),
|
||||
choice(
|
||||
$._variable,
|
||||
$._function,
|
||||
alias('$$',$.escape),
|
||||
alias('//',$.escape),
|
||||
),
|
||||
),
|
||||
// }}}
|
||||
|
||||
comment: $ => token(prec(-1,/#.*/)),
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function noneOf(...characters) {
|
||||
const negatedString = characters.map(c => c == '\\' ? '\\\\' : c).join('')
|
||||
return new RegExp('[^' + negatedString + ']')
|
||||
}
|
||||
|
||||
function delimitedVariable(rule) {
|
||||
return choice(
|
||||
seq(token.immediate('('), rule, ')'),
|
||||
seq(token.immediate('{'), rule, '}')
|
||||
)
|
||||
}
|
||||
|
||||
function text($, text, fenced_vars) {
|
||||
const raw_text = token(repeat1(choice(
|
||||
text,
|
||||
new RegExp ('\\\\['+ESCAPE_SET+']'),
|
||||
new RegExp ('\\\\[0-9]{3}'),
|
||||
new RegExp ('\\\\[^\n\r]'), // used in cmd like sed \1
|
||||
)))
|
||||
return choice(
|
||||
seq(
|
||||
raw_text,
|
||||
repeat(seq(
|
||||
fenced_vars,
|
||||
optional(raw_text)
|
||||
)),
|
||||
),
|
||||
seq(
|
||||
fenced_vars,
|
||||
repeat(seq(
|
||||
optional(raw_text),
|
||||
fenced_vars
|
||||
)),
|
||||
optional(raw_text)
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "tree-sitter-make",
|
||||
"version": "0.0.1",
|
||||
"description": "make grammar for tree-sitter",
|
||||
"author": "Alexandre Muller",
|
||||
"license": "MIT",
|
||||
"main": "bindings/node",
|
||||
"homepage": "https://github.com/alemuller/tree-sitter-make#readme",
|
||||
|
||||
"bugs": {
|
||||
"url": "https://github.com/alemuller/tree-sitter-make/issues"
|
||||
},
|
||||
"homepage": "https://github.com/alemuller/tree-sitter-make#readme",
|
||||
|
||||
"keywords": [
|
||||
"parsing",
|
||||
"incremental",
|
||||
"tree-sitter",
|
||||
"make",
|
||||
"makefile",
|
||||
"GNUMAKEFILE"
|
||||
],
|
||||
"dependencies": {
|
||||
"nan": "^2.12.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tree-sitter-cli": "^0.19.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tree-sitter test"
|
||||
},
|
||||
"tree-sitter": [
|
||||
{
|
||||
"scope": "source.mk",
|
||||
"file-types": [
|
||||
"makefile",
|
||||
"Makefile",
|
||||
"MAKEFILE",
|
||||
"GNUmakefile",
|
||||
"mk",
|
||||
"mak",
|
||||
"dsp"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,171 +0,0 @@
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
":"
|
||||
"&:"
|
||||
"::"
|
||||
"|"
|
||||
";"
|
||||
"\""
|
||||
"'"
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"$"
|
||||
"$$"
|
||||
] @punctuation.special
|
||||
|
||||
(automatic_variable
|
||||
[ "@" "%" "<" "?" "^" "+" "/" "*" "D" "F"] @punctuation.special)
|
||||
|
||||
(automatic_variable
|
||||
"/" @error . ["D" "F"])
|
||||
|
||||
[
|
||||
"="
|
||||
":="
|
||||
"::="
|
||||
"?="
|
||||
"+="
|
||||
"!="
|
||||
"@"
|
||||
"-"
|
||||
"+"
|
||||
] @operator
|
||||
|
||||
[
|
||||
(text)
|
||||
(string)
|
||||
(raw_text)
|
||||
] @string
|
||||
|
||||
(variable_assignment (word) @string)
|
||||
|
||||
[
|
||||
"ifeq"
|
||||
"ifneq"
|
||||
"ifdef"
|
||||
"ifndef"
|
||||
"else"
|
||||
"endif"
|
||||
"if"
|
||||
"or" ; boolean functions are conditional in make grammar
|
||||
"and"
|
||||
] @conditional
|
||||
|
||||
"foreach" @repeat
|
||||
|
||||
[
|
||||
"define"
|
||||
"endef"
|
||||
"vpath"
|
||||
"undefine"
|
||||
"export"
|
||||
"unexport"
|
||||
"override"
|
||||
"private"
|
||||
; "load"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"include"
|
||||
"sinclude"
|
||||
"-include"
|
||||
] @include
|
||||
|
||||
[
|
||||
"subst"
|
||||
"patsubst"
|
||||
"strip"
|
||||
"findstring"
|
||||
"filter"
|
||||
"filter-out"
|
||||
"sort"
|
||||
"word"
|
||||
"words"
|
||||
"wordlist"
|
||||
"firstword"
|
||||
"lastword"
|
||||
"dir"
|
||||
"notdir"
|
||||
"suffix"
|
||||
"basename"
|
||||
"addsuffix"
|
||||
"addprefix"
|
||||
"join"
|
||||
"wildcard"
|
||||
"realpath"
|
||||
"abspath"
|
||||
"call"
|
||||
"eval"
|
||||
"file"
|
||||
"value"
|
||||
"shell"
|
||||
] @keyword.function
|
||||
|
||||
[
|
||||
"error"
|
||||
"warning"
|
||||
"info"
|
||||
] @exception
|
||||
|
||||
;; Variable
|
||||
(variable_assignment
|
||||
name: (word) @constant)
|
||||
|
||||
(variable_reference
|
||||
(word) @constant)
|
||||
|
||||
(comment) @comment
|
||||
|
||||
((word) @clean @string.regex
|
||||
(#match? @clean "[%\*\?]"))
|
||||
|
||||
(function_call
|
||||
function: "error"
|
||||
(arguments (text) @text.danger))
|
||||
|
||||
(function_call
|
||||
function: "warning"
|
||||
(arguments (text) @text.warning))
|
||||
|
||||
(function_call
|
||||
function: "info"
|
||||
(arguments (text) @text.note))
|
||||
|
||||
;; Install Command Categories
|
||||
;; Others special variables
|
||||
;; Variables Used by Implicit Rules
|
||||
[
|
||||
"VPATH"
|
||||
".RECIPEPREFIX"
|
||||
] @constant.builtin
|
||||
|
||||
(variable_assignment
|
||||
name: (word) @clean @constant.builtin
|
||||
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS)$"))
|
||||
|
||||
(variable_reference
|
||||
(word) @clean @constant.builtin
|
||||
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS\.VARIABLES|\.FEATURES|\.INCLUDE_DIRS|\.LOADED)$"))
|
||||
|
||||
;; Standart targets
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
|
||||
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
|
||||
|
||||
;; Builtin targets
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^\.(PHONY|SUFFIXES|DEFAULT|PRECIOUS|INTERMEDIATE|SECONDARY|SECONDEXPANSION|DELETE_ON_ERROR|IGNORE|LOW_RESOLUTION_TIME|SILENT|EXPORT_ALL_VARIABLES|NOTPARALLEL|ONESHELL|POSIX)$"))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,223 +0,0 @@
|
||||
#ifndef TREE_SITTER_PARSER_H_
|
||||
#define TREE_SITTER_PARSER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
TSFieldId field_id;
|
||||
uint8_t child_index;
|
||||
bool inherited;
|
||||
} TSFieldMapEntry;
|
||||
|
||||
typedef struct {
|
||||
uint16_t index;
|
||||
uint16_t length;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef struct {
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} TSSymbolMetadata;
|
||||
|
||||
typedef struct TSLexer TSLexer;
|
||||
|
||||
struct TSLexer {
|
||||
int32_t lookahead;
|
||||
TSSymbol result_symbol;
|
||||
void (*advance)(TSLexer *, bool);
|
||||
void (*mark_end)(TSLexer *);
|
||||
uint32_t (*get_column)(TSLexer *);
|
||||
bool (*is_at_included_range_start)(const TSLexer *);
|
||||
bool (*eof)(const TSLexer *);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TSParseActionTypeShift,
|
||||
TSParseActionTypeReduce,
|
||||
TSParseActionTypeAccept,
|
||||
TSParseActionTypeRecover,
|
||||
} TSParseActionType;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t type;
|
||||
TSStateId state;
|
||||
bool extra;
|
||||
bool repetition;
|
||||
} shift;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t child_count;
|
||||
TSSymbol symbol;
|
||||
int16_t dynamic_precedence;
|
||||
uint16_t production_id;
|
||||
} reduce;
|
||||
uint8_t type;
|
||||
} TSParseAction;
|
||||
|
||||
typedef struct {
|
||||
uint16_t lex_state;
|
||||
uint16_t external_lex_state;
|
||||
} TSLexMode;
|
||||
|
||||
typedef union {
|
||||
TSParseAction action;
|
||||
struct {
|
||||
uint8_t count;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
struct TSLanguage {
|
||||
uint32_t version;
|
||||
uint32_t symbol_count;
|
||||
uint32_t alias_count;
|
||||
uint32_t token_count;
|
||||
uint32_t external_token_count;
|
||||
uint32_t state_count;
|
||||
uint32_t large_state_count;
|
||||
uint32_t production_id_count;
|
||||
uint32_t field_count;
|
||||
uint16_t max_alias_sequence_length;
|
||||
const uint16_t *parse_table;
|
||||
const uint16_t *small_parse_table;
|
||||
const uint32_t *small_parse_table_map;
|
||||
const TSParseActionEntry *parse_actions;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const TSSymbol *public_symbol_map;
|
||||
const uint16_t *alias_map;
|
||||
const TSSymbol *alias_sequences;
|
||||
const TSLexMode *lex_modes;
|
||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||
TSSymbol keyword_capture_token;
|
||||
struct {
|
||||
const bool *states;
|
||||
const TSSymbol *symbol_map;
|
||||
void *(*create)(void);
|
||||
void (*destroy)(void *);
|
||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||
unsigned (*serialize)(void *, char *);
|
||||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
};
|
||||
|
||||
/*
|
||||
* Lexer Macros
|
||||
*/
|
||||
|
||||
#define START_LEXER() \
|
||||
bool result = false; \
|
||||
bool skip = false; \
|
||||
bool eof = false; \
|
||||
int32_t lookahead; \
|
||||
goto start; \
|
||||
next_state: \
|
||||
lexer->advance(lexer, skip); \
|
||||
start: \
|
||||
skip = false; \
|
||||
lookahead = lexer->lookahead;
|
||||
|
||||
#define ADVANCE(state_value) \
|
||||
{ \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define SKIP(state_value) \
|
||||
{ \
|
||||
skip = true; \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define ACCEPT_TOKEN(symbol_value) \
|
||||
result = true; \
|
||||
lexer->result_symbol = symbol_value; \
|
||||
lexer->mark_end(lexer);
|
||||
|
||||
#define END_STATE() return result;
|
||||
|
||||
/*
|
||||
* Parse Table Macros
|
||||
*/
|
||||
|
||||
#define SMALL_STATE(id) id - LARGE_STATE_COUNT
|
||||
|
||||
#define STATE(id) id
|
||||
|
||||
#define ACTIONS(id) id
|
||||
|
||||
#define SHIFT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_REPEAT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value, \
|
||||
.repetition = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_EXTRA() \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.extra = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_val, \
|
||||
.child_count = child_count_val, \
|
||||
__VA_ARGS__ \
|
||||
}, \
|
||||
}}
|
||||
|
||||
#define RECOVER() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeRecover \
|
||||
}}
|
||||
|
||||
#define ACCEPT_INPUT() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeAccept \
|
||||
}}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_PARSER_H_
|
||||
@ -1,330 +0,0 @@
|
||||
=======================================
|
||||
Conditionals, ifeq, ifneq, ifdef, ifdef
|
||||
=======================================
|
||||
ifeq ("string $(sort 1 2 3)", 'string ${VAR}')
|
||||
endif
|
||||
|
||||
ifneq (arg0, arg1)
|
||||
endif
|
||||
|
||||
ifdef var
|
||||
endif
|
||||
|
||||
ifndef var
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (string
|
||||
string: (function_call
|
||||
(arguments
|
||||
argument: (text))))
|
||||
arg1: (string
|
||||
string: (variable_reference
|
||||
(word)))))
|
||||
(conditional
|
||||
condition: (ifneq_directive
|
||||
arg0: (word)
|
||||
arg1: (word)))
|
||||
(conditional
|
||||
condition: (ifdef_directive
|
||||
variable: (word)))
|
||||
(conditional
|
||||
condition: (ifndef_directive
|
||||
variable: (word))))
|
||||
|
||||
======================================
|
||||
Conditionals, parenthesis, parenthesis
|
||||
======================================
|
||||
ifeq (arg0, arg1)
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))))
|
||||
|
||||
========================================
|
||||
Conditionals, single quote, single quote
|
||||
========================================
|
||||
ifeq 'arg0' 'arg1'
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (string)
|
||||
arg1: (string))))
|
||||
|
||||
========================================
|
||||
Conditionals, double quote, double quote
|
||||
========================================
|
||||
ifeq "arg0" "arg1"
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (string)
|
||||
arg1: (string))))
|
||||
|
||||
========================================
|
||||
Conditionals, double quote, single quote
|
||||
========================================
|
||||
ifeq "arg0" 'arg1'
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (string)
|
||||
arg1: (string))))
|
||||
|
||||
========================================
|
||||
Conditionals, single quote, double quote
|
||||
========================================
|
||||
ifeq 'arg0' "arg1"
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (string)
|
||||
arg1: (string))))
|
||||
|
||||
======================================
|
||||
Conditionals, else
|
||||
======================================
|
||||
ifeq (arg0, arg1)
|
||||
else
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
(else_directive)))
|
||||
|
||||
=============================
|
||||
Conditionals, else if, single
|
||||
=============================
|
||||
ifeq (arg0, arg1)
|
||||
else ifeq (arg0, arg1)
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
(elsif_directive
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word)))))
|
||||
|
||||
===================================
|
||||
Conditionals, else if, single, else
|
||||
===================================
|
||||
ifeq (arg0, arg1)
|
||||
else ifeq (arg0, arg1)
|
||||
else
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
(elsif_directive
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word)))
|
||||
(else_directive)))
|
||||
|
||||
===============================
|
||||
Conditionals, else if, multiple
|
||||
===============================
|
||||
ifeq (arg0, arg1)
|
||||
else ifeq (arg0, arg1)
|
||||
else ifneq (arg0, arg1)
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
(elsif_directive
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word)))
|
||||
(elsif_directive
|
||||
condition: (ifneq_directive
|
||||
arg0: (word)
|
||||
arg1: (word)))))
|
||||
|
||||
===============================
|
||||
Conditionals, else if, multiple, else
|
||||
===============================
|
||||
ifeq (arg0, arg1)
|
||||
else ifeq (arg0, arg1)
|
||||
else ifneq (arg0, arg1)
|
||||
else
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
(elsif_directive
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word)))
|
||||
(elsif_directive
|
||||
condition: (ifneq_directive
|
||||
arg0: (word)
|
||||
arg1: (word)))
|
||||
(else_directive)))
|
||||
|
||||
================================
|
||||
Conditionals, consequence, rules
|
||||
================================
|
||||
ifneq (,)
|
||||
all:
|
||||
echo a
|
||||
else
|
||||
all:
|
||||
echo b
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifneq_directive)
|
||||
consequence: (rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text))))
|
||||
(else_directive
|
||||
consequence: (rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)))))))
|
||||
|
||||
===============================
|
||||
Conditionals, in recipe
|
||||
===============================
|
||||
foo:
|
||||
ifeq (x,y)
|
||||
echo a
|
||||
else
|
||||
echo b
|
||||
endif
|
||||
|
||||
----
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
consequence: (recipe_line
|
||||
(shell_text))
|
||||
(else_directive
|
||||
consequence: (recipe_line
|
||||
(shell_text)))))))
|
||||
|
||||
=======================================
|
||||
Conditionals, rules, recipe, prec.right
|
||||
=======================================
|
||||
ifeq (a,b)
|
||||
all:
|
||||
echo foo
|
||||
|
||||
echo foo
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
consequence: (rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text))
|
||||
(recipe_line
|
||||
(shell_text))))))
|
||||
|
||||
=======================================
|
||||
Conditionals, in recipe, in consequence
|
||||
=======================================
|
||||
ifneq (a,b)
|
||||
all:
|
||||
ifeq (a,b)
|
||||
echo foo
|
||||
else
|
||||
echo bar
|
||||
endif
|
||||
endif
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(conditional
|
||||
condition: (ifneq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
consequence: (rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(conditional
|
||||
condition: (ifeq_directive
|
||||
arg0: (word)
|
||||
arg1: (word))
|
||||
consequence: (recipe_line
|
||||
(shell_text))
|
||||
(else_directive
|
||||
consequence: (recipe_line
|
||||
(shell_text))))))))
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
=========================================
|
||||
Define directive (whitespace after name)
|
||||
=========================================
|
||||
define two-lines
|
||||
echo foo
|
||||
echo bar
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(define_directive
|
||||
name: (word)
|
||||
value: (raw_text)))
|
||||
|
||||
============================================
|
||||
Define directive (whitespace after operator)
|
||||
============================================
|
||||
define two-lines =
|
||||
echo foo
|
||||
echo bar
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(define_directive
|
||||
name: (word)
|
||||
value: (raw_text)))
|
||||
|
||||
@ -1,175 +0,0 @@
|
||||
==================
|
||||
Directive, include
|
||||
==================
|
||||
include foo *.mk
|
||||
-include foo *.mk
|
||||
sinclude foo *.mk
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(include_directive
|
||||
filenames: (list (word) (word)))
|
||||
(include_directive
|
||||
filenames: (list (word) (word)))
|
||||
(include_directive
|
||||
filenames: (list (word) (word))))
|
||||
|
||||
================
|
||||
Directive, vpath
|
||||
================
|
||||
vpath
|
||||
vpath %.p
|
||||
vpath %.p ../foo
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(vpath_directive)
|
||||
(vpath_directive
|
||||
pattern: (word))
|
||||
(vpath_directive
|
||||
pattern: (word)
|
||||
directories: (paths (word))))
|
||||
|
||||
================================
|
||||
Directive, vpath, list delimiter
|
||||
================================
|
||||
vpath % foo:bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(vpath_directive
|
||||
pattern: (word)
|
||||
directories: (paths (word) (word))))
|
||||
|
||||
======================
|
||||
Directive, export, all
|
||||
======================
|
||||
export
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(export_directive))
|
||||
|
||||
================================
|
||||
Directive, export, variable name
|
||||
================================
|
||||
export foo bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(export_directive
|
||||
variables: (list (word) (word))))
|
||||
|
||||
======================================
|
||||
Directive, export, variable assignment
|
||||
======================================
|
||||
export foo = bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(export_directive
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text))))
|
||||
|
||||
========================
|
||||
Directive, unexport, all
|
||||
========================
|
||||
unexport
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(unexport_directive))
|
||||
|
||||
==================================
|
||||
Directive, unexport, variable name
|
||||
==================================
|
||||
unexport foo bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(unexport_directive
|
||||
variables: (list (word) (word))))
|
||||
|
||||
========================================
|
||||
Directive, override, variable assignment
|
||||
========================================
|
||||
override v = foo
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(override_directive
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text))))
|
||||
|
||||
========================================
|
||||
Directive, override, variable definition
|
||||
========================================
|
||||
override define foo =
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(override_directive
|
||||
(define_directive
|
||||
name: (word))))
|
||||
|
||||
=============================
|
||||
Directive, override, undefine
|
||||
=============================
|
||||
override undefine foo
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(override_directive
|
||||
(undefine_directive
|
||||
variable: (word))))
|
||||
|
||||
===================
|
||||
Directive, undefine
|
||||
===================
|
||||
undefine foo
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(undefine_directive
|
||||
variable: (word)))
|
||||
|
||||
=======================================
|
||||
Directive, private, variable assignment
|
||||
=======================================
|
||||
private foo = bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(private_directive
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text))))
|
||||
|
||||
================================================================
|
||||
Directive, private, variable assignment, target/pattern-specific
|
||||
================================================================
|
||||
%.o : CFLAGS = -O
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
target_or_pattern: (list (word))
|
||||
name: (word)
|
||||
value: (text)))
|
||||
@ -1,3 +0,0 @@
|
||||
|
||||
$(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog))))
|
||||
|
||||
@ -1,770 +0,0 @@
|
||||
================================================================================
|
||||
Rule, targets, single
|
||||
================================================================================
|
||||
target:
|
||||
%.o:
|
||||
*.o:
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word)))
|
||||
(rule
|
||||
(targets
|
||||
(word)))
|
||||
(rule
|
||||
(targets
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, targets, multiple
|
||||
================================================================================
|
||||
target %.o *.o:
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word)
|
||||
(word)
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, targets, archive
|
||||
================================================================================
|
||||
foo(bar):
|
||||
foo(bar baz):
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(archive
|
||||
archive: (word)
|
||||
members: (list
|
||||
(word)))))
|
||||
(rule
|
||||
(targets
|
||||
(archive
|
||||
archive: (word)
|
||||
members: (list
|
||||
(word)
|
||||
(word))))))
|
||||
|
||||
================================================================================
|
||||
Rule, grouped targets
|
||||
================================================================================
|
||||
foo %.n *.o &:
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word)
|
||||
(word)
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, normal, single
|
||||
================================================================================
|
||||
target: foo
|
||||
target: %.c
|
||||
target: *.d
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word)))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word)))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, normal, multiple
|
||||
================================================================================
|
||||
target: foo %.b c.o
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word)
|
||||
(word)
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, normal, archive
|
||||
================================================================================
|
||||
target: foo(foo) bar(foo bar)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(archive
|
||||
archive: (word)
|
||||
members: (list
|
||||
(word)))
|
||||
(archive
|
||||
archive: (word)
|
||||
members: (list
|
||||
(word)
|
||||
(word))))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, normal, multiple, splited lines, one per line
|
||||
================================================================================
|
||||
target: foo\
|
||||
%.b\
|
||||
c.o
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word)
|
||||
(word)
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, normal, multiple, splited lines, multiple per line
|
||||
================================================================================
|
||||
target: foo %.b c.o\
|
||||
foo %.b c.o\
|
||||
foo %.b c.o
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, order only, single
|
||||
================================================================================
|
||||
foo: | bar
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
order_only: (prerequisites
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, order only, multiple, splited line, multiple per line
|
||||
================================================================================
|
||||
target: | foo %.b c.o\
|
||||
foo %.b c.o\
|
||||
foo %.b c.o
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
order_only: (prerequisites
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word)
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, pre-requisites, normal and order-only
|
||||
================================================================================
|
||||
target: foo \
|
||||
bar | baz \
|
||||
foobar
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word)
|
||||
(word))
|
||||
order_only: (prerequisites
|
||||
(word)
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, empty rule
|
||||
================================================================================
|
||||
target: ;
|
||||
|
||||
target:
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe)))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line
|
||||
================================================================================
|
||||
target:
|
||||
echo "foobar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, custom .RECIPEPREFIX I (TODO)
|
||||
================================================================================
|
||||
.RECIPEPREFIX = >
|
||||
|
||||
target:
|
||||
>echo "foobar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, custom .RECIPEPREFIX II (TODO)
|
||||
================================================================================
|
||||
.RECIPEPREFIX = a
|
||||
|
||||
target:
|
||||
aecho "foobar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, custom .RECIPEPREFIX III (TODO)
|
||||
================================================================================
|
||||
.RECIPEPREFIX = >
|
||||
|
||||
target: ;
|
||||
>echo "foobar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, suppress echoing
|
||||
================================================================================
|
||||
target:
|
||||
@echo "foobar"
|
||||
|
||||
target: ; @echo "foobar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text))))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, NOT comment
|
||||
================================================================================
|
||||
target:
|
||||
# foo
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, splitted
|
||||
================================================================================
|
||||
target:
|
||||
echo "foo\
|
||||
bar"
|
||||
|
||||
target:
|
||||
echo "foo\
|
||||
bar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text))))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, splited, supress echoing
|
||||
================================================================================
|
||||
target:
|
||||
@echo "foo\
|
||||
bar"
|
||||
|
||||
target:
|
||||
@echo "foo\
|
||||
bar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text))))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, splited, escape
|
||||
================================================================================
|
||||
target:
|
||||
@echo "\\foo\
|
||||
bar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, single line, splited, backslash (sed)
|
||||
================================================================================
|
||||
target:
|
||||
sed -e 's/\([^-]*-g\)/r\1/'
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets (word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, multiple lines
|
||||
================================================================================
|
||||
target:
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text))
|
||||
(recipe_line
|
||||
(shell_text))
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, multiple lines, comments
|
||||
================================================================================
|
||||
target:
|
||||
|
||||
foo
|
||||
# comment
|
||||
baz
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text))
|
||||
(comment)
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, multiple lines, whitespace after ":"
|
||||
================================================================================
|
||||
all:
|
||||
@echo foo\
|
||||
bar
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, attached to targets-and-prerequisites, single line
|
||||
================================================================================
|
||||
target: ; echo "foobar"
|
||||
|
||||
target: ;
|
||||
echo "foobar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text))))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, attached to targets-and-prerequisites, single line, splited
|
||||
================================================================================
|
||||
target: ; echo "foo\
|
||||
bar"
|
||||
|
||||
target: ; echo "foo\
|
||||
bar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text))))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, attached to targets-and-prerequisites, multiple lines
|
||||
================================================================================
|
||||
target: ; @echo "foo\
|
||||
bar"
|
||||
|
||||
target: ; @echo "foo\
|
||||
bar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text))))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, blank lines
|
||||
================================================================================
|
||||
target:
|
||||
|
||||
echo "foo\
|
||||
bar\
|
||||
bar"
|
||||
|
||||
|
||||
echo "foobar"
|
||||
|
||||
target: ;
|
||||
|
||||
@echo "foo\
|
||||
bar\
|
||||
bar"
|
||||
|
||||
echo "foobar"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)
|
||||
(shell_text))
|
||||
(recipe_line
|
||||
(shell_text))))
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)
|
||||
(shell_text)
|
||||
(shell_text))
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, automatic variable I
|
||||
================================================================================
|
||||
%.o: %.c
|
||||
gcc -c -o $@ $<
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text
|
||||
(automatic_variable)
|
||||
(automatic_variable))))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, automatic variable II
|
||||
================================================================================
|
||||
%.o: %.c
|
||||
gcc -c -o $(@) ${<}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text
|
||||
(automatic_variable)
|
||||
(automatic_variable))))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, automatic variable, file and directory names variants
|
||||
================================================================================
|
||||
foo : bar/lose
|
||||
cd $(@D)
|
||||
gobble ${@F} > ../$@
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text
|
||||
(automatic_variable)))
|
||||
(recipe_line
|
||||
(shell_text
|
||||
(automatic_variable)
|
||||
(automatic_variable))))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, automatic variable, secondary expansion I
|
||||
================================================================================
|
||||
foo: foo.1 bar.1 $$< $$^ $$+
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word)
|
||||
(word)
|
||||
(automatic_variable)
|
||||
(automatic_variable)
|
||||
(automatic_variable))))
|
||||
|
||||
================================================================================
|
||||
Rule, recipe, automatic variable, secondary expansion II
|
||||
================================================================================
|
||||
%oo: $$< $$^ $$+ $$*
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(automatic_variable)
|
||||
(automatic_variable)
|
||||
(automatic_variable)
|
||||
(automatic_variable))))
|
||||
|
||||
================================================================================
|
||||
Rule, complete
|
||||
================================================================================
|
||||
target: prereq | prereq2
|
||||
recipe
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
normal: (prerequisites
|
||||
(word))
|
||||
order_only: (prerequisites
|
||||
(word))
|
||||
(recipe
|
||||
(recipe_line
|
||||
(shell_text)))))
|
||||
|
||||
================================================================================
|
||||
Rule, static pattern
|
||||
================================================================================
|
||||
foo.o bar.o: %.o: %.c
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word)
|
||||
(word))
|
||||
target: (pattern_list
|
||||
(word))
|
||||
prerequisite: (pattern_list
|
||||
(word))))
|
||||
|
||||
================================================================================
|
||||
Rule, static pattern, whitespace
|
||||
================================================================================
|
||||
foo : bar : baz
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(makefile
|
||||
(rule
|
||||
(targets
|
||||
(word))
|
||||
target: (pattern_list
|
||||
(word))
|
||||
prerequisite: (pattern_list
|
||||
(word))))
|
||||
@ -1,145 +0,0 @@
|
||||
======================================
|
||||
Shell function (AKA command expansion)
|
||||
======================================
|
||||
v = $(shell echo *.ls)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(shell_function
|
||||
(shell_command)))))
|
||||
|
||||
==========================
|
||||
Shell function, line split
|
||||
==========================
|
||||
v = $(shell echo foo\
|
||||
bar\
|
||||
baz)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(shell_function
|
||||
(shell_command)))))
|
||||
|
||||
=================================================
|
||||
Shell function, line split, condensate whitespace
|
||||
=================================================
|
||||
v = $(shell echo foo$\
|
||||
bar)
|
||||
|
||||
v = $(shell echo foo$ bar)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(shell_function
|
||||
(shell_command
|
||||
(variable_reference
|
||||
(word))))))
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(shell_function
|
||||
(shell_command
|
||||
(variable_reference
|
||||
(word)))))))
|
||||
|
||||
======================================
|
||||
Shell function, escaped delimiter '\)'
|
||||
======================================
|
||||
v = $(shell echo "\(foo\)")
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(shell_function
|
||||
(shell_command)))))
|
||||
|
||||
======================================
|
||||
Shell function, escaped dolar signal
|
||||
======================================
|
||||
v = $(shell echo $$PWD)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(shell_function
|
||||
(shell_command
|
||||
(escape))))))
|
||||
|
||||
==================================
|
||||
Shell function, variable reference
|
||||
==================================
|
||||
v = $(shell echo $(foo) ${bar})
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(shell_function
|
||||
(shell_command
|
||||
(variable_reference (word))
|
||||
(variable_reference (word)))))))
|
||||
|
||||
|
||||
======================================
|
||||
Shell assignment (AKA command expansion)
|
||||
======================================
|
||||
v != echo *.ls
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(shell_assignment
|
||||
name: (word)
|
||||
value: (shell_command)))
|
||||
|
||||
============================
|
||||
Shell assignment, line split
|
||||
============================
|
||||
v != echo foo\
|
||||
bar\
|
||||
baz
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(shell_assignment
|
||||
name: (word)
|
||||
value: (shell_command)))
|
||||
|
||||
===================================================
|
||||
Shell assignment, line split, condensate whitespace
|
||||
===================================================
|
||||
|
||||
|
||||
========================================
|
||||
Shell assignment, escaped delimiter '\)'
|
||||
========================================
|
||||
|
||||
======================================
|
||||
Shell assignment, escaped dolar signal
|
||||
======================================
|
||||
|
||||
====================================
|
||||
Shell assignment, variable reference
|
||||
====================================
|
||||
|
||||
@ -1,314 +0,0 @@
|
||||
=======================================
|
||||
Variable, recursively expanded, setting
|
||||
=======================================
|
||||
v = foo.o bar.o
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text)))
|
||||
|
||||
==================================
|
||||
Variable, simply expanded, setting
|
||||
==================================
|
||||
v := foo.o bar.o
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text)))
|
||||
|
||||
=========================================
|
||||
Variable, simply expanded, POSIX, setting
|
||||
=========================================
|
||||
v ::= foo.o bar.o
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text)))
|
||||
|
||||
=======================
|
||||
Variable, splitted line
|
||||
=======================
|
||||
var := foo\
|
||||
bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text)))
|
||||
|
||||
=======================
|
||||
Variable, special chars
|
||||
=======================
|
||||
var := 'hello\
|
||||
world'
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text)))
|
||||
|
||||
==================================
|
||||
Variable, define directive
|
||||
==================================
|
||||
define two-lines
|
||||
echo foo
|
||||
echo bar
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(define_directive
|
||||
name: (word)
|
||||
value: (raw_text)))
|
||||
|
||||
==================================
|
||||
Variable, define directive, operator
|
||||
==================================
|
||||
define two-lines :=
|
||||
echo foo
|
||||
echo bar
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(define_directive
|
||||
name: (word)
|
||||
value: (raw_text)))
|
||||
|
||||
=====================================
|
||||
Variable, define directive, make code
|
||||
=====================================
|
||||
define rule =
|
||||
foo: bar
|
||||
baz
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(define_directive
|
||||
name: (word)
|
||||
value: (raw_text)))
|
||||
|
||||
=======================================
|
||||
Variable, define directive, whitespace
|
||||
======================================
|
||||
define foo =
|
||||
bar
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(define_directive
|
||||
name: (word)
|
||||
value: (raw_text)))
|
||||
|
||||
=======================================
|
||||
Variable, define directive, NOT comments
|
||||
======================================
|
||||
define foo =
|
||||
#comment
|
||||
endef
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(define_directive
|
||||
name: (word)
|
||||
value: (raw_text)))
|
||||
|
||||
================================
|
||||
Variable, VPATH, Linux delimiter
|
||||
================================
|
||||
VPATH = foo:../bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(VPATH_assignment
|
||||
value: (paths (word) (word))))
|
||||
|
||||
==================================
|
||||
Variable, VPATH, Windows delimiter
|
||||
==================================
|
||||
VPATH = foo;../bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(VPATH_assignment
|
||||
value: (paths (word) (word))))
|
||||
|
||||
=================================
|
||||
Variable, target/pattern-specific
|
||||
=================================
|
||||
%.o : v = foo
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
target_or_pattern: (list (word))
|
||||
name: (word)
|
||||
value: (text)))
|
||||
|
||||
=====================
|
||||
Variable, empty value
|
||||
=====================
|
||||
v =
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)))
|
||||
|
||||
=====================
|
||||
Variable, reference
|
||||
=====================
|
||||
v = $(v) ${v}
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(variable_reference (word))
|
||||
(variable_reference (word)))))
|
||||
|
||||
==============================
|
||||
Variable, reference, nested
|
||||
==============================
|
||||
v = $($(v)) $(${v}) ${${v}} ${$(v)}
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(variable_reference
|
||||
(variable_reference (word)))
|
||||
(variable_reference
|
||||
(variable_reference (word)))
|
||||
(variable_reference
|
||||
(variable_reference (word)))
|
||||
(variable_reference
|
||||
(variable_reference (word))))))
|
||||
|
||||
===============================================
|
||||
Variable, substitution reference I
|
||||
===============================================
|
||||
v := $(foo:.o=.c)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(substitution_reference
|
||||
text: (word)
|
||||
pattern: (word)
|
||||
replacement: (word)))))
|
||||
|
||||
===============================================
|
||||
Variable, substitution reference II
|
||||
===============================================
|
||||
v := $(foo:%.o=%.c)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text
|
||||
(substitution_reference
|
||||
text: (word)
|
||||
pattern: (word)
|
||||
replacement: (word)))))
|
||||
|
||||
===============================================
|
||||
Variable, VPATH, concatenation, var reference and text
|
||||
===============================================
|
||||
VPATH = foo/$(bar)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(VPATH_assignment
|
||||
value: (paths
|
||||
(concatenation
|
||||
(word)
|
||||
(variable_reference (word))))))
|
||||
|
||||
========================================================
|
||||
Variable, concatenation, var reference and var reference
|
||||
========================================================
|
||||
VPATH = $(foo)$(bar)
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(VPATH_assignment
|
||||
value: (paths
|
||||
(concatenation
|
||||
(variable_reference (word))
|
||||
(variable_reference (word))))))
|
||||
|
||||
==========================================
|
||||
Variable, computed variable, concatenation
|
||||
==========================================
|
||||
VPATH := $($(foo)_$(bar))
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(VPATH_assignment
|
||||
value: (paths
|
||||
(variable_reference
|
||||
(concatenation
|
||||
(variable_reference (word))
|
||||
(word)
|
||||
(variable_reference (word)))))))
|
||||
|
||||
==============================================
|
||||
Variable, shell command (not shell assignment)
|
||||
==============================================
|
||||
v = echo "foo" > bar
|
||||
v = echo "foo" !> bar
|
||||
v = echo "foo" 1> bar
|
||||
v = echo "foo" &> bar
|
||||
|
||||
---
|
||||
|
||||
(makefile
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text))
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text))
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text))
|
||||
(variable_assignment
|
||||
name: (word)
|
||||
value: (text)))
|
||||
Loading…
Reference in New Issue