blob: 0f63bea2fe9b12c903de1f57189e7bab6468971e [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: TADS
3" Maintainer: Amir Karger <karger@post.harvard.edu>
Bram Moolenaar5c736222010-01-06 20:54:52 +01004" $Date: 2004/06/13 19:28:45 $
5" $Revision: 1.1 $
Bram Moolenaar071d4272004-06-13 20:20:40 +00006" Stolen from: Bram Moolenaar's C language file
7" Newest version at: http://www.hec.utah.edu/~karger/vim/syntax/tads.vim
8" History info at the bottom of the file
9
10" TODO lots more keywords
11" global, self, etc. are special *objects*, not functions. They should
12" probably be a different color than the special functions
13" Actually, should cvtstr etc. be functions?! (change tadsFunction)
14" Make global etc. into Identifiers, since we don't have regular variables?
15
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020016" quit when a syntax file was already loaded
17if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000018 finish
19endif
20
21" A bunch of useful keywords
22syn keyword tadsStatement goto break return continue pass
23syn keyword tadsLabel case default
24syn keyword tadsConditional if else switch
25syn keyword tadsRepeat while for do
26syn keyword tadsStorageClass local compoundWord formatstring specialWords
27syn keyword tadsBoolean nil true
28
29" TADS keywords
30syn keyword tadsKeyword replace modify
31syn keyword tadsKeyword global self inherited
32" builtin functions
33syn keyword tadsKeyword cvtstr cvtnum caps lower upper substr
34syn keyword tadsKeyword say length
35syn keyword tadsKeyword setit setscore
36syn keyword tadsKeyword datatype proptype
37syn keyword tadsKeyword car cdr
38syn keyword tadsKeyword defined isclass
39syn keyword tadsKeyword find firstobj nextobj
40syn keyword tadsKeyword getarg argcount
41syn keyword tadsKeyword input yorn askfile
42syn keyword tadsKeyword rand randomize
43syn keyword tadsKeyword restart restore quit save undo
44syn keyword tadsException abort exit exitobj
45
46syn keyword tadsTodo contained TODO FIXME XXX
47
48" String and Character constants
49" Highlight special characters (those which have a backslash) differently
50syn match tadsSpecial contained "\\."
51syn region tadsDoubleString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=tadsSpecial,tadsEmbedded
52syn region tadsSingleString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=tadsSpecial
53" Embedded expressions in strings
54syn region tadsEmbedded contained start="<<" end=">>" contains=tadsKeyword
55
56" TADS doesn't have \xxx, right?
57"syn match cSpecial contained "\\[0-7][0-7][0-7]\=\|\\."
58"syn match cSpecialCharacter "'\\[0-7][0-7]'"
59"syn match cSpecialCharacter "'\\[0-7][0-7][0-7]'"
60
61"catch errors caused by wrong parenthesis
62"syn region cParen transparent start='(' end=')' contains=ALLBUT,cParenError,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel
63"syn match cParenError ")"
64"syn match cInParen contained "[{}]"
65syn region tadsBrace transparent start='{' end='}' contains=ALLBUT,tadsBraceError,tadsIncluded,tadsSpecial,tadsTodo
66syn match tadsBraceError "}"
67
68"integer number (TADS has no floating point numbers)
69syn case ignore
70syn match tadsNumber "\<[0-9]\+\>"
71"hex number
72syn match tadsNumber "\<0x[0-9a-f]\+\>"
73syn match tadsIdentifier "\<[a-z][a-z0-9_$]*\>"
74syn case match
75" flag an octal number with wrong digits
76syn match tadsOctalError "\<0[0-7]*[89]"
77
78" Removed complicated c_comment_strings
79syn region tadsComment start="/\*" end="\*/" contains=tadsTodo
80syn match tadsComment "//.*" contains=tadsTodo
81syntax match tadsCommentError "\*/"
82
83syn region tadsPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=tadsComment,tadsString,tadsNumber,tadsCommentError
84syn region tadsIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
85syn match tadsIncluded contained "<[^>]*>"
86syn match tadsInclude "^\s*#\s*include\>\s*["<]" contains=tadsIncluded
87syn region tadsDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInBrace,tadsIdentifier
88
89syn region tadsPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInParen,tadsIdentifier
90
91" Highlight User Labels
92" TODO labels for gotos?
93"syn region cMulti transparent start='?' end=':' contains=ALLBUT,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel,cBitField
94" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
95"syn match cUserCont "^\s*\I\i*\s*:$" contains=cUserLabel
96"syn match cUserCont ";\s*\I\i*\s*:$" contains=cUserLabel
97"syn match cUserCont "^\s*\I\i*\s*:[^:]" contains=cUserLabel
98"syn match cUserCont ";\s*\I\i*\s*:[^:]" contains=cUserLabel
99
100"syn match cUserLabel "\I\i*" contained
101
102" identifier: class-name [, class-name [...]] [property-list] ;
103" Don't highlight comment in class def
104syn match tadsClassDef "\<class\>[^/]*" contains=tadsObjectDef,tadsClass
105syn match tadsClass contained "\<class\>"
106syn match tadsObjectDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*[a-zA-Z0-9_$]\+\(\s*,\s*[a-zA-Z][a-zA-Z0-9_$]*\)*\(\s*;\)\="
107syn keyword tadsFunction contained function
108syn match tadsFunctionDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*function[^{]*" contains=tadsFunction
109"syn region tadsObject transparent start = '[a-zA-Z][\i$]\s*:\s*' end=";" contains=tadsBrace,tadsObjectDef
110
111" How far back do we go to find matching groups
112if !exists("tads_minlines")
113 let tads_minlines = 15
114endif
115exec "syn sync ccomment tadsComment minlines=" . tads_minlines
116if !exists("tads_sync_dist")
117 let tads_sync_dist = 100
118endif
119execute "syn sync maxlines=" . tads_sync_dist
120
121" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200122" Only when an item doesn't have highlighting yet
123command -nargs=+ HiLink hi def link <args>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200125" The default methods for highlighting. Can be overridden later
126HiLink tadsFunctionDef Function
127HiLink tadsFunction Structure
128HiLink tadsClass Structure
129HiLink tadsClassDef Identifier
130HiLink tadsObjectDef Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131" no highlight for tadsEmbedded, so it prints as normal text w/in the string
132
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200133HiLink tadsOperator Operator
134HiLink tadsStructure Structure
135HiLink tadsTodo Todo
136HiLink tadsLabel Label
137HiLink tadsConditional Conditional
138HiLink tadsRepeat Repeat
139HiLink tadsException Exception
140HiLink tadsStatement Statement
141HiLink tadsStorageClass StorageClass
142HiLink tadsKeyWord Keyword
143HiLink tadsSpecial SpecialChar
144HiLink tadsNumber Number
145HiLink tadsBoolean Boolean
146HiLink tadsDoubleString tadsString
147HiLink tadsSingleString tadsString
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200149HiLink tadsOctalError tadsError
150HiLink tadsCommentError tadsError
151HiLink tadsBraceError tadsError
152HiLink tadsInBrace tadsError
153HiLink tadsError Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200155HiLink tadsInclude Include
156HiLink tadsPreProc PreProc
157HiLink tadsDefine Macro
158HiLink tadsIncluded tadsString
159HiLink tadsPreCondit PreCondit
Bram Moolenaar071d4272004-06-13 20:20:40 +0000160
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200161HiLink tadsString String
162HiLink tadsComment Comment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200164delcommand HiLink
Bram Moolenaar071d4272004-06-13 20:20:40 +0000165
166
167let b:current_syntax = "tads"
168
169" Changes:
170" 11/18/99 Added a bunch of TADS functions, tadsException
171" 10/22/99 Misspelled Moolenaar (sorry!), c_minlines to tads_minlines
172"
173" vim: ts=8