xref: /vim-8.2.3635/runtime/syntax/freebasic.vim (revision 8fe1000e)
1c81e5e79SBram Moolenaar" Vim syntax file
2c81e5e79SBram Moolenaar" Language:    FreeBasic
3*8fe1000eSBram Moolenaar" Maintainer:  Mark Manning <[email protected]>
4*8fe1000eSBram Moolenaar" Updated:     10/9/2019
5*8fe1000eSBram Moolenaar" Version:		7.0b
6c81e5e79SBram Moolenaar"
7c81e5e79SBram Moolenaar" Description:
8c81e5e79SBram Moolenaar"
9c81e5e79SBram Moolenaar"	Based originally on the work done by Allan Kelly <[email protected]>
10*8fe1000eSBram Moolenaar"	Updated by Mark Manning <[email protected]>
11c81e5e79SBram Moolenaar"	Applied FreeBasic support to the already excellent support
12c81e5e79SBram Moolenaar"	for standard basic syntax (like QB).
13c81e5e79SBram Moolenaar"
14c81e5e79SBram Moolenaar"	First version based on Micro$soft QBASIC circa
15c81e5e79SBram Moolenaar"	1989, as documented in 'Learn BASIC Now' by
16c81e5e79SBram Moolenaar"	Halvorson&Rygmyr. Microsoft Press 1989.  This syntax file
17c81e5e79SBram Moolenaar"	not a complete implementation yet.  Send suggestions to
18c81e5e79SBram Moolenaar"	the maintainer.
19c81e5e79SBram Moolenaar"
20c81e5e79SBram Moolenaar"	Quit when a (custom) syntax file was already loaded (Taken from c.vim)
21c81e5e79SBram Moolenaar"
22c81e5e79SBram Moolenaarif exists("b:current_syntax")
23c81e5e79SBram Moolenaar  finish
24c81e5e79SBram Moolenaarendif
25c81e5e79SBram Moolenaar"
26c81e5e79SBram Moolenaar"	Be sure to turn on the "case ignore" since current versions
27c81e5e79SBram Moolenaar"	of freebasic support both upper as well as lowercase
28c81e5e79SBram Moolenaar"	letters. - MEM 10/1/2006
29c81e5e79SBram Moolenaar"
30c81e5e79SBram Moolenaarsyn case ignore
31c81e5e79SBram Moolenaar"
32c81e5e79SBram Moolenaar"	This list of keywords is taken directly from the FreeBasic
33c81e5e79SBram Moolenaar"	user's guide as presented by the FreeBasic online site.
34c81e5e79SBram Moolenaar"
35c81e5e79SBram Moolenaarsyn keyword	freebasicArrays			ERASE LBOUND REDIM PRESERVE UBOUND
36c81e5e79SBram Moolenaar
37c81e5e79SBram Moolenaarsyn keyword	freebasicBitManipulation	BIT BITRESET BITSET HIBYTE HIWORD LOBYTE LOWORD SHL SHR
38c81e5e79SBram Moolenaar
39c81e5e79SBram Moolenaarsyn keyword	freebasicCompilerSwitches	DEFBYTE DEFDBL DEFINT DEFLNG DEFLNGINT DEFSHORT DEFSNG DEFSTR
40c81e5e79SBram Moolenaarsyn keyword	freebasicCompilerSwitches	DEFUBYTE DEFUINT DEFULNGINT DEFUSHORT
41c81e5e79SBram Moolenaarsyn match	freebasicCompilerSwitches	"\<option\s+\(BASE\|BYVAL\|DYNAMIC\|ESCAPE\|EXPLICIT\|NOKEYWORD\)\>"
42c81e5e79SBram Moolenaarsyn match	freebasicCompilerSwitches	"\<option\s+\(PRIVATE\|STATIC\)\>"
43c81e5e79SBram Moolenaar
44c81e5e79SBram Moolenaarsyn region	freebasicConditional		start="\son\s+" skip=".*" end="gosub"
45c81e5e79SBram Moolenaarsyn region	freebasicConditional		start="\son\s+" skip=".*" end="goto"
46c81e5e79SBram Moolenaarsyn match	freebasicConditional		"\<select\s+case\>"
47c81e5e79SBram Moolenaarsyn keyword	freebasicConditional		if iif then case else elseif with
48c81e5e79SBram Moolenaar
49c81e5e79SBram Moolenaarsyn match	freebasicConsole		"\<open\s+\(CONS\|ERR\|PIPE\|SCRN\)\>"
50c81e5e79SBram Moolenaarsyn keyword	freebasicConsole		BEEP CLS CSRLIN LOCATE PRINT POS SPC TAB VIEW WIDTH
51c81e5e79SBram Moolenaar
52c81e5e79SBram Moolenaarsyn keyword	freebasicDataTypes		BYTE AS DIM CONST DOUBLE ENUM INTEGER LONG LONGINT SHARED SHORT STRING
53c81e5e79SBram Moolenaarsyn keyword	freebasicDataTypes		SINGLE TYPE UBYTE UINTEGER ULONGINT UNION UNSIGNED USHORT WSTRING ZSTRING
54c81e5e79SBram Moolenaar
55c81e5e79SBram Moolenaarsyn keyword	freebasicDateTime		DATE DATEADD DATEDIFF DATEPART DATESERIAL DATEVALUE DAY HOUR MINUTE
56c81e5e79SBram Moolenaarsyn keyword	freebasicDateTime		MONTH MONTHNAME NOW SECOND SETDATE SETTIME TIME TIMESERIAL TIMEVALUE
57c81e5e79SBram Moolenaarsyn keyword	freebasicDateTime		TIMER YEAR WEEKDAY WEEKDAYNAME
58c81e5e79SBram Moolenaar
59c81e5e79SBram Moolenaarsyn keyword	freebasicDebug			ASSERT STOP
60c81e5e79SBram Moolenaar
61c81e5e79SBram Moolenaarsyn keyword	freebasicErrorHandling		ERR ERL ERROR LOCAL RESUME
62c81e5e79SBram Moolenaarsyn match	freebasicErrorHandling		"\<resume\s+next\>"
63c81e5e79SBram Moolenaarsyn match	freebasicErrorHandling		"\<on\s+error\>"
64c81e5e79SBram Moolenaar
65c81e5e79SBram Moolenaarsyn match	freebasicFiles			"\<get\s+#\>"
66c81e5e79SBram Moolenaarsyn match	freebasicFiles			"\<input\s+#\>"
67c81e5e79SBram Moolenaarsyn match	freebasicFiles			"\<line\s+input\s+#\>"
68c81e5e79SBram Moolenaarsyn match	freebasicFiles			"\<put\s+#\>"
69c81e5e79SBram Moolenaarsyn keyword	freebasicFiles			ACCESS APPEND BINARY BLOAD BSAVE CLOSE EOF FREEFILE INPUT LOC
70c81e5e79SBram Moolenaarsyn keyword	freebasicFiles			LOCK LOF OPEN OUTPUT RANDOM RESET SEEK UNLOCK WRITE
71c81e5e79SBram Moolenaar
72c81e5e79SBram Moolenaarsyn keyword	freebasicFunctions		ALIAS ANY BYREF BYVAL CALL CDECL CONSTRUCTOR DESTRUCTOR
73c81e5e79SBram Moolenaarsyn keyword	freebasicFunctions		DECLARE FUNCTION LIB OVERLOAD PASCAL STATIC SUB STDCALL
74c81e5e79SBram Moolenaarsyn keyword	freebasicFunctions		VA_ARG VA_FIRST VA_NEXT
75c81e5e79SBram Moolenaar
76c81e5e79SBram Moolenaarsyn match	freebasicGraphics		"\<palette\s+get\>"
77c81e5e79SBram Moolenaarsyn keyword	freebasicGraphics		ALPHA CIRCLE CLS COLOR CUSTOM DRAW FLIP GET
78c81e5e79SBram Moolenaarsyn keyword	freebasicGraphics		IMAGECREATE IMAGEDESTROY LINE PAINT PALETTE PCOPY PMAP POINT
79c81e5e79SBram Moolenaarsyn keyword	freebasicGraphics		PRESET PSET PUT RGB RGBA SCREEN SCREENCOPY SCREENINFO SCREENLIST
80c81e5e79SBram Moolenaarsyn keyword	freebasicGraphics		SCREENLOCK SCREENPTR SCREENRES SCREENSET SCREENSYNC SCREENUNLOCK
81c81e5e79SBram Moolenaarsyn keyword	freebasicGraphics		TRANS USING VIEW WINDOW
82c81e5e79SBram Moolenaar
83c81e5e79SBram Moolenaarsyn match	freebasicHardware		"\<open\s+com\>"
84c81e5e79SBram Moolenaarsyn keyword	freebasicHardware		INP OUT WAIT LPT LPOS LPRINT
85c81e5e79SBram Moolenaar
86c81e5e79SBram Moolenaarsyn keyword	freebasicLogical		AND EQV IMP OR NOT XOR
87c81e5e79SBram Moolenaar
88c81e5e79SBram Moolenaarsyn keyword	freebasicMath			ABS ACOS ASIN ATAN2 ATN COS EXP FIX INT LOG MOD RANDOMIZE
89c81e5e79SBram Moolenaarsyn keyword	freebasicMath			RND SGN SIN SQR TAN
90c81e5e79SBram Moolenaar
91c81e5e79SBram Moolenaarsyn keyword	freebasicMemory			ALLOCATE CALLOCATE CLEAR DEALLOCATE FIELD FRE PEEK POKE REALLOCATE
92c81e5e79SBram Moolenaar
93c81e5e79SBram Moolenaarsyn keyword	freebasicMisc			ASM DATA LET TO READ RESTORE SIZEOF SWAP OFFSETOF
94c81e5e79SBram Moolenaar
95c81e5e79SBram Moolenaarsyn keyword	freebasicModularizing		CHAIN COMMON EXPORT EXTERN DYLIBFREE DYLIBLOAD DYLIBSYMBOL
96c81e5e79SBram Moolenaarsyn keyword	freebasicModularizing		PRIVATE PUBLIC
97c81e5e79SBram Moolenaar
98c81e5e79SBram Moolenaarsyn keyword	freebasicMultithreading		MUTEXCREATE MUTEXDESTROY MUTEXLOCK MUTEXUNLOCK THREADCREATE THREADWAIT
99c81e5e79SBram Moolenaar
100c81e5e79SBram Moolenaarsyn keyword	freebasicShell			CHDIR DIR COMMAND ENVIRON EXEC EXEPATH KILL NAME MKDIR RMDIR RUN
101c81e5e79SBram Moolenaar
102c81e5e79SBram Moolenaarsyn keyword	freebasicEnviron		SHELL SYSTEM WINDOWTITLE POINTERS
103c81e5e79SBram Moolenaar
104c81e5e79SBram Moolenaarsyn keyword	freebasicLoops			FOR LOOP WHILE WEND DO CONTINUE STEP UNTIL next
105c81e5e79SBram Moolenaar
106c81e5e79SBram Moolenaarsyn match	freebasicInclude		"\<#\s*\(inclib\|include\)\>"
107c81e5e79SBram Moolenaarsyn match	freebasicInclude		"\<\$\s*include\>"
108c81e5e79SBram Moolenaar
109c81e5e79SBram Moolenaarsyn keyword	freebasicPointer		PROCPTR PTR SADD STRPTR VARPTR
110c81e5e79SBram Moolenaar
111c81e5e79SBram Moolenaarsyn keyword	freebasicPredefined		__DATE__ __FB_DOS__ __FB_LINUX__ __FB_MAIN__ __FB_MIN_VERSION__
112c81e5e79SBram Moolenaarsyn keyword	freebasicPredefined		__FB_SIGNATURE__ __FB_VERSION__ __FB_WIN32__ __FB_VER_MAJOR__
113c81e5e79SBram Moolenaarsyn keyword	freebasicPredefined		__FB_VER_MINOR__ __FB_VER_PATCH__ __FILE__ __FUNCTION__
114c81e5e79SBram Moolenaarsyn keyword	freebasicPredefined		__LINE__ __TIME__
115c81e5e79SBram Moolenaar
116c81e5e79SBram Moolenaarsyn match	freebasicPreProcessor		"\<^#\s*\(define\|undef\)\>"
117c81e5e79SBram Moolenaarsyn match	freebasicPreProcessor		"\<^#\s*\(ifdef\|ifndef\|else\|elseif\|endif\|if\)\>"
118c81e5e79SBram Moolenaarsyn match	freebasicPreProcessor		"\<#\s*error\>"
119c81e5e79SBram Moolenaarsyn match	freebasicPreProcessor		"\<#\s*\(print\|dynamic\|static\)\>"
120c81e5e79SBram Moolenaarsyn keyword	freebasicPreProcessor		DEFINED ONCE
121c81e5e79SBram Moolenaar
122c81e5e79SBram Moolenaarsyn keyword	freebasicProgramFlow		END EXIT GOSUB GOTO
123c81e5e79SBram Moolenaarsyn keyword	freebasicProgramFlow		IS RETURN SCOPE SLEEP
124c81e5e79SBram Moolenaar
125c81e5e79SBram Moolenaarsyn keyword	freebasicString			INSTR LCASE LEFT LEN LSET LTRIM MID RIGHT RSET RTRIM
126c81e5e79SBram Moolenaarsyn keyword	freebasicString			SPACE STRING TRIM UCASE ASC BIN CHR CVD CVI CVL CVLONGINT
127c81e5e79SBram Moolenaarsyn keyword	freebasicString			CVS CVSHORT FORMAT HEX MKD MKI MKL MKLONGINT MKS MKSHORT
128c81e5e79SBram Moolenaarsyn keyword	freebasicString			OCT STR VAL VALLNG VALINT VALUINT VALULNG
129c81e5e79SBram Moolenaar
130c81e5e79SBram Moolenaarsyn keyword	freebasicTypeCasting		CAST CBYTE CDBL CINT CLNG CLNGINT CPTR CSHORT CSIGN CSNG
131c81e5e79SBram Moolenaarsyn keyword	freebasicTypeCasting		CUBYTE CUINT CULNGINT CUNSG CURDIR CUSHORT
132c81e5e79SBram Moolenaar
133c81e5e79SBram Moolenaarsyn match	freebasicUserInput		"\<line\s+input\>"
134c81e5e79SBram Moolenaarsyn keyword	freebasicUserInput		GETJOYSTICK GETKEY GETMOUSE INKEY INPUT MULTIKEY SETMOUSE
135c81e5e79SBram Moolenaar"
136c81e5e79SBram Moolenaar"	Do the Basic variables names first.  This is because it
137c81e5e79SBram Moolenaar"	is the most inclusive of the tests.  Later on we change
138c81e5e79SBram Moolenaar"	this so the identifiers are split up into the various
139c81e5e79SBram Moolenaar"	types of identifiers like functions, basic commands and
140c81e5e79SBram Moolenaar"	such. MEM 9/9/2006
141c81e5e79SBram Moolenaar"
142c81e5e79SBram Moolenaarsyn match	freebasicIdentifier			"\<[a-zA-Z_][a-zA-Z0-9_]*\>"
143c81e5e79SBram Moolenaarsyn match	freebasicGenericFunction	"\<[a-zA-Z_][a-zA-Z0-9_]*\>\s*("me=e-1,he=e-1
144c81e5e79SBram Moolenaar"
145c81e5e79SBram Moolenaar"	Function list
146c81e5e79SBram Moolenaar"
147c81e5e79SBram Moolenaarsyn keyword	freebasicTodo		contained TODO
148c81e5e79SBram Moolenaar"
149c81e5e79SBram Moolenaar"	Catch errors caused by wrong parenthesis
150c81e5e79SBram Moolenaar"
151c81e5e79SBram Moolenaarsyn region	freebasicParen		transparent start='(' end=')' contains=ALLBUT,@freebasicParenGroup
152c81e5e79SBram Moolenaarsyn match	freebasicParenError	")"
153c81e5e79SBram Moolenaarsyn match	freebasicInParen	contained "[{}]"
154c81e5e79SBram Moolenaarsyn cluster	freebasicParenGroup	contains=freebasicParenError,freebasicSpecial,freebasicTodo,freebasicUserCont,freebasicUserLabel,freebasicBitField
155c81e5e79SBram Moolenaar"
156c81e5e79SBram Moolenaar"	Integer number, or floating point number without a dot and with "f".
157c81e5e79SBram Moolenaar"
158c81e5e79SBram Moolenaarsyn region	freebasicHex			start="&h" end="\W"
159c81e5e79SBram Moolenaarsyn region	freebasicHexError		start="&h\x*[g-zG-Z]" end="\W"
160*8fe1000eSBram Moolenaarsyn region	freebasicOctal			start="&o" end="\W"
161*8fe1000eSBram Moolenaarsyn region	freebasicOctalError		start="&o[0-7]*[89a-zA-Z]" end="\W"
162*8fe1000eSBram Moolenaarsyn region	freebasicBinary			start="&b" end="\W"
163*8fe1000eSBram Moolenaarsyn region	freebasicBinaryError	start="&b[01]*[2-9a-zA-Z]" end="\W"
164c81e5e79SBram Moolenaarsyn match	freebasicInteger		"\<\d\+\(u\=l\=\|lu\|f\)\>"
165c81e5e79SBram Moolenaar"
166c81e5e79SBram Moolenaar"	Floating point number, with dot, optional exponent
167c81e5e79SBram Moolenaar"
168c81e5e79SBram Moolenaarsyn match	freebasicFloat		"\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
169c81e5e79SBram Moolenaar"
170c81e5e79SBram Moolenaar"	Floating point number, starting with a dot, optional exponent
171c81e5e79SBram Moolenaar"
172c81e5e79SBram Moolenaarsyn match	freebasicFloat		"\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
173c81e5e79SBram Moolenaar"
174c81e5e79SBram Moolenaar"	Floating point number, without dot, with exponent
175c81e5e79SBram Moolenaar"
176c81e5e79SBram Moolenaarsyn match	freebasicFloat		"\<\d\+e[-+]\=\d\+[fl]\=\>"
177c81e5e79SBram Moolenaar"
178*8fe1000eSBram Moolenaar"	Octal number
179c81e5e79SBram Moolenaar"
180c81e5e79SBram Moolenaarsyn case match
181*8fe1000eSBram Moolenaarsyn match	freebasicOctal2			"\<0\o*\>"
182*8fe1000eSBram Moolenaarsyn match	freebasicOctal2Error	"\<0\o*[89a-zA-Z]"
183c81e5e79SBram Moolenaar"
184c81e5e79SBram Moolenaar"	String and Character contstants
185c81e5e79SBram Moolenaar"
186c81e5e79SBram Moolenaarsyn region	freebasicString		start='"' end='"' contains=freebasicSpecial,freebasicTodo
187c81e5e79SBram Moolenaarsyn region	freebasicString		start="'" end="'" contains=freebasicSpecial,freebasicTodo
188c81e5e79SBram Moolenaar"
189c81e5e79SBram Moolenaar"	Comments
190c81e5e79SBram Moolenaar"
191*8fe1000eSBram Moolenaarsyn match	freebasicSpecial	contained "\\\\."
192c81e5e79SBram Moolenaarsyn region	freebasicComment	start="^rem" end="$" contains=freebasicSpecial,freebasicTodo
193c81e5e79SBram Moolenaarsyn region	freebasicComment	start=":\s*rem" end="$" contains=freebasicSpecial,freebasicTodo
194c81e5e79SBram Moolenaarsyn region	freebasicComment	start="\s*'" end="$" contains=freebasicSpecial,freebasicTodo
195c81e5e79SBram Moolenaarsyn region	freebasicComment	start="^'" end="$" contains=freebasicSpecial,freebasicTodo
196c81e5e79SBram Moolenaar"
197c81e5e79SBram Moolenaar"	Now do the comments and labels
198c81e5e79SBram Moolenaar"
199c81e5e79SBram Moolenaarsyn match	freebasicLabel		"^\d"
200c81e5e79SBram Moolenaarsyn match	freebasicLabel		"\<^\w+:\>"
201c81e5e79SBram Moolenaarsyn region	freebasicLineNumber	start="^\d" end="\s"
202c81e5e79SBram Moolenaar"
203c81e5e79SBram Moolenaar"	Create the clusters
204c81e5e79SBram Moolenaar"
205*8fe1000eSBram Moolenaarsyn cluster	freebasicNumber		contains=freebasicHex,freebasicOctal,freebasicOctal2,freebasicBinary,freebasicInteger,freebasicFloat
206*8fe1000eSBram Moolenaarsyn cluster	freebasicError		contains=freebasicHexError,freebasicOctalError,freebasicOctal2,freebasicBinary
207c81e5e79SBram Moolenaar"
208c81e5e79SBram Moolenaar"	Used with OPEN statement
209c81e5e79SBram Moolenaar"
210c81e5e79SBram Moolenaarsyn match	freebasicFilenumber		"#\d\+"
211c81e5e79SBram Moolenaarsyn match	freebasicMathOperator	"[\+\-\=\|\*\/\>\<\%\()[\]]" contains=freebasicParen
212c81e5e79SBram Moolenaar"
213c81e5e79SBram Moolenaar"	The default methods for highlighting.  Can be overridden later
214c81e5e79SBram Moolenaar"
215c81e5e79SBram Moolenaarhi def link freebasicArrays		StorageClass
216c81e5e79SBram Moolenaarhi def link freebasicBitManipulation	Operator
217c81e5e79SBram Moolenaarhi def link freebasicCompilerSwitches	PreCondit
218c81e5e79SBram Moolenaarhi def link freebasicConsole		Special
219c81e5e79SBram Moolenaarhi def link freebasicDataTypes		Type
220c81e5e79SBram Moolenaarhi def link freebasicDateTime		Type
221c81e5e79SBram Moolenaarhi def link freebasicDebug		Special
222c81e5e79SBram Moolenaarhi def link freebasicErrorHandling	Special
223c81e5e79SBram Moolenaarhi def link freebasicFiles		Special
224c81e5e79SBram Moolenaarhi def link freebasicFunctions		Function
225c81e5e79SBram Moolenaarhi def link freebasicGraphics		Function
226c81e5e79SBram Moolenaarhi def link freebasicHardware		Special
227c81e5e79SBram Moolenaarhi def link freebasicLogical		Conditional
228c81e5e79SBram Moolenaarhi def link freebasicMath		Function
229c81e5e79SBram Moolenaarhi def link freebasicMemory		Function
230c81e5e79SBram Moolenaarhi def link freebasicMisc		Special
231c81e5e79SBram Moolenaarhi def link freebasicModularizing	Special
232c81e5e79SBram Moolenaarhi def link freebasicMultithreading	Special
233c81e5e79SBram Moolenaarhi def link freebasicShell		Special
234c81e5e79SBram Moolenaarhi def link freebasicEnviron		Special
235c81e5e79SBram Moolenaarhi def link freebasicPointer		Special
236c81e5e79SBram Moolenaarhi def link freebasicPredefined		PreProc
237c81e5e79SBram Moolenaarhi def link freebasicPreProcessor	PreProc
238c81e5e79SBram Moolenaarhi def link freebasicProgramFlow	Statement
239c81e5e79SBram Moolenaarhi def link freebasicString		String
240c81e5e79SBram Moolenaarhi def link freebasicTypeCasting	Type
241c81e5e79SBram Moolenaarhi def link freebasicUserInput		Statement
242c81e5e79SBram Moolenaarhi def link freebasicComment		Comment
243c81e5e79SBram Moolenaarhi def link freebasicConditional	Conditional
244c81e5e79SBram Moolenaarhi def link freebasicError		Error
245c81e5e79SBram Moolenaarhi def link freebasicIdentifier		Identifier
246c81e5e79SBram Moolenaarhi def link freebasicInclude		Include
247c81e5e79SBram Moolenaarhi def link freebasicGenericFunction	Function
248c81e5e79SBram Moolenaarhi def link freebasicLabel		Label
249c81e5e79SBram Moolenaarhi def link freebasicLineNumber		Label
250c81e5e79SBram Moolenaarhi def link freebasicMathOperator	Operator
251c81e5e79SBram Moolenaarhi def link freebasicNumber		Number
252c81e5e79SBram Moolenaarhi def link freebasicSpecial		Special
253c81e5e79SBram Moolenaarhi def link freebasicTodo		Todo
254c81e5e79SBram Moolenaar
255c81e5e79SBram Moolenaarlet b:current_syntax = "freebasic"
256c81e5e79SBram Moolenaar
257c81e5e79SBram Moolenaar" vim: ts=8
258