robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
79b92da0d2
master
1" Vim syntax file 2" Language: QB64 3" Maintainer: Doug Kearns <dougkearns@gmail.com> 4" Last Change: 2022 Jan 21 5 6" Prelude {{{1 7if exists ( "b:current_syntax" ) 8finish 9endif 10 11let s: cpo_save = & cpo 12set cpo & vim 13 14" syn iskeyword set after sourcing of basic.vim 15 16syn case ignore 17 18let s: prefix = search ( '\c^\s*$NOPREFIX\>' , 'n' ) ? '_\=' : '_' 19 20" Statements {{{1 21 22let s: statements =<< trim EOL " {{{2 23acceptfiledrop 24allowfullscreen 25assert 26console 27consolecursor 28consolefont 29consoletitle 30continue 31copypalette 32define 33delay 34depthbuffer 35displayorder 36dontblend 37echo 38exit\s\+\%(select\|case\) 39finishdrop 40freefont 41freeimage 42icon 43keyclear 44limit 45maptriangle 46memcopy 47memfill 48memfree 49memput 50mousehide 51mousemove 52mouseshow 53printimage 54printstring 55putimage 56screenclick 57screenhide 58screenmove 59screenprint 60screenshow 61setalpha 62sndbal 63sndclose 64sndlimit 65sndloop 66sndpause 67sndplay 68sndplaycopy 69sndplayfile 70sndraw 71sndrawdone 72sndsetpos 73sndstop 74sndvol 75title 76EOL 77" }}} 78 79for s in s: statements 80exe 'syn match qb64Statement "\<' .. s: prefix .. s .. '\>" contained contains=qb64Underscore' 81endfor 82 83" Functions {{{1 84 85let s: functions =<< trim EOL " {{{2 86acos 87acosh 88alpha 89alpha32 90arccot 91arccsc 92arcsec 93asin 94asinh 95atan2 96atanh 97axis 98backgroundcolor 99blue 100blue32 101button 102buttonchange 103ceil 104cinp 105commandcount 106connected 107connectionaddress 108connectionaddress$ 109consoleinput 110copyimage 111cot 112coth 113cosh 114csc 115csch 116cv 117cwd$ 118d2g 119d2r 120defaultcolor 121deflate$ 122desktopheight 123desktopwidth 124device$ 125deviceinput 126devices 127dir$ 128direxists 129droppedfile 130droppedfile$ 131errorline 132errormessage$ 133exit 134fileexists 135fontheight 136fontwidth 137freetimer 138g2d 139g2r 140green 141green32 142height 143hypot 144inclerrorfile$ 145inclerrorline 146inflate$ 147instrrev 148keyhit 149keydown 150lastaxis 151lastbutton 152lastwheel 153loadfont 154loadimage 155mem 156memelement 157memexists 158memimage 159memnew 160memsound 161mk$ 162mousebutton 163mouseinput 164mousemovementx 165mousemovementy 166mousepipeopen 167mousewheel 168mousex 169mousey 170newimage 171offset 172openclient 173os$ 174pi 175pixelsize 176printwidth 177r2d 178r2g 179red 180red32 181readbit 182resetbit 183resizeheight 184resizewidth 185rgb 186rgb32 187rgba 188rgba32 189round 190sec 191sech 192screenexists 193screenimage 194screenx 195screeny 196setbit 197shellhide 198shl 199shr 200sinh 201sndcopy 202sndgetpos 203sndlen 204sndopen 205sndopenraw 206sndpaused 207sndplaying 208sndrate 209sndrawlen 210startdir$ 211strcmp 212stricmp 213tanh 214title$ 215togglebit 216totaldroppedfiles 217trim$ 218wheel 219width 220windowhandle 221windowhasfocus 222EOL 223" }}} 224 225for f in s: functions 226exe 'syn match qb64Function "\<' .. s: prefix .. f .. '\>" contains=qb64Underscore' 227endfor 228 229" Functions and statements (same name) {{{1 230 231let s: common =<< trim EOL " {{{2 232autodisplay 233blend 234blink 235capslock 236clearcolor 237clipboard$ 238clipboardimage 239controlchr 240dest 241display 242font 243fullscreen 244mapunicode 245memget 246numlock 247palettecolor 248printmode 249resize 250screenicon 251scrolllock 252source 253EOL 254" }}} 255 256for c in s: common 257exe 'syn match qb64Statement "\<' .. s: prefix .. c .. '\>" contains=qb64Underscore contained' 258exe 'syn match qb64Function "\<' .. s: prefix .. c .. '\>" contains=qb64Underscore' 259endfor 260 261" Keywords {{{1 262 263" Non-prefixed keywords {{{2 264" TIMER FREE 265" _DEPTH_BUFFER LOCK 266syn keyword qb64Keyword free lock 267 268let s: keywords =<< trim EOL " {{{2 269all 270anticlockwise 271behind 272clear 273clip 274console 275dontwait 276explicit 277explicitarray 278fillbackground 279hardware 280hardware1 281hide 282keepbackground 283middle 284none 285off 286only 287onlybackground 288ontop 289openconnection 290openhost 291preserve 292seamless 293smooth 294smoothshrunk 295smoothstretched 296software 297squarepixels 298stretch 299toggle 300EOL 301" }}} 302 303for k in s: keywords 304exe 'syn match qb64Keyword "\<' .. s: prefix .. k .. '\>" contains=qb64Underscore' 305endfor 306 307syn match qb64Underscore "\<_ "contained conceal transparent 308 309" Source QuickBASIC syntax {{{1 310runtime ! syntax/basic.vim 311 312" add after the BASIC syntax file is sourced so cluster already exists 313syn cluster basicStatements add = qb64Statement , qb64Metacommand , qb64IfMetacommand 314syn cluster basicLineIdentifier add = qb64LineLabel 315syn cluster qb64NotTop contains = @basicNotTop , qb64Metavariable 316 317syn iskeyword @,48-57,.,_,!,#,$,%,&,` 318 319" Unsupported QuickBASIC features {{{1 320" TODO: add linux only missing features 321syn keyword qb64Unsupported alias any byval calls cdecl erdev erdev $ fileattr 322syn keyword qb64Unsupported fre ioctl ioctl $ pen play setmem signal uevent 323syn keyword qb64Unsupported tron troff 324syn match qb64Unsupported "\<declare\%(\s\+\%(sub\|function\)\>\)\@= " 325syn match qb64Unsupported "\<\%(date\|time\)$\ze\s * = "" statements only 326syn match qb64Unsupported "\<def\zs\s\+FN " 327syn match qb64Unsupported "\<\%(exit\|end\)\s\+def\> " 328syn match qb64Unsupported "\<width\s\+lprint\> " 329 330" Types {{{1 331syn keyword qb64Type _BIT _BYTE _FLOAT _INTEGER64 _MEM _OFFSET _UNSIGNED 332 333" Type suffixes {{{1 334if exists ( "basic_type_suffixes" ) 335" TODO: handle leading word boundary and __+ prefix 336syn match qb64TypeSuffix "\%(\a [ [:alnum: ] ._] * \)\@<=\~\=`\%(\d\+\)\= " 337syn match qb64TypeSuffix "\%(\a [ [:alnum: ] ._] * \)\@<=\~\=\%(%\|%%\|&\|&&\|%&\) " 338syn match qb64TypeSuffix "\%(\a [ [:alnum: ] ._] * \)\@<=\%(!\|##\|#\) " 339syn match qb64TypeSuffix "\%(\a [ [:alnum: ] ._] * \)\@<=$\%(\d\+\)\= " 340endif 341 342" Numbers {{{1 343 344" Integers 345syn match qb64Number "-\=&b [ 01 ] \+&\>\= " 346 347syn match qb64Number "-\=\< [ 01 ] \~\=`\> " 348syn match qb64Number "-\=\<\d\+`\d\+\> " 349 350syn match qb64Number "-\=\<\d\+\%(%%\|&&\|%&\)\> " 351syn match qb64Number "\<\d\+\~\%(%%\|&&\|%&\)\> " 352 353syn match qb64Number "-\=\<&b [ 01 ] \+\%(%%\|&&\|%&\)\> " 354syn match qb64Number "\<&b [ 01 ] \+\~\%(%%\|&&\|%&\)\> " 355 356syn match qb64Number "-\=\<&o\=\o\+\%(%%\|&&\|%&\)\> " 357syn match qb64Number "\<&o\=\o\+\~\%(%%\|&&\|%&\)\> " 358 359syn match qb64Number "-\=\<&h\x\+\%(%%\|&&\|%&\)\> " 360syn match qb64Number "\<&h\x\+\~\%(%%\|&&\|%&\)\> " 361 362" Floats 363syn match qb64Float "-\=\<\d\+\.\=\d * ##\> " 364syn match qb64Float "-\=\<\.\d\+##\> " 365 366" Line numbers and labels {{{1 367syn match qb64LineLabel "\%(_\{2,}\)\=\a [ [:alnum: ] ._] * [ [:alnum: ] ]\ze\s * : "nextgroup = @basicStatements skipwhite contained 368 369" Metacommands {{{1 370syn match qb64Metacommand contained "$NOPREFIX\> " 371syn match qb64Metacommand contained "$ASSERTS\%(:CONSOLE\)\=\> " 372syn match qb64Metacommand contained "$CHECKING:\%(ON\|OFF\)\> " 373syn match qb64Metacommand contained "$COLOR:\%(0\|32\)\> " 374syn match qb64Metacommand contained "$CONSOLE\%(:ONLY\)\=\> " 375syn match qb64Metacommand contained "$EXEICON\s * :\s * ' [ ^' ] \+' " 376syn match qb64Metacommand contained "$ERROR\> " 377syn match qb64Metacommand contained "$LET\> " 378syn match qb64Metacommand contained "$RESIZE:\%(ON\|OFF\|STRETCH\|SMOOTH\)\> " 379syn match qb64Metacommand contained "$SCREEN\%(HIDE\|SHOW\)\> " 380syn match qb64Metacommand contained "$VERSIONINFO\s * :. * " 381syn match qb64Metacommand contained "$VIRTUALKEYBOARD:\%(ON\|OFF\)\> " 382 383syn region qb64IfMetacommand contained matchgroup = qb64Metacommand start = "$\%(IF\|ELSEIF\)\> "end = "\<THEN\> "oneline transparent contains = qb64Metavariable 384syn match qb64Metacommand contained "$\%(ELSE\|END\s * IF\)\> " 385 386syn keyword qb64Metavariable contained defined undefined 387syn keyword qb64Metavariable contained windows win linux mac maxosx 388syn keyword qb64Metavariable contained 32bit 64bit version 389 390" Default Highlighting {{{1 391hi def link qb64Float basicFloat 392hi def link qb64Function Function 393hi def link qb64Keyword Keyword 394hi def link qb64LineLabel basicLineLabel 395hi def link qb64Metacommand PreProc 396hi def link qb64Metavariable Identifier 397hi def link qb64Number basicNumber 398hi def link qb64Statement Statement 399hi def link qb64TypeSuffix basicTypeSuffix 400hi def link qb64Type Type 401hi def link qb64Unsupported Error 402 403" Postscript {{{1 404let b: current_syntax = "qb64" 405 406let & cpo = s: cpo_save 407unlet s: cpo_save 408 409" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: