1" ninja build file syntax. 2" Language: ninja build file as described at 3" http://martine.github.com/ninja/manual.html 4" Version: 1.3 5" Last Change: 2013 Apr 12 6" Maintainer: Nicolas Weber <[email protected]> 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/manifest_parser.cc 11 12if exists("b:current_syntax") 13 finish 14endif 15 16syn case match 17 18syn match ninjaComment /#.*/ contains=@Spell 19 20" Toplevel statements are the ones listed here and 21" toplevel variable assignments (ident '=' value). 22" lexer.in.cc, ReadToken() and manifest_parser.cc, Parse() 23syn match ninjaKeyword "^build\>" 24syn match ninjaKeyword "^rule\>" 25syn match ninjaKeyword "^pool\>" 26syn 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. 34" manifest_parser.cc, ParseRule() 35syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent 36syn 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 40 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 62hi def link ninjaComment Comment 63hi def link ninjaKeyword Keyword 64hi def link ninjaRuleCommand Statement 65hi def link ninjaPoolCommand Statement 66hi 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" 72