blob: ad9450b3b8e826faf613e704e0573965db947272 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaare0e39172021-01-25 21:14:57 +01002" Language: BASIC
3" Maintainer: Doug Kearns <dougkearns@gmail.com>
4" Previous Maintainer: Allan Kelly <allan@fruitloaf.co.uk>
5" Contributors: Thilo Six
6" Last Change: 2015 Jan 10
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
8" First version based on Micro$soft QBASIC circa 1989, as documented in
9" 'Learn BASIC Now' by Halvorson&Rygmyr. Microsoft Press 1989.
10" This syntax file not a complete implementation yet. Send suggestions to the
11" maintainer.
12
Bram Moolenaare0e39172021-01-25 21:14:57 +010013" Prelude {{{1
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020014if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000015 finish
16endif
17
Bram Moolenaarb6b046b2011-12-30 13:11:27 +010018let s:cpo_save = &cpo
19set cpo&vim
20
Bram Moolenaare0e39172021-01-25 21:14:57 +010021" Keywords {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000022syn keyword basicStatement BEEP beep Beep BLOAD bload Bload BSAVE bsave Bsave
23syn keyword basicStatement CALL call Call ABSOLUTE absolute Absolute
24syn keyword basicStatement CHAIN chain Chain CHDIR chdir Chdir
25syn keyword basicStatement CIRCLE circle Circle CLEAR clear Clear
26syn keyword basicStatement CLOSE close Close CLS cls Cls COLOR color Color
27syn keyword basicStatement COM com Com COMMON common Common
28syn keyword basicStatement CONST const Const DATA data Data
29syn keyword basicStatement DECLARE declare Declare DEF def Def
30syn keyword basicStatement DEFDBL defdbl Defdbl DEFINT defint Defint
31syn keyword basicStatement DEFLNG deflng Deflng DEFSNG defsng Defsng
32syn keyword basicStatement DEFSTR defstr Defstr DIM dim Dim
33syn keyword basicStatement DO do Do LOOP loop Loop
34syn keyword basicStatement DRAW draw Draw END end End
35syn keyword basicStatement ENVIRON environ Environ ERASE erase Erase
36syn keyword basicStatement ERROR error Error EXIT exit Exit
37syn keyword basicStatement FIELD field Field FILES files Files
38syn keyword basicStatement FOR for For NEXT next Next
39syn keyword basicStatement FUNCTION function Function GET get Get
40syn keyword basicStatement GOSUB gosub Gosub GOTO goto Goto
41syn keyword basicStatement IF if If THEN then Then ELSE else Else
42syn keyword basicStatement INPUT input Input INPUT# input# Input#
43syn keyword basicStatement IOCTL ioctl Ioctl KEY key Key
44syn keyword basicStatement KILL kill Kill LET let Let
45syn keyword basicStatement LINE line Line LOCATE locate Locate
46syn keyword basicStatement LOCK lock Lock UNLOCK unlock Unlock
47syn keyword basicStatement LPRINT lprint Lprint USING using Using
48syn keyword basicStatement LSET lset Lset MKDIR mkdir Mkdir
49syn keyword basicStatement NAME name Name ON on On
50syn keyword basicStatement ERROR error Error OPEN open Open
51syn keyword basicStatement OPTION option Option BASE base Base
52syn keyword basicStatement OUT out Out PAINT paint Paint
53syn keyword basicStatement PALETTE palette Palette PCOPY pcopy Pcopy
54syn keyword basicStatement PEN pen Pen PLAY play Play
55syn keyword basicStatement PMAP pmap Pmap POKE poke Poke
56syn keyword basicStatement PRESET preset Preset PRINT print Print
57syn keyword basicStatement PRINT# print# Print# USING using Using
58syn keyword basicStatement PSET pset Pset PUT put Put
59syn keyword basicStatement RANDOMIZE randomize Randomize READ read Read
60syn keyword basicStatement REDIM redim Redim RESET reset Reset
61syn keyword basicStatement RESTORE restore Restore RESUME resume Resume
62syn keyword basicStatement RETURN return Return RMDIR rmdir Rmdir
63syn keyword basicStatement RSET rset Rset RUN run Run
64syn keyword basicStatement SEEK seek Seek SELECT select Select
65syn keyword basicStatement CASE case Case SHARED shared Shared
66syn keyword basicStatement SHELL shell Shell SLEEP sleep Sleep
67syn keyword basicStatement SOUND sound Sound STATIC static Static
68syn keyword basicStatement STOP stop Stop STRIG strig Strig
69syn keyword basicStatement SUB sub Sub SWAP swap Swap
70syn keyword basicStatement SYSTEM system System TIMER timer Timer
71syn keyword basicStatement TROFF troff Troff TRON tron Tron
72syn keyword basicStatement TYPE type Type UNLOCK unlock Unlock
73syn keyword basicStatement VIEW view View WAIT wait Wait
74syn keyword basicStatement WHILE while While WEND wend Wend
75syn keyword basicStatement WIDTH width Width WINDOW window Window
76syn keyword basicStatement WRITE write Write DATE$ date$ Date$
77syn keyword basicStatement MID$ mid$ Mid$ TIME$ time$ Time$
78
79syn keyword basicFunction ABS abs Abs ASC asc Asc
80syn keyword basicFunction ATN atn Atn CDBL cdbl Cdbl
81syn keyword basicFunction CINT cint Cint CLNG clng Clng
82syn keyword basicFunction COS cos Cos CSNG csng Csng
83syn keyword basicFunction CSRLIN csrlin Csrlin CVD cvd Cvd
84syn keyword basicFunction CVDMBF cvdmbf Cvdmbf CVI cvi Cvi
85syn keyword basicFunction CVL cvl Cvl CVS cvs Cvs
86syn keyword basicFunction CVSMBF cvsmbf Cvsmbf EOF eof Eof
87syn keyword basicFunction ERDEV erdev Erdev ERL erl Erl
88syn keyword basicFunction ERR err Err EXP exp Exp
89syn keyword basicFunction FILEATTR fileattr Fileattr FIX fix Fix
90syn keyword basicFunction FRE fre Fre FREEFILE freefile Freefile
91syn keyword basicFunction INP inp Inp INSTR instr Instr
92syn keyword basicFunction INT int Int LBOUND lbound Lbound
93syn keyword basicFunction LEN len Len LOC loc Loc
94syn keyword basicFunction LOF lof Lof LOG log Log
95syn keyword basicFunction LPOS lpos Lpos PEEK peek Peek
96syn keyword basicFunction PEN pen Pen POINT point Point
97syn keyword basicFunction POS pos Pos RND rnd Rnd
98syn keyword basicFunction SADD sadd Sadd SCREEN screen Screen
99syn keyword basicFunction SEEK seek Seek SETMEM setmem Setmem
100syn keyword basicFunction SGN sgn Sgn SIN sin Sin
101syn keyword basicFunction SPC spc Spc SQR sqr Sqr
102syn keyword basicFunction STICK stick Stick STRIG strig Strig
103syn keyword basicFunction TAB tab Tab TAN tan Tan
104syn keyword basicFunction UBOUND ubound Ubound VAL val Val
105syn keyword basicFunction VALPTR valptr Valptr VALSEG valseg Valseg
106syn keyword basicFunction VARPTR varptr Varptr VARSEG varseg Varseg
107syn keyword basicFunction CHR$ Chr$ chr$ COMMAND$ command$ Command$
108syn keyword basicFunction DATE$ date$ Date$ ENVIRON$ environ$ Environ$
109syn keyword basicFunction ERDEV$ erdev$ Erdev$ HEX$ hex$ Hex$
110syn keyword basicFunction INKEY$ inkey$ Inkey$ INPUT$ input$ Input$
111syn keyword basicFunction IOCTL$ ioctl$ Ioctl$ LCASES$ lcases$ Lcases$
112syn keyword basicFunction LAFT$ laft$ Laft$ LTRIM$ ltrim$ Ltrim$
113syn keyword basicFunction MID$ mid$ Mid$ MKDMBF$ mkdmbf$ Mkdmbf$
114syn keyword basicFunction MKD$ mkd$ Mkd$ MKI$ mki$ Mki$
115syn keyword basicFunction MKL$ mkl$ Mkl$ MKSMBF$ mksmbf$ Mksmbf$
116syn keyword basicFunction MKS$ mks$ Mks$ OCT$ oct$ Oct$
117syn keyword basicFunction RIGHT$ right$ Right$ RTRIM$ rtrim$ Rtrim$
118syn keyword basicFunction SPACE$ space$ Space$ STR$ str$ Str$
119syn keyword basicFunction STRING$ string$ String$ TIME$ time$ Time$
120syn keyword basicFunction UCASE$ ucase$ Ucase$ VARPTR$ varptr$ Varptr$
Bram Moolenaar071d4272004-06-13 20:20:40 +0000121
Bram Moolenaare0e39172021-01-25 21:14:57 +0100122" Numbers {{{1
123" Integer number, or floating point number without a dot.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124syn match basicNumber "\<\d\+\>"
Bram Moolenaare0e39172021-01-25 21:14:57 +0100125" Floating point number, with dot
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126syn match basicNumber "\<\d\+\.\d*\>"
Bram Moolenaare0e39172021-01-25 21:14:57 +0100127" Floating point number, starting with a dot
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128syn match basicNumber "\.\d\+\>"
129
Bram Moolenaare0e39172021-01-25 21:14:57 +0100130" String and Character constants {{{1
131syn match basicSpecial "\\\d\d\d\|\\." contained
132syn region basicString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=basicSpecial
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133
Bram Moolenaare0e39172021-01-25 21:14:57 +0100134" Line numbers {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000135syn region basicLineNumber start="^\d" end="\s"
Bram Moolenaare0e39172021-01-25 21:14:57 +0100136
137" Data-type suffixes {{{1
138syn match basicTypeSpecifier "[a-zA-Z0-9][$%&!#]"ms=s+1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139" Used with OPEN statement
140syn match basicFilenumber "#\d\+"
Bram Moolenaare0e39172021-01-25 21:14:57 +0100141
142" Mathematical operators {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143" syn match basicMathsOperator "[<>+\*^/\\=-]"
Bram Moolenaare0e39172021-01-25 21:14:57 +0100144syn match basicMathsOperator "-\|=\|[:<>+\*^/\\]\|AND\|OR"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000145
Bram Moolenaare0e39172021-01-25 21:14:57 +0100146" Comments {{{1
147syn keyword basicTodo TODO FIXME XXX NOTE contained
148syn region basicComment start="^\s*\zsREM\>" start="\%(:\s*\)\@<=REM\>" end="$" contains=basicTodo
149syn region basicComment start="'" end="$" contains=basicTodo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000150
Bram Moolenaare0e39172021-01-25 21:14:57 +0100151"syn sync ccomment basicComment
152
153" Default Highlighting {{{1
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200154hi def link basicLabel Label
155hi def link basicConditional Conditional
156hi def link basicRepeat Repeat
157hi def link basicLineNumber Comment
158hi def link basicNumber Number
159hi def link basicError Error
160hi def link basicStatement Statement
161hi def link basicString String
Bram Moolenaare0e39172021-01-25 21:14:57 +0100162hi def link basicComment Comment
163hi def link basicSpecial Special
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200164hi def link basicTodo Todo
Bram Moolenaare0e39172021-01-25 21:14:57 +0100165hi def link basicFunction Identifier
166hi def link basicTypeSpecifier Type
167hi def link basicFilenumber basicTypeSpecifier
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200168"hi basicMathsOperator term=bold cterm=bold gui=bold
Bram Moolenaar071d4272004-06-13 20:20:40 +0000169
Bram Moolenaare0e39172021-01-25 21:14:57 +0100170" Postscript {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000171let b:current_syntax = "basic"
172
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100173let &cpo = s:cpo_save
174unlet s:cpo_save
Bram Moolenaare0e39172021-01-25 21:14:57 +0100175
176" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: