Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: dts/dtsi (device tree files) |
| 3 | " Maintainer: Daniel Mack <vim@zonque.org> |
Bram Moolenaar | d592deb | 2022-06-17 15:42:40 +0100 | [diff] [blame] | 4 | " Last Change: 2022 Jun 14 |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 5 | |
| 6 | if exists("b:current_syntax") |
| 7 | finish |
| 8 | endif |
Bram Moolenaar | d592deb | 2022-06-17 15:42:40 +0100 | [diff] [blame] | 9 | let b:current_syntax = 'dts' |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 10 | |
| 11 | syntax region dtsComment start="/\*" end="\*/" |
| 12 | syntax match dtsReference "&[[:alpha:][:digit:]_]\+" |
Bram Moolenaar | 3ec3217 | 2021-05-16 12:39:47 +0200 | [diff] [blame] | 13 | syntax region dtsBinaryProperty start="\[" end="\]" |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 14 | syntax match dtsStringProperty "\".*\"" |
Bram Moolenaar | d5d015d | 2013-11-03 21:14:31 +0100 | [diff] [blame] | 15 | syntax match dtsKeyword "/.\{-1,\}/" |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 16 | syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:" |
Bram Moolenaar | bf88493 | 2013-04-05 22:26:15 +0200 | [diff] [blame] | 17 | syntax match dtsNode /[[:alpha:][:digit:]-_]\+\(@[0-9a-fA-F]\+\|\)[[:space:]]*{/he=e-1 |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 18 | syntax region dtsCellProperty start="<" end=">" contains=dtsReference,dtsBinaryProperty,dtsStringProperty,dtsComment |
| 19 | syntax region dtsCommentInner start="/\*" end="\*/" |
Bram Moolenaar | d5d015d | 2013-11-03 21:14:31 +0100 | [diff] [blame] | 20 | syntax match dtsCommentLine "//.*$" |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 21 | |
Bram Moolenaar | 3ec3217 | 2021-05-16 12:39:47 +0200 | [diff] [blame] | 22 | " Accept %: for # (C99) |
| 23 | syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError |
| 24 | syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>" |
| 25 | if !exists("c_no_if0") |
| 26 | syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip |
| 27 | syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold |
| 28 | syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse |
| 29 | if !exists("c_no_if0_fold") |
| 30 | 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 |
| 31 | else |
| 32 | syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell |
| 33 | endif |
| 34 | syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit |
| 35 | syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold |
| 36 | syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit |
| 37 | if !exists("c_no_if0_fold") |
| 38 | syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold |
| 39 | else |
| 40 | syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 |
| 41 | endif |
| 42 | syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell |
| 43 | syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip |
| 44 | 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 |
| 45 | endif |
| 46 | syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ |
| 47 | syn match cIncluded display contained "<[^>]*>" |
| 48 | syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded |
| 49 | "syn match cLineSkip "\\$" |
| 50 | syn 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 |
| 51 | syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell |
| 52 | syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell |
| 53 | |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 54 | hi def link dtsCellProperty Number |
| 55 | hi def link dtsBinaryProperty Number |
| 56 | hi def link dtsStringProperty String |
| 57 | hi def link dtsKeyword Include |
| 58 | hi def link dtsLabel Label |
Bram Moolenaar | ac7bd63 | 2013-03-19 11:35:58 +0100 | [diff] [blame] | 59 | hi def link dtsNode Structure |
Bram Moolenaar | 0c5fa7d | 2012-10-05 22:26:30 +0200 | [diff] [blame] | 60 | hi def link dtsReference Macro |
| 61 | hi def link dtsComment Comment |
Bram Moolenaar | 3ec3217 | 2021-05-16 12:39:47 +0200 | [diff] [blame] | 62 | hi def link dtsCommentInner Comment |
Bram Moolenaar | d5d015d | 2013-11-03 21:14:31 +0100 | [diff] [blame] | 63 | hi def link dtsCommentLine Comment |
Bram Moolenaar | 3ec3217 | 2021-05-16 12:39:47 +0200 | [diff] [blame] | 64 | |
| 65 | hi def link cInclude Include |
| 66 | hi def link cPreProc PreProc |
| 67 | hi def link cDefine Macro |
| 68 | hi def link cIncluded cString |
| 69 | hi def link cString String |
| 70 | |
| 71 | hi def link cCppInWrapper cCppOutWrapper |
| 72 | hi def link cCppOutWrapper cPreCondit |
| 73 | hi def link cPreConditMatch cPreCondit |
| 74 | hi def link cPreCondit PreCondit |
| 75 | hi def link cCppOutSkip cCppOutIf2 |
| 76 | |
| 77 | hi def link cCppInElse2 cCppOutIf2 |
| 78 | hi def link cCppOutIf2 cCppOut |
| 79 | hi def link cCppOut Comment |