blob: d75b9c178a0342ade616090ee56b3dcc9b66e8df [file] [log] [blame]
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +02001" Vim syntax file
2" Language: dts/dtsi (device tree files)
3" Maintainer: Daniel Mack <vim@zonque.org>
Bram Moolenaar3ec32172021-05-16 12:39:47 +02004" Last Change: 2021 May 15
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +02005
6if exists("b:current_syntax")
7 finish
8endif
9
10syntax region dtsComment start="/\*" end="\*/"
11syntax match dtsReference "&[[:alpha:][:digit:]_]\+"
Bram Moolenaar3ec32172021-05-16 12:39:47 +020012syntax region dtsBinaryProperty start="\[" end="\]"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020013syntax match dtsStringProperty "\".*\""
Bram Moolenaard5d015d2013-11-03 21:14:31 +010014syntax match dtsKeyword "/.\{-1,\}/"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020015syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:"
Bram Moolenaarbf884932013-04-05 22:26:15 +020016syntax match dtsNode /[[:alpha:][:digit:]-_]\+\(@[0-9a-fA-F]\+\|\)[[:space:]]*{/he=e-1
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020017syntax region dtsCellProperty start="<" end=">" contains=dtsReference,dtsBinaryProperty,dtsStringProperty,dtsComment
18syntax region dtsCommentInner start="/\*" end="\*/"
Bram Moolenaard5d015d2013-11-03 21:14:31 +010019syntax match dtsCommentLine "//.*$"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020020
Bram Moolenaar3ec32172021-05-16 12:39:47 +020021" Accept %: for # (C99)
22syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
23syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>"
24if !exists("c_no_if0")
25 syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip
26 syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
27 syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
28 if !exists("c_no_if0_fold")
29 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold
30 else
31 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
32 endif
33 syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
34 syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
35 syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
36 if !exists("c_no_if0_fold")
37 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
38 else
39 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
40 endif
41 syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
42 syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
43 syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc
44endif
45syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
46syn match cIncluded display contained "<[^>]*>"
47syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
48"syn match cLineSkip "\\$"
49syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock
50syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
51syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
52
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020053hi def link dtsCellProperty Number
54hi def link dtsBinaryProperty Number
55hi def link dtsStringProperty String
56hi def link dtsKeyword Include
57hi def link dtsLabel Label
Bram Moolenaarac7bd632013-03-19 11:35:58 +010058hi def link dtsNode Structure
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020059hi def link dtsReference Macro
60hi def link dtsComment Comment
Bram Moolenaar3ec32172021-05-16 12:39:47 +020061hi def link dtsCommentInner Comment
Bram Moolenaard5d015d2013-11-03 21:14:31 +010062hi def link dtsCommentLine Comment
Bram Moolenaar3ec32172021-05-16 12:39:47 +020063
64hi def link cInclude Include
65hi def link cPreProc PreProc
66hi def link cDefine Macro
67hi def link cIncluded cString
68hi def link cString String
69
70hi def link cCppInWrapper cCppOutWrapper
71hi def link cCppOutWrapper cPreCondit
72hi def link cPreConditMatch cPreCondit
73hi def link cPreCondit PreCondit
74hi def link cCppOutSkip cCppOutIf2
75
76hi def link cCppInElse2 cCppOutIf2
77hi def link cCppOutIf2 cCppOut
78hi def link cCppOut Comment