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