3 " Copyright (C) 2004 Chris Larson <kergoth@handhelds.org>
4 " This file is licensed under the MIT license, see COPYING.MIT in
5 " this source distribution for the terms.
8 " Maintainer: Chris Larson <kergoth@handhelds.org>
9 " Filenames: *.bb, *.bbclass
13 elseif exists("b:current_syntax")
19 syn match bbComment "^#.*$" display contains=bbTodo
20 syn keyword bbTodo TODO FIXME XXX contained
21 syn match bbDelimiter "[(){}=]" contained
22 syn match bbQuote /['"]/ contained
24 "syn region bbString matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ keepend contains=bbTodo
25 "syn region bbString matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ keepend contains=bbTodo
26 syn match bbContinue "\\$"
27 syn region bbString matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ contained keepend contains=bbTodo,bbContinue,bbVarDeref
28 syn region bbString matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ contained keepend contains=bbTodo,bbContinue,bbVarDeref
31 " syn keyword bbPythonFlag python contained nextgroup=bbFunction
32 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef
33 " syn match bbPythonFuncDef "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag
34 " hi def link bbPythonFuncRegion Comment
35 " hi def link bbPythonFlag Type
38 " syn keyword bbPythonFlag python contained nextgroup=bbFunction
39 " syn match bbPythonFuncDef "^python\s\+\w\+\s*()\s*{" contained contains=bbPythonFlag,bbFunction,bbDelimiter
40 " syn region bbPythonFuncRegion start="^python\s\+\w\+\s*()\s*{" end="^}$" keepend contains=bbPythonFuncDef,bbDelimiter
41 " hi def link bbPythonFuncRegion Comment
42 " hi def link bbPythonFlag Type
45 " syn keyword bbPythonFlag python contained nextgroup=bbFunction
46 " syn match bbPythonFuncDef "^\(python\s\+\w\+\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
47 " syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained
48 " hi def link bbPythonFuncRegion Comment
49 " hi def link bbPythonFlag Type
51 " BitBake variable metadata
53 syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite
54 syn match bbVarDeref "${[a-zA-Z0-9\-_\.]\+}" contained
55 syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.]\+\(_[${}a-zA-Z0-9\-_\.]\+\)\?\)\s*\(\(:=\)\|\(+=\)\|\(=+\)\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbVarDeref nextgroup=bbVarEq
57 syn match bbIdentifier "[a-zA-Z0-9\-_\.]\+" display contained
58 "syn keyword bbVarEq = display contained nextgroup=bbVarValue
59 syn match bbVarEq "\(:=\)\|\(+=\)\|\(=+\)\|=" contained nextgroup=bbVarValue
60 syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref
63 " BitBake variable metadata flags
64 syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag
65 syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\)\@=" keepend excludenl contained contains=bbIdentifier nextgroup=bbVarEq
66 "syn match bbVarFlagFlag "\[\([a-zA-Z0-9\-_\.]\+\)\]\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq
70 syn match bbFunction "\h\w*" display contained
73 " BitBake python metadata
74 syn include @python syntax/python.vim
75 if exists("b:current_syntax")
76 unlet b:current_syntax
79 syn keyword bbPythonFlag python contained nextgroup=bbFunction
80 syn match bbPythonFuncDef "^\(python\s\+\)\(\w\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion
81 syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@python
82 "hi def link bbPythonFuncRegion Comment
85 " BitBake shell metadata
86 syn include @shell syntax/sh.vim
87 if exists("b:current_syntax")
88 unlet b:current_syntax
91 syn match bbShellFuncDef "^\(\w\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbFunction,bbDelimiter nextgroup=bbShellFuncRegion
92 syn region bbShellFuncRegion matchgroup=bbDelimiter start="{" end="^}$" keepend contained contains=@shell
93 "hi def link bbShellFuncRegion Comment
96 " BitBake 'def'd python functions
97 syn keyword bbDef def contained
99 syn match bbDefCmd "^def" contains=bbDef skipwhite nextgroup=bbDefFunc
100 syn match bbDefFunc "\w\+" contains=bbFunction contained skipwhite nextgroup=bbDefArgs
101 syn region bbDefArgs matchgroup=bbDelimiter start="(" end=")" excludenl contained skipwhite keepend contains=bbIdentifier nextgroup=bbDefRegion
102 syn region bbDefRegion matchgroup=bbDelimiter start=":$" end='^\(\s\|$\)\@!' contained contains=@python
106 syn keyword bbStatement include inherit addtask addhandler EXPORT_FUNCTIONS display contained
107 syn match bbStatementLine "^\(include\|inherit\|addtask\|addhandler\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest
108 syn match bbStatementRest ".*$" contained contains=bbString,bbVarDeref
110 syn match bbArrayBrackets "[\[\]]" contained
111 hi def link bbArrayBrackets Statement
113 hi def link bbVarDeref String
114 hi def link bbContinue Special
115 hi def link bbDef Statement
116 hi def link bbPythonFlag Type
117 hi def link bbExportFlag Type
118 hi def link bbStatement Statement
119 hi def link bbString String
120 hi def link bbTodo Todo
121 hi def link bbComment Comment
122 hi def link bbOperator Operator
123 hi def link bbError Error
124 hi def link bbFunction Function
125 hi def link bbDelimiter Delimiter
126 hi def link bbIdentifier Identifier
127 hi def link bbVarEq Operator
129 hi def link bbQuote String
130 hi def link bbVarValue String
132 let b:current_syntax = "bb"