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