1121
|
1 " Vim syntax file
|
|
2 " Language: ibasic
|
|
3 " Maintainer: Mark Manning <markem@airmail.net>
|
|
4 " Originator: Allan Kelly <Allan.Kelly@ed.ac.uk>
|
|
5 " Created: 10/1/2006
|
|
6 " Updated: 10/21/2006
|
|
7 " Description: A vim file to handle the IBasic file format.
|
|
8 " Notes:
|
|
9 " Updated by Mark Manning <markem@airmail.net>
|
|
10 " Applied IBasic support to the already excellent support for standard
|
|
11 " basic syntax (like QB).
|
|
12 "
|
|
13 " First version based on Micro$soft QBASIC circa 1989, as documented in
|
|
14 " 'Learn BASIC Now' by Halvorson&Rygmyr. Microsoft Press 1989.
|
|
15 " This syntax file not a complete implementation yet.
|
|
16 " Send suggestions to the maintainer.
|
|
17 "
|
|
18 " This version is based upon the commands found in IBasic (www.pyxia.com).
|
|
19 " MEM 10/6/2006
|
|
20 "
|
|
21 " Quit when a (custom) syntax file was already loaded (Taken from c.vim)
|
|
22 "
|
|
23 if exists("b:current_syntax")
|
|
24 finish
|
|
25 endif
|
|
26 "
|
|
27 " Be sure to turn on the "case ignore" since current versions of basic
|
|
28 " support both upper as well as lowercase letters.
|
|
29 "
|
|
30 syn case ignore
|
|
31 "
|
|
32 " A bunch of useful BASIC keywords
|
|
33 "
|
|
34 syn keyword ibasicStatement beep bload bsave call absolute chain chdir circle
|
|
35 syn keyword ibasicStatement clear close cls color com common const data
|
|
36 syn keyword ibasicStatement loop draw end environ erase error exit field
|
|
37 syn keyword ibasicStatement files function get gosub goto
|
|
38 syn keyword ibasicStatement input input# ioctl key kill let line locate
|
|
39 syn keyword ibasicStatement lock unlock lprint using lset mkdir name
|
|
40 syn keyword ibasicStatement on error open option base out paint palette pcopy
|
|
41 syn keyword ibasicStatement pen play pmap poke preset print print# using pset
|
|
42 syn keyword ibasicStatement put randomize read redim reset restore resume
|
|
43 syn keyword ibasicStatement return rmdir rset run seek screen
|
|
44 syn keyword ibasicStatement shared shell sleep sound static stop strig sub
|
|
45 syn keyword ibasicStatement swap system timer troff tron type unlock
|
|
46 syn keyword ibasicStatement view wait width window write
|
|
47 syn keyword ibasicStatement date$ mid$ time$
|
|
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 "
|
|
55 syn match ibasicIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>"
|
|
56 syn match ibasicGenericFunction "\<[a-zA-Z_][a-zA-Z0-9_]*\>\s*("me=e-1,he=e-1
|
|
57 "
|
|
58 " Function list
|
|
59 "
|
|
60 syn keyword ibasicBuiltInFunction abs asc atn cdbl cint clng cos csng csrlin cvd cvdmbf
|
|
61 syn keyword ibasicBuiltInFunction cvi cvl cvs cvsmbf eof erdev erl err exp fileattr
|
|
62 syn keyword ibasicBuiltInFunction fix fre freefile inp instr lbound len loc lof
|
|
63 syn keyword ibasicBuiltInFunction log lpos mod peek pen point pos rnd sadd screen seek
|
|
64 syn keyword ibasicBuiltInFunction setmem sgn sin spc sqr stick strig tab tan ubound
|
|
65 syn keyword ibasicBuiltInFunction val valptr valseg varptr varseg
|
|
66 syn keyword ibasicBuiltInFunction chr\$ command$ date$ environ$ erdev$ hex$ inkey$
|
|
67 syn keyword ibasicBuiltInFunction input$ ioctl$ lcases$ laft$ ltrim$ mid$ mkdmbf$ mkd$
|
|
68 syn keyword ibasicBuiltInFunction mki$ mkl$ mksmbf$ mks$ oct$ right$ rtrim$ space$
|
|
69 syn keyword ibasicBuiltInFunction str$ string$ time$ ucase$ varptr$
|
|
70 syn keyword ibasicTodo contained TODO
|
|
71 syn cluster ibasicFunctionCluster contains=ibasicBuiltInFunction,ibasicGenericFunction
|
|
72
|
|
73 syn keyword Conditional if else then elseif endif select case endselect
|
|
74 syn keyword Repeat for do while next enddo endwhile wend
|
|
75
|
|
76 syn keyword ibasicTypeSpecifier single double defdbl defsng
|
|
77 syn keyword ibasicTypeSpecifier int integer uint uinteger int64 uint64 defint deflng
|
|
78 syn keyword ibasicTypeSpecifier byte char string istring defstr
|
|
79 syn keyword ibasicDefine dim def declare
|
|
80 "
|
|
81 "catch errors caused by wrong parenthesis
|
|
82 "
|
|
83 syn cluster ibasicParenGroup contains=ibasicParenError,ibasicIncluded,ibasicSpecial,ibasicTodo,ibasicUserCont,ibasicUserLabel,ibasicBitField
|
|
84 syn region ibasicParen transparent start='(' end=')' contains=ALLBUT,@bParenGroup
|
|
85 syn match ibasicParenError ")"
|
|
86 syn match ibasicInParen contained "[{}]"
|
|
87 "
|
|
88 "integer number, or floating point number without a dot and with "f".
|
|
89 "
|
|
90 syn region ibasicHex start="&h" end="\W"
|
|
91 syn region ibasicHexError start="&h\x*[g-zG-Z]" end="\W"
|
|
92 syn match ibasicInteger "\<\d\+\(u\=l\=\|lu\|f\)\>"
|
|
93 "
|
|
94 "floating point number, with dot, optional exponent
|
|
95 "
|
|
96 syn match ibasicFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
|
|
97 "
|
|
98 "floating point number, starting with a dot, optional exponent
|
|
99 "
|
|
100 syn match ibasicFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
|
|
101 "
|
|
102 "floating point number, without dot, with exponent
|
|
103 "
|
|
104 syn match ibasicFloat "\<\d\+e[-+]\=\d\+[fl]\=\>"
|
|
105 "
|
|
106 "hex number
|
|
107 "
|
|
108 syn match ibasicIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>"
|
|
109 syn match ibasicFunction "\<[a-zA-Z_][a-zA-Z0-9_]*\>\s*("me=e-1,he=e-1
|
|
110 syn case match
|
|
111 syn match ibasicOctalError "\<0\o*[89]"
|
|
112 "
|
|
113 " String and Character contstants
|
|
114 "
|
|
115 syn region ibasicString start='"' end='"' contains=ibasicSpecial,ibasicTodo
|
|
116 syn region ibasicString start="'" end="'" contains=ibasicSpecial,ibasicTodo
|
|
117 "
|
|
118 " Comments
|
|
119 "
|
|
120 syn match ibasicSpecial contained "\\."
|
|
121 syn region ibasicComment start="^rem" end="$" contains=ibasicSpecial,ibasicTodo
|
|
122 syn region ibasicComment start=":\s*rem" end="$" contains=ibasicSpecial,ibasicTodo
|
|
123 syn region ibasicComment start="\s*'" end="$" contains=ibasicSpecial,ibasicTodo
|
|
124 syn region ibasicComment start="^'" end="$" contains=ibasicSpecial,ibasicTodo
|
|
125 "
|
|
126 " Now do the comments and labels
|
|
127 "
|
|
128 syn match ibasicLabel "^\d"
|
|
129 syn region ibasicLineNumber start="^\d" end="\s"
|
|
130 "
|
|
131 " Pre-compiler options : FreeBasic
|
|
132 "
|
|
133 syn region ibasicPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=ibasicString,ibasicCharacter,ibasicNumber,ibasicCommentError,ibasicSpaceError
|
|
134 syn match ibasicInclude "^\s*#\s*include\s*"
|
|
135 "
|
|
136 " Create the clusters
|
|
137 "
|
|
138 syn cluster ibasicNumber contains=ibasicHex,ibasicInteger,ibasicFloat
|
|
139 syn cluster ibasicError contains=ibasicHexError
|
|
140 "
|
|
141 " Used with OPEN statement
|
|
142 "
|
|
143 syn match ibasicFilenumber "#\d\+"
|
|
144 "
|
|
145 "syn sync ccomment ibasicComment
|
|
146 "
|
|
147 syn match ibasicMathOperator "[\+\-\=\|\*\/\>\<\%\()[\]]" contains=ibasicParen
|
|
148 "
|
|
149 " The default methods for highlighting. Can be overridden later
|
|
150 "
|
|
151 hi def link ibasicLabel Label
|
|
152 hi def link ibasicConditional Conditional
|
|
153 hi def link ibasicRepeat Repeat
|
|
154 hi def link ibasicHex Number
|
|
155 hi def link ibasicInteger Number
|
|
156 hi def link ibasicFloat Number
|
|
157 hi def link ibasicError Error
|
|
158 hi def link ibasicHexError Error
|
|
159 hi def link ibasicStatement Statement
|
|
160 hi def link ibasicString String
|
|
161 hi def link ibasicComment Comment
|
|
162 hi def link ibasicLineNumber Comment
|
|
163 hi def link ibasicSpecial Special
|
|
164 hi def link ibasicTodo Todo
|
|
165 hi def link ibasicGenericFunction Function
|
|
166 hi def link ibasicBuiltInFunction Function
|
|
167 hi def link ibasicTypeSpecifier Type
|
|
168 hi def link ibasicDefine Type
|
|
169 hi def link ibasicInclude Include
|
|
170 hi def link ibasicIdentifier Identifier
|
|
171 hi def link ibasicFilenumber ibasicTypeSpecifier
|
|
172 hi def link ibasicMathOperator Operator
|
|
173
|
|
174 let b:current_syntax = "ibasic"
|
|
175
|
|
176 " vim: ts=8
|