1" Vim syntax file
2" Language:	Gunyah Type Files
3" Maintainer:	Carl van Schaik <quic_cvanscha@quicinc.com>
4" Extensions:   *.tc
5"
6" © 2021 Qualcomm Innovation Center, Inc. All rights reserved.
7"
8" SPDX-License-Identifier: BSD-3-Clause
9
10" quit when a syntax file was already loaded
11"if exists("b:current_syntax")
12"  finish
13"endif
14
15syn match tcComment '\/\/.*$' contains=@Spell
16
17syn match Constant contained '\<\(0x[0-9a-fA-f]\+\|0b[01]\+\|[0-9]\+\)\>'
18syn match Bits contained '<[0-9]\+>'
19syn match TypeName contained /[_A-Za-z0-9]\+/
20
21syn keyword tcBaseType contained sint8 sint16 sint32 sint64 bool uint8 uint16 uint32 uint64 char sintptr uintptr sregister uregister size
22syn keyword tcQual contained pointer array atomic aligned lockable
23syn keyword tcBitmap contained unknown
24
25syn match tcContained contained "\%#=1\<contained\>"
26
27syn match tcConstantEqual /=/ contained skipwhite nextgroup=Constant
28syn keyword tcConstant constant contained skipwhite nextgroup=tcConstantEqual
29syn keyword Aggregates type object public structure enumeration bitfield contained
30syn keyword newtype newtype
31syn region tcNewType start="newtype" end=";" contained contains=tcBaseType,tcQual,Constant,Aggregates,newtype
32syn keyword tcDefine define contained skipwhite nextgroup=TypeName
33syn keyword tcExtend extend contained skipwhite nextgroup=TypeName
34
35"syn match assignment '=' skipwhite contained nextgroup=Constant
36"hi def link assignment 	TODO
37
38syn region tcDef start="\(define\|extend\)" end=";" keepend contains=tcDefine,tcExtend,Bits,Aggregates,tcConstant,tcNewType,tcQual,tcBlock,tcComment
39
40"hi def link tcDef 		Error
41
42syn region tcBlock start="{" end="}" contained extend contains=Constant,tcComment,tcBaseType,Aggregates,tcQual,tcBitmap,cppDirective,cppSingle,tcContained
43"hi def link tcBlock 		TODO
44
45syntax region cppDirective	display start="^\s*\zs\(%:\|#\)\s*\(define\|if\|ifdef\|elif\|error\)\>\s\+" skip="\\$" end="$" keepend contains=Constant
46syntax match cppSingle	display /^\s*\zs\(%:\|#\)\s*\(endif\|else\)\>/
47
48hi def link tcComment		Comment
49hi def link tcDefine 		Identifier
50hi def link tcExtend 		tcDefine
51hi def link cppDirective	PreProc
52hi def link cppSingle 		cppDirective
53hi def link Aggregates 		Keyword
54hi def link newtype		Keyword
55hi def link tcQual 		Keyword
56hi def link tcBitmap		Special
57hi def link tcConstant 		Keyword
58hi def link tcContained		Keyword
59"hi def link TypeName		Define
60hi def link tcBaseType		Type
61hi def link Bits		Operator
62
63let b:current_syntax = "types"
64