3256
|
1 " ninja build file syntax.
|
|
2 " Language: ninja build file as described at
|
|
3 " http://martine.github.com/ninja/manual.html
|
4278
|
4 " Version: 1.3
|
4339
|
5 " Last Change: 2013/04/16
|
3256
|
6 " Maintainer: Nicolas Weber <nicolasweber@gmx.de>
|
4339
|
7 " Version 1.3 of this script is in the upstream vim repository and will be
|
|
8 " included in the next vim release. If you change this, please send your change
|
|
9 " upstream.
|
3256
|
10
|
|
11 " ninja lexer and parser are at
|
|
12 " https://github.com/martine/ninja/blob/master/src/lexer.in.cc
|
4278
|
13 " https://github.com/martine/ninja/blob/master/src/manifest_parser.cc
|
3256
|
14
|
|
15 if exists("b:current_syntax")
|
|
16 finish
|
|
17 endif
|
|
18
|
4339
|
19 let s:cpo_save = &cpo
|
|
20 set cpo&vim
|
|
21
|
3256
|
22 syn case match
|
|
23
|
3682
|
24 syn match ninjaComment /#.*/ contains=@Spell
|
3513
|
25
|
3256
|
26 " Toplevel statements are the ones listed here and
|
|
27 " toplevel variable assignments (ident '=' value).
|
4278
|
28 " lexer.in.cc, ReadToken() and manifest_parser.cc, Parse()
|
3256
|
29 syn match ninjaKeyword "^build\>"
|
|
30 syn match ninjaKeyword "^rule\>"
|
4278
|
31 syn match ninjaKeyword "^pool\>"
|
3256
|
32 syn match ninjaKeyword "^default\>"
|
|
33 syn match ninjaKeyword "^include\>"
|
|
34 syn match ninjaKeyword "^subninja\>"
|
|
35
|
|
36 " Both 'build' and 'rule' begin a variable scope that ends
|
|
37 " on the first line without indent. 'rule' allows only a
|
|
38 " limited set of magic variables, 'build' allows general
|
|
39 " let assignments.
|
4278
|
40 " manifest_parser.cc, ParseRule()
|
3256
|
41 syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent
|
4339
|
42 syn keyword ninjaRuleCommand contained command deps depfile description generator
|
|
43 \ pool restat rspfile rspfile_content
|
4278
|
44
|
|
45 syn region ninjaPool start="^pool" end="^\ze\S" contains=ALL transparent
|
|
46 syn keyword ninjaPoolCommand contained depth
|
3256
|
47
|
|
48 " Strings are parsed as follows:
|
|
49 " lexer.in.cc, ReadEvalString()
|
|
50 " simple_varname = [a-zA-Z0-9_-]+;
|
|
51 " varname = [a-zA-Z0-9_.-]+;
|
|
52 " $$ -> $
|
|
53 " $\n -> line continuation
|
|
54 " '$ ' -> escaped space
|
|
55 " $simple_varname -> variable
|
|
56 " ${varname} -> variable
|
|
57
|
|
58 syn match ninjaWrapLineOperator "\$$"
|
|
59 syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"
|
|
60 syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"
|
|
61
|
|
62 " operators are:
|
|
63 " variable assignment =
|
|
64 " rule definition :
|
|
65 " implicit dependency |
|
|
66 " order-only dependency ||
|
|
67 syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"
|
|
68
|
3513
|
69 hi def link ninjaComment Comment
|
3256
|
70 hi def link ninjaKeyword Keyword
|
|
71 hi def link ninjaRuleCommand Statement
|
4278
|
72 hi def link ninjaPoolCommand Statement
|
3256
|
73 hi def link ninjaWrapLineOperator ninjaOperator
|
|
74 hi def link ninjaOperator Operator
|
|
75 hi def link ninjaSimpleVar ninjaVar
|
|
76 hi def link ninjaVar Identifier
|
|
77
|
|
78 let b:current_syntax = "ninja"
|
4339
|
79
|
|
80 let &cpo = s:cpo_save
|
|
81 unlet s:cpo_save
|