1" Vim syntax file
2" Language:	MS Message Text files (*.mc)
3" Maintainer:	Kevin Locke <kwl7@cornell.edu>
4" Last Change:	2008 April 09
5" Location:	http://kevinlocke.name/programs/vim/syntax/msmessages.vim
6
7" See format description at <http://msdn2.microsoft.com/en-us/library/aa385646.aspx>
8" This file is based on the rc.vim and c.vim
9
10" For version 5.x: Clear all syntax items
11" For version 6.x: Quit when a syntax file was already loaded
12if version < 600
13  syntax clear
14elseif exists("b:current_syntax")
15  finish
16endif
17
18" Common MS Messages keywords
19syn case ignore
20syn keyword msmessagesIdentifier MessageIdTypedef
21syn keyword msmessagesIdentifier SeverityNames
22syn keyword msmessagesIdentifier FacilityNames
23syn keyword msmessagesIdentifier LanguageNames
24syn keyword msmessagesIdentifier OutputBase
25
26syn keyword msmessagesIdentifier MessageId
27syn keyword msmessagesIdentifier Severity
28syn keyword msmessagesIdentifier Facility
29syn keyword msmessagesIdentifier OutputBase
30
31syn match msmessagesIdentifier /\<SymbolicName\>/ nextgroup=msmessagesIdentEq skipwhite
32syn match msmessagesIdentEq transparent /=/ nextgroup=msmessagesIdentDef skipwhite contained
33syn match msmessagesIdentDef display /\w\+/ contained
34" Note:  The Language keyword is highlighted as part of an msmessagesLangEntry
35
36" Set value
37syn case match
38syn region msmessagesSet	start="(" end=")" transparent fold contains=msmessagesName keepend
39syn match msmessagesName /\w\+/ nextgroup=msmessagesSetEquals skipwhite contained
40syn match msmessagesSetEquals /=/ display transparent nextgroup=msmessagesNumVal skipwhite contained
41syn match msmessagesNumVal	display transparent "\<\d\|\.\d" contains=msmessagesNumber,msmessagesFloat,msmessagesOctalError,msmessagesOctal nextgroup=msmessagesValSep
42syn match msmessagesValSep /:/ display nextgroup=msmessagesNameDef contained
43syn match msmessagesNameDef /\w\+/ display contained
44
45
46" Comments are converted to C source (by removing leading ;)
47" So we highlight the comments as C
48syn include @msmessagesC syntax/c.vim
49unlet b:current_syntax
50syn region msmessagesCComment matchgroup=msmessagesComment start=/;/ end=/$/ contains=@msmessagesC keepend
51
52" String and Character constants
53" Highlight special characters (those which have a escape) differently
54syn case ignore
55syn region msmessagesLangEntry start=/\<Language\>\s*=\s*\S\+\s*$/hs=e+1 end=/^\./ contains=msmessagesFormat,msmessagesLangEntryEnd,msmessagesLanguage keepend
56syn match msmessagesLanguage /\<Language\(\s*=\)\@=/ contained
57syn match msmessagesLangEntryEnd display /^\./ contained
58syn case match
59syn match msmessagesFormat display	/%[1-9]\d\?\(![-+0 #]*\d*\(\.\d\+\)\?\(h\|l\|ll\|I\|I32\|I64\)\?[aAcCdeEfgGinopsSuxX]!\)\?/ contained
60syn match msmessagesFormat display	/%[0.%\\br]/ contained
61syn match msmessagesFormat display	/%!\(\s\)\@=/ contained
62
63" Integer number, or floating point number without a dot and with "f".
64" Copied from c.vim
65syn case ignore
66"(long) integer
67syn match msmessagesNumber	display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
68"hex number
69syn match msmessagesNumber	display contained "\<0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
70" Flag the first zero of an octal number as something special
71syn match msmessagesOctal	display contained "\<0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=msmessagesOctalZero
72syn match msmessagesOctalZero	display contained "\<0"
73" flag an octal number with wrong digits
74syn match msmessagesOctalError	display contained "\<0\o*[89]\d*"
75syn match msmessagesFloat	display contained "\d\+f"
76"floating point number, with dot, optional exponent
77syn match msmessagesFloat	display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
78"floating point number, starting with a dot, optional exponent
79syn match msmessagesFloat	display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
80"floating point number, without dot, with exponent
81syn match msmessagesFloat	display contained "\d\+e[-+]\=\d\+[fl]\=\>"
82"hexadecimal floating point number, optional leading digits, with dot, with exponent
83syn match msmessagesFloat	display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
84"hexadecimal floating point number, with leading digits, optional dot, with exponent
85syn match msmessagesFloat	display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
86
87" Types (used in MessageIdTypedef statement)
88syn case match
89syn keyword msmessagesType	int long short char
90syn keyword msmessagesType	signed unsigned
91syn keyword msmessagesType	size_t ssize_t sig_atomic_t
92syn keyword msmessagesType	int8_t int16_t int32_t int64_t
93syn keyword msmessagesType	uint8_t uint16_t uint32_t uint64_t
94syn keyword msmessagesType	int_least8_t int_least16_t int_least32_t int_least64_t
95syn keyword msmessagesType	uint_least8_t uint_least16_t uint_least32_t uint_least64_t
96syn keyword msmessagesType	int_fast8_t int_fast16_t int_fast32_t int_fast64_t
97syn keyword msmessagesType	uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
98syn keyword msmessagesType	intptr_t uintptr_t
99syn keyword msmessagesType	intmax_t uintmax_t
100" Add some Windows datatypes that will be common in msmessages files
101syn keyword msmessagesType	BYTE CHAR SHORT SIZE_T SSIZE_T TBYTE TCHAR UCHAR USHORT
102syn keyword msmessagesType	DWORD DWORDLONG DWORD32 DWORD64
103syn keyword msmessagesType	INT INT32 INT64 UINT UINT32 UINT64
104syn keyword msmessagesType	LONG LONGLONG LONG32 LONG64
105syn keyword msmessagesType	ULONG ULONGLONG ULONG32 ULONG64
106
107" Sync to language entries, since they should be most common
108syn sync match msmessagesLangSync grouphere msmessagesLangEntry "\<Language\s*="
109syn sync match msmessagesLangEndSync grouphere NONE "^\."
110
111" Define the default highlighting.
112hi def link msmessagesNumber		Number
113hi def link msmessagesOctal		Number
114hi def link msmessagesFloat		Float
115hi def link msmessagesOctalError	msmessagesError
116hi def link msmessagesSetError		msmessagesError
117hi def link msmessagesError		Error
118hi def link msmessagesLangEntry		String
119hi def link msmessagesLangEntryEnd	Special
120hi def link msmessagesComment		Comment
121hi def link msmessagesFormat		msmessagesSpecial
122hi def link msmessagesSpecial		SpecialChar
123
124hi def link msmessagesType		Type
125hi def link msmessagesIdentifier	Identifier
126hi def link msmessagesLanguage		msmessagesIdentifier
127hi def link msmessagesName		msmessagesIdentifier
128hi def link msmessagesNameDef		Macro
129hi def link msmessagesIdentDef		Macro
130hi def link msmessagesValSep		Special
131hi def link msmessagesNameErr		Error
132
133let b:current_syntax = "msmessages"
134
135" vim: ts=8
136