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