3 " Maintainer: Jean Privat <jean@pryen.org>
5 " This file is part of NIT ( http://www.nitlanguage.org ).
7 " Copyright 2009 Jean Privat <jean@pryen.org>
9 " Licensed under the Apache License, Version 2.0 (the "License");
10 " you may not use this file except in compliance with the License.
11 " You may obtain a copy of the License at
13 " http://www.apache.org/licenses/LICENSE-2.0
15 " Unless required by applicable law or agreed to in writing, software
16 " distributed under the License is distributed on an "AS IS" BASIS,
17 " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 " See the License for the specific language governing permissions and
19 " limitations under the License.
21 if exists("b:current_syntax")
25 " Expression Substitution and Backslash Notation
26 syn match NITExprSubstError "{\|}" contained
27 syn match NITExprSubst "\\." contained
28 syn match NITExprSubst "{[^}]*}" contained
30 " Numbers and ASCII Codes
31 syn match NITNumber "\<\(\d\+\.\d\+\|\d\+\)\>"
34 syn match NITClass "\<\u\w*"
35 syn match NITAttribute "\<_\h\w*"
38 syn region NITString matchgroup=NITStringDelimit start="\"" end="\"" skip="\\\\\|\\\"" contains=NITExprSubst,NITExprSubstError
39 syn region NITString matchgroup=NITStringDelimit start="'" end="'" skip="\\\\\|\\'"
42 syn match NITLabel "\<label \h\w*"
44 " Fallback highlight keywords
45 syn match NITNull "\<\(null\)\>"
46 syn match NITControl "\<\(init\|end\|not null\|not\|var\|do\|then\|else\|with\)\>"
48 syn match Error "\<end\>"
50 " Declarations, definitions and blocks
51 syn region NITPackageDecl matchgroup=NITDefine start="\<\(import\|package\)\>\s*" matchgroup=NONE end="\ze\(\s\|:\|(\|$\)" oneline
52 syn region NITClassBlock matchgroup=NITDefine start="\<\(class\|universal\|interface\)\>" matchgroup=NITDefine end="\<end\>" contains=ALL fold
53 syn region NITFunctionDecl matchgroup=NITDefine start="\<\(meth\|fun\)\>\s*" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline
54 syn region NITTypeDecl matchgroup=NITDefine start="\<type\>\s*" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline contained containedin=NITClassBlock
55 syn region NITAttrDecl matchgroup=NITDefine start="\<\(var\|attr\)\>\s*\ze_" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline contained containedin=NITClassBlock
56 syn region NITInitDecl matchgroup=NITDefine start="\<init\>\s*" matchgroup=NONE end="\ze\(\<do\>\|\s\|:\|(\|$\)" oneline contained containedin=NITClassBlock
58 syn region NITStmtBlock matchgroup=NITControl start="\<\(do\|then\|else\)\>\ze\s*\(#\|$\)" matchgroup=NITControl end="^\s*\<\(end\|\zeelse\|with\)\>" contains=ALLBUT,NITTypeDecl,NITAttrDecl,NITInitDecl
59 syn region NITStmtBlock matchgroup=NITControl start="\<\(do\|then\|else\)\>" matchgroup=NITControl end="\<end\>" oneline
61 if !exists("NIT_minlines")
64 exec "syn sync minlines=" . NIT_minlines
66 " Comments and Documentation
67 syn match NITSharpBang "\%^#!.*"
68 syn match NITComment "#.*" contains=NITTodo
71 syn keyword NITKeyword is abstract intern extern super new
72 syn keyword NITDefine private public protected intrude readable writable redef
73 syn keyword NITControl if while for assert and or in as isa once break continue return abort
74 syn keyword NITClass nullable
75 syn keyword NITInclude special
76 syn keyword NITTodo FIXME NOTE TODO XXX contained
77 syn keyword NITBoolean true false
78 syn keyword NITSelf self
80 " Define the default highlighting.
81 hi def link NITDefine Define
82 hi def link NITPackageDecl Identifier
83 hi def link NITFunctionDecl Function
84 hi def link NITTypeDecl Function
85 hi def link NITAttrDecl Function
86 hi def link NITInitDecl Function
87 hi def link NITControl Statement
88 hi def link NITLabel PreProc
89 hi def link NITInclude Include
90 hi def link NITNumber Number
91 hi def link NITBoolean Boolean
92 hi def link NITNull Constant
93 hi def link NITSelf Constant
94 hi def link NITClass Type
95 hi def link NITAttribute Identifier
96 hi def link NITSharpBang PreProc
97 hi def link NITKeyword Keyword
99 hi def link NITString String
100 hi def link NITStringDelimit Delimiter
101 hi def link NITExprSubst Special
102 hi def link NITExprSubstError Error
104 hi def link NITComment Comment
105 hi def link NITTodo Todo
107 let b:current_syntax = "Nit"