Mercurial > hg > RemoteEditor > vim7
comparison runtime/syntax/forth.vim @ 0:76efa0be13f1
Initial revision
author | atsuki |
---|---|
date | Sat, 10 Nov 2007 15:07:22 +0900 |
parents | |
children | 6a13985590e6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:76efa0be13f1 |
---|---|
1 " Vim syntax file | |
2 " Language: FORTH | |
3 " Maintainer: Christian V. J. Brüssow <cvjb@cvjb.de> | |
4 " Last Change: Di 06 Jul 2004 18:40:33 CEST | |
5 " Filenames: *.fs,*.ft | |
6 " URL: http://www.cvjb.de/comp/vim/forth.vim | |
7 | |
8 " $Id$ | |
9 | |
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 | |
12 " the patches. | |
13 | |
14 " Many Thanks to... | |
15 " | |
16 " 2004-07-06: | |
17 " Changed "syn sync ccomment maxlines=200" line: splitted it into two separate | |
18 " lines. | |
19 " | |
20 " 2003-05-10: | |
21 " Andrew Gaul <andrew at gaul.org> send me a patch for | |
22 " forthOperators. | |
23 " | |
24 " 2003-04-03: | |
25 " Ron Aaron <ronaharon at yahoo.com> made updates for an | |
26 " improved Win32Forth support. | |
27 " | |
28 " 2002-04-22: | |
29 " Charles Shattuck <charley at forth.org> helped me to settle up with the | |
30 " binary and hex number highlighting. | |
31 " | |
32 " 2002-04-20: | |
33 " Charles Shattuck <charley at forth.org> send me some code for correctly | |
34 " highlighting char and [char] followed by an opening paren. He also added | |
35 " some words for operators, conditionals, and definitions; and added the | |
36 " highlighting for s" and c". | |
37 " | |
38 " 2000-03-28: | |
39 " John Providenza <john at probo.com> made improvements for the | |
40 " highlighting of strings, and added the code for highlighting hex numbers. | |
41 " | |
42 | |
43 | |
44 " For version 5.x: Clear all syntax items | |
45 " For version 6.x: Quit when a syntax file was already loaded | |
46 if version < 600 | |
47 syntax clear | |
48 elseif exists("b:current_syntax") | |
49 finish | |
50 endif | |
51 | |
52 " Synchronization method | |
53 syn sync ccomment | |
54 syn sync maxlines=200 | |
55 | |
56 " I use gforth, so I set this to case ignore | |
57 syn case ignore | |
58 | |
59 " Some special, non-FORTH keywords | |
60 syn keyword forthTodo contained TODO FIXME XXX | |
61 syn match forthTodo contained 'Copyright\(\s([Cc])\)\=\(\s[0-9]\{2,4}\)\=' | |
62 | |
63 " Characters allowed in keywords | |
64 " I don't know if 128-255 are allowed in ANS-FORHT | |
65 if version >= 600 | |
66 setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 | |
67 else | |
68 set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 | |
69 endif | |
70 | |
71 | |
72 " Keywords | |
73 | |
74 " basic mathematical and logical operators | |
75 syn keyword forthOperators + - * / MOD /MOD NEGATE ABS MIN MAX | |
76 syn keyword forthOperators AND OR XOR NOT INVERT 2* 2/ 1+ 1- 2+ 2- 8* | |
77 syn keyword forthOperators M+ */ */MOD M* UM* M*/ UM/MOD FM/MOD SM/REM | |
78 syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX | |
79 syn keyword forthOperators F+ F- F* F/ FNEGATE FABS FMAX FMIN FLOOR FROUND | |
80 syn keyword forthOperators F** FSQRT FEXP FEXPM1 FLN FLNP1 FLOG FALOG FSIN | |
81 syn keyword forthOperators FCOS FSINCOS FTAN FASIN FACOS FATAN FATAN2 FSINH | |
82 syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH | |
83 syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= < <= <> = > >= | |
84 syn keyword forthOperators ?NEGATE ?DNEGATE | |
85 | |
86 " stack manipulations | |
87 syn keyword forthStack DROP NIP DUP OVER TUCK SWAP ROT -ROT ?DUP PICK ROLL | |
88 syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT | |
89 syn keyword forthStack 3DUP 4DUP | |
90 syn keyword forthRStack >R R> R@ RDROP 2>R 2R> 2R@ 2RDROP | |
91 syn keyword forthFStack FDROP FNIP FDUP FOVER FTUCK FSWAP FROT | |
92 | |
93 " stack pointer manipulations | |
94 syn keyword forthSP SP@ SP! FP@ FP! RP@ RP! LP@ LP! | |
95 | |
96 " address operations | |
97 syn keyword forthMemory @ ! +! C@ C! 2@ 2! F@ F! SF@ SF! DF@ DF! | |
98 syn keyword forthAdrArith CHARS CHAR+ CELLS CELL+ CELL ALIGN ALIGNED FLOATS | |
99 syn keyword forthAdrArith FLOAT+ FLOAT FALIGN FALIGNED SFLOATS SFLOAT+ | |
100 syn keyword forthAdrArith SFALIGN SFALIGNED DFLOATS DFLOAT+ DFALIGN DFALIGNED | |
101 syn keyword forthAdrArith MAXALIGN MAXALIGNED CFALIGN CFALIGNED | |
102 syn keyword forthAdrArith ADDRESS-UNIT-BITS ALLOT ALLOCATE HERE | |
103 syn keyword forthMemBlks MOVE ERASE CMOVE CMOVE> FILL BLANK | |
104 | |
105 " conditionals | |
106 syn keyword forthCond IF ELSE ENDIF THEN CASE OF ENDOF ENDCASE ?DUP-IF | |
107 syn keyword forthCond ?DUP-0=-IF AHEAD CS-PICK CS-ROLL CATCH THROW WITHIN | |
108 | |
109 " iterations | |
110 syn keyword forthLoop BEGIN WHILE REPEAT UNTIL AGAIN | |
111 syn keyword forthLoop ?DO LOOP I J K +DO U+DO -DO U-DO DO +LOOP -LOOP | |
112 syn keyword forthLoop UNLOOP LEAVE ?LEAVE EXIT DONE FOR NEXT | |
113 | |
114 " new words | |
115 syn match forthColonDef '\<:m\?\s*[^ \t]\+\>' | |
116 syn keyword forthEndOfColonDef ; ;M ;m | |
117 syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE CREATE | |
118 syn keyword forthDefine USER VALUE TO DEFER IS DOES> IMMEDIATE COMPILE-ONLY | |
119 syn keyword forthDefine COMPILE RESTRICT INTERPRET POSTPONE EXECUTE LITERAL | |
120 syn keyword forthDefine CREATE-INTERPRET/COMPILE INTERPRETATION> <INTERPRETATION | |
121 syn keyword forthDefine COMPILATION> <COMPILATION ] LASTXT COMP' POSTPONE, | |
122 syn keyword forthDefine FIND-NAME NAME>INT NAME?INT NAME>COMP NAME>STRING STATE | |
123 syn keyword forthDefine C; CVARIABLE | |
124 syn match forthDefine "\[COMP']" | |
125 syn match forthDefine "'" | |
126 syn match forthDefine '\<\[\>' | |
127 syn match forthDefine "\[']" | |
128 syn match forthDefine '\[COMPILE]' | |
129 syn match forthClassDef '\<:class\s*[^ \t]\+\>' | |
130 syn match forthObjectDef '\<:object\s*[^ \t]\+\>' | |
131 syn keyword forthEndOfClassDef ';class' | |
132 syn keyword forthEndOfObjectDef ';object' | |
133 | |
134 " debugging | |
135 syn keyword forthDebug PRINTDEBUGDATA PRINTDEBUGLINE | |
136 syn match forthDebug "\<\~\~\>" | |
137 | |
138 " Assembler | |
139 syn keyword forthAssembler ASSEMBLER CODE END-CODE ;CODE FLUSH-ICACHE C, | |
140 | |
141 " basic character operations | |
142 syn keyword forthCharOps (.) CHAR EXPECT FIND WORD TYPE -TRAILING EMIT KEY | |
143 syn keyword forthCharOps KEY? TIB CR | |
144 " recognize 'char (' or '[char] (' correctly, so it doesn't | |
145 " highlight everything after the paren as a comment till a closing ')' | |
146 syn match forthCharOps '\<char\s\S\s' | |
147 syn match forthCharOps '\<\[char\]\s\S\s' | |
148 syn region forthCharOps start=+."\s+ skip=+\\"+ end=+"+ | |
149 | |
150 " char-number conversion | |
151 syn keyword forthConversion <# # #> #S (NUMBER) (NUMBER?) CONVERT D>F D>S DIGIT | |
152 syn keyword forthConversion DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER | |
153 | |
154 " interptreter, wordbook, compiler | |
155 syn keyword forthForth (LOCAL) BYE COLD ABORT >BODY >NEXT >LINK CFA >VIEW HERE | |
156 syn keyword forthForth PAD WORDS VIEW VIEW> N>LINK NAME> LINK> L>NAME FORGET | |
157 syn keyword forthForth BODY> | |
158 syn region forthForth start=+ABORT"\s+ skip=+\\"+ end=+"+ | |
159 | |
160 " vocabularies | |
161 syn keyword forthVocs ONLY FORTH ALSO ROOT SEAL VOCS ORDER CONTEXT #VOCS | |
162 syn keyword forthVocs VOCABULARY DEFINITIONS | |
163 | |
164 " numbers | |
165 syn keyword forthMath DECIMAL HEX BASE | |
166 syn match forthInteger '\<-\=[0-9.]*[0-9.]\+\>' | |
167 " recognize hex and binary numbers, the '$' and '%' notation is for gforth | |
168 syn match forthInteger '\<\$\x*\x\+\>' " *1* --- dont't mess | |
169 syn match forthInteger '\<\x*\d\x*\>' " *2* --- this order! | |
170 syn match forthInteger '\<%[0-1]*[0-1]\+\>' | |
171 syn match forthFloat '\<-\=\d*[.]\=\d\+[Ee]\d\+\>' | |
172 | |
173 " Strings | |
174 syn region forthString start=+\.*\"+ end=+"+ end=+$+ | |
175 " XXX | |
176 syn region forthString start=+s\"+ end=+"+ end=+$+ | |
177 syn region forthString start=+c\"+ end=+"+ end=+$+ | |
178 | |
179 " Comments | |
180 syn match forthComment '\\\s.*$' contains=forthTodo | |
181 syn region forthComment start='\\S\s' end='.*' contains=forthTodo | |
182 syn match forthComment '\.(\s[^)]*)' contains=forthTodo | |
183 syn region forthComment start='(\s' skip='\\)' end=')' contains=forthTodo | |
184 syn region forthComment start='/\*' end='\*/' contains=forthTodo | |
185 "syn match forthComment '(\s[^\-]*\-\-[^\-]*)' contains=forthTodo | |
186 | |
187 " Include files | |
188 syn match forthInclude '^INCLUDE\s\+\k\+' | |
189 syn match forthInclude '^fload\s\+' | |
190 syn match forthInclude '^needs\s\+' | |
191 | |
192 " Define the default highlighting. | |
193 " For version 5.7 and earlier: only when not done already | |
194 " For version 5.8 and later: only when an item doesn't have highlighting yet | |
195 if version >= 508 || !exists("did_forth_syn_inits") | |
196 if version < 508 | |
197 let did_forth_syn_inits = 1 | |
198 command -nargs=+ HiLink hi link <args> | |
199 else | |
200 command -nargs=+ HiLink hi def link <args> | |
201 endif | |
202 | |
203 " The default methods for highlighting. Can be overriden later. | |
204 HiLink forthTodo Todo | |
205 HiLink forthOperators Operator | |
206 HiLink forthMath Number | |
207 HiLink forthInteger Number | |
208 HiLink forthFloat Float | |
209 HiLink forthStack Special | |
210 HiLink forthRstack Special | |
211 HiLink forthFStack Special | |
212 HiLink forthSP Special | |
213 HiLink forthMemory Function | |
214 HiLink forthAdrArith Function | |
215 HiLink forthMemBlks Function | |
216 HiLink forthCond Conditional | |
217 HiLink forthLoop Repeat | |
218 HiLink forthColonDef Define | |
219 HiLink forthEndOfColonDef Define | |
220 HiLink forthDefine Define | |
221 HiLink forthDebug Debug | |
222 HiLink forthAssembler Include | |
223 HiLink forthCharOps Character | |
224 HiLink forthConversion String | |
225 HiLink forthForth Statement | |
226 HiLink forthVocs Statement | |
227 HiLink forthString String | |
228 HiLink forthComment Comment | |
229 HiLink forthClassDef Define | |
230 HiLink forthEndOfClassDef Define | |
231 HiLink forthObjectDef Define | |
232 HiLink forthEndOfObjectDef Define | |
233 HiLink forthInclude Include | |
234 | |
235 delcommand HiLink | |
236 endif | |
237 | |
238 let b:current_syntax = "forth" | |
239 | |
240 " vim:ts=8:sw=4:nocindent:smartindent: |