1" Vim syntax file
2" Language:	Gunyah Event Files
3" Maintainer:	Carl van Schaik <quic_cvanscha@quicinc.com>
4" Extensions:   *.ev
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 evComment '\/\/.*$'
16
17syn match moduleName contained /[_A-Za-z0-9]\+/
18syn keyword module module interface contained nextgroup=moduleName skipwhite
19syn match moduleDef '^\(module\|interface\)\>.*$' contains=module,evComment
20
21syn match handlerName contained /[_A-Za-z0-9]\+/
22syn keyword evHandler handler contained skipwhite nextgroup=handlerName
23syn keyword evUnwinder unwinder contained skipwhite nextgroup=handlerName
24
25syn match priorityNum contained /[0-9]\+\>/
26syn keyword priorityKeyword contained first last
27syn match priorityVal /[_A-Za-z0-9]\+/ contained contains=priorityNum,priorityKeyword
28syn keyword priority priority contained skipwhite nextgroup=priorityVal
29
30syn match lockAttrib /(acquire|release|require|exclude)_(lock|read|count)/ contained skipwhite
31
32syn match evName contained /[_A-Za-z0-9]\+/
33syn keyword evDirective subscribe event selector_event handled_event contained skipwhite nextgroup=evName
34
35syn match evSubscriber '^subscribe\s.*$' skipnl nextgroup=evSubscriberBody contains=evComment,evDirective
36syn match evSubscriberBody '^\(\s\+\).*$' contained skipnl nextgroup=evSubscriberBody contains=evComment,evHandler,evUnwinder,priority
37
38" simple for now
39"syn match evSep contained /:/ skipwhite nextgroup=evParam
40syn match evParam contained /[_A-Za-z0-9]\+/ nextgroup=evSep
41syn keyword evEventDef selector param return contained skipwhite nextgroup=evParam,evSep
42
43syn match evEvent '^\(\(selector\|handled\)_\)\?event\s.*$' skipnl nextgroup=evEventBody contains=evComment,evDirective
44syn match evEventBody '^\(\s\+\).*$' contained skipnl nextgroup=evEventBody contains=evComment,evEventDef
45
46" TODO
47" handler function params
48
49hi def link evComment		Comment
50hi def link evName 		Label
51hi def link evDirective		Type
52hi def link handlerName		Identifier
53hi def link evParam		Identifier
54hi def link evHandler		PreProc
55hi def link evUnwinder		PreProc
56hi def link evEventDef		PreProc
57hi def link module		PreProc
58hi def link priorityNum		Constant
59hi def link priorityKeyword	Special
60hi def link priority		PreProc
61hi def link lockAttrib		PreProc
62hi def link moduleName		Label
63
64"hi def link evEventBody		TODO
65
66let b:current_syntax = "events"
67