1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
|
{-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: SynHighlighterJava.pas, released 2000-04-10.
The Original Code is based on the DcjSynJava.pas file from the
mwEdit component suite by Martin Waldenburg and other developers, the Initial
Author of this file is Michael Trier.
All Rights Reserved.
Contributors to the SynEdit and mwEdit projects are listed in the
Contributors.txt file.
Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.
$Id: synhighlighterjava.pas 46388 2014-09-30 23:57:55Z martin $
You may retrieve the latest version of this file at the SynEdit home page,
located at http://SynEdit.SourceForge.net
Known Issues:
-------------------------------------------------------------------------------}
{
@abstract(Provides a Pike highlighter for SynEdit)
@author(Felipe Monteiro de Carvalho)
@created(March 2015)
@lastmod(2015-03-14)
The SynHighlighterPike unit provides SynEdit with a Pike source (.pike) highlighter.
}
unit synhighlighterpike;
{$I SynEdit.inc}
interface
uses
SysUtils, Classes,
LCLIntf, LCLType, Graphics,
SynEditHighlighter, synhighlighterjava;
type
TSynPikeSyn = class(TSynJavaSyn)
private
function Func17: TtkTokenKind;
function Func21: TtkTokenKind;
function Func32: TtkTokenKind;
function Func34: TtkTokenKind;
function Func39: TtkTokenKind;
function Func40: TtkTokenKind;
function Func42: TtkTokenKind;
function Func45: TtkTokenKind;
function Func46: TtkTokenKind;
function Func47: TtkTokenKind;
function Func48: TtkTokenKind;
function Func54: TtkTokenKind;
function Func55: TtkTokenKind;
function Func57: TtkTokenKind;
function Func59: TtkTokenKind;
function Func60: TtkTokenKind;
function Func61: TtkTokenKind;
function Func62: TtkTokenKind;
function Func63: TtkTokenKind;
function Func66: TtkTokenKind;
function Func68: TtkTokenKind;
function Func69: TtkTokenKind;
function Func76: TtkTokenKind;
function Func78: TtkTokenKind;
function Func79: TtkTokenKind;
function Func83: TtkTokenKind;
function Func86: TtkTokenKind;
function Func88: TtkTokenKind;
function Func89: TtkTokenKind;
function Func90: TtkTokenKind;
function Func92: TtkTokenKind;
function Func93: TtkTokenKind;
function Func95: TtkTokenKind;
function Func97: TtkTokenKind;
function Func98: TtkTokenKind;
function Func102: TtkTokenKind;
function Func109: TtkTokenKind;
function Func110: TtkTokenKind;
function Func114: TtkTokenKind;
function Func115: TtkTokenKind;
function Func119: TtkTokenKind;
function Func127: TtkTokenKind;
function Func136: TtkTokenKind;
function Func172: TtkTokenKind;
protected
procedure InitIdent; override;
function GetSampleSource: string; override;
public
class function Pike_GetSampleSource: string;
class function GetLanguageName: string; override;
end;
implementation
uses
SynEditStrConst;
procedure TSynPikeSyn.InitIdent;
var
I: Integer;
begin
for I := 0 to 172 do
Case I of
17: fIdentFuncTable[I] := @Func17;
21: fIdentFuncTable[I] := @Func21;
32: fIdentFuncTable[I] := @Func32;
34: fIdentFuncTable[I] := @Func34;
39: fIdentFuncTable[I] := @Func39;
40: fIdentFuncTable[I] := @Func40;
42: fIdentFuncTable[I] := @Func42;
45: fIdentFuncTable[I] := @Func45;
46: fIdentFuncTable[I] := @Func46;
47: fIdentFuncTable[I] := @Func47;
48: fIdentFuncTable[I] := @Func48;
54: fIdentFuncTable[I] := @Func54;
55: fIdentFuncTable[I] := @Func55;
57: fIdentFuncTable[I] := @Func57;
59: fIdentFuncTable[I] := @Func59;
60: fIdentFuncTable[I] := @Func60;
61: fIdentFuncTable[I] := @Func61;
62: fIdentFuncTable[I] := @Func62;
63: fIdentFuncTable[I] := @Func63;
66: fIdentFuncTable[I] := @Func66;
68: fIdentFuncTable[I] := @Func68;
69: fIdentFuncTable[I] := @Func69;
76: fIdentFuncTable[I] := @Func76;
78: fIdentFuncTable[I] := @Func78;
79: fIdentFuncTable[I] := @Func79;
83: fIdentFuncTable[I] := @Func83;
86: fIdentFuncTable[I] := @Func86;
88: fIdentFuncTable[I] := @Func88;
89: fIdentFuncTable[I] := @Func89;
90: fIdentFuncTable[I] := @Func90;
92: fIdentFuncTable[I] := @Func92;
93: fIdentFuncTable[I] := @Func93;
95: fIdentFuncTable[I] := @Func95;
97: fIdentFuncTable[I] := @Func97;
98: fIdentFuncTable[I] := @Func98;
102: fIdentFuncTable[I] := @Func102;
109: fIdentFuncTable[I] := @Func109;
110: fIdentFuncTable[I] := @Func110;
114: fIdentFuncTable[I] := @Func114;
115: fIdentFuncTable[I] := @Func115;
119: fIdentFuncTable[I] := @Func119;
127: fIdentFuncTable[I] := @Func127;
136: fIdentFuncTable[I] := @Func136;
172: fIdentFuncTable[I] := @Func172;
else fIdentFuncTable[I] := @AltFunc;
end;
end;
function TSynPikeSyn.Func17: TtkTokenKind;
begin
if KeyComp('if') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func21: TtkTokenKind;
begin
if KeyComp('do') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func32: TtkTokenKind;
begin
if KeyComp('case') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func34: TtkTokenKind;
begin
if KeyComp('char') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func39: TtkTokenKind;
begin
if KeyComp('lambda') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func40: TtkTokenKind;
begin
if KeyComp('catch') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func42: TtkTokenKind;
begin
if KeyComp('for') then Result := tkKey else
if KeyComp('break') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func45: TtkTokenKind;
begin
if KeyComp('else') or KeyComp('new') then
Result := tkKey
else Result := tkIdentifier;
end;
function TSynPikeSyn.Func46: TtkTokenKind;
begin
if KeyComp('int') or KeyComp('gauge') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func47: TtkTokenKind;
begin
if KeyComp('final') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func48: TtkTokenKind;
begin
if KeyComp('false') or KeyComp('local') or KeyComp('bool') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func54: TtkTokenKind;
begin
if KeyComp('void') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func55: TtkTokenKind;
begin
if KeyComp('global') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func57: TtkTokenKind;
begin
if KeyComp('enum') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func59: TtkTokenKind;
begin
if KeyComp('class') or KeyComp('float') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func60: TtkTokenKind;
begin
if KeyComp('this') or KeyComp('mixed') or KeyComp('prefed') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func61: TtkTokenKind;
begin
if KeyComp('goto') or KeyComp('object') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func62: TtkTokenKind;
begin
if KeyComp('while') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func63: TtkTokenKind;
begin
if KeyComp('null') or KeyComp('foreach') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func66: TtkTokenKind;
begin
if KeyComp('try') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func68: TtkTokenKind;
begin
if KeyComp('true') or KeyComp('array') or KeyComp('sscanf') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func69: TtkTokenKind;
begin
if KeyComp('public') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func76: TtkTokenKind;
begin
if KeyComp('default') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func78: TtkTokenKind;
begin
if KeyComp('static') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func79: TtkTokenKind;
begin
if KeyComp('nomask') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func83: TtkTokenKind;
begin
if KeyComp('mapping') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func86: TtkTokenKind;
begin
if KeyComp('finally') or KeyComp('sizeof') or KeyComp('inline') then
Result := tkKey
else Result := tkIdentifier;
end;
function TSynPikeSyn.Func88: TtkTokenKind;
begin
if KeyComp('switch') or KeyComp('typedef') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func89: TtkTokenKind;
begin
if KeyComp('throw') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func90: TtkTokenKind;
begin
if KeyComp('inherit') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func92: TtkTokenKind;
begin
if KeyComp('variant') or KeyComp('extern') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func93: TtkTokenKind;
begin
if KeyComp('string') or KeyComp('typeof') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func95: TtkTokenKind;
begin
if KeyComp('program') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func97: TtkTokenKind;
begin
if KeyComp('import') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func98: TtkTokenKind;
begin
if KeyComp('private') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func102: TtkTokenKind;
begin
if KeyComp('return') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func109: TtkTokenKind;
begin
if KeyComp('continue') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func110: TtkTokenKind;
begin
if KeyComp('function') or KeyComp('optional') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func114: TtkTokenKind;
begin
if KeyComp('constant') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func115: TtkTokenKind;
begin
if KeyComp('protected') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func119: TtkTokenKind;
begin
if KeyComp('strictfp') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func127: TtkTokenKind;
begin
if KeyComp('multiset') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func136: TtkTokenKind;
begin
if KeyComp('implements') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.Func172: TtkTokenKind;
begin
if KeyComp('synchronized') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPikeSyn.GetSampleSource: string;
begin
Result := Pike_GetSampleSource();
end;
class function TSynPikeSyn.Pike_GetSampleSource: string;
begin
Result := '/* Pike syntax highlighting */'#13#10 +
'int main()'#13#10 +
'{'#13#10 +
' array(string) words = ({ "first", "second" });'#13#10 +
' foreach(words, string cur_word)'#13#10 +
' write("%O\n", cur_word);'#13#10 +
' return 0;'#13#10 +
'}'#13#10 +
'/* Text Block */'#13#10 + #13#10;
end;
class function TSynPikeSyn.GetLanguageName: string;
begin
Result := SYNS_LangPike;
end;
initialization
RegisterPlaceableHighlighter(TSynPikeSyn);
end.
|