robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
0c23525b59
master
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" ) 25finish 26endif 27" 28" Dialect detection 29" 30let s: lang = freebasic#GetDialect () 31" 32" Whitespace Errors 33" 34if exists ( "freebasic_space_errors" ) 35if ! exists ( "freebasic_no_trail_space_error" ) 36syn match freebasicSpaceError display excludenl "\s\+$ " 37endif 38if ! exists ( "freebasic_no_tab_space_error" ) 39syn match freebasicSpaceError display "\+\t "me= e-1 40endif 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\)\>' 56syn iskeyword @,48-57,_,192-255,. 57syn match freebasicIdentifier "\<\h\%(\w\|\.\) * \> " 58syn match freebasicGenericFunction "\<\h\%(\w\|\.\) * \>\ze\s * ( " 59else 60syn iskeyword @,48-57,_,192-255 61syn match freebasicIdentifier "\<\h\w * \> " 62syn 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" 73syn keyword freebasicArrays ArrayConstDescriptorPtr ArrayDescriptorPtr FBARRAY 74endif 75 76if s: lang == "qb" 77syn keyword freebasicAsm __ASM 78syn match freebasicAsm "\<end\s\+__asm\> " 79else 80syn keyword freebasicAsm ASM 81syn match freebasicAsm "\<end\s\+asm\> " 82endif 83 84if s: lang == "qb" 85syn keyword freebasicBitManipulation __BIT __BITRESET __BITSET __HIBYTE __HIWORD __LOBYTE __LOWORD 86else 87syn keyword freebasicBitManipulation BIT BITRESET BITSET HIBYTE HIWORD LOBYTE LOWORD 88endif 89 90if s: lang != "fb" 91syn keyword freebasicCompilerSwitches DEFDBL DEFINT DEFLNG DEFSNG DEFSTR 92endif 93if s: lang == "qb" 94syn keyword freebasicCompilerSwitches __DEFBYTE __DEFLONGINT __DEFSHORT __DEFUBYTE __DEFUINT __DEFULONGINT __DEFUSHORT 95elseif s: lang == "fblite" || s: lang == "deprecated" 96syn 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" 107syn keyword freebasicProgramFlow __SLEEP 108endif 109if s: lang == "fblite" || s: lang == "qb" 110syn keyword freebasicProgramFlow GOSUB 111endif 112if s: lang == "fb" || s: lang == "deprecated" 113syn keyword freebasicProgramFlow SCOPE 114syn match freebasicProgramFlow "\<end\s\+scope\> " 115endif 116 117if s: lang == "fblite" || s: lang == "qb" 118syn region freebasicConditional matchgroup = freebasicConditional start = "\<on\> "end = "\<gosub\> "transparent 119syn region freebasicConditional matchgroup = freebasicConditional start = "\<on\> "end = "\<goto\> "transparent 120endif 121syn keyword freebasicConditional IF THEN ELSE ELSEIF 122if s: lang == "qb" 123syn keyword freebasicConditional __IIF __WITH 124syn match freebasicConditional "\<end\s\+__with\> " 125else 126syn keyword freebasicConditional IIF WITH 127syn 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 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" 144syn keyword freebasicDataTypes __BOOLEAN __BYTE __LONGINT __SHORT __UBYTE __UINTEGER __ULONG __ULONGINT __UNSIGNED __USHORT __ZSTRING 145syn match freebasicDataTypes "\<__WSTRING\> " 146syn keyword freebasicDataTypes __EXPLICIT __EXTENDS __IMPLEMENTS __OBJECT __POINTER __PTR __SIZEOF __TYPEOF 147syn keyword freebasicDataTypes __UNION 148syn match freebasicDataTypes "\<end\s\+__union\> " 149else 150syn keyword freebasicDataTypes BOOLEAN BYTE LONGINT SHORT UBYTE UINTEGER ULONG ULONGINT UNSIGNED USHORT ZSTRING 151syn match freebasicDataTypes "\<WSTRING\> " 152syn keyword freebasicDataTypes EXPLICIT EXTENDS IMPLEMENTS OBJECT POINTER PTR SIZEOF TYPEOF 153syn keyword freebasicDataTypes UNION 154syn match freebasicDataTypes "\<end\s\+union\> " 155endif 156if s: lang == "fb" 157syn keyword freebasicDataTypes BASE CLASS THIS VAR 158endif 159 160if s: lang == "qb" 161syn match freebasicDateTime "\<\%(date\|time\)\$ " 162elseif s: lang == "fblite" || s: lang == "deprecated" 163syn match freebasicDateTime "\<\%(date\|time\)\>\$\= " 164else " fb 165syn 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" 176syn keyword freebasicDebug __ASSERT __ASSERTWARN 177else 178syn keyword freebasicDebug ASSERT ASSERTWARN 179endif 180 181syn keyword freebasicErrorHandling ERR ERL ERROR 182if s: lang == "qb" 183syn keyword freebasicErrorHandling __ERFN __ERMN 184syn match freebasicErrorHandling "\<on\s\+error\> " 185else 186syn keyword freebasicErrorHandling ERFN ERMN 187syn match freebasicErrorHandling "\<on\s\+\%(local\s\+\)\=error\> " 188endif 189if s: lang != "fb" 190syn 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" 201syn keyword freebasicFiles __ENCODING 202else 203syn keyword freebasicFiles ENCODING WINPUT 204syn 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" 214syn keyword freebasicFunctions __CVA_ARG __CVA_COPY __CVA_END __CVA_LIST __CVA_START 215syn keyword freebasicFunctions __VA_ARG __VA_FIRST __VA_NEXT 216else 217syn keyword freebasicFunctions CVA_ARG CVA_COPY CVA_END CVA_LIST CVA_START 218syn keyword freebasicFunctions VA_ARG VA_FIRST VA_NEXT 219syn 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" 227syn keyword freebasicFunctions ABSTRACT OVERRIDE VIRTUAL __THISCALL 228syn keyword freebasicFunctions CONSTRUCTOR DESTRUCTOR OPERATOR PROPERTY 229syn match freebasicFunctions "\<end\s\+constructor\> " 230syn match freebasicFunctions "\<end\s\+destructor\> " 231syn match freebasicFunctions "\<end\s\+operator\> " 232syn match freebasicFunctions "\<end\s\+property\> " 233else 234syn 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" 243syn keyword freebasicGraphics __FLIP __IMAGECONVERTROW __IMAGECREATE __IMAGEDESTROY __IMAGEINFO __POINTCOORD 244syn keyword freebasicGraphics __RGB __RGBA __SCREENCOPY __SCREENCONTROL __SCREENEVENT __SCREENGLPROC __SCREENINFO 245syn keyword freebasicGraphics __SCREENLIST __SCREENLOCK __SCREENPTR __SCREENRES __SCREENSET __SCREENSYNC 246syn keyword freebasicGraphics __SCREENUNLOCK __WINDOWTITLE 247else 248syn keyword freebasicGraphics CUSTOM 249syn keyword freebasicGraphics FLIP IMAGECONVERTROW IMAGECREATE IMAGEDESTROY IMAGEINFO POINTCOORD 250syn keyword freebasicGraphics RGB RGBA SCREENCOPY SCREENCONTROL SCREENEVENT SCREENGLPROC SCREENINFO 251syn keyword freebasicGraphics SCREENLIST SCREENLOCK SCREENPTR SCREENRES SCREENSET SCREENSYNC 252syn keyword freebasicGraphics SCREENUNLOCK WINDOWTITLE 253endif 254 255if s: lang != "qb" 256syn 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" 263syn keyword freebasicMath __ACOS __ASIN __ATAN2 264else 265syn keyword freebasicMath ACOS ASIN ATAN2 266endif 267 268if s: lang == "qb" 269syn keyword freebasicMemory __ALLOCATE __CALLOCATE __DEALLOCATE __REALLOCATE 270else 271syn keyword freebasicMemory ALLOCATE CALLOCATE DEALLOCATE REALLOCATE 272syn keyword freebasicMemory PEEK POKE CLEAR FB_MEMCOPY FB_MEMCOPYCLEAR FB_MEMMOVE SWAP SADD 273syn keyword freebasicMemory FIELD FRE 274endif 275 276syn keyword freebasicMisc LET TO 277if s: lang == "qb" 278syn keyword freebasicMisc __OFFSETOF 279else 280syn keyword freebasicMisc OFFSETOF 281endif 282 283syn keyword freebasicModularizing CHAIN COMMON 284if s: lang == "fb" 285syn keyword freebasicModularizing EXTERN 286syn match freebasicModularizing "\<end\s\+extern\> " 287syn keyword freebasicModularizing PROTECTED 288endif 289if s: lang == "qb" 290syn keyword freebasicModularizing __EXPORT __IMPORT __DYLIBFREE __DYLIBLOAD __DYLIBSYMBOL 291else 292syn keyword freebasicModularizing EXPORT IMPORT DYLIBFREE DYLIBLOAD DYLIBSYMBOL 293syn keyword freebasicModularizing PRIVATE PUBLIC 294syn keyword freebasicModularizing NAMESPACE 295syn match freebasicModularizing "\<end\s\+namespace\> " 296endif 297 298if s: lang != "qb" 299syn keyword freebasicMultithreading MUTEXCREATE MUTEXDESTROY MUTEXLOCK MUTEXUNLOCK THREADCREATE THREADWAIT 300syn keyword freebasicMultithreading CONDBROADCAST CONDCREATE CONDDESTROY CONDSIGNAL CONDWAIT 301syn keyword freebasicMultithreading THREADCALL THREADDETACH THREADSELF 302endif 303 304syn keyword freebasicShell CHDIR KILL NAME MKDIR RMDIR RUN SETENVIRON 305if s: lang == "qb" 306syn keyword freebasicShell __CURDIR __DIR __EXEC __EXEPATH 307syn match freebasicString "\<\%(command\|environ\)\$ " 308else 309" fbio.bi 310syn keyword freebasicShell ISREDIRECTED 311syn keyword freebasicShell CURDIR DIR EXEC EXEPATH 312syn 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" 319syn keyword freebasicLoops __CONTINUE 320else 321syn 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" 379syn match freebasicString "\<string\$\ze\s * ( " 380syn match freebasicString "\<__wstring\ze\s * ( " 381syn match freebasicString "\<space\$ " 382syn keyword freebasicString __WSPACE 383syn match freebasicString "\<chr\$ " 384syn keyword freebasicString __WCHR 385syn keyword freebasicString __WBIN __WHEX __WOCT __WSTR 386syn match freebasicString "\<\%(bin\|hex\|oct\|str\)\$ " 387syn keyword freebasicString __VALLNG __VALINT __VALUINT __VALULNG 388syn match freebasicString "\<\%(mkd\|mki\|mkl\|mks\)\$ " 389syn keyword freebasicString __MKLONGINT __MKSHORT 390syn keyword freebasicString __CVLONGINT __CVSHORT 391syn match freebasicString "\<\%(left\|mid\|right\|lcase\|ucase\|ltrim\|rtrim\)\$ " 392syn keyword freebasicString __TRIM 393syn keyword freebasicString __INSTRREV 394else 395syn match freebasicString "\<string\$\=\ze\s * ( " 396syn match freebasicString "\<wstring\ze\s * ( " 397syn match freebasicString "\<space\>\$\= " 398syn keyword freebasicString WSPACE 399syn match freebasicString "\<chr\>\$\= " 400syn keyword freebasicString WCHR 401syn keyword freebasicString WBIN WHEX WOCT WSTR 402syn match freebasicString "\<\%(bin\|hex\|oct\|str\)\>\$\= " 403syn keyword freebasicString VALLNG VALINT VALUINT VALULNG 404syn match freebasicString "\<\%(mkd\|mki\|mkl\|mks\)\>\$\= " 405syn match freebasicString "\<\%(mklongint\|mkshort\)\>\$\= " 406syn keyword freebasicString CVLONGINT CVSHORT 407syn match freebasicString "\<\%(left\|mid\|right\|lcase\|ucase\|ltrim\|rtrim\)\>\$\= " 408syn match freebasicString "\<trim\>\$\= " 409syn keyword freebasicString INSTRREV 410endif 411 412syn keyword freebasicTypeCasting CDBL CINT CLNG CSNG 413if s: lang == "qb" 414syn keyword freebasicTypeCasting __CAST __CBOOL __CBYTE __CLNGINT __CPTR __CSHORT __CSIGN __CYBTE __CUINT __CULNG 415syn keyword freebasicTypeCasting __CULNGINT __CUNSG __CUSHORT 416else 417syn 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" 423syn keyword freebasicUserInput __GETJOYSTICK __GETKEY __GETMOUSE __MULTIKEY __SETMOUSE STICK STRIG 424else 425syn 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" 434syn match freebasicArithmeticOperator "\<\%(MOD\|__SHL\|__SHR\)\> " 435else 436syn match freebasicArithmeticOperator "\<\%(MOD\|SHL\|SHR\)\> " 437endif 438syn match freebasicBitwiseOperator "\<\%(AND\|EQV\|IMP\|NOT\|OR\|XOR\)\> "" freebaseLogical? 439if s: lang == "qb" 440syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|__SHL\|__SHR\)=\@= "" exclude trailing '=' 441else 442syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|SHL\|SHR\)=\@= " 443endif 444syn match freebasicShortcircuitOperator "\<\%(ANDALSO\|ORELSE\)\> " 445if s: lang == "fb" 446syn match freebasicMemoryOperator '\<\%(new\|delete\)\> ' 447endif 448syn keyword freebasicPointerOperator STRPTR VARPTR 449if s: lang == "qb" 450syn keyword freebasicPointerOperator __PROCPTR 451else 452syn keyword freebasicPointerOperator PROCPTR 453endif 454syn match freebasicTypeOperator '\<is\> ' 455syn match freebasicTypeOperator '\. 'nextgroup = freebasicIdentifier skipwhite 456if s: lang == "fb" 457syn match freebasicTypeOperator '-> 'nextgroup = freebasicIdentifier skipwhite 458endif 459 460if exists ( "freebasic_operators" ) 461syn match freebasicAssignmentOperator "=>\=\| [ -+&/\\*^ ] = " 462if s: lang == "qb" 463syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|__SHL\|__SHR\)= "" include trailing '=' 464else 465syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|SHL\|SHR\)= " 466endif 467syn match freebasicArithmeticOperator "[ -+&/\\*^ ] " 468" syn match freebasicIndexingOperator "[[\]()]" " FIXME 469syn match freebasicRelationalOperator "=\|<>\|<=\|<\|>=\|> " 470syn match freebasicPreprocessorOperator '\%(^\s * \)\@<!\%(##\|#\)\| [ $! ] "\@= ' 471syn match freebasicPointerOperator '[ @* ] ' 472syn match freebasicTypeOperator '\. 'nextgroup = freebasicIdentifier skipwhite 473if s: lang == "fb" 474syn match freebasicTypeOperator '-> 'nextgroup = freebasicIdentifier skipwhite 475endif 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" 524syn 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\)\>' 543syn match freebasicLineLabel "^\s * \zs\h\%(\w\|\.\) * \ze\s * : " 544else 545syn 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\)\>' 558syn 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" ) 569syn region freebasicMultilineComment start = "/' "end = "'/ "contains = freebasicTodo , @Spell , freeBasicMultilineComment fold keepend extend 570syn region freebasicMultilineComment2 start = "^\s * '. * \n\%(\s * '\)\@= "end = "^\s * '. * \n\%(\s * '\)\@! "contains = freebasicComment , freebasicDoubleComment keepend fold 571else 572syn 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" 587hi def link freebasicCompilerSwitches freebasicUnsupportedError 588else 589hi 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" 605hi def link freebasicMetacommand freebasicUnsupportedError 606else 607hi 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" 633hi def link freebasicLineNumber freebasicUnsupportedError 634else 635hi 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" ) 658hi 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