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