Merge branch 'hack/autopaste'
[vim-kana.git] / runtime / syntax / logtalk.vim
blob6faf5960eb5e8533ba847735ac9940d2c2b84030
1 " Vim syntax file
3 " Language:     Logtalk
4 " Maintainer:   Paulo Moura <pmoura@logtalk.org>
5 " Last Change:  February 24, 2006
8 " Quit when a syntax file was already loaded:
10 if version < 600
11         syntax clear
12 elseif exists("b:current_syntax")
13         finish
14 endif
17 " Logtalk is case sensitive:
19 syn case match
22 " Logtalk variables
24 syn match   logtalkVariable             "\<\(\u\|_\)\(\w\)*\>"
27 " Logtalk clause functor
29 syn match       logtalkOperator         ":-"
32 " Logtalk quoted atoms and strings
34 syn region      logtalkString           start=+"+       skip=+\\"+      end=+"+
35 syn region      logtalkAtom             start=+'+       skip=+\\'+      end=+'+
38 " Logtalk message sending operators
40 syn match       logtalkOperator         "::"
41 syn match       logtalkOperator         "\^\^"
44 " Logtalk external call
46 syn region      logtalkExtCall          matchgroup=logtalkExtCallTag            start="{"               matchgroup=logtalkExtCallTag            end="}"         contains=ALL
49 " Logtalk opening entity directives
51 syn region      logtalkOpenEntityDir    matchgroup=logtalkOpenEntityDirTag      start=":- object("      matchgroup=logtalkOpenEntityDirTag      end=")\."       contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator,logtalkEntityRel
52 syn region      logtalkOpenEntityDir    matchgroup=logtalkOpenEntityDirTag      start=":- protocol("    matchgroup=logtalkOpenEntityDirTag      end=")\."       contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator,logtalkEntityRel
53 syn region      logtalkOpenEntityDir    matchgroup=logtalkOpenEntityDirTag      start=":- category("    matchgroup=logtalkOpenEntityDirTag      end=")\."       contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator,logtalkEntityRel
56 " Logtalk closing entity directives
58 syn match       logtalkCloseEntityDir   ":- end_object\."
59 syn match       logtalkCloseEntityDir   ":- end_protocol\."
60 syn match       logtalkCloseEntityDir   ":- end_category\."
63 " Logtalk entity relations
65 syn region      logtalkEntityRel        matchgroup=logtalkEntityRelTag  start="instantiates("   matchgroup=logtalkEntityRelTag  end=")"         contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator    contained
66 syn region      logtalkEntityRel        matchgroup=logtalkEntityRelTag  start="specializes("    matchgroup=logtalkEntityRelTag  end=")"         contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator    contained
67 syn region      logtalkEntityRel        matchgroup=logtalkEntityRelTag  start="extends("        matchgroup=logtalkEntityRelTag  end=")"         contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator    contained
68 syn region      logtalkEntityRel        matchgroup=logtalkEntityRelTag  start="imports("        matchgroup=logtalkEntityRelTag  end=")"         contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator    contained
69 syn region      logtalkEntityRel        matchgroup=logtalkEntityRelTag  start="implements("     matchgroup=logtalkEntityRelTag  end=")"         contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator    contained
72 " Logtalk directives
74 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- alias("               matchgroup=logtalkDirTag        end=")\."       contains=ALL
75 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- encoding("    matchgroup=logtalkDirTag        end=")\."       contains=ALL
76 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- initialization("      matchgroup=logtalkDirTag        end=")\."       contains=ALL
77 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- info("                matchgroup=logtalkDirTag        end=")\."       contains=ALL
78 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- mode("                matchgroup=logtalkDirTag        end=")\."       contains=logtalkOperator, logtalkAtom
79 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- dynamic("             matchgroup=logtalkDirTag        end=")\."       contains=ALL
80 syn match       logtalkDirTag           ":- dynamic\."
81 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- discontiguous("       matchgroup=logtalkDirTag        end=")\."       contains=ALL
82 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- multifile("           matchgroup=logtalkDirTag        end=")\."       contains=ALL
83 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- public("              matchgroup=logtalkDirTag        end=")\."       contains=ALL
84 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- protected("           matchgroup=logtalkDirTag        end=")\."       contains=ALL
85 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- private("             matchgroup=logtalkDirTag        end=")\."       contains=ALL
86 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- metapredicate("       matchgroup=logtalkDirTag        end=")\."       contains=ALL
87 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- op("                  matchgroup=logtalkDirTag        end=")\."       contains=ALL
88 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- calls("               matchgroup=logtalkDirTag        end=")\."       contains=ALL
89 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- uses("                matchgroup=logtalkDirTag        end=")\."       contains=ALL
92 " Module directives
94 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- module("              matchgroup=logtalkDirTag        end=")\."       contains=ALL
95 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- export("              matchgroup=logtalkDirTag        end=")\."       contains=ALL
96 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- meta_predicate("              matchgroup=logtalkDirTag        end=")\."       contains=ALL
97 syn region      logtalkDir              matchgroup=logtalkDirTag        start=":- use_module("          matchgroup=logtalkDirTag        end=")\."       contains=ALL
100 " Logtalk built-in predicates
102 syn match       logtalkBuiltIn          "\<\(abolish\|c\(reate\|urrent\)\)_\(object\|protocol\|category\)\ze("
104 syn match       logtalkBuiltIn          "\<\(object\|protocol\|category\)_property\ze("
106 syn match       logtalkBuiltIn          "\<extends_\(object\|protocol\)\ze("
107 syn match       logtalkBuiltIn          "\<imp\(orts_category\|lements_protocol\)\ze("
108 syn match       logtalkBuiltIn          "\<\(instantiates\|specializes\)_class\ze("
110 syn match       logtalkBuiltIn          "\<\(abolish\|define\)_events\ze("
111 syn match       logtalkBuiltIn          "\<current_event\ze("
113 syn match       logtalkBuiltIn          "\<\(current\|set\)_logtalk_flag\ze("
115 syn match       logtalkBuiltIn          "\<logtalk_\(compile\|l\(ibrary_path\|oad\)\)\ze("
117 syn match       logtalkBuiltIn          "\<\(for\|retract\)all\ze("
120 " Logtalk built-in methods
122 syn match       logtalkBuiltInMethod    "\<parameter\ze("
123 syn match       logtalkBuiltInMethod    "\<se\(lf\|nder\)\ze("
124 syn match       logtalkBuiltInMethod    "\<this\ze("
126 syn match       logtalkBuiltInMethod    "\<current_predicate\ze("
127 syn match       logtalkBuiltInMethod    "\<predicate_property\ze("
129 syn match       logtalkBuiltInMethod    "\<a\(bolish\|ssert\(a\|z\)\)\ze("
130 syn match       logtalkBuiltInMethod    "\<clause\ze("
131 syn match       logtalkBuiltInMethod    "\<retract\(all\)\?\ze("
133 syn match       logtalkBuiltInMethod    "\<\(bag\|set\)of\ze("
134 syn match       logtalkBuiltInMethod    "\<f\(ind\|or\)all\ze("
136 syn match       logtalkBuiltInMethod    "\<before\ze("
137 syn match       logtalkBuiltInMethod    "\<after\ze("
139 syn match       logtalkBuiltInMethod    "\<expand_term\ze("
140 syn match       logtalkBuiltInMethod    "\<term_expansion\ze("
141 syn match       logtalkBuiltInMethod    "\<phrase\ze("
144 " Mode operators
146 syn match       logtalkOperator         "?"
147 syn match       logtalkOperator         "@"
150 " Control constructs
152 syn match       logtalkKeyword          "\<true\>"
153 syn match       logtalkKeyword          "\<fail\>"
154 syn match       logtalkKeyword          "\<ca\(ll\|tch\)\ze("
155 syn match       logtalkOperator         "!"
156 " syn match     logtalkOperator         ","
157 syn match       logtalkOperator         ";"
158 syn match       logtalkOperator         "-->"
159 syn match       logtalkOperator         "->"
160 syn match       logtalkKeyword          "\<throw\ze("
163 " Term unification
165 syn match       logtalkOperator         "="
166 syn match       logtalkKeyword          "\<unify_with_occurs_check\ze("
167 syn match       logtalkOperator         "\\="
170 " Term testing
172 syn match       logtalkKeyword          "\<var\ze("
173 syn match       logtalkKeyword          "\<atom\(ic\)\?\ze("
174 syn match       logtalkKeyword          "\<integer\ze("
175 syn match       logtalkKeyword          "\<float\ze("
176 syn match       logtalkKeyword          "\<compound\ze("
177 syn match       logtalkKeyword          "\<n\(onvar\|umber\)\ze("
180 " Term comparison
182 syn match       logtalkOperator         "@=<"
183 syn match       logtalkOperator         "=="
184 syn match       logtalkOperator         "\\=="
185 syn match       logtalkOperator         "@<"
186 syn match       logtalkOperator         "@>"
187 syn match       logtalkOperator         "@>="
190 " Term creation and decomposition
192 syn match       logtalkKeyword          "\<functor\ze("
193 syn match       logtalkKeyword          "\<arg\ze("
194 syn match       logtalkOperator         "=\.\."
195 syn match       logtalkKeyword          "\<copy_term\ze("
198 " Arithemtic evaluation
200 syn match       logtalkOperator         "\<is\>"
203 " Arithemtic comparison
205 syn match       logtalkOperator         "=:="
206 syn match       logtalkOperator         "=\\="
207 syn match       logtalkOperator         "<"
208 syn match       logtalkOperator         "=<"
209 syn match       logtalkOperator         ">"
210 syn match       logtalkOperator         ">="
213 " Stream selection and control
215 syn match       logtalkKeyword          "\<\(current\|set\)_\(in\|out\)put\ze("
216 syn match       logtalkKeyword          "\<open\ze("
217 syn match       logtalkKeyword          "\<close\ze("
218 syn match       logtalkKeyword          "\<flush_output\ze("
219 syn match       logtalkKeyword          "\<flush_output\>"
220 syn match       logtalkKeyword          "\<stream_property\ze("
221 syn match       logtalkKeyword          "\<at_end_of_stream\ze("
222 syn match       logtalkKeyword          "\<at_end_of_stream\>"
223 syn match       logtalkKeyword          "\<set_stream_position\ze("
226 " Character and byte input/output
228 syn match       logtalkKeyword          "\<\(get\|p\(eek\|ut\)\)_\(c\(har\|ode\)\|byte\)\ze("
229 syn match       logtalkKeyword          "\<nl\ze("
230 syn match       logtalkKeyword          "\<nl\>"
233 " Term input/output
235 syn match       logtalkKeyword          "\<read\(_term\)\?\ze("
236 syn match       logtalkKeyword          "\<write\(q\|_\(canonical\|term\)\)\?\ze("
237 syn match       logtalkKeyword          "\<\(current_\)\?op\ze("
238 syn match       logtalkKeyword          "\<\(current\)\?char_conversion\ze("
241 " Logic and control
243 syn match       logtalkOperator         "\\+"
244 syn match       logtalkKeyword          "\<once\ze("
245 syn match       logtalkKeyword          "\<repeat\>"
248 " Atomic term processing
250 syn match       logtalkKeyword          "\<atom_\(length\|c\(hars\|o\(ncat\|des\)\)\)\ze("
251 syn match       logtalkKeyword          "\<sub_atom\ze("
252 syn match       logtalkKeyword          "\<char_code\ze("
253 syn match       logtalkKeyword          "\<number_\(c\(hars\|odes\)\)\ze("
256 " Implementation defined hooks functions
258 syn match       logtalkKeyword          "\<\(current\|set\)_prolog_flag\ze("
259 syn match       logtalkKeyword          "\<halt\ze("
260 syn match       logtalkKeyword          "\<halt\>"
263 " Evaluable functors
265 syn match       logtalkOperator         "+"
266 syn match       logtalkOperator         "-"
267 syn match       logtalkOperator         "\*"
268 syn match       logtalkOperator         "//"
269 syn match       logtalkOperator         "/"
270 syn match       logtalkKeyword          "\<r\(ound\|em\)\ze("
271 syn match       logtalkKeyword          "\<rem\>"
272 syn match       logtalkKeyword          "\<mod\ze("
273 syn match       logtalkKeyword          "\<mod\>"
274 syn match       logtalkKeyword          "\<abs\ze("
275 syn match       logtalkKeyword          "\<sign\ze("
276 syn match       logtalkKeyword          "\<flo\(or\|at\(_\(integer\|fractional\)_part\)\?\)\ze("
277 syn match       logtalkKeyword          "\<truncate\ze("
278 syn match       logtalkKeyword          "\<ceiling\ze("
281 " Other arithemtic functors
283 syn match       logtalkOperator         "\*\*"
284 syn match       logtalkKeyword          "\<s\(in\|qrt\)\ze("
285 syn match       logtalkKeyword          "\<cos\ze("
286 syn match       logtalkKeyword          "\<atan\ze("
287 syn match       logtalkKeyword          "\<exp\ze("
288 syn match       logtalkKeyword          "\<log\ze("
291 " Bitwise functors
293 syn match       logtalkOperator         ">>"
294 syn match       logtalkOperator         "<<"
295 syn match       logtalkOperator         "/\\"
296 syn match       logtalkOperator         "\\/"
297 syn match       logtalkOperator         "\\"
300 " Logtalk list operator
302 syn match       logtalkOperator         "|"
305 " Logtalk numbers 
307 syn match       logtalkNumber           "\<\d\+\>"
308 syn match       logtalkNumber           "\<\d\+\.\d\+\>"
309 syn match       logtalkNumber           "\<\d\+[eE][-+]\=\d\+\>"
310 syn match       logtalkNumber           "\<\d\+\.\d\+[eE][-+]\=\d\+\>"
311 syn match       logtalkNumber           "\<0'.\>"
312 syn match       logtalkNumber           "\<0b[0-1]\+\>"
313 syn match       logtalkNumber           "\<0o\o\+\>"
314 syn match       logtalkNumber           "\<0x\x\+\>"
317 " Logtalk end-of-clause
319 syn match       logtalkOperator         "\."
322 " Logtalk comments
324 syn region      logtalkBlockComment     start="/\*"     end="\*/"       fold
325 syn match       logtalkLineComment      "%.*"
328 " Logtalk entity folding
330 syn region logtalkEntity transparent fold keepend start=":- object(" end=":- end_object\." contains=ALL
331 syn region logtalkEntity transparent fold keepend start=":- protocol(" end=":- end_protocol\." contains=ALL
332 syn region logtalkEntity transparent fold keepend start=":- category(" end=":- end_category\." contains=ALL
335 syn sync ccomment logtalkBlockComment maxlines=50
338 " Define the default highlighting.
339 " For version 5.7 and earlier: only when not done already
340 " For version 5.8 and later: only when an item doesn't have highlighting yet
342 if version >= 508 || !exists("did_logtalk_syn_inits")
343         if version < 508
344                 let did_logtalk_syn_inits = 1
345                 command -nargs=+ HiLink hi link <args>
346         else
347                 command -nargs=+ HiLink hi def link <args>
348         endif
349         
350         HiLink  logtalkBlockComment     Comment
351         HiLink  logtalkLineComment      Comment
353         HiLink  logtalkOpenEntityDir    Normal
354         HiLink  logtalkOpenEntityDirTag PreProc
356         HiLink  logtalkEntity           Normal
358         HiLink  logtalkEntityRel        Normal
359         HiLink  logtalkEntityRelTag     PreProc
361         HiLink  logtalkCloseEntityDir   PreProc
363         HiLink  logtalkDir              Normal
364         HiLink  logtalkDirTag           PreProc
366         HiLink  logtalkAtom             String
367         HiLink  logtalkString           String
369         HiLink  logtalkNumber           Number
371         HiLink  logtalkKeyword          Keyword
373         HiLink  logtalkBuiltIn          Keyword
374         HiLink  logtalkBuiltInMethod    Keyword
376         HiLink  logtalkOperator         Operator
378         HiLink  logtalkExtCall          Normal
379         HiLink  logtalkExtCallTag       Operator
381         HiLink  logtalkVariable         Identifier
383         delcommand HiLink
385 endif
388 let b:current_syntax = "logtalk"
390 setlocal ts=4
391 setlocal fdm=syntax
392 setlocal fdc=2