blob: 23a65b99eccaf2a7bc8bd22189b5ed92c799e855 [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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200124" The default methods for highlighting. Can be overridden later
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200125hi def link tadsFunctionDef Function
126hi def link tadsFunction Structure
127hi def link tadsClass Structure
128hi def link tadsClassDef Identifier
129hi def link tadsObjectDef Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000130" no highlight for tadsEmbedded, so it prints as normal text w/in the string
131
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200132hi def link tadsOperator Operator
133hi def link tadsStructure Structure
134hi def link tadsTodo Todo
135hi def link tadsLabel Label
136hi def link tadsConditional Conditional
137hi def link tadsRepeat Repeat
138hi def link tadsException Exception
139hi def link tadsStatement Statement
140hi def link tadsStorageClass StorageClass
141hi def link tadsKeyWord Keyword
142hi def link tadsSpecial SpecialChar
143hi def link tadsNumber Number
144hi def link tadsBoolean Boolean
145hi def link tadsDoubleString tadsString
146hi def link tadsSingleString tadsString
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200148hi def link tadsOctalError tadsError
149hi def link tadsCommentError tadsError
150hi def link tadsBraceError tadsError
151hi def link tadsInBrace tadsError
152hi def link tadsError Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200154hi def link tadsInclude Include
155hi def link tadsPreProc PreProc
156hi def link tadsDefine Macro
157hi def link tadsIncluded tadsString
158hi def link tadsPreCondit PreCondit
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200160hi def link tadsString String
161hi def link tadsComment Comment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000162
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163
164
165let b:current_syntax = "tads"
166
167" Changes:
168" 11/18/99 Added a bunch of TADS functions, tadsException
169" 10/22/99 Misspelled Moolenaar (sorry!), c_minlines to tads_minlines
170"
171" vim: ts=8