1 {-------------------------------------------------------------------------------
2 The contents of this file are subject to the Mozilla Public License
3 Version 1.1 (the "License"); you may not use this file except in compliance
4 with the License. You may obtain a copy of the License at
5 http://www.mozilla.org/MPL/
6
7 Software distributed under the License is distributed on an "AS IS" basis,
8 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9 the specific language governing rights and limitations under the License.
10
11 The Original Code is: SynHighlighterJava.pas, released 2000-04-10.
12 The Original Code is based on the DcjSynJava.pas file from the
13 mwEdit component suite by Martin Waldenburg and other developers, the Initial
14 Author of this file is Michael Trier.
15 All Rights Reserved.
16
17 Contributors to the SynEdit and mwEdit projects are listed in the
18 Contributors.txt file.
19
20 Alternatively, the contents of this file may be used under the terms of the
21 GNU General Public License Version 2 or later (the "GPL"), in which case
22 the provisions of the GPL are applicable instead of those above.
23 If you wish to allow use of your version of this file only under the terms
24 of the GPL and not to allow others to use your version of this file
25 under the MPL, indicate your decision by deleting the provisions above and
26 replace them with the notice and other provisions required by the GPL.
27 If you do not delete the provisions above, a recipient may use your version
28 of this file under either the MPL or the GPL.
29
30 $Id: synhighlighterjava.pas 46388 2014-09-30 23:57:55Z martin $
31
32 You may retrieve the latest version of this file at the SynEdit home page,
33 located at http://SynEdit.SourceForge.net
34
35 Known Issues:
36 -------------------------------------------------------------------------------}
37 {
38 @abstract(Provides a Pike highlighter for SynEdit)
39 @author(Felipe Monteiro de Carvalho)
40 @created(March 2015)
41 @lastmod(2015-03-14)
42 The SynHighlighterPike unit provides SynEdit with a Pike source (.pike) highlighter.
43 }
44 unit synhighlighterpike;
45
46 {$I SynEdit.inc}
47
48 interface
49
50 uses
51 SysUtils, Classes,
52 LCLIntf, LCLType, Graphics,
53 SynEditHighlighter, synhighlighterjava, SynEditStrConst;
54
55 type
56 TSynPikeSyn = class(TSynJavaSyn)
57 private
Func17null58 function Func17: TtkTokenKind;
Func21null59 function Func21: TtkTokenKind;
Func32null60 function Func32: TtkTokenKind;
Func34null61 function Func34: TtkTokenKind;
Func39null62 function Func39: TtkTokenKind;
Func40null63 function Func40: TtkTokenKind;
Func42null64 function Func42: TtkTokenKind;
Func45null65 function Func45: TtkTokenKind;
Func46null66 function Func46: TtkTokenKind;
Func47null67 function Func47: TtkTokenKind;
Func48null68 function Func48: TtkTokenKind;
Func54null69 function Func54: TtkTokenKind;
Func55null70 function Func55: TtkTokenKind;
Func57null71 function Func57: TtkTokenKind;
Func59null72 function Func59: TtkTokenKind;
Func60null73 function Func60: TtkTokenKind;
Func61null74 function Func61: TtkTokenKind;
Func62null75 function Func62: TtkTokenKind;
Func63null76 function Func63: TtkTokenKind;
Func66null77 function Func66: TtkTokenKind;
Func68null78 function Func68: TtkTokenKind;
Func69null79 function Func69: TtkTokenKind;
Func76null80 function Func76: TtkTokenKind;
Func78null81 function Func78: TtkTokenKind;
Func79null82 function Func79: TtkTokenKind;
Func83null83 function Func83: TtkTokenKind;
Func86null84 function Func86: TtkTokenKind;
Func88null85 function Func88: TtkTokenKind;
Func89null86 function Func89: TtkTokenKind;
Func90null87 function Func90: TtkTokenKind;
Func92null88 function Func92: TtkTokenKind;
Func93null89 function Func93: TtkTokenKind;
Func95null90 function Func95: TtkTokenKind;
Func97null91 function Func97: TtkTokenKind;
Func98null92 function Func98: TtkTokenKind;
Func102null93 function Func102: TtkTokenKind;
Func109null94 function Func109: TtkTokenKind;
Func110null95 function Func110: TtkTokenKind;
Func114null96 function Func114: TtkTokenKind;
Func115null97 function Func115: TtkTokenKind;
Func119null98 function Func119: TtkTokenKind;
Func127null99 function Func127: TtkTokenKind;
Func136null100 function Func136: TtkTokenKind;
Func172null101 function Func172: TtkTokenKind;
102 protected
103 procedure InitIdent; override;
GetSampleSourcenull104 function GetSampleSource: string; override;
105 public
Pike_GetSampleSourcenull106 class function Pike_GetSampleSource: string;
GetLanguageNamenull107 class function GetLanguageName: string; override;
108 end;
109
110 implementation
111
112 procedure TSynPikeSyn.InitIdent;
113 var
114 I: Integer;
115 begin
116 for I := 0 to 172 do
117 Case I of
118 17: fIdentFuncTable[I] := @Func17;
119 21: fIdentFuncTable[I] := @Func21;
120 32: fIdentFuncTable[I] := @Func32;
121 34: fIdentFuncTable[I] := @Func34;
122 39: fIdentFuncTable[I] := @Func39;
123 40: fIdentFuncTable[I] := @Func40;
124 42: fIdentFuncTable[I] := @Func42;
125 45: fIdentFuncTable[I] := @Func45;
126 46: fIdentFuncTable[I] := @Func46;
127 47: fIdentFuncTable[I] := @Func47;
128 48: fIdentFuncTable[I] := @Func48;
129 54: fIdentFuncTable[I] := @Func54;
130 55: fIdentFuncTable[I] := @Func55;
131 57: fIdentFuncTable[I] := @Func57;
132 59: fIdentFuncTable[I] := @Func59;
133 60: fIdentFuncTable[I] := @Func60;
134 61: fIdentFuncTable[I] := @Func61;
135 62: fIdentFuncTable[I] := @Func62;
136 63: fIdentFuncTable[I] := @Func63;
137 66: fIdentFuncTable[I] := @Func66;
138 68: fIdentFuncTable[I] := @Func68;
139 69: fIdentFuncTable[I] := @Func69;
140 76: fIdentFuncTable[I] := @Func76;
141 78: fIdentFuncTable[I] := @Func78;
142 79: fIdentFuncTable[I] := @Func79;
143 83: fIdentFuncTable[I] := @Func83;
144 86: fIdentFuncTable[I] := @Func86;
145 88: fIdentFuncTable[I] := @Func88;
146 89: fIdentFuncTable[I] := @Func89;
147 90: fIdentFuncTable[I] := @Func90;
148 92: fIdentFuncTable[I] := @Func92;
149 93: fIdentFuncTable[I] := @Func93;
150 95: fIdentFuncTable[I] := @Func95;
151 97: fIdentFuncTable[I] := @Func97;
152 98: fIdentFuncTable[I] := @Func98;
153 102: fIdentFuncTable[I] := @Func102;
154 109: fIdentFuncTable[I] := @Func109;
155 110: fIdentFuncTable[I] := @Func110;
156 114: fIdentFuncTable[I] := @Func114;
157 115: fIdentFuncTable[I] := @Func115;
158 119: fIdentFuncTable[I] := @Func119;
159 127: fIdentFuncTable[I] := @Func127;
160 136: fIdentFuncTable[I] := @Func136;
161 172: fIdentFuncTable[I] := @Func172;
162 else fIdentFuncTable[I] := @AltFunc;
163 end;
164 end;
165
TSynPikeSyn.Func17null166 function TSynPikeSyn.Func17: TtkTokenKind;
167 begin
168 if KeyComp('if') then Result := tkKey else Result := tkIdentifier;
169 end;
170
TSynPikeSyn.Func21null171 function TSynPikeSyn.Func21: TtkTokenKind;
172 begin
173 if KeyComp('do') then Result := tkKey else Result := tkIdentifier;
174 end;
175
TSynPikeSyn.Func32null176 function TSynPikeSyn.Func32: TtkTokenKind;
177 begin
178 if KeyComp('case') then Result := tkKey else Result := tkIdentifier;
179 end;
180
Func34null181 function TSynPikeSyn.Func34: TtkTokenKind;
182 begin
183 if KeyComp('char') then Result := tkKey else Result := tkIdentifier;
184 end;
185
TSynPikeSyn.Func39null186 function TSynPikeSyn.Func39: TtkTokenKind;
187 begin
188 if KeyComp('lambda') then Result := tkKey else Result := tkIdentifier;
189 end;
190
Func40null191 function TSynPikeSyn.Func40: TtkTokenKind;
192 begin
193 if KeyComp('catch') then Result := tkKey else Result := tkIdentifier;
194 end;
195
Func42null196 function TSynPikeSyn.Func42: TtkTokenKind;
197 begin
198 if KeyComp('for') then Result := tkKey else
199 if KeyComp('break') then Result := tkKey else Result := tkIdentifier;
200 end;
201
Func45null202 function TSynPikeSyn.Func45: TtkTokenKind;
203 begin
204 if KeyComp('else') or KeyComp('new') then
205 Result := tkKey
206 else Result := tkIdentifier;
207 end;
208
Func46null209 function TSynPikeSyn.Func46: TtkTokenKind;
210 begin
211 if KeyComp('int') or KeyComp('gauge') then Result := tkKey else Result := tkIdentifier;
212 end;
213
Func47null214 function TSynPikeSyn.Func47: TtkTokenKind;
215 begin
216 if KeyComp('final') then Result := tkKey else Result := tkIdentifier;
217 end;
218
TSynPikeSyn.Func48null219 function TSynPikeSyn.Func48: TtkTokenKind;
220 begin
221 if KeyComp('false') or KeyComp('local') or KeyComp('bool') then Result := tkKey else Result := tkIdentifier;
222 end;
223
TSynPikeSyn.Func54null224 function TSynPikeSyn.Func54: TtkTokenKind;
225 begin
226 if KeyComp('void') then Result := tkKey else Result := tkIdentifier;
227 end;
228
TSynPikeSyn.Func55null229 function TSynPikeSyn.Func55: TtkTokenKind;
230 begin
231 if KeyComp('global') then Result := tkKey else Result := tkIdentifier;
232 end;
233
Func57null234 function TSynPikeSyn.Func57: TtkTokenKind;
235 begin
236 if KeyComp('enum') then Result := tkKey else Result := tkIdentifier;
237 end;
238
TSynPikeSyn.Func59null239 function TSynPikeSyn.Func59: TtkTokenKind;
240 begin
241 if KeyComp('class') or KeyComp('float') then Result := tkKey else Result := tkIdentifier;
242 end;
243
Func60null244 function TSynPikeSyn.Func60: TtkTokenKind;
245 begin
246 if KeyComp('this') or KeyComp('mixed') or KeyComp('prefed') then Result := tkKey else Result := tkIdentifier;
247 end;
248
Func61null249 function TSynPikeSyn.Func61: TtkTokenKind;
250 begin
251 if KeyComp('goto') or KeyComp('object') then Result := tkKey else Result := tkIdentifier;
252 end;
253
Func62null254 function TSynPikeSyn.Func62: TtkTokenKind;
255 begin
256 if KeyComp('while') then Result := tkKey else Result := tkIdentifier;
257 end;
258
Func63null259 function TSynPikeSyn.Func63: TtkTokenKind;
260 begin
261 if KeyComp('null') or KeyComp('foreach') then Result := tkKey else Result := tkIdentifier;
262 end;
263
TSynPikeSyn.Func66null264 function TSynPikeSyn.Func66: TtkTokenKind;
265 begin
266 if KeyComp('try') then Result := tkKey else Result := tkIdentifier;
267 end;
268
Func68null269 function TSynPikeSyn.Func68: TtkTokenKind;
270 begin
271 if KeyComp('true') or KeyComp('array') or KeyComp('sscanf') then Result := tkKey else Result := tkIdentifier;
272 end;
273
Func69null274 function TSynPikeSyn.Func69: TtkTokenKind;
275 begin
276 if KeyComp('public') then Result := tkKey else Result := tkIdentifier;
277 end;
278
TSynPikeSyn.Func76null279 function TSynPikeSyn.Func76: TtkTokenKind;
280 begin
281 if KeyComp('default') then Result := tkKey else Result := tkIdentifier;
282 end;
283
Func78null284 function TSynPikeSyn.Func78: TtkTokenKind;
285 begin
286 if KeyComp('static') then Result := tkKey else Result := tkIdentifier;
287 end;
288
Func79null289 function TSynPikeSyn.Func79: TtkTokenKind;
290 begin
291 if KeyComp('nomask') then Result := tkKey else Result := tkIdentifier;
292 end;
293
Func83null294 function TSynPikeSyn.Func83: TtkTokenKind;
295 begin
296 if KeyComp('mapping') then Result := tkKey else Result := tkIdentifier;
297 end;
298
Func86null299 function TSynPikeSyn.Func86: TtkTokenKind;
300 begin
301 if KeyComp('finally') or KeyComp('sizeof') or KeyComp('inline') then
302 Result := tkKey
303 else Result := tkIdentifier;
304 end;
305
TSynPikeSyn.Func88null306 function TSynPikeSyn.Func88: TtkTokenKind;
307 begin
308 if KeyComp('switch') or KeyComp('typedef') then Result := tkKey else Result := tkIdentifier;
309 end;
310
Func89null311 function TSynPikeSyn.Func89: TtkTokenKind;
312 begin
313 if KeyComp('throw') then Result := tkKey else Result := tkIdentifier;
314 end;
315
TSynPikeSyn.Func90null316 function TSynPikeSyn.Func90: TtkTokenKind;
317 begin
318 if KeyComp('inherit') then Result := tkKey else Result := tkIdentifier;
319 end;
320
Func92null321 function TSynPikeSyn.Func92: TtkTokenKind;
322 begin
323 if KeyComp('variant') or KeyComp('extern') then Result := tkKey else Result := tkIdentifier;
324 end;
325
Func93null326 function TSynPikeSyn.Func93: TtkTokenKind;
327 begin
328 if KeyComp('string') or KeyComp('typeof') then Result := tkKey else Result := tkIdentifier;
329 end;
330
Func95null331 function TSynPikeSyn.Func95: TtkTokenKind;
332 begin
333 if KeyComp('program') then Result := tkKey else Result := tkIdentifier;
334 end;
335
Func97null336 function TSynPikeSyn.Func97: TtkTokenKind;
337 begin
338 if KeyComp('import') then Result := tkKey else Result := tkIdentifier;
339 end;
340
TSynPikeSyn.Func98null341 function TSynPikeSyn.Func98: TtkTokenKind;
342 begin
343 if KeyComp('private') then Result := tkKey else Result := tkIdentifier;
344 end;
345
Func102null346 function TSynPikeSyn.Func102: TtkTokenKind;
347 begin
348 if KeyComp('return') then Result := tkKey else Result := tkIdentifier;
349 end;
350
Func109null351 function TSynPikeSyn.Func109: TtkTokenKind;
352 begin
353 if KeyComp('continue') then Result := tkKey else Result := tkIdentifier;
354 end;
355
TSynPikeSyn.Func110null356 function TSynPikeSyn.Func110: TtkTokenKind;
357 begin
358 if KeyComp('function') or KeyComp('optional') then Result := tkKey else Result := tkIdentifier;
359 end;
360
Func114null361 function TSynPikeSyn.Func114: TtkTokenKind;
362 begin
363 if KeyComp('constant') then Result := tkKey else Result := tkIdentifier;
364 end;
365
Func115null366 function TSynPikeSyn.Func115: TtkTokenKind;
367 begin
368 if KeyComp('protected') then Result := tkKey else Result := tkIdentifier;
369 end;
370
Func119null371 function TSynPikeSyn.Func119: TtkTokenKind;
372 begin
373 if KeyComp('strictfp') then Result := tkKey else Result := tkIdentifier;
374 end;
375
Func127null376 function TSynPikeSyn.Func127: TtkTokenKind;
377 begin
378 if KeyComp('multiset') then Result := tkKey else Result := tkIdentifier;
379 end;
380
Func136null381 function TSynPikeSyn.Func136: TtkTokenKind;
382 begin
383 if KeyComp('implements') then Result := tkKey else Result := tkIdentifier;
384 end;
385
TSynPikeSyn.Func172null386 function TSynPikeSyn.Func172: TtkTokenKind;
387 begin
388 if KeyComp('synchronized') then Result := tkKey else Result := tkIdentifier;
389 end;
390
TSynPikeSyn.GetSampleSourcenull391 function TSynPikeSyn.GetSampleSource: string;
392 begin
393 Result := Pike_GetSampleSource();
394 end;
395
TSynPikeSyn.Pike_GetSampleSourcenull396 class function TSynPikeSyn.Pike_GetSampleSource: string;
397 begin
398 Result := '/* Pike syntax highlighting */'#13#10 +
399 'int main()'#13#10 +
400 '{'#13#10 +
401 ' array(string) words = ({ "first", "second" });'#13#10 +
402 ' foreach(words, string cur_word)'#13#10 +
403 ' write("%O\n", cur_word);'#13#10 +
404 ' return 0;'#13#10 +
405 '}'#13#10 +
406 '/* Text Block */'#13#10 + #13#10;
407 end;
408
TSynPikeSyn.GetLanguageNamenull409 class function TSynPikeSyn.GetLanguageName: string;
410 begin
411 Result := SYNS_LangPike;
412 end;
413
414 initialization
415 RegisterPlaceableHighlighter(TSynPikeSyn);
416
417 end.
418
419