blob: f7008ecfd89dadd6f4d4a37e9083afdd5b5eb6c8 [file] [log] [blame]
Bram Moolenaar6ee8d892012-01-10 14:55:01 +01001" ninja build file syntax.
2" Language: ninja build file as described at
3" http://martine.github.com/ninja/manual.html
Bram Moolenaar0187ca02013-04-12 15:09:51 +02004" Version: 1.3
5" Last Change: 2013 Apr 12
Bram Moolenaar6ee8d892012-01-10 14:55:01 +01006" Maintainer: Nicolas Weber <nicolasweber@gmx.de>
7
8" ninja lexer and parser are at
9" https://github.com/martine/ninja/blob/master/src/lexer.in.cc
Bram Moolenaar0187ca02013-04-12 15:09:51 +020010" https://github.com/martine/ninja/blob/master/src/manifest_parser.cc
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010011
12if exists("b:current_syntax")
13 finish
14endif
15
16syn case match
17
Bram Moolenaar30b65812012-07-12 22:01:11 +020018syn match ninjaComment /#.*/ contains=@Spell
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +020019
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010020" Toplevel statements are the ones listed here and
21" toplevel variable assignments (ident '=' value).
Bram Moolenaar0187ca02013-04-12 15:09:51 +020022" lexer.in.cc, ReadToken() and manifest_parser.cc, Parse()
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010023syn match ninjaKeyword "^build\>"
24syn match ninjaKeyword "^rule\>"
Bram Moolenaar0187ca02013-04-12 15:09:51 +020025syn match ninjaKeyword "^pool\>"
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010026syn match ninjaKeyword "^default\>"
27syn match ninjaKeyword "^include\>"
28syn match ninjaKeyword "^subninja\>"
29
30" Both 'build' and 'rule' begin a variable scope that ends
31" on the first line without indent. 'rule' allows only a
32" limited set of magic variables, 'build' allows general
33" let assignments.
Bram Moolenaar0187ca02013-04-12 15:09:51 +020034" manifest_parser.cc, ParseRule()
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010035syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent
Bram Moolenaar0187ca02013-04-12 15:09:51 +020036syn keyword ninjaRuleCommand contained command deps depfile description generator pool restat rspfile rspfile_content
37
38syn region ninjaPool start="^pool" end="^\ze\S" contains=ALL transparent
39syn keyword ninjaPoolCommand contained depth
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010040
41" Strings are parsed as follows:
42" lexer.in.cc, ReadEvalString()
43" simple_varname = [a-zA-Z0-9_-]+;
44" varname = [a-zA-Z0-9_.-]+;
45" $$ -> $
46" $\n -> line continuation
47" '$ ' -> escaped space
48" $simple_varname -> variable
49" ${varname} -> variable
50
51syn match ninjaWrapLineOperator "\$$"
52syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"
53syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"
54
55" operators are:
56" variable assignment =
57" rule definition :
58" implicit dependency |
59" order-only dependency ||
60syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"
61
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +020062hi def link ninjaComment Comment
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010063hi def link ninjaKeyword Keyword
64hi def link ninjaRuleCommand Statement
Bram Moolenaar0187ca02013-04-12 15:09:51 +020065hi def link ninjaPoolCommand Statement
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010066hi def link ninjaWrapLineOperator ninjaOperator
67hi def link ninjaOperator Operator
68hi def link ninjaSimpleVar ninjaVar
69hi def link ninjaVar Identifier
70
71let b:current_syntax = "ninja"