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