1125
|
1 " Vim syntax file
|
29352
|
2 " Language: FreeBASIC
|
|
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
|
|
4 " Previous Maintainer: Mark Manning <markem@sim1.us>
|
|
5 " Last Change: 2022 Jun 26
|
1125
|
6 "
|
|
7 " Description:
|
|
8 "
|
|
9 " Based originally on the work done by Allan Kelly <Allan.Kelly@ed.ac.uk>
|
18053
|
10 " Updated by Mark Manning <markem@sim1.us>
|
29352
|
11 " Applied FreeBASIC support to the already excellent support
|
1125
|
12 " for standard basic syntax (like QB).
|
|
13 "
|
|
14 " First version based on Micro$soft QBASIC circa
|
|
15 " 1989, as documented in 'Learn BASIC Now' by
|
|
16 " Halvorson&Rygmyr. Microsoft Press 1989. This syntax file
|
|
17 " not a complete implementation yet. Send suggestions to
|
|
18 " the maintainer.
|
|
19 "
|
29352
|
20 " TODO: split this into separate dialect-based files, possibly with a common base
|
|
21 "
|
1125
|
22 " Quit when a (custom) syntax file was already loaded (Taken from c.vim)
|
|
23 "
|
|
24 if exists("b:current_syntax")
|
|
25 finish
|
|
26 endif
|
|
27 "
|
29352
|
28 " Dialect detection
|
|
29 "
|
|
30 let s:lang = freebasic#GetDialect()
|
|
31 "
|
|
32 " Whitespace Errors
|
|
33 "
|
|
34 if exists("freebasic_space_errors")
|
|
35 if !exists("freebasic_no_trail_space_error")
|
|
36 syn match freebasicSpaceError display excludenl "\s\+$"
|
|
37 endif
|
|
38 if !exists("freebasic_no_tab_space_error")
|
|
39 syn match freebasicSpaceError display " \+\t"me=e-1
|
|
40 endif
|
|
41 endif
|
|
42 "
|
1125
|
43 " Be sure to turn on the "case ignore" since current versions
|
|
44 " of freebasic support both upper as well as lowercase
|
|
45 " letters. - MEM 10/1/2006
|
|
46 "
|
|
47 syn case ignore
|
|
48 "
|
|
49 " Do the Basic variables names first. This is because it
|
|
50 " is the most inclusive of the tests. Later on we change
|
|
51 " this so the identifiers are split up into the various
|
|
52 " types of identifiers like functions, basic commands and
|
|
53 " such. MEM 9/9/2006
|
|
54 "
|
29352
|
55 if s:lang =~# '\<\%(qb\|fblite\)\>'
|
|
56 syn iskeyword @,48-57,_,192-255,.
|
|
57 syn match freebasicIdentifier "\<\h\%(\w\|\.\)*\>"
|
|
58 syn match freebasicGenericFunction "\<\h\%(\w\|\.\)*\>\ze\s*("
|
|
59 else
|
|
60 syn iskeyword @,48-57,_,192-255
|
|
61 syn match freebasicIdentifier "\<\h\w*\>"
|
|
62 syn match freebasicGenericFunction "\<\h\w*\>\ze\s*("
|
|
63 endif
|
|
64 "
|
|
65 " This list of keywords is taken directly from the FreeBASIC
|
|
66 " user's guide as presented by the FreeBASIC online site.
|
1125
|
67 "
|
29352
|
68 syn keyword freebasicArrays ERASE LBOUND PRESERVE REDIM UBOUND
|
|
69
|
|
70 " array.bi
|
|
71 syn keyword freebasicArrays ARRAYLEN ARRAYSIZE
|
|
72 if s:lang == "fb"
|
|
73 syn keyword freebasicArrays ArrayConstDescriptorPtr ArrayDescriptorPtr FBARRAY
|
|
74 endif
|
|
75
|
|
76 if s:lang == "qb"
|
|
77 syn keyword freebasicAsm __ASM
|
|
78 syn match freebasicAsm "\<end\s\+__asm\>"
|
|
79 else
|
|
80 syn keyword freebasicAsm ASM
|
|
81 syn match freebasicAsm "\<end\s\+asm\>"
|
|
82 endif
|
|
83
|
|
84 if s:lang == "qb"
|
|
85 syn keyword freebasicBitManipulation __BIT __BITRESET __BITSET __HIBYTE __HIWORD __LOBYTE __LOWORD
|
|
86 else
|
|
87 syn keyword freebasicBitManipulation BIT BITRESET BITSET HIBYTE HIWORD LOBYTE LOWORD
|
|
88 endif
|
|
89
|
|
90 if s:lang != "fb"
|
|
91 syn keyword freebasicCompilerSwitches DEFDBL DEFINT DEFLNG DEFSNG DEFSTR
|
|
92 endif
|
|
93 if s:lang == "qb"
|
|
94 syn keyword freebasicCompilerSwitches __DEFBYTE __DEFLONGINT __DEFSHORT __DEFUBYTE __DEFUINT __DEFULONGINT __DEFUSHORT
|
|
95 elseif s:lang == "fblite" || s:lang == "deprecated"
|
|
96 syn keyword freebasicCompilerSwitches DEFBYTE DEFLONGINT DEFSHORT DEFUBYTE DEFUINT DEFUILONGINT DEFUSHORT
|
|
97 endif
|
|
98
|
|
99 syn match freebasicCompilerSwitches "\<option\s\+\%(BASE\|BYVAL\|DYNAMIC\|ESCAPE\|EXPLICIT\|GOSUB\|NOGOSUB\)\>"
|
|
100 syn match freebasicCompilerSwitches "\<option\s\+\%(NOKEYWORD\|PRIVATE\|STATIC\)\>"
|
|
101
|
|
102 syn keyword freebasicData DATA READ RESTORE
|
|
103
|
|
104 syn keyword freebasicProgramFlow EXIT GOTO RETURN SLEEP
|
|
105 syn match freebasicProgramFlow "\<end\>"
|
|
106 if s:lang == "qb"
|
|
107 syn keyword freebasicProgramFlow __SLEEP
|
|
108 endif
|
|
109 if s:lang == "fblite" || s:lang == "qb"
|
|
110 syn keyword freebasicProgramFlow GOSUB
|
|
111 endif
|
|
112 if s:lang == "fb" || s:lang == "deprecated"
|
|
113 syn keyword freebasicProgramFlow SCOPE
|
|
114 syn match freebasicProgramFlow "\<end\s\+scope\>"
|
|
115 endif
|
|
116
|
|
117 if s:lang == "fblite" || s:lang == "qb"
|
|
118 syn region freebasicConditional matchgroup=freebasicConditional start="\<on\>" end="\<gosub\>" transparent
|
|
119 syn region freebasicConditional matchgroup=freebasicConditional start="\<on\>" end="\<goto\>" transparent
|
|
120 endif
|
|
121 syn keyword freebasicConditional IF THEN ELSE ELSEIF
|
|
122 if s:lang == "qb"
|
|
123 syn keyword freebasicConditional __IIF __WITH
|
|
124 syn match freebasicConditional "\<end\s\+__with\>"
|
|
125 else
|
|
126 syn keyword freebasicConditional IIF WITH
|
|
127 syn match freebasicConditional "\<end\s\+with\>"
|
|
128 endif
|
|
129 syn match freebasicConditional "\<end\s\+if\>"
|
|
130 syn match freebasicConditional "\<select\s\+case\>"
|
|
131 syn match freebasicConditional "\<case\>"
|
|
132 syn match freebasicConditional "\<case\s\+is\>"
|
|
133 syn match freebasicConditional "\<end\s\+select\>"
|
|
134
|
|
135 syn keyword freebasicConsole BEEP CLS CSRLIN LOCATE PRINT POS SPC TAB USING VIEW WIDTH
|
|
136 syn match freebasicConsole "?"
|
|
137
|
|
138 syn keyword freebasicDataTypes SINGLE DOUBLE INTEGER LONG
|
|
139 syn match freebasicDataTypes "\<string\>"
|
|
140 syn keyword freebasicDataTypes AS DIM CONST ENUM SHARED TYPE
|
|
141 syn match freebasicDataTypes "\<end\s\+enum\>"
|
|
142 syn match freebasicDataTypes "\<end\s\+type\>"
|
|
143 if s:lang == "qb"
|
|
144 syn keyword freebasicDataTypes __BOOLEAN __BYTE __LONGINT __SHORT __UBYTE __UINTEGER __ULONG __ULONGINT __UNSIGNED __USHORT __ZSTRING
|
|
145 syn match freebasicDataTypes "\<__WSTRING\>"
|
|
146 syn keyword freebasicDataTypes __EXPLICIT __EXTENDS __IMPLEMENTS __OBJECT __POINTER __PTR __SIZEOF __TYPEOF
|
|
147 syn keyword freebasicDataTypes __UNION
|
|
148 syn match freebasicDataTypes "\<end\s\+__union\>"
|
|
149 else
|
|
150 syn keyword freebasicDataTypes BOOLEAN BYTE LONGINT SHORT UBYTE UINTEGER ULONG ULONGINT UNSIGNED USHORT ZSTRING
|
|
151 syn match freebasicDataTypes "\<WSTRING\>"
|
|
152 syn keyword freebasicDataTypes EXPLICIT EXTENDS IMPLEMENTS OBJECT POINTER PTR SIZEOF TYPEOF
|
|
153 syn keyword freebasicDataTypes UNION
|
|
154 syn match freebasicDataTypes "\<end\s\+union\>"
|
|
155 endif
|
|
156 if s:lang == "fb"
|
|
157 syn keyword freebasicDataTypes BASE CLASS THIS VAR
|
|
158 endif
|
|
159
|
|
160 if s:lang == "qb"
|
|
161 syn match freebasicDateTime "\<\%(date\|time\)\$"
|
|
162 elseif s:lang == "fblite" || s:lang == "deprecated"
|
|
163 syn match freebasicDateTime "\<\%(date\|time\)\>\$\="
|
|
164 else " fb
|
|
165 syn keyword freebasicDateTime DATE TIME
|
|
166 endif
|
|
167 syn keyword freebasicDateTime SETDATE SETTIME
|
|
168
|
|
169 " datetime.bi
|
|
170 syn keyword freebasicDateTime DATEADD DATEDIFF DATEPART DATESERIAL DATEVALUE DAY HOUR ISDATE MINUTE
|
|
171 syn keyword freebasicDateTime MONTH MONTHNAME NOW SECOND TIMESERIAL TIMEVALUE
|
|
172 syn keyword freebasicDateTime TIMER YEAR WEEKDAY WEEKDAYNAME
|
|
173
|
|
174 syn keyword freebasicDebug STOP
|
|
175 if s:lang == "qb"
|
|
176 syn keyword freebasicDebug __ASSERT __ASSERTWARN
|
|
177 else
|
|
178 syn keyword freebasicDebug ASSERT ASSERTWARN
|
|
179 endif
|
|
180
|
|
181 syn keyword freebasicErrorHandling ERR ERL ERROR
|
|
182 if s:lang == "qb"
|
|
183 syn keyword freebasicErrorHandling __ERFN __ERMN
|
|
184 syn match freebasicErrorHandling "\<on\s\+error\>"
|
|
185 else
|
|
186 syn keyword freebasicErrorHandling ERFN ERMN
|
|
187 syn match freebasicErrorHandling "\<on\s\+\%(local\s\+\)\=error\>"
|
|
188 endif
|
|
189 if s:lang != "fb"
|
|
190 syn match freebasicErrorHandling "\<resume\%(\s\+next\)\=\>"
|
|
191 endif
|
|
192
|
|
193 syn match freebasicFiles "\<get\s\+#\>"
|
|
194 syn match freebasicFiles "\<input\s\+#\>"
|
|
195 syn match freebasicFiles "\<line\s\+input\s\+#\>"
|
|
196 syn match freebasicFiles "\<put\s\+#\>"
|
|
197 syn keyword freebasicFiles ACCESS APPEND BINARY CLOSE EOF FREEFILE INPUT LOC
|
|
198 syn keyword freebasicFiles LOCK LOF OUTPUT RANDOM RESET SEEK UNLOCK WRITE
|
|
199 syn match freebasicFiles "\<open\>"
|
|
200 if s:lang == "qb"
|
|
201 syn keyword freebasicFiles __ENCODING
|
|
202 else
|
|
203 syn keyword freebasicFiles ENCODING WINPUT
|
|
204 syn match freebasicFiles "\<open\s\+\%(cons\|err\|pipe\|scrn\)\>"
|
|
205 endif
|
|
206
|
|
207 " file.bi
|
|
208 syn keyword freebasicFiles FILEATTR FILECOPY FILEDATETIME FILEEXISTS FILEFLUSH FILELEN FILESETEOF
|
|
209
|
|
210 syn keyword freebasicFunctions ALIAS BYREF BYVAL CDECL DECLARE LIB NAKED PASCAL STATIC STDCALL
|
|
211 syn match freebasicFunctions "\<option\ze\s*("
|
|
212
|
|
213 if s:lang == "qb"
|
|
214 syn keyword freebasicFunctions __CVA_ARG __CVA_COPY __CVA_END __CVA_LIST __CVA_START
|
|
215 syn keyword freebasicFunctions __VA_ARG __VA_FIRST __VA_NEXT
|
|
216 else
|
|
217 syn keyword freebasicFunctions CVA_ARG CVA_COPY CVA_END CVA_LIST CVA_START
|
|
218 syn keyword freebasicFunctions VA_ARG VA_FIRST VA_NEXT
|
|
219 syn keyword freebasicFunctions ANY OVERLOAD
|
|
220 endif
|
|
221
|
|
222 syn keyword freebasicFunctions FUNCTION SUB
|
|
223 syn match freebasicFunctions "\<end\s\+function\>"
|
|
224 syn match freebasicFunctions "\<end\s\+sub\>"
|
|
225
|
|
226 if s:lang == "fb"
|
|
227 syn keyword freebasicFunctions ABSTRACT OVERRIDE VIRTUAL __THISCALL
|
|
228 syn keyword freebasicFunctions CONSTRUCTOR DESTRUCTOR OPERATOR PROPERTY
|
|
229 syn match freebasicFunctions "\<end\s\+constructor\>"
|
|
230 syn match freebasicFunctions "\<end\s\+destructor\>"
|
|
231 syn match freebasicFunctions "\<end\s\+operator\>"
|
|
232 syn match freebasicFunctions "\<end\s\+property\>"
|
|
233 else
|
|
234 syn keyword freebasicFunctions CALL
|
|
235 endif
|
|
236
|
|
237 syn match freebasicGraphics "\<palette\s\+get\>"
|
|
238 syn keyword freebasicGraphics ADD ALPHA BLOAD BSAVE CIRCLE CLS COLOR DRAW GET
|
|
239 syn keyword freebasicGraphics LINE PAINT PALETTE PCOPY PMAP POINT
|
|
240 syn keyword freebasicGraphics PRESET PSET PUT SCREEN
|
|
241 syn keyword freebasicGraphics TRANS WINDOW
|
|
242 if s:lang == "qb"
|
|
243 syn keyword freebasicGraphics __FLIP __IMAGECONVERTROW __IMAGECREATE __IMAGEDESTROY __IMAGEINFO __POINTCOORD
|
|
244 syn keyword freebasicGraphics __RGB __RGBA __SCREENCOPY __SCREENCONTROL __SCREENEVENT __SCREENGLPROC __SCREENINFO
|
|
245 syn keyword freebasicGraphics __SCREENLIST __SCREENLOCK __SCREENPTR __SCREENRES __SCREENSET __SCREENSYNC
|
|
246 syn keyword freebasicGraphics __SCREENUNLOCK __WINDOWTITLE
|
|
247 else
|
|
248 syn keyword freebasicGraphics CUSTOM
|
|
249 syn keyword freebasicGraphics FLIP IMAGECONVERTROW IMAGECREATE IMAGEDESTROY IMAGEINFO POINTCOORD
|
|
250 syn keyword freebasicGraphics RGB RGBA SCREENCOPY SCREENCONTROL SCREENEVENT SCREENGLPROC SCREENINFO
|
|
251 syn keyword freebasicGraphics SCREENLIST SCREENLOCK SCREENPTR SCREENRES SCREENSET SCREENSYNC
|
|
252 syn keyword freebasicGraphics SCREENUNLOCK WINDOWTITLE
|
|
253 endif
|
|
254
|
|
255 if s:lang != "qb"
|
|
256 syn match freebasicHardware "\<open\s\+\%(com\|lpt\)\>"
|
|
257 endif
|
|
258 syn keyword freebasicHardware INP OUT WAIT LPOS LPRINT
|
|
259
|
|
260 syn keyword freebasicMath ABS ATN COS EXP FIX FRAC INT LOG MOD RANDOMIZE RND SGN SIN SQR TAN
|
|
261
|
|
262 if s:lang == "qb"
|
|
263 syn keyword freebasicMath __ACOS __ASIN __ATAN2
|
|
264 else
|
|
265 syn keyword freebasicMath ACOS ASIN ATAN2
|
|
266 endif
|
|
267
|
|
268 if s:lang == "qb"
|
|
269 syn keyword freebasicMemory __ALLOCATE __CALLOCATE __DEALLOCATE __REALLOCATE
|
|
270 else
|
|
271 syn keyword freebasicMemory ALLOCATE CALLOCATE DEALLOCATE REALLOCATE
|
|
272 syn keyword freebasicMemory PEEK POKE CLEAR FB_MEMCOPY FB_MEMCOPYCLEAR FB_MEMMOVE SWAP SADD
|
|
273 syn keyword freebasicMemory FIELD FRE
|
|
274 endif
|
|
275
|
|
276 syn keyword freebasicMisc LET TO
|
|
277 if s:lang == "qb"
|
|
278 syn keyword freebasicMisc __OFFSETOF
|
|
279 else
|
|
280 syn keyword freebasicMisc OFFSETOF
|
|
281 endif
|
|
282
|
|
283 syn keyword freebasicModularizing CHAIN COMMON
|
|
284 if s:lang == "fb"
|
|
285 syn keyword freebasicModularizing EXTERN
|
|
286 syn match freebasicModularizing "\<end\s\+extern\>"
|
|
287 syn keyword freebasicModularizing PROTECTED
|
|
288 endif
|
|
289 if s:lang == "qb"
|
|
290 syn keyword freebasicModularizing __EXPORT __IMPORT __DYLIBFREE __DYLIBLOAD __DYLIBSYMBOL
|
|
291 else
|
|
292 syn keyword freebasicModularizing EXPORT IMPORT DYLIBFREE DYLIBLOAD DYLIBSYMBOL
|
|
293 syn keyword freebasicModularizing PRIVATE PUBLIC
|
|
294 syn keyword freebasicModularizing NAMESPACE
|
|
295 syn match freebasicModularizing "\<end\s\+namespace\>"
|
|
296 endif
|
|
297
|
|
298 if s:lang != "qb"
|
|
299 syn keyword freebasicMultithreading MUTEXCREATE MUTEXDESTROY MUTEXLOCK MUTEXUNLOCK THREADCREATE THREADWAIT
|
|
300 syn keyword freebasicMultithreading CONDBROADCAST CONDCREATE CONDDESTROY CONDSIGNAL CONDWAIT
|
|
301 syn keyword freebasicMultithreading THREADCALL THREADDETACH THREADSELF
|
|
302 endif
|
|
303
|
|
304 syn keyword freebasicShell CHDIR KILL NAME MKDIR RMDIR RUN SETENVIRON
|
|
305 if s:lang == "qb"
|
|
306 syn keyword freebasicShell __CURDIR __DIR __EXEC __EXEPATH
|
|
307 syn match freebasicString "\<\%(command\|environ\)\$"
|
|
308 else
|
|
309 " fbio.bi
|
|
310 syn keyword freebasicShell ISREDIRECTED
|
|
311 syn keyword freebasicShell CURDIR DIR EXEC EXEPATH
|
|
312 syn match freebasicString "\<\%(command\|environ\)\>\$\="
|
|
313 endif
|
|
314
|
|
315 syn keyword freebasicEnviron SHELL SYSTEM
|
|
316
|
|
317 syn keyword freebasicLoops FOR LOOP WHILE WEND DO STEP UNTIL NEXT
|
|
318 if s:lang == "qb"
|
|
319 syn keyword freebasicLoops __CONTINUE
|
|
320 else
|
|
321 syn keyword freebasicLoops CONTINUE
|
|
322 endif
|
1125
|
323 "
|
29352
|
324 " File numbers
|
|
325 "
|
|
326 syn match freebasicFilenumber "#\d\+"
|
|
327 syn match freebasicFilenumber "#\a[[:alpha:].]*[%&!#]\="
|
|
328
|
|
329 syn match freebasicMetacommand "$\s*\%(dynamic\|static\)"
|
|
330 syn match freebasicMetacommand "$\s*include\s*\%(once\)\=\s*:\s*'[^']\+'"
|
|
331 syn match freebasicMetacommand '$\s*include\s*\%(once\)\=\s*:\s*"[^"]\+"'
|
|
332 syn match freebasicMetacommand '$\s*lang\s*:\s*"[^"]\+"'
|
|
333 "
|
|
334 " Intrinsic defines
|
|
335 "
|
|
336 syn keyword freebasicPredefined __DATE__ __DATE_ISO__
|
|
337 syn keyword freebasicPredefined __FB_64BIT__ __FB_ARGC__ __FB_ARG_COUNT__ __FB_ARG_EXTRACT__ __FB_ARG_LEFTOF__
|
|
338 syn keyword freebasicPredefined __FB_ARG_RIGHTOF__ __FB_ARGV__ __FB_ARM__ __FB_ASM__ __FB_BACKEND__
|
|
339 syn keyword freebasicPredefined __FB_BIGENDIAN__ __FB_BUILD_DATE__ __FB_BUILD_DATE_ISO__ __FB_BUILD_SHA1__
|
|
340 syn keyword freebasicPredefined __FB_CYGWIN__ __FB_DARWIN__ __FB_DEBUG__ __FB_DOS__ __FB_ERR__ __FB_EVAL__
|
|
341 syn keyword freebasicPredefined __FB_FPMODE__ __FB_FPU__ __FB_FREEBSD__ __FB_GCC__ __FB_GUI__ __FB_JOIN__
|
|
342 syn keyword freebasicPredefined __FB_LANG__ __FB_LINUX__ __FB_MAIN__ __FB_MIN_VERSION__ __FB_MT__ __FB_NETBSD__
|
|
343 syn keyword freebasicPredefined __FB_OPENBSD__ __FB_OPTIMIZE__ __FB_OPTION_BYVAL__ __FB_OPTION_DYNAMIC__
|
|
344 syn keyword freebasicPredefined __FB_OPTION_ESCAPE__ __FB_OPTION_EXPLICIT__ __FB_OPTION_GOSUB__
|
|
345 syn keyword freebasicPredefined __FB_OPTION_PRIVATE__ __FB_OUT_DLL__ __FB_OUT_EXE__ __FB_OUT_LIB__ __FB_OUT_OBJ__
|
|
346 syn keyword freebasicPredefined __FB_PCOS__ __FB_PPC__ __FB_QUOTE__ __FB_SIGNATURE__ __FB_SSE__ __FB_UNIQUEID__
|
|
347 syn keyword freebasicPredefined __FB_UNIQUEID_POP__ __FB_UNIQUEID_PUSH__ __FB_UNIX__ __FB_UNQUOTE__
|
|
348 syn keyword freebasicPredefined __FB_VECTORIZE__ __FB_VER_MAJOR__ __FB_VER_MINOR__ __FB_VER_PATCH__ __FB_VERSION__
|
|
349 syn keyword freebasicPredefined __FB_WIN32__ __FB_X86__ __FB_XBOX__
|
|
350 syn keyword freebasicPredefined __FILE__ __FILE_NQ__ __FUNCTION__ __FUNCTION_NQ__
|
|
351 syn keyword freebasicPredefined __LINE__ __PATH__ __TIME__
|
|
352 "
|
|
353 " Preprocessor directives
|
|
354 "
|
|
355 syn match freebasicInclude "#\s*\%(inclib\|include\%(\s\+once\)\=\|libpath\)\>"
|
|
356
|
|
357 syn match freebasicPreProcessor "#\s*assert\>"
|
|
358 syn match freebasicPreProcessor "#\s*cmdline\>"
|
|
359 syn match freebasicPreProcessor "#\s*\%(define\|undef\)\>"
|
|
360 syn match freebasicPreProcessor "#\s*\%(if\|ifdef\|ifndef\|else\|elseif\|endif\)\>"
|
|
361 syn match freebasicPreProcessor "#\s*\%(macro\|endmacro\)\>"
|
|
362 syn match freebasicPreProcessor "#\s*error\>"
|
|
363 syn match freebasicPreProcessor "#\s*lang\>"
|
|
364 syn match freebasicPreProcessor "#\s*line\>"
|
|
365 syn match freebasicPreProcessor "#\s*pragma\%(\s\+reserve\)\=\>"
|
|
366 syn match freebasicPreProcessor "#\s*\%(print\|dynamic\|static\)\>"
|
|
367 syn keyword freebasicPreProcessor DEFINED
|
|
368
|
|
369 syn keyword freebasicString LEN
|
|
370 syn keyword freebasicString ASC
|
|
371 " string.bi
|
|
372 syn keyword freebasicString FORMAT
|
|
373 syn keyword freebasicString VAL
|
|
374 syn keyword freebasicString CVD CVI CVL CVS
|
|
375 syn keyword freebasicString INSTR
|
|
376 syn keyword freebasicString LSET RSET
|
|
377
|
|
378 if s:lang == "qb"
|
|
379 syn match freebasicString "\<string\$\ze\s*("
|
|
380 syn match freebasicString "\<__wstring\ze\s*("
|
|
381 syn match freebasicString "\<space\$"
|
|
382 syn keyword freebasicString __WSPACE
|
|
383 syn match freebasicString "\<chr\$"
|
|
384 syn keyword freebasicString __WCHR
|
|
385 syn keyword freebasicString __WBIN __WHEX __WOCT __WSTR
|
|
386 syn match freebasicString "\<\%(bin\|hex\|oct\|str\)\$"
|
|
387 syn keyword freebasicString __VALLNG __VALINT __VALUINT __VALULNG
|
|
388 syn match freebasicString "\<\%(mkd\|mki\|mkl\|mks\)\$"
|
|
389 syn keyword freebasicString __MKLONGINT __MKSHORT
|
|
390 syn keyword freebasicString __CVLONGINT __CVSHORT
|
|
391 syn match freebasicString "\<\%(left\|mid\|right\|lcase\|ucase\|ltrim\|rtrim\)\$"
|
|
392 syn keyword freebasicString __TRIM
|
|
393 syn keyword freebasicString __INSTRREV
|
|
394 else
|
|
395 syn match freebasicString "\<string\$\=\ze\s*("
|
|
396 syn match freebasicString "\<wstring\ze\s*("
|
|
397 syn match freebasicString "\<space\>\$\="
|
|
398 syn keyword freebasicString WSPACE
|
|
399 syn match freebasicString "\<chr\>\$\="
|
|
400 syn keyword freebasicString WCHR
|
|
401 syn keyword freebasicString WBIN WHEX WOCT WSTR
|
|
402 syn match freebasicString "\<\%(bin\|hex\|oct\|str\)\>\$\="
|
|
403 syn keyword freebasicString VALLNG VALINT VALUINT VALULNG
|
|
404 syn match freebasicString "\<\%(mkd\|mki\|mkl\|mks\)\>\$\="
|
|
405 syn match freebasicString "\<\%(mklongint\|mkshort\)\>\$\="
|
|
406 syn keyword freebasicString CVLONGINT CVSHORT
|
|
407 syn match freebasicString "\<\%(left\|mid\|right\|lcase\|ucase\|ltrim\|rtrim\)\>\$\="
|
|
408 syn match freebasicString "\<trim\>\$\="
|
|
409 syn keyword freebasicString INSTRREV
|
|
410 endif
|
|
411
|
|
412 syn keyword freebasicTypeCasting CDBL CINT CLNG CSNG
|
|
413 if s:lang == "qb"
|
|
414 syn keyword freebasicTypeCasting __CAST __CBOOL __CBYTE __CLNGINT __CPTR __CSHORT __CSIGN __CYBTE __CUINT __CULNG
|
|
415 syn keyword freebasicTypeCasting __CULNGINT __CUNSG __CUSHORT
|
|
416 else
|
|
417 syn keyword freebasicTypeCasting CAST CBOOL CBYTE CLNGINT CPTR CSHORT CSIGN CUBYTE CUINT CULNG CULNGINT CUNSG CUSHORT
|
|
418 endif
|
|
419
|
|
420 syn match freebasicUserInput "\<line\s\+input\>"
|
|
421 syn keyword freebasicUserInput INKEY INPUT
|
|
422 if s:lang == "qb"
|
|
423 syn keyword freebasicUserInput __GETJOYSTICK __GETKEY __GETMOUSE __MULTIKEY __SETMOUSE STICK STRIG
|
|
424 else
|
|
425 syn keyword freebasicUserInput GETJOYSTICK GETKEY GETMOUSE MULTIKEY SETMOUSE
|
|
426 endif
|
|
427 "
|
|
428 " Operators
|
|
429 "
|
|
430 " TODO: make these context sensitive to remove the overlap of common operators
|
|
431 " : alpha operators should probably always be highlighted
|
|
432 " -- DJK 20/11/19
|
|
433 if s:lang == "qb"
|
|
434 syn match freebasicArithmeticOperator "\<\%(MOD\|__SHL\|__SHR\)\>"
|
|
435 else
|
|
436 syn match freebasicArithmeticOperator "\<\%(MOD\|SHL\|SHR\)\>"
|
|
437 endif
|
|
438 syn match freebasicBitwiseOperator "\<\%(AND\|EQV\|IMP\|NOT\|OR\|XOR\)\>" " freebaseLogical?
|
|
439 if s:lang == "qb"
|
|
440 syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|__SHL\|__SHR\)=\@=" " exclude trailing '='
|
|
441 else
|
|
442 syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|SHL\|SHR\)=\@="
|
|
443 endif
|
|
444 syn match freebasicShortcircuitOperator "\<\%(ANDALSO\|ORELSE\)\>"
|
|
445 if s:lang == "fb"
|
|
446 syn match freebasicMemoryOperator '\<\%(new\|delete\)\>'
|
|
447 endif
|
|
448 syn keyword freebasicPointerOperator STRPTR VARPTR
|
|
449 if s:lang == "qb"
|
|
450 syn keyword freebasicPointerOperator __PROCPTR
|
|
451 else
|
|
452 syn keyword freebasicPointerOperator PROCPTR
|
|
453 endif
|
|
454 syn match freebasicTypeOperator '\<is\>'
|
|
455 syn match freebasicTypeOperator '\.' nextgroup=freebasicIdentifier skipwhite
|
|
456 if s:lang == "fb"
|
|
457 syn match freebasicTypeOperator '->' nextgroup=freebasicIdentifier skipwhite
|
|
458 endif
|
|
459
|
|
460 if exists("freebasic_operators")
|
|
461 syn match freebasicAssignmentOperator "=>\=\|[-+&/\\*^]="
|
|
462 if s:lang == "qb"
|
|
463 syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|__SHL\|__SHR\)=" " include trailing '='
|
|
464 else
|
|
465 syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|SHL\|SHR\)="
|
|
466 endif
|
|
467 syn match freebasicArithmeticOperator "[-+&/\\*^]"
|
|
468 " syn match freebasicIndexingOperator "[[\]()]" " FIXME
|
|
469 syn match freebasicRelationalOperator "=\|<>\|<=\|<\|>=\|>"
|
|
470 syn match freebasicPreprocessorOperator '\%(^\s*\)\@<!\%(##\|#\)\|[$!]"\@='
|
|
471 syn match freebasicPointerOperator '[@*]'
|
|
472 syn match freebasicTypeOperator '\.' nextgroup=freebasicIdentifier skipwhite
|
|
473 if s:lang == "fb"
|
|
474 syn match freebasicTypeOperator '->' nextgroup=freebasicIdentifier skipwhite
|
|
475 endif
|
|
476 endif
|
|
477
|
|
478 syn cluster freebasicOperator contains=freebasic.*Operator
|
1125
|
479 "
|
|
480 " Catch errors caused by wrong parenthesis
|
|
481 "
|
29352
|
482 " syn region freebasicParen transparent start='(' end=')' contains=ALLBUT,@freebasicParenGroup
|
|
483 " syn match freebasicParenError ")"
|
|
484 " syn match freebasicInParen contained "[{}]"
|
|
485 " syn cluster freebasicParenGroup contains=freebasicParenError,freebasicSpecial,freebasicTodo,freebasicUserCont,freebasicUserLabel,freebasicBitField
|
|
486 "
|
|
487 " Integer number
|
1125
|
488 "
|
29352
|
489 syn match freebasicHexError "&h\w*\>"
|
|
490 syn match freebasicOctalError "&o\w*\>"
|
|
491 syn match freebasicBinaryError "&b\w*\>"
|
|
492 syn match freebasicHex "&h\x\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
|
|
493 syn match freebasicOctal "&o\o\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
|
|
494 syn match freebasicBinary "&b[10]\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
|
|
495 syn match freebasicInteger "\<\d\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
|
|
496 "
|
|
497 " Floating point
|
|
498 " See: https://www.freebasic.net/forum/viewtopic.php?t=20323
|
1125
|
499 "
|
29352
|
500 " Floating point number, with dot, optional exponent, optional suffix
|
|
501 "
|
|
502 syn match freebasicFloat "\<\d\+\.\d*\%([de][-+]\=\d*\)\=[f!#]\="
|
|
503 "
|
|
504 " Floating point number, starting with a dot, optional exponent, optional suffix
|
|
505 "
|
|
506 syn match freebasicFloat "\.\d\+\%([de][-+]\=\d*\)\=[f!#]\="
|
|
507 "
|
|
508 " Floating point number, without dot, with optional exponent, optional suffix
|
1125
|
509 "
|
29352
|
510 syn match freebasicFloat "\<\d\+\%([de][-+]\=\d*\)[f!#]\="
|
|
511 "
|
|
512 " Floating point number, without dot, without exponent, with suffix
|
1125
|
513 "
|
29352
|
514 syn match freebasicFloat "\<\d\+[f!#]"
|
|
515 "
|
|
516 " Create the clusters
|
|
517 "
|
|
518 syn cluster freebasicNumber contains=freebasicHex,freebasicOctal,freebasicBinary,freebasicInteger,freebasicFloat
|
|
519 syn cluster freebasicNumberError contains=freebasicHexError,freebasicOctalError,freebasicBinaryError
|
1125
|
520 "
|
29352
|
521 " Booleans
|
1125
|
522 "
|
29352
|
523 if s:lang != "qb"
|
|
524 syn keyword freebasicBoolean TRUE FALSE
|
|
525 endif
|
|
526 "
|
|
527 "
|
|
528 " String and escape sequences
|
1125
|
529 "
|
29352
|
530 syn match freebasicSpecial contained "\\."
|
|
531 syn match freebasicSpecial contained "\\\d\{1,3}"
|
|
532 syn match freebasicSpecial contained "\\&h\x\{1,2}"
|
|
533 syn match freebasicSpecial contained "\\&o\o\{1,3}"
|
|
534 syn match freebasicSpecial contained "\\&b[01]\{1,8}"
|
|
535 syn match freebasicSpecial contained "\\u\x\{1,4}"
|
|
536 syn region freebasicString start='"' end='"' " TODO: Toggle contains on Option Escape in fblite and qb? -- DJK 20/11/19
|
|
537 syn region freebasicString start='!\zs"' end='"' contains=freebasicSpecial
|
|
538 syn region freebasicString start='$\zs"' end='"'
|
1125
|
539 "
|
29352
|
540 " Line labels
|
|
541 "
|
|
542 if s:lang =~# '\<\%(qb\|fblite\)\>'
|
|
543 syn match freebasicLineLabel "^\s*\zs\h\%(\w\|\.\)*\ze\s*:"
|
|
544 else
|
|
545 syn match freebasicLineLabel "^\s*\zs\h\w*\ze\s*:"
|
|
546 endif
|
|
547 syn match freebasicLineNumber "^\s*\zs\d\+"
|
1125
|
548 "
|
29352
|
549 " Line continuations
|
|
550 "
|
|
551 " syn match freebasicLineContinuation "\<_\>" nextgroup=freebasicComment,freebasicPostLineContinuation skipwhite
|
|
552 syn keyword freebasicLineContinuation _ nextgroup=freebasicComment,freebasicPostLineContinuation skipwhite
|
|
553 syn match freebasicPostLineContinuation ".*" contained
|
1125
|
554 "
|
|
555 "
|
29352
|
556 " Type suffixes
|
|
557 if exists("freebasic_type_suffixes") && s:lang =~# '\<\%(qb\|fblite\)\>'
|
|
558 syn match freebasicTypeSuffix "\h\%(\w\|.\)*\zs[$%&!#]"
|
|
559 endif
|
1125
|
560 "
|
|
561 " Comments
|
|
562 "
|
29352
|
563 syn keyword freebasicTodo TODO FIXME XXX NOTE contained
|
|
564 syn region freebasicComment start="\<rem\>" end="$" contains=freebasicTodo,@Spell,freebasicMetacommand
|
|
565 syn region freebasicComment start="'" end="$" contains=freebasicTodo,@Spell,freebasicMetacommand
|
|
566 syn region freebasicDoubleComment start="''" end="$" contains=freebasicTodo,@Spell
|
|
567
|
|
568 if !exists("freebasic_no_comment_fold")
|
|
569 syn region freebasicMultilineComment start="/'" end="'/" contains=freebasicTodo,@Spell,freeBasicMultilineComment fold keepend extend
|
|
570 syn region freebasicMultilineComment2 start="^\s*'.*\n\%(\s*'\)\@=" end="^\s*'.*\n\%(\s*'\)\@!" contains=freebasicComment,freebasicDoubleComment keepend fold
|
|
571 else
|
|
572 syn region freebasicMultilineComment start="/'" end="'/" contains=freebasicTodo,@Spell,freeBasicMultilineComment
|
|
573 endif
|
|
574
|
|
575 syn case match
|
|
576
|
|
577 syn sync linebreaks=1
|
|
578
|
1125
|
579 "
|
|
580 " The default methods for highlighting. Can be overridden later
|
|
581 "
|
|
582 hi def link freebasicArrays StorageClass
|
29352
|
583 hi def link freebasicAsm Special
|
1125
|
584 hi def link freebasicBitManipulation Operator
|
29352
|
585 hi def link freebasicBoolean Boolean
|
|
586 if s:lang == "fb"
|
|
587 hi def link freebasicCompilerSwitches freebasicUnsupportedError
|
|
588 else
|
|
589 hi def link freebasicCompilerSwitches PreCondit
|
|
590 endif
|
1125
|
591 hi def link freebasicConsole Special
|
29352
|
592 hi def link freebasicData Special
|
1125
|
593 hi def link freebasicDataTypes Type
|
|
594 hi def link freebasicDateTime Type
|
|
595 hi def link freebasicDebug Special
|
|
596 hi def link freebasicErrorHandling Special
|
29352
|
597 hi def link freebasicFilenumber Special
|
1125
|
598 hi def link freebasicFiles Special
|
|
599 hi def link freebasicFunctions Function
|
|
600 hi def link freebasicGraphics Function
|
|
601 hi def link freebasicHardware Special
|
29352
|
602 hi def link freebasicLoops Repeat
|
1125
|
603 hi def link freebasicMath Function
|
29352
|
604 if s:lang == "fb"
|
|
605 hi def link freebasicMetacommand freebasicUnsupportedError
|
|
606 else
|
|
607 hi def link freebasicMetacommand SpecialComment
|
|
608 endif
|
1125
|
609 hi def link freebasicMemory Function
|
|
610 hi def link freebasicMisc Special
|
|
611 hi def link freebasicModularizing Special
|
|
612 hi def link freebasicMultithreading Special
|
|
613 hi def link freebasicShell Special
|
|
614 hi def link freebasicEnviron Special
|
|
615 hi def link freebasicPointer Special
|
|
616 hi def link freebasicPredefined PreProc
|
|
617 hi def link freebasicPreProcessor PreProc
|
|
618 hi def link freebasicProgramFlow Statement
|
|
619 hi def link freebasicString String
|
|
620 hi def link freebasicTypeCasting Type
|
|
621 hi def link freebasicUserInput Statement
|
|
622 hi def link freebasicComment Comment
|
29352
|
623 hi def link freebasicDoubleComment Comment
|
|
624 hi def link freebasicMultilineComment Comment
|
1125
|
625 hi def link freebasicConditional Conditional
|
|
626 hi def link freebasicError Error
|
|
627 hi def link freebasicIdentifier Identifier
|
|
628 hi def link freebasicInclude Include
|
|
629 hi def link freebasicGenericFunction Function
|
29352
|
630 hi def link freebasicLineContinuation Special
|
|
631 hi def link freebasicLineLabel LineNr
|
|
632 if s:lang == "fb"
|
|
633 hi def link freebasicLineNumber freebasicUnsupportedError
|
|
634 else
|
|
635 hi def link freebasicLineNumber LineNr
|
|
636 endif
|
1125
|
637 hi def link freebasicMathOperator Operator
|
29352
|
638
|
|
639 hi def link freebasicHex Number
|
|
640 hi def link freebasicOctal Number
|
|
641 hi def link freebasicBinary Number
|
|
642 hi def link freebasicInteger Number
|
|
643 hi def link freebasicFloat Float
|
|
644
|
|
645 hi def link freebasicHexError Error
|
|
646 hi def link freebasicOctalError Error
|
|
647 hi def link freebasicBinaryError Error
|
|
648
|
|
649 hi def link freebasicAssignmentOperator Operator
|
|
650 hi def link freebasicArithmeticOperator Operator
|
|
651 hi def link freebasicIndexingOperator Operator
|
|
652 hi def link freebasicRelationalOperator Operator
|
|
653 hi def link freebasicBitwiseOperator Operator
|
|
654 hi def link freebasicShortcircuitOperator Operator
|
|
655 hi def link freebasicPreprocessorOperator Operator
|
|
656 hi def link freebasicPointerOperator Operator
|
|
657 if exists("freebasic_operators")
|
|
658 hi def link freebasicTypeOperator Operator
|
|
659 endif
|
|
660 hi def link freebasicMemoryOperator Operator
|
|
661
|
|
662 hi def link freebasicSpaceError Error
|
|
663
|
1125
|
664 hi def link freebasicSpecial Special
|
|
665 hi def link freebasicTodo Todo
|
|
666
|
29352
|
667 hi def link freebasicUnsupported freebasicUnsupportedError
|
|
668 hi def link freebasicUnsupportedError Error
|
|
669
|
|
670 unlet s:lang
|
|
671
|
1125
|
672 let b:current_syntax = "freebasic"
|
|
673
|
29352
|
674 " vim: ts=8 tw=132 fdm=marker
|