robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Christian Clasonvim-patch:20b33b56ad5d0c23525b59

master
26.0 KiB674 linesraw
1" Vim syntax file
2" Language:		FreeBASIC
3" Maintainer:		Doug Kearns <dougkearns@gmail.com>
4" Previous Maintainer:	Mark Manning <markem@sim1.us>
5" Last Change:		2023 Aug 14
6"
7" Description:
8"
9"	Based originally on the work done by Allan Kelly <Allan.Kelly@ed.ac.uk>
10"	Updated by Mark Manning <markem@sim1.us>
11"	Applied FreeBASIC support to the already excellent support
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"
20"	TODO: split this into separate dialect-based files, possibly with a common base
21"
22"	Quit when a (custom) syntax file was already loaded (Taken from c.vim)
23"
24if exists("b:current_syntax")
25  finish
26endif
27"
28"	Dialect detection
29"
30let s:lang = freebasic#GetDialect()
31"
32"	Whitespace Errors
33"
34if 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
41endif
42"
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"
47syn 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"
55if 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*("
59else
60  syn iskeyword @,48-57,_,192-255
61  syn match	freebasicIdentifier		"\<\h\w*\>"
62  syn match	freebasicGenericFunction	"\<\h\w*\>\ze\s*("
63endif
64"
65"	This list of keywords is taken directly from the FreeBASIC
66"	user's guide as presented by the FreeBASIC online site.
67"
68syn keyword	freebasicArrays			ERASE LBOUND PRESERVE REDIM UBOUND
69
70" array.bi
71syn keyword	freebasicArrays			ARRAYLEN ARRAYSIZE
72if s:lang == "fb"
73  syn keyword	freebasicArrays			ArrayConstDescriptorPtr ArrayDescriptorPtr FBARRAY
74endif
75
76if s:lang == "qb"
77  syn keyword	freebasicAsm			__ASM
78  syn match	freebasicAsm			"\<end\s\+__asm\>"
79else
80  syn keyword	freebasicAsm			ASM
81  syn match	freebasicAsm			"\<end\s\+asm\>"
82endif
83
84if s:lang == "qb"
85  syn keyword	freebasicBitManipulation	__BIT __BITRESET __BITSET __HIBYTE __HIWORD __LOBYTE __LOWORD
86else
87  syn keyword	freebasicBitManipulation	BIT BITRESET BITSET HIBYTE HIWORD LOBYTE LOWORD
88endif
89
90if s:lang != "fb"
91  syn keyword	freebasicCompilerSwitches	DEFDBL DEFINT DEFLNG DEFSNG DEFSTR
92endif
93if s:lang == "qb"
94  syn keyword	freebasicCompilerSwitches	__DEFBYTE __DEFLONGINT __DEFSHORT __DEFUBYTE __DEFUINT __DEFULONGINT __DEFUSHORT
95elseif s:lang == "fblite" || s:lang == "deprecated"
96  syn keyword	freebasicCompilerSwitches	DEFBYTE DEFLONGINT DEFSHORT DEFUBYTE DEFUINT DEFUILONGINT DEFUSHORT
97endif
98
99syn match	freebasicCompilerSwitches	"\<option\s\+\%(BASE\|BYVAL\|DYNAMIC\|ESCAPE\|EXPLICIT\|GOSUB\|NOGOSUB\)\>"
100syn match	freebasicCompilerSwitches	"\<option\s\+\%(NOKEYWORD\|PRIVATE\|STATIC\)\>"
101
102syn keyword	freebasicData			DATA READ RESTORE
103
104syn keyword	freebasicProgramFlow		EXIT GOTO RETURN SLEEP
105syn match	freebasicProgramFlow		"\<end\>"
106if s:lang == "qb"
107  syn keyword	freebasicProgramFlow		__SLEEP
108endif
109if s:lang == "fblite" || s:lang == "qb"
110  syn keyword	freebasicProgramFlow		GOSUB
111endif
112if s:lang == "fb" || s:lang == "deprecated"
113  syn keyword	freebasicProgramFlow		SCOPE
114  syn match	freebasicProgramFlow		"\<end\s\+scope\>"
115endif
116
117if 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
120endif
121syn keyword	freebasicConditional		IF THEN ELSE ELSEIF
122if s:lang == "qb"
123  syn keyword	freebasicConditional		__IIF __WITH
124  syn match	freebasicConditional		"\<end\s\+__with\>"
125else
126  syn keyword	freebasicConditional		IIF WITH
127  syn match	freebasicConditional		"\<end\s\+with\>"
128endif
129syn match	freebasicConditional		"\<end\s\+if\>"
130syn match	freebasicConditional		"\<select\s\+case\>"
131syn match	freebasicConditional		"\<case\>"
132syn match	freebasicConditional		"\<case\s\+is\>"
133syn match	freebasicConditional		"\<end\s\+select\>"
134
135syn keyword	freebasicConsole		BEEP CLS CSRLIN LOCATE PRINT POS SPC TAB USING VIEW WIDTH
136syn match	freebasicConsole		"?"
137
138syn keyword	freebasicDataTypes		SINGLE DOUBLE INTEGER LONG
139syn match	freebasicDataTypes		"\<string\>"
140syn keyword	freebasicDataTypes		AS DIM CONST ENUM SHARED TYPE
141syn match	freebasicDataTypes		"\<end\s\+enum\>"
142syn match	freebasicDataTypes		"\<end\s\+type\>"
143if 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\>"
149else
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\>"
155endif
156if s:lang == "fb"
157  syn keyword	freebasicDataTypes		BASE CLASS THIS VAR
158endif
159
160if s:lang == "qb"
161  syn match	freebasicDateTime		"\<\%(date\|time\)\$"
162elseif s:lang == "fblite" || s:lang == "deprecated"
163  syn match	freebasicDateTime		"\<\%(date\|time\)\>\$\="
164else " fb
165  syn keyword	freebasicDateTime		DATE TIME
166endif
167syn keyword	freebasicDateTime		SETDATE SETTIME
168
169" datetime.bi
170syn keyword	freebasicDateTime		DATEADD DATEDIFF DATEPART DATESERIAL DATEVALUE DAY HOUR ISDATE MINUTE
171syn keyword	freebasicDateTime		MONTH MONTHNAME NOW SECOND TIMESERIAL TIMEVALUE
172syn keyword	freebasicDateTime		TIMER YEAR WEEKDAY WEEKDAYNAME
173
174syn keyword	freebasicDebug			STOP
175if s:lang == "qb"
176  syn keyword	freebasicDebug			__ASSERT __ASSERTWARN
177else
178  syn keyword	freebasicDebug			ASSERT ASSERTWARN
179endif
180
181syn keyword	freebasicErrorHandling		ERR ERL ERROR
182if s:lang == "qb"
183  syn keyword	freebasicErrorHandling		__ERFN __ERMN
184  syn match	freebasicErrorHandling		"\<on\s\+error\>"
185else
186  syn keyword	freebasicErrorHandling		ERFN ERMN
187  syn match	freebasicErrorHandling		"\<on\s\+\%(local\s\+\)\=error\>"
188endif
189if s:lang != "fb"
190  syn match	freebasicErrorHandling		"\<resume\%(\s\+next\)\=\>"
191endif
192
193syn match	freebasicFiles			"\<get\s\+#\>"
194syn match	freebasicFiles			"\<input\s\+#\>"
195syn match	freebasicFiles			"\<line\s\+input\s\+#\>"
196syn match	freebasicFiles			"\<put\s\+#\>"
197syn keyword	freebasicFiles			ACCESS APPEND BINARY CLOSE EOF FREEFILE INPUT LOC
198syn keyword	freebasicFiles			LOCK LOF OUTPUT RANDOM RESET SEEK UNLOCK WRITE
199syn match	freebasicFiles			"\<open\>"
200if s:lang == "qb"
201  syn keyword	freebasicFiles			__ENCODING
202else
203  syn keyword	freebasicFiles			ENCODING WINPUT
204  syn match	freebasicFiles			"\<open\s\+\%(cons\|err\|pipe\|scrn\)\>"
205endif
206
207" file.bi
208syn keyword	freebasicFiles			FILEATTR FILECOPY FILEDATETIME FILEEXISTS FILEFLUSH FILELEN FILESETEOF
209
210syn keyword	freebasicFunctions		ALIAS BYREF BYVAL CDECL DECLARE LIB NAKED PASCAL STATIC STDCALL
211syn match	freebasicFunctions		"\<option\ze\s*("
212
213if 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
216else
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
220endif
221
222syn keyword	freebasicFunctions		FUNCTION SUB
223syn match	freebasicFunctions		"\<end\s\+function\>"
224syn match	freebasicFunctions		"\<end\s\+sub\>"
225
226if 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\>"
233else
234  syn keyword	freebasicFunctions		CALL
235endif
236
237syn match	freebasicGraphics		"\<palette\s\+get\>"
238syn keyword	freebasicGraphics		ADD ALPHA BLOAD BSAVE CIRCLE CLS COLOR DRAW GET
239syn keyword	freebasicGraphics		LINE PAINT PALETTE PCOPY PMAP POINT
240syn keyword	freebasicGraphics		PRESET PSET PUT SCREEN
241syn keyword	freebasicGraphics		TRANS WINDOW
242if 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
247else
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
253endif
254
255if s:lang != "qb"
256  syn match	freebasicHardware		"\<open\s\+\%(com\|lpt\)\>"
257endif
258syn keyword	freebasicHardware		INP OUT WAIT LPOS LPRINT
259
260syn keyword	freebasicMath			ABS ATN COS EXP FIX FRAC INT LOG MOD RANDOMIZE RND SGN SIN SQR TAN
261
262if s:lang == "qb"
263  syn keyword	freebasicMath			__ACOS __ASIN __ATAN2
264else
265  syn keyword	freebasicMath			ACOS ASIN ATAN2
266endif
267
268if s:lang == "qb"
269  syn keyword	freebasicMemory			__ALLOCATE __CALLOCATE __DEALLOCATE __REALLOCATE
270else
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
274endif
275
276syn keyword	freebasicMisc			LET TO
277if s:lang == "qb"
278  syn keyword freebasicMisc			__OFFSETOF
279else
280  syn keyword freebasicMisc			OFFSETOF
281endif
282
283syn keyword	freebasicModularizing		CHAIN COMMON
284if s:lang == "fb"
285  syn keyword	freebasicModularizing		EXTERN
286  syn match	freebasicModularizing		"\<end\s\+extern\>"
287  syn keyword	freebasicModularizing		PROTECTED
288endif
289if s:lang == "qb"
290  syn keyword	freebasicModularizing		__EXPORT __IMPORT __DYLIBFREE __DYLIBLOAD __DYLIBSYMBOL
291else
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\>"
296endif
297
298if 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
302endif
303
304syn keyword	freebasicShell			CHDIR KILL NAME MKDIR RMDIR RUN SETENVIRON
305if s:lang == "qb"
306  syn keyword	freebasicShell			__CURDIR __DIR __EXEC __EXEPATH
307  syn match	freebasicString			"\<\%(command\|environ\)\$"
308else
309  " fbio.bi
310  syn keyword	freebasicShell			ISREDIRECTED
311  syn keyword	freebasicShell			CURDIR DIR EXEC EXEPATH
312  syn match	freebasicString			"\<\%(command\|environ\)\>\$\="
313endif
314
315syn keyword	freebasicEnviron		SHELL SYSTEM
316
317syn keyword	freebasicLoops			FOR LOOP WHILE WEND DO STEP UNTIL NEXT
318if s:lang == "qb"
319  syn keyword	freebasicLoops			__CONTINUE
320else
321  syn keyword	freebasicLoops			CONTINUE
322endif
323"
324"	File numbers
325"
326syn match	freebasicFilenumber		"#\d\+"
327syn match	freebasicFilenumber		"#\a[[:alpha:].]*[%&!#]\="
328
329syn match	freebasicMetacommand		"$\s*\%(dynamic\|static\)"
330syn match	freebasicMetacommand		"$\s*include\s*\%(once\)\=\s*:\s*'[^']\+'"
331syn match	freebasicMetacommand		'$\s*include\s*\%(once\)\=\s*:\s*"[^"]\+"'
332syn match	freebasicMetacommand		'$\s*lang\s*:\s*"[^"]\+"'
333"
334"	Intrinsic defines
335"
336syn keyword	freebasicPredefined		__DATE__ __DATE_ISO__
337syn keyword	freebasicPredefined		__FB_64BIT__ __FB_ARGC__ __FB_ARG_COUNT__ __FB_ARG_EXTRACT__ __FB_ARG_LEFTOF__
338syn keyword	freebasicPredefined		__FB_ARG_RIGHTOF__ __FB_ARGV__ __FB_ARM__ __FB_ASM__ __FB_BACKEND__
339syn keyword	freebasicPredefined		__FB_BIGENDIAN__ __FB_BUILD_DATE__ __FB_BUILD_DATE_ISO__ __FB_BUILD_SHA1__
340syn keyword	freebasicPredefined		__FB_CYGWIN__ __FB_DARWIN__ __FB_DEBUG__ __FB_DOS__ __FB_ERR__ __FB_EVAL__
341syn keyword	freebasicPredefined		__FB_FPMODE__ __FB_FPU__ __FB_FREEBSD__ __FB_GCC__ __FB_GUI__ __FB_IIF__ __FB_JOIN__
342syn keyword	freebasicPredefined		__FB_LANG__ __FB_LINUX__ __FB_MAIN__ __FB_MIN_VERSION__ __FB_MT__ __FB_NETBSD__
343syn keyword	freebasicPredefined		__FB_OPENBSD__ __FB_OPTIMIZE__ __FB_OPTION_BYVAL__ __FB_OPTION_DYNAMIC__
344syn keyword	freebasicPredefined		__FB_OPTION_ESCAPE__ __FB_OPTION_EXPLICIT__ __FB_OPTION_GOSUB__
345syn keyword	freebasicPredefined		__FB_OPTION_PRIVATE__ __FB_OUT_DLL__ __FB_OUT_EXE__ __FB_OUT_LIB__ __FB_OUT_OBJ__
346syn keyword	freebasicPredefined		__FB_PCOS__ __FB_PPC__ __FB_QUERY_SYMBOL__ __FB_QUOTE__ __FB_SIGNATURE__ __FB_SSE__
347syn keyword	freebasicPredefined		__FB_UNIQUEID__ __FB_UNIQUEID_POP__ __FB_UNIQUEID_PUSH__ __FB_UNIX__ __FB_UNQUOTE__
348syn keyword	freebasicPredefined		__FB_VECTORIZE__ __FB_VER_MAJOR__ __FB_VER_MINOR__ __FB_VER_PATCH__ __FB_VERSION__
349syn keyword	freebasicPredefined		__FB_WIN32__ __FB_X86__ __FB_XBOX__
350syn keyword	freebasicPredefined		__FILE__ __FILE_NQ__ __FUNCTION__ __FUNCTION_NQ__
351syn keyword	freebasicPredefined		__LINE__ __PATH__ __TIME__
352"
353"	Preprocessor directives
354"
355syn match	freebasicInclude		"#\s*\%(inclib\|include\%(\s\+once\)\=\|libpath\)\>"
356
357syn match	freebasicPreProcessor		"#\s*assert\>"
358syn match	freebasicPreProcessor		"#\s*cmdline\>"
359syn match	freebasicPreProcessor		"#\s*\%(define\|undef\)\>"
360syn match	freebasicPreProcessor		"#\s*\%(if\|ifdef\|ifndef\|else\|elseif\|endif\)\>"
361syn match	freebasicPreProcessor		"#\s*\%(macro\|endmacro\)\>"
362syn match	freebasicPreProcessor		"#\s*error\>"
363syn match	freebasicPreProcessor		"#\s*lang\>"
364syn match	freebasicPreProcessor		"#\s*line\>"
365syn match	freebasicPreProcessor		"#\s*pragma\%(\s\+reserve\)\=\>"
366syn match	freebasicPreProcessor		"#\s*\%(print\|dynamic\|static\)\>"
367syn keyword	freebasicPreProcessor		DEFINED
368
369syn keyword	freebasicString			LEN
370syn keyword	freebasicString			ASC
371" string.bi
372syn keyword	freebasicString			FORMAT
373syn keyword	freebasicString			VAL
374syn keyword	freebasicString			CVD CVI CVL CVS
375syn keyword	freebasicString			INSTR
376syn keyword	freebasicString			LSET RSET
377
378if 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
394else
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
410endif
411
412syn keyword	freebasicTypeCasting		CDBL CINT CLNG CSNG
413if s:lang == "qb"
414  syn keyword	freebasicTypeCasting		__CAST __CBOOL __CBYTE __CLNGINT __CPTR __CSHORT __CSIGN __CYBTE __CUINT __CULNG
415  syn keyword	freebasicTypeCasting		__CULNGINT __CUNSG __CUSHORT
416else
417  syn keyword	freebasicTypeCasting		CAST CBOOL CBYTE CLNGINT CPTR CSHORT CSIGN CUBYTE CUINT CULNG CULNGINT CUNSG CUSHORT
418endif
419
420syn match	freebasicUserInput		"\<line\s\+input\>"
421syn keyword	freebasicUserInput		INKEY INPUT
422if s:lang == "qb"
423  syn keyword	freebasicUserInput		__GETJOYSTICK __GETKEY __GETMOUSE __MULTIKEY __SETMOUSE STICK STRIG
424else
425  syn keyword	freebasicUserInput		GETJOYSTICK GETKEY GETMOUSE MULTIKEY SETMOUSE
426endif
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
433if s:lang == "qb"
434  syn match	freebasicArithmeticOperator	"\<\%(MOD\|__SHL\|__SHR\)\>"
435else
436  syn match	freebasicArithmeticOperator	"\<\%(MOD\|SHL\|SHR\)\>"
437endif
438syn match	freebasicBitwiseOperator	"\<\%(AND\|EQV\|IMP\|NOT\|OR\|XOR\)\>" " freebaseLogical?
439if s:lang == "qb"
440  syn match	freebasicAssignmentOperator	"\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|__SHL\|__SHR\)=\@=" " exclude trailing '='
441else
442  syn match	freebasicAssignmentOperator	"\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|SHL\|SHR\)=\@="
443endif
444syn match	freebasicShortcircuitOperator	"\<\%(ANDALSO\|ORELSE\)\>"
445if s:lang == "fb"
446  syn match	freebasicMemoryOperator		'\<\%(new\|delete\)\>'
447endif
448syn keyword	freebasicPointerOperator	STRPTR VARPTR
449if s:lang == "qb"
450  syn keyword	freebasicPointerOperator	__PROCPTR
451else
452  syn keyword	freebasicPointerOperator	PROCPTR
453endif
454syn match	freebasicTypeOperator		'\<is\>'
455syn match	freebasicTypeOperator		'\.' nextgroup=freebasicIdentifier skipwhite
456if s:lang == "fb"
457  syn match	freebasicTypeOperator		'->' nextgroup=freebasicIdentifier skipwhite
458endif
459
460if 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
476endif
477
478syn cluster	freebasicOperator		contains=freebasic.*Operator
479"
480"	Catch errors caused by wrong parenthesis
481"
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
488"
489syn match	freebasicHexError	"&h\w*\>"
490syn match	freebasicOctalError	"&o\w*\>"
491syn match	freebasicBinaryError	"&b\w*\>"
492syn match	freebasicHex		"&h\x\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
493syn match	freebasicOctal		"&o\o\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
494syn match	freebasicBinary		"&b[10]\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
495syn match	freebasicInteger	"\<\d\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
496"
497"	Floating point
498"	See: https://www.freebasic.net/forum/viewtopic.php?t=20323
499"
500"	Floating point number, with dot, optional exponent, optional suffix
501"
502syn match	freebasicFloat		"\<\d\+\.\d*\%([de][-+]\=\d*\)\=[f!#]\="
503"
504"	Floating point number, starting with a dot, optional exponent, optional suffix
505"
506syn match	freebasicFloat		"\.\d\+\%([de][-+]\=\d*\)\=[f!#]\="
507"
508"	Floating point number, without dot, with optional exponent, optional suffix
509"
510syn match	freebasicFloat		"\<\d\+\%([de][-+]\=\d*\)[f!#]\="
511"
512"	Floating point number, without dot, without exponent, with suffix
513"
514syn match	freebasicFloat		"\<\d\+[f!#]"
515"
516"	Create the clusters
517"
518syn cluster	freebasicNumber		contains=freebasicHex,freebasicOctal,freebasicBinary,freebasicInteger,freebasicFloat
519syn cluster	freebasicNumberError	contains=freebasicHexError,freebasicOctalError,freebasicBinaryError
520"
521"	Booleans
522"
523if s:lang != "qb"
524  syn keyword	freebasicBoolean	TRUE FALSE
525endif
526"
527"
528"	String and escape sequences
529"
530syn match	freebasicSpecial	contained "\\."
531syn match	freebasicSpecial	contained "\\\d\{1,3}"
532syn match	freebasicSpecial	contained "\\&h\x\{1,2}"
533syn match	freebasicSpecial	contained "\\&o\o\{1,3}"
534syn match	freebasicSpecial	contained "\\&b[01]\{1,8}"
535syn match	freebasicSpecial	contained "\\u\x\{1,4}"
536syn region	freebasicString		start='"'     end='"' " TODO: Toggle contains on Option Escape in fblite and qb? -- DJK 20/11/19
537syn region	freebasicString		start='!\zs"' end='"' contains=freebasicSpecial
538syn region	freebasicString		start='$\zs"' end='"'
539"
540"	Line labels
541"
542if s:lang =~# '\<\%(qb\|fblite\)\>'
543  syn match	freebasicLineLabel	"^\s*\zs\h\%(\w\|\.\)*\ze\s*:"
544else
545  syn match	freebasicLineLabel	"^\s*\zs\h\w*\ze\s*:"
546endif
547syn match	freebasicLineNumber	"^\s*\zs\d\+"
548"
549"	Line continuations
550"
551" syn match	freebasicLineContinuation	"\<_\>"	nextgroup=freebasicComment,freebasicPostLineContinuation skipwhite
552syn keyword	freebasicLineContinuation	_	nextgroup=freebasicComment,freebasicPostLineContinuation skipwhite
553syn match	freebasicPostLineContinuation	".*"	contained
554"
555"
556" Type suffixes
557if exists("freebasic_type_suffixes") && s:lang =~# '\<\%(qb\|fblite\)\>'
558  syn match freebasicTypeSuffix "\h\%(\w\|.\)*\zs[$%&!#]"
559endif
560"
561"	Comments
562"
563syn keyword	freebasicTodo			TODO FIXME XXX NOTE      contained
564syn region	freebasicComment		start="\<rem\>" end="$"  contains=freebasicTodo,@Spell,freebasicMetacommand
565syn region	freebasicComment		start="'"	end="$"  contains=freebasicTodo,@Spell,freebasicMetacommand
566syn region	freebasicDoubleComment		start="''"	end="$"  contains=freebasicTodo,@Spell
567
568if !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
571else
572  syn region	freebasicMultilineComment	start="/'"	end="'/" contains=freebasicTodo,@Spell,freeBasicMultilineComment
573endif
574
575syn case match
576
577syn sync linebreaks=1
578
579"
580"	The default methods for highlighting.  Can be overridden later
581"
582hi def link freebasicArrays		StorageClass
583hi def link freebasicAsm		Special
584hi def link freebasicBitManipulation	Operator
585hi def link freebasicBoolean		Boolean
586if s:lang == "fb"
587  hi def link freebasicCompilerSwitches	freebasicUnsupportedError
588else
589  hi def link freebasicCompilerSwitches	PreCondit
590endif
591hi def link freebasicConsole		Special
592hi def link freebasicData		Special
593hi def link freebasicDataTypes		Type
594hi def link freebasicDateTime		Type
595hi def link freebasicDebug		Special
596hi def link freebasicErrorHandling	Special
597hi def link freebasicFilenumber		Special
598hi def link freebasicFiles		Special
599hi def link freebasicFunctions		Function
600hi def link freebasicGraphics		Function
601hi def link freebasicHardware		Special
602hi def link freebasicLoops		Repeat
603hi def link freebasicMath		Function
604if s:lang == "fb"
605  hi def link freebasicMetacommand	freebasicUnsupportedError
606else
607  hi def link freebasicMetacommand	SpecialComment
608endif
609hi def link freebasicMemory		Function
610hi def link freebasicMisc		Special
611hi def link freebasicModularizing	Special
612hi def link freebasicMultithreading	Special
613hi def link freebasicShell		Special
614hi def link freebasicEnviron		Special
615hi def link freebasicPointer		Special
616hi def link freebasicPredefined		PreProc
617hi def link freebasicPreProcessor	PreProc
618hi def link freebasicProgramFlow	Statement
619hi def link freebasicString		String
620hi def link freebasicTypeCasting	Type
621hi def link freebasicUserInput		Statement
622hi def link freebasicComment		Comment
623hi def link freebasicDoubleComment	Comment
624hi def link freebasicMultilineComment	Comment
625hi def link freebasicConditional	Conditional
626hi def link freebasicError		Error
627hi def link freebasicIdentifier		Identifier
628hi def link freebasicInclude		Include
629hi def link freebasicGenericFunction	Function
630hi def link freebasicLineContinuation	Special
631hi def link freebasicLineLabel		LineNr
632if s:lang == "fb"
633  hi def link freebasicLineNumber	freebasicUnsupportedError
634else
635  hi def link freebasicLineNumber	LineNr
636endif
637hi def link freebasicMathOperator	Operator
638
639hi def link freebasicHex		Number
640hi def link freebasicOctal		Number
641hi def link freebasicBinary		Number
642hi def link freebasicInteger		Number
643hi def link freebasicFloat		Float
644
645hi def link freebasicHexError		Error
646hi def link freebasicOctalError		Error
647hi def link freebasicBinaryError	Error
648
649hi def link freebasicAssignmentOperator		Operator
650hi def link freebasicArithmeticOperator		Operator
651hi def link freebasicIndexingOperator		Operator
652hi def link freebasicRelationalOperator		Operator
653hi def link freebasicBitwiseOperator		Operator
654hi def link freebasicShortcircuitOperator	Operator
655hi def link freebasicPreprocessorOperator	Operator
656hi def link freebasicPointerOperator		Operator
657if exists("freebasic_operators")
658  hi def link freebasicTypeOperator		Operator
659endif
660hi def link freebasicMemoryOperator		Operator
661
662hi def link freebasicSpaceError			Error
663
664hi def link freebasicSpecial		Special
665hi def link freebasicTodo		Todo
666
667hi def link freebasicUnsupported	freebasicUnsupportedError
668hi def link freebasicUnsupportedError	Error
669
670unlet s:lang
671
672let b:current_syntax = "freebasic"
673
674" vim: ts=8 tw=132 fdm=marker