comparison runtime/syntax/forth.vim @ 1698:f4f8014d516e v7.2c.000

updated for version 7.2c-000
author vimboss
date Wed, 06 Aug 2008 17:06:04 +0000
parents 73fe8baea242
children 7bc41231fbc7
comparison
equal deleted inserted replaced
1697:2f9308b31181 1698:f4f8014d516e
1 " Vim syntax file 1 " Vim syntax file
2 " Language: FORTH 2 " Language: FORTH
3 " Maintainer: Christian V. J. Brüssow <cvjb@cvjb.de> 3 " Maintainer: Christian V. J. Brüssow <cvjb@cvjb.de>
4 " Last Change: Sa 14 Jul 2007 21:39:53 CEST 4 " Last Change: Sa 09 Feb 2008 13:27:29 CET
5 " Filenames: *.fs,*.ft 5 " Filenames: *.fs,*.ft
6 " URL: http://www.cvjb.de/comp/vim/forth.vim 6 " URL: http://www.cvjb.de/comp/vim/forth.vim
7 7
8 " $Id$ 8 " $Id$
9 9
10 " The list of keywords is incomplete, compared with the offical ANS 10 " The list of keywords is incomplete, compared with the offical ANS
11 " wordlist. If you use this language, please improve it, and send me 11 " wordlist. If you use this language, please improve it, and send me
12 " the patches. 12 " the patches.
13 "
14 " Before sending me patches, please download the newest version of this file
15 " from http://www.cvjb.de/comp/vim/forth.vim or http://www.vim.org/ (search
16 " for forth.vim).
13 17
14 " Many Thanks to... 18 " Many Thanks to...
19 "
20 " 2008-02-09:
21 " Shawn K. Quinn <sjquinn at speakeasy dot net> send a big patch with
22 " new words commonly used in Forth programs or defined by GNU Forth.
15 " 23 "
16 " 2007-07-11: 24 " 2007-07-11:
17 " Benjamin Krill <ben at codiert dot org> send me a patch 25 " Benjamin Krill <ben at codiert dot org> send me a patch
18 " to highlight space errors. 26 " to highlight space errors.
19 " You can toggle this feature on through setting the 27 " You can toggle this feature on through setting the
77 " Some special, non-FORTH keywords 85 " Some special, non-FORTH keywords
78 syn keyword forthTodo contained TODO FIXME XXX 86 syn keyword forthTodo contained TODO FIXME XXX
79 syn match forthTodo contained 'Copyright\(\s([Cc])\)\=\(\s[0-9]\{2,4}\)\=' 87 syn match forthTodo contained 'Copyright\(\s([Cc])\)\=\(\s[0-9]\{2,4}\)\='
80 88
81 " Characters allowed in keywords 89 " Characters allowed in keywords
82 " I don't know if 128-255 are allowed in ANS-FORHT 90 " I don't know if 128-255 are allowed in ANS-FORTH
83 if version >= 600 91 if version >= 600
84 setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 92 setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
85 else 93 else
86 set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 94 set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
87 endif 95 endif
98 106
99 " Keywords 107 " Keywords
100 108
101 " basic mathematical and logical operators 109 " basic mathematical and logical operators
102 syn keyword forthOperators + - * / MOD /MOD NEGATE ABS MIN MAX 110 syn keyword forthOperators + - * / MOD /MOD NEGATE ABS MIN MAX
103 syn keyword forthOperators AND OR XOR NOT INVERT 2* 2/ 1+ 1- 2+ 2- 8* 111 syn keyword forthOperators AND OR XOR NOT LSHIFT RSHIFT INVERT 2* 2/ 1+
112 syn keyword forthOperators 1- 2+ 2- 8* UNDER+
104 syn keyword forthOperators M+ */ */MOD M* UM* M*/ UM/MOD FM/MOD SM/REM 113 syn keyword forthOperators M+ */ */MOD M* UM* M*/ UM/MOD FM/MOD SM/REM
105 syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX 114 syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX D2* D2/
106 syn keyword forthOperators F+ F- F* F/ FNEGATE FABS FMAX FMIN FLOOR FROUND 115 syn keyword forthOperators F+ F- F* F/ FNEGATE FABS FMAX FMIN FLOOR FROUND
107 syn keyword forthOperators F** FSQRT FEXP FEXPM1 FLN FLNP1 FLOG FALOG FSIN 116 syn keyword forthOperators F** FSQRT FEXP FEXPM1 FLN FLNP1 FLOG FALOG FSIN
108 syn keyword forthOperators FCOS FSINCOS FTAN FASIN FACOS FATAN FATAN2 FSINH 117 syn keyword forthOperators FCOS FSINCOS FTAN FASIN FACOS FATAN FATAN2 FSINH
109 syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH 118 syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH F2* F2/ 1/F
110 syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= < <= <> = > >= 119 syn keyword forthOperators F~REL F~ABS F~
111 syn keyword forthOperators ?NEGATE ?DNEGATE 120 syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= < <= <> = > >= U< U<=
121 syn keyword forthOperators U> U>= D0< D0<= D0<> D0= D0> D0>= D< D<= D<>
122 syn keyword forthOperators D= D> D>= DU< DU<= DU> DU>= WITHIN ?NEGATE
123 syn keyword forthOperators ?DNEGATE
112 124
113 " stack manipulations 125 " stack manipulations
114 syn keyword forthStack DROP NIP DUP OVER TUCK SWAP ROT -ROT ?DUP PICK ROLL 126 syn keyword forthStack DROP NIP DUP OVER TUCK SWAP ROT -ROT ?DUP PICK ROLL
115 syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT 127 syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT 2-ROT
116 syn keyword forthStack 3DUP 4DUP 128 syn keyword forthStack 3DUP 4DUP 5DUP 3DROP 4DROP 5DROP 8DROP 4SWAP 4ROT
129 syn keyword forthStack 4-ROT 4TUCK 8SWAP 8DUP
117 syn keyword forthRStack >R R> R@ RDROP 2>R 2R> 2R@ 2RDROP 130 syn keyword forthRStack >R R> R@ RDROP 2>R 2R> 2R@ 2RDROP
131 syn keyword forthRstack 4>R 4R> 4R@ 4RDROP
118 syn keyword forthFStack FDROP FNIP FDUP FOVER FTUCK FSWAP FROT 132 syn keyword forthFStack FDROP FNIP FDUP FOVER FTUCK FSWAP FROT
119 133
120 " stack pointer manipulations 134 " stack pointer manipulations
121 syn keyword forthSP SP@ SP! FP@ FP! RP@ RP! LP@ LP! 135 syn keyword forthSP SP@ SP! FP@ FP! RP@ RP! LP@ LP!
122 136
137 syn keyword forthLoop BEGIN WHILE REPEAT UNTIL AGAIN 151 syn keyword forthLoop BEGIN WHILE REPEAT UNTIL AGAIN
138 syn keyword forthLoop ?DO LOOP I J K +DO U+DO -DO U-DO DO +LOOP -LOOP 152 syn keyword forthLoop ?DO LOOP I J K +DO U+DO -DO U-DO DO +LOOP -LOOP
139 syn keyword forthLoop UNLOOP LEAVE ?LEAVE EXIT DONE FOR NEXT 153 syn keyword forthLoop UNLOOP LEAVE ?LEAVE EXIT DONE FOR NEXT
140 154
141 " new words 155 " new words
156 syn match forthClassDef '\<:class\s*[^ \t]\+\>'
157 syn match forthObjectDef '\<:object\s*[^ \t]\+\>'
142 syn match forthColonDef '\<:m\?\s*[^ \t]\+\>' 158 syn match forthColonDef '\<:m\?\s*[^ \t]\+\>'
143 syn keyword forthEndOfColonDef ; ;M ;m 159 syn keyword forthEndOfColonDef ; ;M ;m
144 syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE CREATE 160 syn keyword forthEndOfClassDef ;class
145 syn keyword forthDefine USER VALUE TO DEFER IS DOES> IMMEDIATE COMPILE-ONLY 161 syn keyword forthEndOfObjectDef ;object
146 syn keyword forthDefine COMPILE RESTRICT INTERPRET POSTPONE EXECUTE LITERAL 162 syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE
147 syn keyword forthDefine CREATE-INTERPRET/COMPILE INTERPRETATION> <INTERPRETATION 163 syn keyword forthDefine FVARIABLE CREATE USER VALUE TO DEFER IS DOES> IMMEDIATE
148 syn keyword forthDefine COMPILATION> <COMPILATION ] LASTXT COMP' POSTPONE, 164 syn keyword forthDefine COMPILE-ONLY COMPILE RESTRICT INTERPRET POSTPONE EXECUTE
149 syn keyword forthDefine FIND-NAME NAME>INT NAME?INT NAME>COMP NAME>STRING STATE 165 syn keyword forthDefine LITERAL CREATE-INTERPRET/COMPILE INTERPRETATION>
150 syn keyword forthDefine C; CVARIABLE 166 syn keyword forthDefine <INTERPRETATION COMPILATION> <COMPILATION ] LASTXT
167 syn keyword forthDefine COMP' POSTPONE, FIND-NAME NAME>INT NAME?INT NAME>COMP
168 syn keyword forthDefine NAME>STRING STATE C; CVARIABLE
169 syn keyword forthDefine , 2, F, C,
170 syn match forthDefine "\[IFDEF]"
171 syn match forthDefine "\[IFUNDEF]"
172 syn match forthDefine "\[THEN]"
173 syn match forthDefine "\[ENDIF]"
174 syn match forthDefine "\[ELSE]"
175 syn match forthDefine "\[?DO]"
176 syn match forthDefine "\[DO]"
177 syn match forthDefine "\[LOOP]"
178 syn match forthDefine "\[+LOOP]"
179 syn match forthDefine "\[NEXT]"
180 syn match forthDefine "\[BEGIN]"
181 syn match forthDefine "\[UNTIL]"
182 syn match forthDefine "\[AGAIN]"
183 syn match forthDefine "\[WHILE]"
184 syn match forthDefine "\[REPEAT]"
151 syn match forthDefine "\[COMP']" 185 syn match forthDefine "\[COMP']"
152 syn match forthDefine "'" 186 syn match forthDefine "'"
153 syn match forthDefine '\<\[\>' 187 syn match forthDefine '\<\[\>'
154 syn match forthDefine "\[']" 188 syn match forthDefine "\[']"
155 syn match forthDefine '\[COMPILE]' 189 syn match forthDefine '\[COMPILE]'
156 syn match forthClassDef '\<:class\s*[^ \t]\+\>'
157 syn match forthObjectDef '\<:object\s*[^ \t]\+\>'
158 syn keyword forthEndOfClassDef ';class'
159 syn keyword forthEndOfObjectDef ';object'
160 190
161 " debugging 191 " debugging
162 syn keyword forthDebug PRINTDEBUGDATA PRINTDEBUGLINE 192 syn keyword forthDebug PRINTDEBUGDATA PRINTDEBUGLINE
163 syn match forthDebug "\<\~\~\>" 193 syn match forthDebug "\<\~\~\>"
164 194
173 syn match forthCharOps '\<char\s\S\s' 203 syn match forthCharOps '\<char\s\S\s'
174 syn match forthCharOps '\<\[char\]\s\S\s' 204 syn match forthCharOps '\<\[char\]\s\S\s'
175 syn region forthCharOps start=+."\s+ skip=+\\"+ end=+"+ 205 syn region forthCharOps start=+."\s+ skip=+\\"+ end=+"+
176 206
177 " char-number conversion 207 " char-number conversion
178 syn keyword forthConversion <# # #> #S (NUMBER) (NUMBER?) CONVERT D>F D>S DIGIT 208 syn keyword forthConversion <<# <# # #> #>> #S (NUMBER) (NUMBER?) CONVERT D>F
179 syn keyword forthConversion DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER 209 syn keyword forthConversion D>S DIGIT DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER
210 syn keyword forthConversion F>S S>F
180 211
181 " interptreter, wordbook, compiler 212 " interptreter, wordbook, compiler
182 syn keyword forthForth (LOCAL) BYE COLD ABORT >BODY >NEXT >LINK CFA >VIEW HERE 213 syn keyword forthForth (LOCAL) BYE COLD ABORT >BODY >NEXT >LINK CFA >VIEW HERE
183 syn keyword forthForth PAD WORDS VIEW VIEW> N>LINK NAME> LINK> L>NAME FORGET 214 syn keyword forthForth PAD WORDS VIEW VIEW> N>LINK NAME> LINK> L>NAME FORGET
184 syn keyword forthForth BODY> 215 syn keyword forthForth BODY> ASSERT( ASSERT0( ASSERT1( ASSERT2( ASSERT3( )
185 syn region forthForth start=+ABORT"\s+ skip=+\\"+ end=+"+ 216 syn region forthForth start=+ABORT"\s+ skip=+\\"+ end=+"+
186 217
187 " vocabularies 218 " vocabularies
188 syn keyword forthVocs ONLY FORTH ALSO ROOT SEAL VOCS ORDER CONTEXT #VOCS 219 syn keyword forthVocs ONLY FORTH ALSO ROOT SEAL VOCS ORDER CONTEXT #VOCS
189 syn keyword forthVocs VOCABULARY DEFINITIONS 220 syn keyword forthVocs VOCABULARY DEFINITIONS
190 221
222 " File keywords
223 syn keyword forthFileMode R/O R/W W/O BIN
224 syn keyword forthFileWords OPEN-FILE CREATE-FILE CLOSE-FILE DELETE-FILE
225 syn keyword forthFileWords RENAME-FILE READ-FILE READ-LINE KEY-FILE
226 syn keyword forthFileWords KEY?-FILE WRITE-FILE WRITE-LINE EMIT-FILE
227 syn keyword forthFileWords FLUSH-FILE FILE-STATUS FILE-POSITION
228 syn keyword forthFileWords REPOSITION-FILE FILE-SIZE RESIZE-FILE
229 syn keyword forthFileWords SLURP-FILE SLURP-FID STDIN STDOUT STDERR
230 syn keyword forthBlocks OPEN-BLOCKS USE LOAD --> BLOCK-OFFSET
231 syn keyword forthBlocks GET-BLOCK-FID BLOCK-POSITION LIST SCR BLOCK
232 syn keyword forthBlocks BUFER EMPTY-BUFFERS EMPTY-BUFFER UPDATE UPDATED?
233 syn keyword forthBlocks SAVE-BUFFERS SAVE-BUFFER FLUSH THRU +LOAD +THRU
234 syn keyword forthBlocks BLOCK-INCLUDED
235
191 " numbers 236 " numbers
192 syn keyword forthMath DECIMAL HEX BASE 237 syn keyword forthMath DECIMAL HEX BASE
193 syn match forthInteger '\<-\=[0-9.]*[0-9.]\+\>' 238 syn match forthInteger '\<-\=[0-9.]*[0-9.]\+\>'
239 syn match forthInteger '\<&-\=[0-9.]*[0-9.]\+\>'
194 " recognize hex and binary numbers, the '$' and '%' notation is for gforth 240 " recognize hex and binary numbers, the '$' and '%' notation is for gforth
195 syn match forthInteger '\<\$\x*\x\+\>' " *1* --- dont't mess 241 syn match forthInteger '\<\$\x*\x\+\>' " *1* --- dont't mess
196 syn match forthInteger '\<\x*\d\x*\>' " *2* --- this order! 242 syn match forthInteger '\<\x*\d\x*\>' " *2* --- this order!
197 syn match forthInteger '\<%[0-1]*[0-1]\+\>' 243 syn match forthInteger '\<%[0-1]*[0-1]\+\>'
198 syn match forthFloat '\<-\=\d*[.]\=\d\+[Ee]\d\+\>' 244 syn match forthFloat '\<-\=\d*[.]\=\d\+[DdEe]\d\+\>'
245 syn match forthFloat '\<-\=\d*[.]\=\d\+[DdEe][-+]\d\+\>'
246
247 " XXX If you find this overkill you can remove it. this has to come after the
248 " highlighting for numbers otherwise it has no effect.
249 syn region forthComment start='0 \[if\]' end='\[endif\]' end='\[then\]' contains=forthTodo
199 250
200 " Strings 251 " Strings
201 syn region forthString start=+\.*\"+ end=+"+ end=+$+ 252 syn region forthString start=+\.*\"+ end=+"+ end=+$+
202 " XXX 253 " XXX
203 syn region forthString start=+s\"+ end=+"+ end=+$+ 254 syn region forthString start=+s\"+ end=+"+ end=+$+
210 syn region forthComment start='\s(\s' skip='\\)' end=')' contains=forthTodo,forthSpaceError 261 syn region forthComment start='\s(\s' skip='\\)' end=')' contains=forthTodo,forthSpaceError
211 syn region forthComment start='/\*' end='\*/' contains=forthTodo,forthSpaceError 262 syn region forthComment start='/\*' end='\*/' contains=forthTodo,forthSpaceError
212 263
213 " Include files 264 " Include files
214 syn match forthInclude '^INCLUDE\s\+\k\+' 265 syn match forthInclude '^INCLUDE\s\+\k\+'
266 syn match forthInclude '^require\s\+\k\+'
215 syn match forthInclude '^fload\s\+' 267 syn match forthInclude '^fload\s\+'
216 syn match forthInclude '^needs\s\+' 268 syn match forthInclude '^needs\s\+'
269
270 " Locals definitions
271 syn region forthLocals start='{\s' start='{$' end='\s}' end='^}'
272 syn match forthLocals '{ }' " otherwise, at least two spaces between
273 syn region forthDeprecated start='locals|' end='|'
217 274
218 " Define the default highlighting. 275 " Define the default highlighting.
219 " For version 5.7 and earlier: only when not done already 276 " For version 5.7 and earlier: only when not done already
220 " For version 5.8 and later: only when an item doesn't have highlighting yet 277 " For version 5.8 and later: only when an item doesn't have highlighting yet
221 if version >= 508 || !exists("did_forth_syn_inits") 278 if version >= 508 || !exists("did_forth_syn_inits")
255 HiLink forthClassDef Define 312 HiLink forthClassDef Define
256 HiLink forthEndOfClassDef Define 313 HiLink forthEndOfClassDef Define
257 HiLink forthObjectDef Define 314 HiLink forthObjectDef Define
258 HiLink forthEndOfObjectDef Define 315 HiLink forthEndOfObjectDef Define
259 HiLink forthInclude Include 316 HiLink forthInclude Include
317 HiLink forthLocals Type " nothing else uses type and locals must stand out
318 HiLink forthDeprecated Error " if you must, change to Type
319 HiLink forthFileMode Function
320 HiLink forthFileWords Statement
321 HiLink forthBlocks Statement
260 HiLink forthSpaceError Error 322 HiLink forthSpaceError Error
261 323
262 delcommand HiLink 324 delcommand HiLink
263 endif 325 endif
264 326