1" ninja build file syntax. 2" Language: ninja build file as described at 3" http://martine.github.com/ninja/manual.html 4" Version: 1.2 5" Last Change: 2012/06/01 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/parsers.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 parsers.cc, Parse() 23syn match ninjaKeyword "^build\>" 24syn match ninjaKeyword "^rule\>" 25syn match ninjaKeyword "^default\>" 26syn match ninjaKeyword "^include\>" 27syn match ninjaKeyword "^subninja\>" 28 29" Both 'build' and 'rule' begin a variable scope that ends 30" on the first line without indent. 'rule' allows only a 31" limited set of magic variables, 'build' allows general 32" let assignments. 33" parsers.cc, ParseRule() 34syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent 35syn keyword ninjaRuleCommand contained command depfile description generator restat 36 37" Strings are parsed as follows: 38" lexer.in.cc, ReadEvalString() 39" simple_varname = [a-zA-Z0-9_-]+; 40" varname = [a-zA-Z0-9_.-]+; 41" $$ -> $ 42" $\n -> line continuation 43" '$ ' -> escaped space 44" $simple_varname -> variable 45" ${varname} -> variable 46 47syn match ninjaWrapLineOperator "\$$" 48syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+" 49syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}" 50 51" operators are: 52" variable assignment = 53" rule definition : 54" implicit dependency | 55" order-only dependency || 56syn match ninjaOperator "\(=\|:\||\|||\)\ze\s" 57 58hi def link ninjaComment Comment 59hi def link ninjaKeyword Keyword 60hi def link ninjaRuleCommand Statement 61hi def link ninjaWrapLineOperator ninjaOperator 62hi def link ninjaOperator Operator 63hi def link ninjaSimpleVar ninjaVar 64hi def link ninjaVar Identifier 65 66let b:current_syntax = "ninja" 67