codekingpro/portable-devtools
114k
1" ninja build file syntax.2" Language: ninja build file as described at3" http://ninja-build.org/manual.html4" Version: 1.55" Last Change: 2018/04/056" Maintainer: Nicolas Weber <nicolasweber@gmx.de>7" Version 1.5 of this script is in the upstream vim repository and will be8" included in the next vim release. If you change this, please send your change9" upstream.10 11" ninja lexer and parser are at12" https://github.com/ninja-build/ninja/blob/master/src/lexer.in.cc13" https://github.com/ninja-build/ninja/blob/master/src/manifest_parser.cc14 15if exists("b:current_syntax")16 finish17endif18 19let s:cpo_save = &cpo20set cpo&vim21 22syn case match23 24" Comments are only matched when the # is at the beginning of the line (with25" optional whitespace), as long as the prior line didn't end with a $26" continuation.27syn match ninjaComment /\(\$\n\)\@<!\_^\s*#.*$/ contains=@Spell28 29" Toplevel statements are the ones listed here and30" toplevel variable assignments (ident '=' value).31" lexer.in.cc, ReadToken() and manifest_parser.cc, Parse()32syn match ninjaKeyword "^build\>"33syn match ninjaKeyword "^rule\>"34syn match ninjaKeyword "^pool\>"35syn match ninjaKeyword "^default\>"36syn match ninjaKeyword "^include\>"37syn match ninjaKeyword "^subninja\>"38 39" Both 'build' and 'rule' begin a variable scope that ends40" on the first line without indent. 'rule' allows only a41" limited set of magic variables, 'build' allows general42" let assignments.43" manifest_parser.cc, ParseRule()44syn region ninjaRule start="^rule" end="^\ze\S" contains=TOP transparent45syn keyword ninjaRuleCommand contained containedin=ninjaRule command46 \ deps depfile description generator47 \ pool restat rspfile rspfile_content48 49syn region ninjaPool start="^pool" end="^\ze\S" contains=TOP transparent50syn keyword ninjaPoolCommand contained containedin=ninjaPool depth51 52" Strings are parsed as follows:53" lexer.in.cc, ReadEvalString()54" simple_varname = [a-zA-Z0-9_-]+;55" varname = [a-zA-Z0-9_.-]+;56" $$ -> $57" $\n -> line continuation58" '$ ' -> escaped space59" $simple_varname -> variable60" ${varname} -> variable61 62syn match ninjaDollar "\$\$"63syn match ninjaWrapLineOperator "\$$"64syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"65syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"66 67" operators are:68" variable assignment =69" rule definition :70" implicit dependency |71" order-only dependency ||72syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"73 74hi def link ninjaComment Comment75hi def link ninjaKeyword Keyword76hi def link ninjaRuleCommand Statement77hi def link ninjaPoolCommand Statement78hi def link ninjaDollar ninjaOperator79hi def link ninjaWrapLineOperator ninjaOperator80hi def link ninjaOperator Operator81hi def link ninjaSimpleVar ninjaVar82hi def link ninjaVar Identifier83 84let b:current_syntax = "ninja"85 86let &cpo = s:cpo_save87unlet s:cpo_save88 