3256
|
1 " ninja build file syntax.
|
|
2 " Language: ninja build file as described at
|
|
3 " http://martine.github.com/ninja/manual.html
|
|
4 " Version: 1.0
|
|
5 " Last Change: 2012 Jan 04
|
|
6 " 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
|
|
10 " https://github.com/martine/ninja/blob/master/src/parsers.cc
|
|
11
|
|
12 if exists("b:current_syntax")
|
|
13 finish
|
|
14 endif
|
|
15
|
|
16 syn case match
|
|
17
|
|
18 " Toplevel statements are the ones listed here and
|
|
19 " toplevel variable assignments (ident '=' value).
|
|
20 " lexer.in.cc, ReadToken() and parsers.cc, Parse()
|
|
21 syn match ninjaKeyword "^build\>"
|
|
22 syn match ninjaKeyword "^rule\>"
|
|
23 syn match ninjaKeyword "^default\>"
|
|
24 syn match ninjaKeyword "^include\>"
|
|
25 syn match ninjaKeyword "^subninja\>"
|
|
26
|
|
27 " Both 'build' and 'rule' begin a variable scope that ends
|
|
28 " on the first line without indent. 'rule' allows only a
|
|
29 " limited set of magic variables, 'build' allows general
|
|
30 " let assignments.
|
|
31 " parsers.cc, ParseRule()
|
|
32 syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent
|
|
33 syn keyword ninjaRuleCommand contained command depfile description generator restat
|
|
34
|
|
35 " Strings are parsed as follows:
|
|
36 " lexer.in.cc, ReadEvalString()
|
|
37 " simple_varname = [a-zA-Z0-9_-]+;
|
|
38 " varname = [a-zA-Z0-9_.-]+;
|
|
39 " $$ -> $
|
|
40 " $\n -> line continuation
|
|
41 " '$ ' -> escaped space
|
|
42 " $simple_varname -> variable
|
|
43 " ${varname} -> variable
|
|
44
|
|
45 syn match ninjaWrapLineOperator "\$$"
|
|
46 syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"
|
|
47 syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"
|
|
48
|
|
49 " operators are:
|
|
50 " variable assignment =
|
|
51 " rule definition :
|
|
52 " implicit dependency |
|
|
53 " order-only dependency ||
|
|
54 syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"
|
|
55
|
|
56 hi def link ninjaKeyword Keyword
|
|
57 hi def link ninjaRuleCommand Statement
|
|
58 hi def link ninjaWrapLineOperator ninjaOperator
|
|
59 hi def link ninjaOperator Operator
|
|
60 hi def link ninjaSimpleVar ninjaVar
|
|
61 hi def link ninjaVar Identifier
|
|
62
|
|
63 let b:current_syntax = "ninja"
|