PageRenderTime 60ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/components/synedit/synhighlightercss.pas

http://github.com/graemeg/lazarus
Pascal | 2161 lines | 1899 code | 214 blank | 48 comment | 191 complexity | 1495752305ee9075843862d627b04367 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception
  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. Software distributed under the License is distributed on an "AS IS" basis,
  7. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  8. the specific language governing rights and limitations under the License.
  9. The Original Code is: SynHighlighterCSS.pas, released 2000-04-14.
  10. The Original Code is based on the mwCSSSyn.pas file from the
  11. mwEdit component suite by Martin Waldenburg and other developers, the Initial
  12. Author of this file is Tony De Buys.
  13. All Rights Reserved.
  14. Contributors to the SynEdit and mwEdit projects are listed in the
  15. Contributors.txt file.
  16. Alternatively, the contents of this file may be used under the terms of the
  17. GNU General Public License Version 2 or later (the "GPL"), in which case
  18. the provisions of the GPL are applicable instead of those above.
  19. If you wish to allow use of your version of this file only under the terms
  20. of the GPL and not to allow others to use your version of this file
  21. under the MPL, indicate your decision by deleting the provisions above and
  22. replace them with the notice and other provisions required by the GPL.
  23. If you do not delete the provisions above, a recipient may use your version
  24. of this file under either the MPL or the GPL.
  25. $Id$
  26. You may retrieve the latest version of this file at the SynEdit home page,
  27. located at http://SynEdit.SourceForge.net
  28. Known Issues:
  29. -------------------------------------------------------------------------------}
  30. {
  31. @abstract(Provides a CSS syntax highlighter for SynEdit)
  32. @author(Tony de Buys)
  33. @created(1999)
  34. @lastmod(2000-06-23)
  35. The SynHighlighterCss unit provides SynEdit with a Cascading Style Sheets syntax highlighter.
  36. Thanks to Martin Waldenburg.
  37. }
  38. unit SynHighlighterCss;
  39. {$I SynEdit.inc}
  40. interface
  41. uses
  42. SysUtils, Classes,
  43. LCLIntf, LCLType,
  44. Controls, Graphics,
  45. SynEditTypes, SynEditHighlighter;
  46. type
  47. TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace,
  48. tkString, tkSymbol, tkMeasurementUnit, tkSelector, tkUnknown);
  49. TRangeState = (rsCStyle, rsInDeclarationBlock);
  50. TRangeStates = set of TRangeState;
  51. TProcTableProc = procedure of object;
  52. PIdentFuncTableFunc = ^TIdentFuncTableFunc;
  53. TIdentFuncTableFunc = function: TtkTokenKind of object;
  54. type
  55. { TSynCssSyn }
  56. TSynCssSyn = class(TSynCustomHighlighter)
  57. private
  58. fRange: TRangeStates;
  59. fLine: PChar;
  60. fLineNumber: Integer;
  61. fProcTable: array[#0..#255] of TProcTableProc;
  62. Run: LongInt;
  63. fStringLen: Integer;
  64. fToIdent: PChar;
  65. fTokenPos: Integer;
  66. FTokenID: TtkTokenKind;
  67. fIdentFuncTable: array[0..275] of TIdentFuncTableFunc;
  68. fCommentAttri: TSynHighlighterAttributes;
  69. fIdentifierAttri: TSynHighlighterAttributes;
  70. fKeyAttri: TSynHighlighterAttributes;
  71. fNumberAttri: TSynHighlighterAttributes;
  72. fSpaceAttri: TSynHighlighterAttributes;
  73. fStringAttri: TSynHighlighterAttributes;
  74. fSymbolAttri: TSynHighlighterAttributes;
  75. fMeasurementUnitAttri: TSynHighlighterAttributes;
  76. fSelectorAttri: TSynHighlighterAttributes;
  77. function KeyHash(ToHash: PChar): Integer;
  78. function KeyComp(const aKey: String): Boolean;
  79. function Func16: TtkTokenKind;
  80. function Func18: TtkTokenKind;
  81. function Func19: TtkTokenKind;
  82. function Func23: TtkTokenKind;
  83. function Func24: TtkTokenKind;
  84. function Func26: TtkTokenKind;
  85. function Func29: TtkTokenKind;
  86. function Func30: TtkTokenKind;
  87. function Func32: TtkTokenKind;
  88. function Func34: TtkTokenKind;
  89. function Func36: TtkTokenKind;
  90. function Func39: TtkTokenKind;
  91. function Func40: TtkTokenKind;
  92. function Func41: TtkTokenKind;
  93. function Func43: TtkTokenKind;
  94. function Func45: TtkTokenKind;
  95. function Func47: TtkTokenKind;
  96. function Func51: TtkTokenKind;
  97. function Func52: TtkTokenKind;
  98. function Func53: TtkTokenKind;
  99. function Func54: TtkTokenKind;
  100. function Func55: TtkTokenKind;
  101. function Func56: TtkTokenKind;
  102. function Func57: TtkTokenKind;
  103. function Func58: TtkTokenKind;
  104. function Func59: TtkTokenKind;
  105. function Func60: TtkTokenKind;
  106. function Func61: TtkTokenKind;
  107. function Func62: TtkTokenKind;
  108. function Func63: TtkTokenKind;
  109. function Func64: TtkTokenKind;
  110. function Func65: TtkTokenKind;
  111. function Func66: TtkTokenKind;
  112. function Func67: TtkTokenKind;
  113. function Func69: TtkTokenKind;
  114. function Func70: TtkTokenKind;
  115. function Func71: TtkTokenKind;
  116. function Func72: TtkTokenKind;
  117. function Func74: TtkTokenKind;
  118. function Func76: TtkTokenKind;
  119. function Func78: TtkTokenKind;
  120. function Func79: TtkTokenKind;
  121. function Func80: TtkTokenKind;
  122. function Func81: TtkTokenKind;
  123. function Func82: TtkTokenKind;
  124. function Func83: TtkTokenKind;
  125. function Func84: TtkTokenKind;
  126. function Func85: TtkTokenKind;
  127. function Func86: TtkTokenKind;
  128. function Func87: TtkTokenKind;
  129. function Func88: TtkTokenKind;
  130. function Func89: TtkTokenKind;
  131. function Func90: TtkTokenKind;
  132. function Func91: TtkTokenKind;
  133. function Func92: TtkTokenKind;
  134. function Func93: TtkTokenKind;
  135. function Func94: TtkTokenKind;
  136. function Func95: TtkTokenKind;
  137. function Func96: TtkTokenKind;
  138. function Func97: TtkTokenKind;
  139. function Func98: TtkTokenKind;
  140. function Func99: TtkTokenKind;
  141. function Func100: TtkTokenKind;
  142. function Func101: TtkTokenKind;
  143. function Func102: TtkTokenKind;
  144. function Func103: TtkTokenKind;
  145. function Func105: TtkTokenKind;
  146. function Func106: TtkTokenKind;
  147. function Func107: TtkTokenKind;
  148. function Func108: TtkTokenKind;
  149. function Func109: TtkTokenKind;
  150. function Func110: TtkTokenKind;
  151. function Func111: TtkTokenKind;
  152. function Func112: TtkTokenKind;
  153. function Func113: TtkTokenKind;
  154. function Func114: TtkTokenKind;
  155. function Func115: TtkTokenKind;
  156. function Func116: TtkTokenKind;
  157. function Func117: TtkTokenKind;
  158. function Func118: TtkTokenKind;
  159. function Func119: TtkTokenKind;
  160. function Func120: TtkTokenKind;
  161. function Func121: TtkTokenKind;
  162. function Func122: TtkTokenKind;
  163. function Func123: TtkTokenKind;
  164. function Func124: TtkTokenKind;
  165. function Func125: TtkTokenKind;
  166. function Func126: TtkTokenKind;
  167. function Func127: TtkTokenKind;
  168. function Func128: TtkTokenKind;
  169. function Func129: TtkTokenKind;
  170. function Func130: TtkTokenKind;
  171. function Func131: TtkTokenKind;
  172. function Func132: TtkTokenKind;
  173. function Func134: TtkTokenKind;
  174. function Func136: TtkTokenKind;
  175. function Func137: TtkTokenKind;
  176. function Func138: TtkTokenKind;
  177. function Func139: TtkTokenKind;
  178. function Func140: TtkTokenKind;
  179. function Func141: TtkTokenKind;
  180. function Func142: TtkTokenKind;
  181. function Func144: TtkTokenKind;
  182. function Func146: TtkTokenKind;
  183. function Func148: TtkTokenKind;
  184. function Func149: TtkTokenKind;
  185. function Func150: TtkTokenKind;
  186. function Func151: TtkTokenKind;
  187. function Func152: TtkTokenKind;
  188. function Func153: TtkTokenKind;
  189. function Func154: TtkTokenKind;
  190. function Func156: TtkTokenKind;
  191. function Func158: TtkTokenKind;
  192. function Func159: TtkTokenKind;
  193. function Func160: TtkTokenKind;
  194. function Func164: TtkTokenKind;
  195. function Func166: TtkTokenKind;
  196. function Func167: TtkTokenKind;
  197. function Func169: TtkTokenKind;
  198. function Func171: TtkTokenKind;
  199. function Func172: TtkTokenKind;
  200. function Func173: TtkTokenKind;
  201. function Func174: TtkTokenKind;
  202. function Func175: TtkTokenKind;
  203. function Func177: TtkTokenKind;
  204. function Func178: TtkTokenKind;
  205. function Func179: TtkTokenKind;
  206. function Func182: TtkTokenKind;
  207. function Func186: TtkTokenKind;
  208. function Func187: TtkTokenKind;
  209. function Func190: TtkTokenKind;
  210. function Func191: TtkTokenKind;
  211. function Func194: TtkTokenKind;
  212. function Func195: TtkTokenKind;
  213. function Func198: TtkTokenKind;
  214. function Func199: TtkTokenKind;
  215. function Func200: TtkTokenKind;
  216. function Func205: TtkTokenKind;
  217. function Func210: TtkTokenKind;
  218. function Func213: TtkTokenKind;
  219. function Func216: TtkTokenKind;
  220. function Func220: TtkTokenKind;
  221. function Func222: TtkTokenKind;
  222. function Func224: TtkTokenKind;
  223. function Func232: TtkTokenKind;
  224. function Func242: TtkTokenKind;
  225. function Func250: TtkTokenKind;
  226. function Func253: TtkTokenKind;
  227. function Func275: TtkTokenKind;
  228. procedure SymbolProc;
  229. procedure ColonProc;
  230. procedure SelectorProc;
  231. procedure PercentProc;
  232. procedure CurlyOpenProc;
  233. procedure CurlyCloseProc;
  234. procedure CRProc;
  235. procedure CStyleCommentProc;
  236. procedure DashProc;
  237. procedure IdentProc;
  238. procedure HashProc;
  239. procedure IntegerProc;
  240. procedure LFProc;
  241. procedure NullProc;
  242. procedure NumberProc;
  243. procedure RoundOpenProc;
  244. procedure SlashProc;
  245. procedure SpaceProc;
  246. procedure StringProc;
  247. procedure UnknownProc;
  248. function AltFunc: TtkTokenKind;
  249. procedure InitIdent;
  250. function IdentKind(MayBe: PChar): TtkTokenKind;
  251. procedure MakeMethodTables;
  252. protected
  253. function GetIdentChars: TSynIdentChars; override;
  254. function GetSampleSource: String; override;
  255. public
  256. class function GetLanguageName: string; override;
  257. public
  258. constructor Create(AOwner: TComponent); override;
  259. function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
  260. override;
  261. function GetEol: Boolean; override;
  262. function GetRange: Pointer; override;
  263. function GetTokenID: TtkTokenKind;
  264. procedure SetLine(const NewValue: String; LineNumber: Integer); override;
  265. function GetToken: string; override;
  266. procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override;
  267. function GetTokenAttribute: TSynHighlighterAttributes; override;
  268. function GetTokenKind: integer; override;
  269. function GetTokenPos: Integer; override;
  270. procedure Next; override;
  271. procedure SetRange(Value: Pointer); override;
  272. procedure ReSetRange; override;
  273. property IdentChars;
  274. function KeyHash2(ToHash: PChar): Integer;
  275. published
  276. property CommentAttri: TSynHighlighterAttributes read fCommentAttri
  277. write fCommentAttri;
  278. property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri
  279. write fIdentifierAttri;
  280. property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri;
  281. property NumberAttri: TSynHighlighterAttributes read fNumberAttri
  282. write fNumberAttri;
  283. property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri
  284. write fSpaceAttri;
  285. property StringAttri: TSynHighlighterAttributes read fStringAttri
  286. write fStringAttri;
  287. property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri
  288. write fSymbolAttri;
  289. property MeasurementUnitAttri: TSynHighlighterAttributes read fMeasurementUnitAttri
  290. write fMeasurementUnitAttri;
  291. property SelectorAttri: TSynHighlighterAttributes read fSelectorAttri
  292. write fSelectorAttri;
  293. end;
  294. implementation
  295. uses
  296. SynEditStrConst;
  297. var
  298. Identifiers: array[#0..#255] of ByteBool;
  299. mHashTable : array[#0..#255] of Integer;
  300. procedure MakeIdentTable;
  301. var
  302. I, J: Char;
  303. begin
  304. for I := #0 to #255 do begin
  305. case I of
  306. 'a'..'z', 'A'..'Z', '-', '_', '0'..'9','@': Identifiers[I] := True;
  307. else
  308. Identifiers[I] := False;
  309. end;
  310. J := UpCase(I);
  311. if I in ['a'..'z', 'A'..'Z', '-', '_','@'] then
  312. mHashTable[I] := Ord(J) - 64
  313. else
  314. mHashTable[I] := 0;
  315. end;
  316. end;
  317. procedure TSynCssSyn.InitIdent;
  318. var
  319. I: Integer;
  320. pF: PIdentFuncTableFunc;
  321. begin
  322. pF := PIdentFuncTableFunc(@FIdentFuncTable);
  323. for I := Low(FIdentFuncTable) to High(FIdentFuncTable) do begin
  324. pF^ := @AltFunc;
  325. Inc(pF);
  326. end;
  327. FIdentFuncTable[16] := @Func16;
  328. FIdentFuncTable[18] := @Func18;
  329. FIdentFuncTable[19] := @Func19;
  330. FIdentFuncTable[23] := @Func23;
  331. FIdentFuncTable[24] := @Func24;
  332. FIdentFuncTable[26] := @Func26;
  333. FIdentFuncTable[29] := @Func29;
  334. FIdentFuncTable[30] := @Func30;
  335. FIdentFuncTable[32] := @Func32;
  336. FIdentFuncTable[34] := @Func34;
  337. FIdentFuncTable[36] := @Func36;
  338. FIdentFuncTable[39] := @Func39;
  339. FIdentFuncTable[40] := @Func40;
  340. FIdentFuncTable[41] := @Func41;
  341. FIdentFuncTable[43] := @Func43;
  342. FIdentFuncTable[45] := @Func45;
  343. FIdentFuncTable[47] := @Func47;
  344. FIdentFuncTable[51] := @Func51;
  345. FIdentFuncTable[52] := @Func52;
  346. FIdentFuncTable[53] := @Func53;
  347. FIdentFuncTable[54] := @Func54;
  348. FIdentFuncTable[55] := @Func55;
  349. FIdentFuncTable[56] := @Func56;
  350. FIdentFuncTable[57] := @Func57;
  351. FIdentFuncTable[58] := @Func58;
  352. FIdentFuncTable[59] := @Func59;
  353. FIdentFuncTable[60] := @Func60;
  354. FIdentFuncTable[61] := @Func61;
  355. FIdentFuncTable[62] := @Func62;
  356. FIdentFuncTable[63] := @Func63;
  357. FIdentFuncTable[64] := @Func64;
  358. FIdentFuncTable[65] := @Func65;
  359. FIdentFuncTable[66] := @Func66;
  360. FIdentFuncTable[67] := @Func67;
  361. FIdentFuncTable[69] := @Func69;
  362. FIdentFuncTable[70] := @Func70;
  363. FIdentFuncTable[71] := @Func71;
  364. FIdentFuncTable[72] := @Func72;
  365. FIdentFuncTable[74] := @Func74;
  366. FIdentFuncTable[76] := @Func76;
  367. FIdentFuncTable[78] := @Func78;
  368. FIdentFuncTable[79] := @Func79;
  369. FIdentFuncTable[80] := @Func80;
  370. FIdentFuncTable[81] := @Func81;
  371. FIdentFuncTable[82] := @Func82;
  372. FIdentFuncTable[83] := @Func83;
  373. FIdentFuncTable[84] := @Func84;
  374. FIdentFuncTable[85] := @Func85;
  375. FIdentFuncTable[86] := @Func86;
  376. FIdentFuncTable[87] := @Func87;
  377. FIdentFuncTable[88] := @Func88;
  378. FIdentFuncTable[89] := @Func89;
  379. FIdentFuncTable[90] := @Func90;
  380. FIdentFuncTable[91] := @Func91;
  381. FIdentFuncTable[92] := @Func92;
  382. FIdentFuncTable[93] := @Func93;
  383. FIdentFuncTable[94] := @Func94;
  384. FIdentFuncTable[95] := @Func95;
  385. FIdentFuncTable[96] := @Func96;
  386. FIdentFuncTable[97] := @Func97;
  387. FIdentFuncTable[98] := @Func98;
  388. FIdentFuncTable[99] := @Func99;
  389. FIdentFuncTable[100] := @Func100;
  390. FIdentFuncTable[101] := @Func101;
  391. FIdentFuncTable[102] := @Func102;
  392. FIdentFuncTable[103] := @Func103;
  393. FIdentFuncTable[105] := @Func105;
  394. FIdentFuncTable[106] := @Func106;
  395. FIdentFuncTable[107] := @Func107;
  396. FIdentFuncTable[108] := @Func108;
  397. FIdentFuncTable[109] := @Func109;
  398. FIdentFuncTable[110] := @Func110;
  399. FIdentFuncTable[111] := @Func111;
  400. FIdentFuncTable[112] := @Func112;
  401. FIdentFuncTable[113] := @Func113;
  402. FIdentFuncTable[114] := @Func114;
  403. FIdentFuncTable[115] := @Func115;
  404. FIdentFuncTable[116] := @Func116;
  405. FIdentFuncTable[117] := @Func117;
  406. FIdentFuncTable[118] := @Func118;
  407. FIdentFuncTable[119] := @Func119;
  408. FIdentFuncTable[120] := @Func120;
  409. FIdentFuncTable[121] := @Func121;
  410. FIdentFuncTable[122] := @Func122;
  411. FIdentFuncTable[123] := @Func123;
  412. FIdentFuncTable[124] := @Func124;
  413. FIdentFuncTable[125] := @Func125;
  414. FIdentFuncTable[126] := @Func126;
  415. FIdentFuncTable[127] := @Func127;
  416. FIdentFuncTable[128] := @Func128;
  417. FIdentFuncTable[129] := @Func129;
  418. FIdentFuncTable[130] := @Func130;
  419. FIdentFuncTable[131] := @Func131;
  420. FIdentFuncTable[132] := @Func132;
  421. FIdentFuncTable[134] := @Func134;
  422. FIdentFuncTable[136] := @Func136;
  423. FIdentFuncTable[137] := @Func137;
  424. FIdentFuncTable[138] := @Func138;
  425. FIdentFuncTable[139] := @Func139;
  426. FIdentFuncTable[140] := @Func140;
  427. FIdentFuncTable[141] := @Func141;
  428. FIdentFuncTable[142] := @Func142;
  429. FIdentFuncTable[144] := @Func144;
  430. FIdentFuncTable[146] := @Func146;
  431. FIdentFuncTable[148] := @Func148;
  432. FIdentFuncTable[149] := @Func149;
  433. FIdentFuncTable[150] := @Func150;
  434. FIdentFuncTable[151] := @Func151;
  435. FIdentFuncTable[152] := @Func152;
  436. FIdentFuncTable[153] := @Func153;
  437. FIdentFuncTable[154] := @Func154;
  438. FIdentFuncTable[156] := @Func156;
  439. FIdentFuncTable[158] := @Func158;
  440. FIdentFuncTable[159] := @Func159;
  441. FIdentFuncTable[160] := @Func160;
  442. FIdentFuncTable[164] := @Func164;
  443. FIdentFuncTable[166] := @Func166;
  444. FIdentFuncTable[167] := @Func167;
  445. FIdentFuncTable[169] := @Func169;
  446. FIdentFuncTable[171] := @Func171;
  447. FIdentFuncTable[172] := @Func172;
  448. FIdentFuncTable[173] := @Func173;
  449. FIdentFuncTable[174] := @Func174;
  450. FIdentFuncTable[175] := @Func175;
  451. FIdentFuncTable[177] := @Func177;
  452. FIdentFuncTable[178] := @Func178;
  453. FIdentFuncTable[179] := @Func179;
  454. FIdentFuncTable[182] := @Func182;
  455. FIdentFuncTable[186] := @Func186;
  456. FIdentFuncTable[187] := @Func187;
  457. FIdentFuncTable[190] := @Func190;
  458. FIdentFuncTable[191] := @Func191;
  459. FIdentFuncTable[194] := @Func194;
  460. FIdentFuncTable[195] := @Func195;
  461. FIdentFuncTable[198] := @Func198;
  462. FIdentFuncTable[199] := @Func199;
  463. FIdentFuncTable[200] := @Func200;
  464. FIdentFuncTable[205] := @Func205;
  465. FIdentFuncTable[210] := @Func210;
  466. FIdentFuncTable[213] := @Func213;
  467. FIdentFuncTable[216] := @Func216;
  468. FIdentFuncTable[220] := @Func220;
  469. FIdentFuncTable[222] := @Func222;
  470. FIdentFuncTable[224] := @Func224;
  471. FIdentFuncTable[232] := @Func232;
  472. FIdentFuncTable[242] := @Func242;
  473. FIdentFuncTable[250] := @Func250;
  474. FIdentFuncTable[253] := @Func253;
  475. FIdentFuncTable[275] := @Func275;
  476. end;
  477. function TSynCssSyn.KeyHash(ToHash: PChar): Integer;
  478. begin
  479. Result := 0;
  480. while ToHash^ in ['a'..'z', 'A'..'Z', '0'..'9', '-', '_','@'] do begin
  481. Inc(Result, mHashTable[ToHash^]);
  482. Inc(ToHash);
  483. end;
  484. FStringLen := ToHash - FToIdent;
  485. end;
  486. function TSynCssSyn.KeyComp(const aKey: String): Boolean;
  487. var
  488. iI : Integer;
  489. Temp: PChar;
  490. begin
  491. Temp := FToIdent;
  492. if Length(aKey) = FStringLen then begin
  493. Result := True;
  494. for iI := 1 to fStringLen do begin
  495. if mHashTable[Temp^] <> mHashTable[aKey[iI]] then begin
  496. Result := False;
  497. Break;
  498. end;
  499. Inc(Temp);
  500. end;
  501. end else
  502. Result := False;
  503. end;
  504. function TSynCssSyn.Func16: TtkTokenKind;
  505. begin
  506. if KeyComp('cm') then
  507. Result := tkMeasurementUnit
  508. else
  509. if KeyComp('deg') then
  510. Result := tkKey
  511. else
  512. Result := tkIdentifier;
  513. end;
  514. function TSynCssSyn.Func18: TtkTokenKind;
  515. begin
  516. if KeyComp('em') then
  517. Result := tkMeasurementUnit
  518. else
  519. Result := tkIdentifier;
  520. end;
  521. function TSynCssSyn.Func19: TtkTokenKind;
  522. begin
  523. if KeyComp('pc') then
  524. Result := tkMeasurementUnit
  525. else if KeyComp('s') then
  526. Result := tkKey
  527. else
  528. Result := tkIdentifier;
  529. end;
  530. function TSynCssSyn.Func23: TtkTokenKind;
  531. begin
  532. if KeyComp('in') then
  533. Result := tkMeasurementUnit
  534. else
  535. if KeyComp('rad') then
  536. Result := tkKey
  537. else
  538. Result := tkIdentifier;
  539. end;
  540. function TSynCssSyn.Func24: TtkTokenKind;
  541. begin
  542. if KeyComp('b-box') then
  543. Result := tkKey
  544. else
  545. Result := tkIdentifier;
  546. end;
  547. function TSynCssSyn.Func26: TtkTokenKind;
  548. begin
  549. if KeyComp('mm') then
  550. Result := tkMeasurementUnit
  551. else
  552. Result := tkIdentifier;
  553. end;
  554. function TSynCssSyn.Func29: TtkTokenKind;
  555. begin
  556. if KeyComp('page') or KeyComp('cue') then
  557. Result := tkKey
  558. else if KeyComp('ex') then
  559. Result := tkMeasurementUnit
  560. else
  561. Result := tkIdentifier;
  562. end;
  563. function TSynCssSyn.Func30: TtkTokenKind;
  564. begin
  565. if KeyComp('grad') then
  566. Result := tkKey
  567. else
  568. Result := tkIdentifier;
  569. end;
  570. function TSynCssSyn.Func32: TtkTokenKind;
  571. begin
  572. if KeyComp('ms') or KeyComp('@media') then
  573. Result := tkKey
  574. else
  575. Result := tkIdentifier;
  576. end;
  577. function TSynCssSyn.Func34: TtkTokenKind;
  578. begin
  579. if KeyComp('Hz') then
  580. Result := tkKey
  581. else
  582. Result := tkIdentifier;
  583. end;
  584. function TSynCssSyn.Func36: TtkTokenKind;
  585. begin
  586. if KeyComp('pt') then
  587. Result := tkMeasurementUnit
  588. else
  589. Result := tkIdentifier;
  590. end;
  591. function TSynCssSyn.Func39: TtkTokenKind;
  592. begin
  593. if KeyComp('clear') then
  594. Result := tkKey
  595. else
  596. Result := tkIdentifier;
  597. end;
  598. function TSynCssSyn.Func40: TtkTokenKind;
  599. begin
  600. if KeyComp('px') then
  601. Result := tkMeasurementUnit
  602. else
  603. if KeyComp('clip') or KeyComp('src') then
  604. Result := tkKey
  605. else
  606. Result := tkIdentifier;
  607. end;
  608. function TSynCssSyn.Func41: TtkTokenKind;
  609. begin
  610. if KeyComp('icon') then
  611. Result := tkKey
  612. else
  613. Result := tkIdentifier;
  614. end;
  615. function TSynCssSyn.Func43: TtkTokenKind;
  616. begin
  617. if KeyComp('left') then
  618. Result := tkKey
  619. else
  620. Result := tkIdentifier;
  621. end;
  622. function TSynCssSyn.Func45: TtkTokenKind;
  623. begin
  624. if KeyComp('ime-mode') or KeyComp('kHz') then
  625. Result := tkKey
  626. else
  627. Result := tkIdentifier;
  628. end;
  629. function TSynCssSyn.Func47: TtkTokenKind;
  630. begin
  631. if KeyComp('flex') then
  632. Result := tkKey
  633. else
  634. Result := tkIdentifier;
  635. end;
  636. function TSynCssSyn.Func51: TtkTokenKind;
  637. begin
  638. if KeyComp('top') or KeyComp('panose-1') or KeyComp('@font-face') then
  639. Result := tkKey
  640. else
  641. Result := tkIdentifier;
  642. end;
  643. function TSynCssSyn.Func52: TtkTokenKind;
  644. begin
  645. if KeyComp('speak') then
  646. Result := tkKey
  647. else
  648. Result := tkIdentifier;
  649. end;
  650. function TSynCssSyn.Func53: TtkTokenKind;
  651. begin
  652. if KeyComp('box-pack') then
  653. Result := tkKey
  654. else
  655. Result := tkIdentifier;
  656. end;
  657. function TSynCssSyn.Func54: TtkTokenKind;
  658. begin
  659. if KeyComp('float') then
  660. Result := tkKey
  661. else
  662. Result := tkIdentifier;
  663. end;
  664. function TSynCssSyn.Func55: TtkTokenKind;
  665. begin
  666. if KeyComp('font') or KeyComp('padding') or KeyComp('nav-up') then
  667. Result := tkKey
  668. else
  669. Result := tkIdentifier;
  670. end;
  671. function TSynCssSyn.Func56: TtkTokenKind;
  672. begin
  673. if KeyComp('pitch') then
  674. Result := tkKey
  675. else
  676. Result := tkIdentifier;
  677. end;
  678. function TSynCssSyn.Func57: TtkTokenKind;
  679. begin
  680. if KeyComp('height') or KeyComp('run-in') then
  681. Result := tkKey
  682. else
  683. Result := tkIdentifier;
  684. end;
  685. function TSynCssSyn.Func58: TtkTokenKind;
  686. begin
  687. if KeyComp('line-break') or KeyComp('cap-height') then
  688. Result := tkKey
  689. else
  690. Result := tkIdentifier;
  691. end;
  692. function TSynCssSyn.Func59: TtkTokenKind;
  693. begin
  694. if KeyComp('size') then
  695. Result := tkKey
  696. else
  697. Result := tkIdentifier;
  698. end;
  699. function TSynCssSyn.Func60: TtkTokenKind;
  700. begin
  701. if KeyComp('cue-after') or KeyComp('order') then
  702. Result := tkKey
  703. else
  704. Result := tkIdentifier;
  705. end;
  706. function TSynCssSyn.Func61: TtkTokenKind;
  707. begin
  708. if KeyComp('cue-before') or KeyComp('nav-left') then
  709. Result := tkKey
  710. else
  711. Result := tkIdentifier;
  712. end;
  713. function TSynCssSyn.Func62: TtkTokenKind;
  714. begin
  715. if KeyComp('margin') or KeyComp('pause') or KeyComp('right') or
  716. KeyComp('marks') or KeyComp('border') or KeyComp('x-height') or
  717. KeyComp('ascent') then
  718. Result := tkKey
  719. else
  720. Result := tkIdentifier;
  721. end;
  722. function TSynCssSyn.Func63: TtkTokenKind;
  723. begin
  724. if KeyComp('color') or KeyComp('z-index') or KeyComp('tab-size') then
  725. Result := tkKey
  726. else
  727. Result := tkIdentifier;
  728. end;
  729. function TSynCssSyn.Func64: TtkTokenKind;
  730. begin
  731. if KeyComp('width') then
  732. Result := tkKey
  733. else
  734. Result := tkIdentifier;
  735. end;
  736. function TSynCssSyn.Func65: TtkTokenKind;
  737. begin
  738. if KeyComp('stemh') or KeyComp('box-align') then
  739. Result := tkKey
  740. else
  741. Result := tkIdentifier;
  742. end;
  743. function TSynCssSyn.Func66: TtkTokenKind;
  744. begin
  745. if KeyComp('align-self') then
  746. Result := tkKey
  747. else
  748. Result := tkIdentifier;
  749. end;
  750. function TSynCssSyn.Func67: TtkTokenKind;
  751. begin
  752. if KeyComp('slope') or KeyComp('baseline') then
  753. Result := tkKey
  754. else
  755. Result := tkIdentifier;
  756. end;
  757. function TSynCssSyn.Func69: TtkTokenKind;
  758. begin
  759. if KeyComp('zoom') or KeyComp('box-flex') then
  760. Result := tkKey
  761. else
  762. Result := tkIdentifier;
  763. end;
  764. function TSynCssSyn.Func70: TtkTokenKind;
  765. begin
  766. if KeyComp('filter') or KeyComp('descent') then
  767. Result := tkKey
  768. else
  769. Result := tkIdentifier;
  770. end;
  771. function TSynCssSyn.Func71: TtkTokenKind;
  772. begin
  773. if KeyComp('target') or KeyComp('object-fit') then
  774. Result := tkKey
  775. else
  776. Result := tkIdentifier;
  777. end;
  778. function TSynCssSyn.Func72: TtkTokenKind;
  779. begin
  780. if KeyComp('top-line') then
  781. Result := tkKey
  782. else
  783. Result := tkIdentifier;
  784. end;
  785. function TSynCssSyn.Func74: TtkTokenKind;
  786. begin
  787. if KeyComp('speak-header') or KeyComp('min-height') or KeyComp('nav-down')
  788. or KeyComp('nav-index') or KeyComp('@charset') then
  789. Result := tkKey
  790. else
  791. Result := tkIdentifier;
  792. end;
  793. function TSynCssSyn.Func76: TtkTokenKind;
  794. begin
  795. if KeyComp('max-height') or KeyComp('unicode-bidi') then
  796. Result := tkKey
  797. else
  798. Result := tkIdentifier;
  799. end;
  800. function TSynCssSyn.Func78: TtkTokenKind;
  801. begin
  802. if KeyComp('page-break-after') or KeyComp('word-break') or KeyComp('border-image')
  803. or KeyComp('line-height') or KeyComp('flex-basis') then
  804. Result := tkKey
  805. else
  806. Result := tkIdentifier;
  807. end;
  808. function TSynCssSyn.Func79: TtkTokenKind;
  809. begin
  810. if KeyComp('padding-left') or KeyComp('page-break-before') or
  811. KeyComp('stemv') then
  812. Result := tkKey
  813. else
  814. Result := tkIdentifier;
  815. end;
  816. function TSynCssSyn.Func80: TtkTokenKind;
  817. begin
  818. if KeyComp('behavior') or KeyComp('appearance') or KeyComp('nav-right') then
  819. Result := tkKey
  820. else
  821. Result := tkIdentifier;
  822. end;
  823. function TSynCssSyn.Func81: TtkTokenKind;
  824. begin
  825. if KeyComp('speech-rate') or KeyComp('min-width') or KeyComp('box-lines') then
  826. Result := tkKey
  827. else
  828. Result := tkIdentifier;
  829. end;
  830. function TSynCssSyn.Func82: TtkTokenKind;
  831. begin
  832. if KeyComp('pitch-range') or KeyComp('mathline') or KeyComp('resize') then
  833. Result := tkKey
  834. else
  835. Result := tkIdentifier;
  836. end;
  837. function TSynCssSyn.Func83: TtkTokenKind;
  838. begin
  839. if KeyComp('max-width') or KeyComp('widths') or KeyComp('column-gap') then
  840. Result := tkKey
  841. else
  842. Result := tkIdentifier;
  843. end;
  844. function TSynCssSyn.Func84: TtkTokenKind;
  845. begin
  846. if KeyComp('flex-flow') then
  847. Result := tkKey
  848. else
  849. Result := tkIdentifier;
  850. end;
  851. function TSynCssSyn.Func85: TtkTokenKind;
  852. begin
  853. if KeyComp('bottom') or KeyComp('target-name') then
  854. Result := tkKey
  855. else
  856. Result := tkIdentifier;
  857. end;
  858. function TSynCssSyn.Func86: TtkTokenKind;
  859. begin
  860. if KeyComp('margin-left') or KeyComp('border-left') or KeyComp('display') or KeyComp('flex-wrap') then
  861. Result := tkKey
  862. else
  863. Result := tkIdentifier;
  864. end;
  865. function TSynCssSyn.Func87: TtkTokenKind;
  866. begin
  867. if KeyComp('padding-top') then
  868. Result := tkKey
  869. else
  870. Result := tkIdentifier;
  871. end;
  872. function TSynCssSyn.Func88: TtkTokenKind;
  873. begin
  874. if KeyComp('page-break-inside') or KeyComp('volume') then
  875. Result := tkKey
  876. else
  877. Result := tkIdentifier;
  878. end;
  879. function TSynCssSyn.Func89: TtkTokenKind;
  880. begin
  881. if KeyComp('opacity') then
  882. Result := tkKey
  883. else
  884. Result := tkIdentifier;
  885. end;
  886. function TSynCssSyn.Func90: TtkTokenKind;
  887. begin
  888. if KeyComp('white-space') or KeyComp('ruby-align') or KeyComp('align-items') then
  889. Result := tkKey
  890. else
  891. Result := tkIdentifier;
  892. end;
  893. function TSynCssSyn.Func91: TtkTokenKind;
  894. begin
  895. if KeyComp('orphans') or KeyComp('content') or KeyComp('@import') or KeyComp('flex-grow') then
  896. Result := tkKey
  897. else
  898. Result := tkIdentifier;
  899. end;
  900. function TSynCssSyn.Func92: TtkTokenKind;
  901. begin
  902. if KeyComp('box-shadow') then
  903. Result := tkKey
  904. else
  905. Result := tkIdentifier;
  906. end;
  907. function TSynCssSyn.Func93: TtkTokenKind;
  908. begin
  909. if KeyComp('text-align') or KeyComp('pause-after') or KeyComp('widows') then
  910. Result := tkKey
  911. else
  912. Result := tkIdentifier;
  913. end;
  914. function TSynCssSyn.Func94: TtkTokenKind;
  915. begin
  916. if KeyComp('margin-top') or KeyComp('border-top') or KeyComp('pause-before') or
  917. KeyComp('cursor') or KeyComp('grid-rows') or KeyComp('target-new') then
  918. Result := tkKey
  919. else
  920. Result := tkIdentifier;
  921. end;
  922. function TSynCssSyn.Func95: TtkTokenKind;
  923. begin
  924. if KeyComp('font-size') or KeyComp('richness') then
  925. Result := tkKey
  926. else
  927. Result := tkIdentifier;
  928. end;
  929. function TSynCssSyn.Func96: TtkTokenKind;
  930. begin
  931. if KeyComp('background') or KeyComp('caption-side') or KeyComp('counter') or
  932. KeyComp('outline') or KeyComp('animation') then
  933. Result := tkKey
  934. else
  935. Result := tkIdentifier;
  936. end;
  937. function TSynCssSyn.Func97: TtkTokenKind;
  938. begin
  939. if KeyComp('quotes') or KeyComp('direction') or KeyComp('unicode-range')
  940. or KeyComp('columns') then
  941. Result := tkKey
  942. else
  943. Result := tkIdentifier;
  944. end;
  945. function TSynCssSyn.Func98: TtkTokenKind;
  946. begin
  947. if KeyComp('padding-right') or KeyComp('azimuth') or KeyComp('column-fill') then
  948. Result := tkKey
  949. else
  950. Result := tkIdentifier;
  951. end;
  952. function TSynCssSyn.Func99: TtkTokenKind;
  953. begin
  954. if KeyComp('word-wrap') then
  955. Result := tkKey
  956. else
  957. Result := tkIdentifier;
  958. end;
  959. function TSynCssSyn.Func100: TtkTokenKind;
  960. begin
  961. if KeyComp('stress') then
  962. Result := tkKey
  963. else
  964. Result := tkIdentifier;
  965. end;
  966. function TSynCssSyn.Func101: TtkTokenKind;
  967. begin
  968. if KeyComp('voice-family') then
  969. Result := tkKey
  970. else
  971. Result := tkIdentifier;
  972. end;
  973. function TSynCssSyn.Func102: TtkTokenKind;
  974. begin
  975. if KeyComp('font-family') or KeyComp('units-per-em') then
  976. Result := tkKey
  977. else
  978. Result := tkIdentifier;
  979. end;
  980. function TSynCssSyn.Func103: TtkTokenKind;
  981. begin
  982. if KeyComp('elevation') or KeyComp('@keyframes') or KeyComp('box-orient') then
  983. Result := tkKey
  984. else
  985. Result := tkIdentifier;
  986. end;
  987. function TSynCssSyn.Func105: TtkTokenKind;
  988. begin
  989. if KeyComp('margin-right') or KeyComp('border-right') or
  990. KeyComp('centerline') then
  991. Result := tkKey
  992. else
  993. Result := tkIdentifier;
  994. end;
  995. function TSynCssSyn.Func106: TtkTokenKind;
  996. begin
  997. if KeyComp('border-color') or KeyComp('box-sizing') then
  998. Result := tkKey
  999. else
  1000. Result := tkIdentifier;
  1001. end;
  1002. function TSynCssSyn.Func107: TtkTokenKind;
  1003. begin
  1004. if KeyComp('border-width') or KeyComp('border-image-slice') or KeyComp('flex-shrink') then
  1005. Result := tkKey
  1006. else
  1007. Result := tkIdentifier;
  1008. end;
  1009. function TSynCssSyn.Func108: TtkTokenKind;
  1010. begin
  1011. if KeyComp('font-weight') or KeyComp('play-during') or KeyComp('text-wrap')
  1012. or KeyComp('user-select') then
  1013. Result := tkKey
  1014. else
  1015. Result := tkIdentifier;
  1016. end;
  1017. function TSynCssSyn.Func109: TtkTokenKind;
  1018. begin
  1019. if KeyComp('column-span') then
  1020. Result := tkKey
  1021. else
  1022. Result := tkIdentifier;
  1023. end;
  1024. function TSynCssSyn.Func110: TtkTokenKind;
  1025. begin
  1026. if KeyComp('word-spacing') or KeyComp('animation-name') then
  1027. Result := tkKey
  1028. else
  1029. Result := tkIdentifier;
  1030. end;
  1031. function TSynCssSyn.Func111: TtkTokenKind;
  1032. begin
  1033. if KeyComp('empty-cells') then
  1034. Result := tkKey
  1035. else
  1036. Result := tkIdentifier;
  1037. end;
  1038. function TSynCssSyn.Func112: TtkTokenKind;
  1039. begin
  1040. if KeyComp('background-image') or KeyComp('border-spacing')
  1041. or KeyComp('rotation') then
  1042. Result := tkKey
  1043. else
  1044. Result := tkIdentifier;
  1045. end;
  1046. function TSynCssSyn.Func113: TtkTokenKind;
  1047. begin
  1048. if KeyComp('layout-grid') then
  1049. Result := tkKey
  1050. else
  1051. Result := tkIdentifier;
  1052. end;
  1053. function TSynCssSyn.Func114: TtkTokenKind;
  1054. begin
  1055. if KeyComp('vertical-align') then
  1056. Result := tkKey
  1057. else
  1058. Result := tkIdentifier;
  1059. end;
  1060. function TSynCssSyn.Func115: TtkTokenKind;
  1061. begin
  1062. if KeyComp('table-layout') or KeyComp('border-radius')
  1063. or KeyComp('column-rule') or KeyComp('align-content') then
  1064. Result := tkKey
  1065. else
  1066. Result := tkIdentifier;
  1067. end;
  1068. function TSynCssSyn.Func116: TtkTokenKind;
  1069. begin
  1070. if KeyComp('text-indent') or KeyComp('overflow') or KeyComp('grid-columns') then
  1071. Result := tkKey
  1072. else
  1073. Result := tkIdentifier;
  1074. end;
  1075. function TSynCssSyn.Func117: TtkTokenKind;
  1076. begin
  1077. if KeyComp('font-style') or KeyComp('position') or KeyComp('speak-numeral')
  1078. or KeyComp('background-clip') then
  1079. Result := tkKey
  1080. else
  1081. Result := tkIdentifier;
  1082. end;
  1083. function TSynCssSyn.Func118: TtkTokenKind;
  1084. begin
  1085. if KeyComp('marker-offset') or KeyComp('writing-mode') then
  1086. Result := tkKey
  1087. else
  1088. Result := tkIdentifier;
  1089. end;
  1090. function TSynCssSyn.Func119: TtkTokenKind;
  1091. begin
  1092. if KeyComp('box-direction') then
  1093. Result := tkKey
  1094. else
  1095. Result := tkIdentifier;
  1096. end;
  1097. function TSynCssSyn.Func120: TtkTokenKind;
  1098. begin
  1099. if KeyComp('text-shadow') then
  1100. Result := tkKey
  1101. else
  1102. Result := tkIdentifier;
  1103. end;
  1104. function TSynCssSyn.Func121: TtkTokenKind;
  1105. begin
  1106. if KeyComp('font-variant') or KeyComp('padding-bottom') or KeyComp('overflow-x') then
  1107. Result := tkKey
  1108. else
  1109. Result := tkIdentifier;
  1110. end;
  1111. function TSynCssSyn.Func122: TtkTokenKind;
  1112. begin
  1113. if KeyComp('list-style') or KeyComp('overflow-y') then
  1114. Result := tkKey
  1115. else
  1116. Result := tkIdentifier;
  1117. end;
  1118. function TSynCssSyn.Func123: TtkTokenKind;
  1119. begin
  1120. if KeyComp('border-image-width') or KeyComp('column-width') then
  1121. Result := tkKey
  1122. else
  1123. Result := tkIdentifier;
  1124. end;
  1125. function TSynCssSyn.Func124: TtkTokenKind;
  1126. begin
  1127. if KeyComp('border-style') or KeyComp('border-image-repeat') or KeyComp('animation-delay')
  1128. or KeyComp('transform') then Result := tkKey
  1129. else
  1130. Result := tkIdentifier;
  1131. end;
  1132. function TSynCssSyn.Func125: TtkTokenKind;
  1133. begin
  1134. if KeyComp('flex-direction') then
  1135. Result := tkKey
  1136. else
  1137. Result := tkIdentifier;
  1138. end;
  1139. function TSynCssSyn.Func126: TtkTokenKind;
  1140. begin
  1141. if KeyComp('border-collapse') or KeyComp('definition-src') or KeyComp('text-align-last') then
  1142. Result := tkKey
  1143. else
  1144. Result := tkIdentifier;
  1145. end;
  1146. function TSynCssSyn.Func127: TtkTokenKind;
  1147. begin
  1148. if KeyComp('box-flex-group') then
  1149. Result := tkKey
  1150. else
  1151. Result := tkIdentifier;
  1152. end;
  1153. function TSynCssSyn.Func128: TtkTokenKind;
  1154. begin
  1155. if KeyComp('margin-bottom') or KeyComp('border-bottom') or
  1156. KeyComp('text-kashida-space') then
  1157. Result := tkKey
  1158. else
  1159. Result := tkIdentifier;
  1160. end;
  1161. function TSynCssSyn.Func129: TtkTokenKind;
  1162. begin
  1163. if KeyComp('font-stretch') then
  1164. Result := tkKey
  1165. else
  1166. Result := tkIdentifier;
  1167. end;
  1168. function TSynCssSyn.Func130: TtkTokenKind;
  1169. begin
  1170. if KeyComp('border-left-color') or KeyComp('letter-spacing') then
  1171. Result := tkKey
  1172. else
  1173. Result := tkIdentifier;
  1174. end;
  1175. function TSynCssSyn.Func131: TtkTokenKind;
  1176. begin
  1177. if KeyComp('border-left-width') or KeyComp('layout-grid-mode') then
  1178. Result := tkKey
  1179. else
  1180. Result := tkIdentifier;
  1181. end;
  1182. function TSynCssSyn.Func132: TtkTokenKind;
  1183. begin
  1184. if KeyComp('column-count') then
  1185. Result := tkKey
  1186. else
  1187. Result := tkIdentifier;
  1188. end;
  1189. function TSynCssSyn.Func134: TtkTokenKind;
  1190. begin
  1191. if KeyComp('layout-grid-line') or KeyComp('animation-fill-mode') then
  1192. Result := tkKey
  1193. else
  1194. Result := tkIdentifier;
  1195. end;
  1196. function TSynCssSyn.Func136: TtkTokenKind;
  1197. begin
  1198. if KeyComp('visibility') or KeyComp('background-size') then
  1199. Result := tkKey
  1200. else
  1201. Result := tkIdentifier;
  1202. end;
  1203. function TSynCssSyn.Func137: TtkTokenKind;
  1204. begin
  1205. if KeyComp('ruby-overhang') then
  1206. Result := tkKey
  1207. else
  1208. Result := tkIdentifier;
  1209. end;
  1210. function TSynCssSyn.Func138: TtkTokenKind;
  1211. begin
  1212. if KeyComp('border-top-color') or KeyComp('list-style-image') or KeyComp('perspective') then
  1213. Result := tkKey
  1214. else
  1215. Result := tkIdentifier;
  1216. end;
  1217. function TSynCssSyn.Func139: TtkTokenKind;
  1218. begin
  1219. if KeyComp('border-top-width') or KeyComp('transition') then
  1220. Result := tkKey
  1221. else
  1222. Result := tkIdentifier;
  1223. end;
  1224. function TSynCssSyn.Func140: TtkTokenKind;
  1225. begin
  1226. if KeyComp('background-color') or KeyComp('outline-color') or KeyComp('text-emphasis') or
  1227. KeyComp('scrollbar-face-color') or KeyComp('border-image-source') then
  1228. Result := tkKey
  1229. else
  1230. Result := tkIdentifier;
  1231. end;
  1232. function TSynCssSyn.Func141: TtkTokenKind;
  1233. begin
  1234. if KeyComp('outline-width') then
  1235. Result := tkKey
  1236. else
  1237. Result := tkIdentifier;
  1238. end;
  1239. function TSynCssSyn.Func142: TtkTokenKind;
  1240. begin
  1241. if KeyComp('background-repeat') then
  1242. Result := tkKey
  1243. else
  1244. Result := tkIdentifier;
  1245. end;
  1246. function TSynCssSyn.Func144: TtkTokenKind;
  1247. begin
  1248. if KeyComp('counter-reset') or KeyComp('box-decoration-break') or KeyComp('@supports') then
  1249. Result := tkKey
  1250. else
  1251. Result := tkIdentifier;
  1252. end;
  1253. function TSynCssSyn.Func146: TtkTokenKind;
  1254. begin
  1255. if KeyComp('text-outline') then
  1256. Result := tkKey
  1257. else
  1258. Result := tkIdentifier;
  1259. end;
  1260. function TSynCssSyn.Func148: TtkTokenKind;
  1261. begin
  1262. if KeyComp('border-left-style') or KeyComp('outline-offset') then
  1263. Result := tkKey
  1264. else
  1265. Result := tkIdentifier;
  1266. end;
  1267. function TSynCssSyn.Func149: TtkTokenKind;
  1268. begin
  1269. if KeyComp('border-right-color') or KeyComp('background-origin') or KeyComp('backface-visibility') then
  1270. Result := tkKey
  1271. else
  1272. Result := tkIdentifier;
  1273. end;
  1274. function TSynCssSyn.Func150: TtkTokenKind;
  1275. begin
  1276. if KeyComp('border-right-width') then
  1277. Result := tkKey
  1278. else
  1279. Result := tkIdentifier;
  1280. end;
  1281. function TSynCssSyn.Func151: TtkTokenKind;
  1282. begin
  1283. if KeyComp('font-size-adjust') or KeyComp('text-autospace') then
  1284. Result := tkKey
  1285. else
  1286. Result := tkIdentifier;
  1287. end;
  1288. function TSynCssSyn.Func152: TtkTokenKind;
  1289. begin
  1290. if KeyComp('scrollbar-base-color') then
  1291. Result := tkKey
  1292. else
  1293. Result := tkIdentifier;
  1294. end;
  1295. function TSynCssSyn.Func153: TtkTokenKind;
  1296. begin
  1297. if KeyComp('box-ordinal-group') or KeyComp('object-position') then
  1298. Result := tkKey
  1299. else
  1300. Result := tkIdentifier;
  1301. end;
  1302. function TSynCssSyn.Func154: TtkTokenKind;
  1303. begin
  1304. if KeyComp('text-decoration') then
  1305. Result := tkKey
  1306. else
  1307. Result := tkIdentifier;
  1308. end;
  1309. function TSynCssSyn.Func156: TtkTokenKind;
  1310. begin
  1311. if KeyComp('border-top-style') then
  1312. Result := tkKey
  1313. else
  1314. Result := tkIdentifier;
  1315. end;
  1316. function TSynCssSyn.Func158: TtkTokenKind;
  1317. begin
  1318. if KeyComp('outline-style') then
  1319. Result := tkKey
  1320. else
  1321. Result := tkIdentifier;
  1322. end;
  1323. function TSynCssSyn.Func159: TtkTokenKind;
  1324. begin
  1325. if KeyComp('border-image-outset') or KeyComp('column-rule-color') then
  1326. Result := tkKey
  1327. else
  1328. Result := tkIdentifier;
  1329. end;
  1330. function TSynCssSyn.Func160: TtkTokenKind;
  1331. begin
  1332. if KeyComp('layout-grid-type') or KeyComp('text-justify')
  1333. or KeyComp('column-rule-width') then
  1334. Result := tkKey
  1335. else
  1336. Result := tkIdentifier;
  1337. end;
  1338. function TSynCssSyn.Func164: TtkTokenKind;
  1339. begin
  1340. if KeyComp('ruby-position') then
  1341. Result := tkKey
  1342. else
  1343. Result := tkIdentifier;
  1344. end;
  1345. function TSynCssSyn.Func166: TtkTokenKind;
  1346. begin
  1347. if KeyComp('scrollbar-3d-light-color') or KeyComp('text-overflow') then
  1348. Result := tkKey
  1349. else
  1350. Result := tkIdentifier;
  1351. end;
  1352. function TSynCssSyn.Func167: TtkTokenKind;
  1353. begin
  1354. if KeyComp('border-right-style') or KeyComp('rotation-point')
  1355. or KeyComp('transition-delay') then
  1356. Result := tkKey
  1357. else
  1358. Result := tkIdentifier;
  1359. end;
  1360. function TSynCssSyn.Func169: TtkTokenKind;
  1361. begin
  1362. if KeyComp('list-style-type') or KeyComp('target-position') then
  1363. Result := tkKey
  1364. else
  1365. Result := tkIdentifier;
  1366. end;
  1367. function TSynCssSyn.Func171: TtkTokenKind;
  1368. begin
  1369. if KeyComp('border-top-left-radius') then
  1370. Result := tkKey
  1371. else
  1372. Result := tkIdentifier;
  1373. end;
  1374. function TSynCssSyn.Func172: TtkTokenKind;
  1375. begin
  1376. if KeyComp('border-bottom-color') then
  1377. Result := tkKey
  1378. else
  1379. Result := tkIdentifier;
  1380. end;
  1381. function TSynCssSyn.Func173: TtkTokenKind;
  1382. begin
  1383. if KeyComp('border-bottom-width') then
  1384. Result := tkKey
  1385. else
  1386. Result := tkIdentifier;
  1387. end;
  1388. function TSynCssSyn.Func174: TtkTokenKind;
  1389. begin
  1390. if KeyComp('text-transform') or KeyComp('animation-direction') then
  1391. Result := tkKey
  1392. else
  1393. Result := tkIdentifier;
  1394. end;
  1395. function TSynCssSyn.Func175: TtkTokenKind;
  1396. begin
  1397. if KeyComp('text-decoration-line') then
  1398. Result := tkKey
  1399. else
  1400. Result := tkIdentifier;
  1401. end;
  1402. function TSynCssSyn.Func177: TtkTokenKind;
  1403. begin
  1404. if KeyComp('animation-play-state') or KeyComp('column-rule-style')
  1405. or KeyComp('transform-origin') then
  1406. Result := tkKey
  1407. else
  1408. Result := tkIdentifier;
  1409. end;
  1410. function TSynCssSyn.Func178: TtkTokenKind;
  1411. begin
  1412. if KeyComp('counter-increment') or KeyComp('overflow-style') then
  1413. Result := tkKey
  1414. else
  1415. Result := tkIdentifier;
  1416. end;
  1417. function TSynCssSyn.Func179: TtkTokenKind;
  1418. begin
  1419. if KeyComp('animation-duration') then
  1420. Result := tkKey
  1421. else
  1422. Result := tkIdentifier;
  1423. end;
  1424. function TSynCssSyn.Func182: TtkTokenKind;
  1425. begin
  1426. if KeyComp('background-attachment') or KeyComp('justify-content') then
  1427. Result := tkKey
  1428. else
  1429. Result := tkIdentifier;
  1430. end;
  1431. function TSynCssSyn.Func186: TtkTokenKind;
  1432. begin
  1433. if KeyComp('transform-style') then
  1434. Result := tkKey
  1435. else
  1436. Result := tkIdentifier;
  1437. end;
  1438. function TSynCssSyn.Func187: TtkTokenKind;
  1439. begin
  1440. if KeyComp('speak-punctuation') then
  1441. Result := tkKey
  1442. else
  1443. Result := tkIdentifier;
  1444. end;
  1445. function TSynCssSyn.Func190: TtkTokenKind;
  1446. begin
  1447. if KeyComp('border-bottom-style') or KeyComp('border-top-right-radius') then
  1448. Result := tkKey
  1449. else
  1450. Result := tkIdentifier;
  1451. end;
  1452. function TSynCssSyn.Func191: TtkTokenKind;
  1453. begin
  1454. if KeyComp('perspective-origin') then
  1455. Result := tkKey
  1456. else
  1457. Result := tkIdentifier;
  1458. end;
  1459. function TSynCssSyn.Func194: TtkTokenKind;
  1460. begin
  1461. if KeyComp('background-position') then
  1462. Result := tkKey
  1463. else
  1464. Result := tkIdentifier;
  1465. end;
  1466. function TSynCssSyn.Func195: TtkTokenKind;
  1467. begin
  1468. if KeyComp('scrollbar-shadow-color') or KeyComp('hanging-punctuation')
  1469. or KeyComp('punctuation-trim') then
  1470. Result := tkKey
  1471. else
  1472. Result := tkIdentifier;
  1473. end;
  1474. function TSynCssSyn.Func198: TtkTokenKind;
  1475. begin
  1476. if KeyComp('text-decoration-color') then
  1477. Result := tkKey
  1478. else
  1479. Result := tkIdentifier;
  1480. end;
  1481. function TSynCssSyn.Func199: TtkTokenKind;
  1482. begin
  1483. if KeyComp('background-position-x') then
  1484. Result := tkKey
  1485. else
  1486. Result := tkIdentifier;
  1487. end;
  1488. function TSynCssSyn.Func200: TtkTokenKind;
  1489. begin
  1490. if KeyComp('background-position-y') or KeyComp('scrollbar-arrow-color') then
  1491. Result := tkKey
  1492. else
  1493. Result := tkIdentifier;
  1494. end;
  1495. function TSynCssSyn.Func205: TtkTokenKind;
  1496. begin
  1497. if KeyComp('border-bottom-left-radius') then
  1498. Result := tkKey
  1499. else
  1500. Result := tkIdentifier;
  1501. end;
  1502. function TSynCssSyn.Func210: TtkTokenKind;
  1503. begin
  1504. if KeyComp('scrollbar-dark-shadow-color') then
  1505. Result := tkKey
  1506. else
  1507. Result := tkIdentifier;
  1508. end;
  1509. function TSynCssSyn.Func213: TtkTokenKind;
  1510. begin
  1511. if KeyComp('scrollbar-highlight-color') then
  1512. Result := tkKey
  1513. else
  1514. Result := tkIdentifier;
  1515. end;
  1516. function TSynCssSyn.Func216: TtkTokenKind;
  1517. begin
  1518. if KeyComp('text-decoration-style') then
  1519. Result := tkKey
  1520. else
  1521. Result := tkIdentifier;
  1522. end;
  1523. function TSynCssSyn.Func220: TtkTokenKind;
  1524. begin
  1525. if KeyComp('list-style-position') then
  1526. Result := tkKey
  1527. else
  1528. Result := tkIdentifier;
  1529. end;
  1530. function TSynCssSyn.Func222: TtkTokenKind;
  1531. begin
  1532. if KeyComp('transition-duration') then
  1533. Result := tkKey
  1534. else
  1535. Result := tkIdentifier;
  1536. end;
  1537. function TSynCssSyn.Func224: TtkTokenKind;
  1538. begin
  1539. if KeyComp('border-bottom-right-radius') then
  1540. Result := tkKey
  1541. else
  1542. Result := tkIdentifier;
  1543. end;
  1544. function TSynCssSyn.Func232: TtkTokenKind;
  1545. begin
  1546. if KeyComp('animation-timing-function') then
  1547. Result := tkKey
  1548. else
  1549. Result := tkIdentifier;
  1550. end;
  1551. function TSynCssSyn.Func242: TtkTokenKind;
  1552. begin
  1553. if KeyComp('animation-iteration-count') then
  1554. Result := tkKey
  1555. else
  1556. Result := tkIdentifier;
  1557. end;
  1558. function TSynCssSyn.Func250: TtkTokenKind;
  1559. begin
  1560. if KeyComp('text-underline-position') then
  1561. Result := tkKey
  1562. else
  1563. Result := tkIdentifier;
  1564. end;
  1565. function TSynCssSyn.Func253: TtkTokenKind;
  1566. begin
  1567. if KeyComp('transition-property') then
  1568. Result := tkKey
  1569. else
  1570. Result := tkIdentifier;
  1571. end;
  1572. function TSynCssSyn.Func275: TtkTokenKind;
  1573. begin
  1574. if KeyComp('transition-timing-function') then
  1575. Result := tkKey
  1576. else
  1577. Result := tkIdentifier;
  1578. end;
  1579. function TSynCssSyn.AltFunc: TtkTokenKind;
  1580. begin
  1581. Result := tkIdentifier;
  1582. end;
  1583. function TSynCssSyn.IdentKind(MayBe: PChar): TtkTokenKind;
  1584. var
  1585. HashKey: Integer;
  1586. begin
  1587. FToIdent := MayBe;
  1588. HashKey := KeyHash(MayBe);
  1589. if (HashKey >= 16) and (HashKey <= 275) then
  1590. Result := fIdentFuncTable[HashKey]()
  1591. else
  1592. Result := tkIdentifier;
  1593. end;
  1594. procedure TSynCssSyn.MakeMethodTables;
  1595. var
  1596. chI: Char;
  1597. begin
  1598. for chI := #0 to #255 do
  1599. case chI of
  1600. '{' : FProcTable[chI] := @CurlyOpenProc;
  1601. '}' : FProcTable[chI] := @CurlyCloseProc;
  1602. ';' : FProcTable[chI] := @SymbolProc;
  1603. ':' : FProcTable[chI] := @ColonProc;
  1604. '.', '*', ',','>','+','~' : FProcTable[chI] := @SelectorProc;
  1605. '%' : FProcTable[chI] := @PercentProc;
  1606. #13 : FProcTable[chI] := @CRProc;
  1607. '-' : FProcTable[chI] := @DashProc;
  1608. 'A'..'Z', 'a'..'z', '_','@' : FProcTable[chI] := @IdentProc;
  1609. '#' : FProcTable[chI] := @HashProc;
  1610. '$' : FProcTable[chI] := @IntegerProc;
  1611. #10 : FProcTable[chI] := @LFProc;
  1612. #0 : FProcTable[chI] := @NullProc;
  1613. '0'..'9' : FProcTable[chI] := @NumberProc;
  1614. ')', '(' : FProcTable[chI] := @RoundOpenProc;
  1615. '/' : FProcTable[chI] := @SlashProc;
  1616. #1..#9, #11, #12, #14..#32 : FProcTable[chI] := @SpaceProc;
  1617. #39 : FProcTable[chI] := @StringProc;
  1618. else
  1619. FProcTable[chI] := @UnknownProc;
  1620. end;
  1621. end;
  1622. constructor TSynCssSyn.Create(AOwner: TComponent);
  1623. begin
  1624. inherited Create(AOwner);
  1625. fCommentAttri := TSynHighlighterAttributes.Create(@SYNS_AttrComment, SYNS_XML_AttrComment);
  1626. fCommentAttri.Style := [fsItalic];
  1627. AddAttribute(fCommentAttri);
  1628. fIdentifierAttri := TSynHighlighterAttributes.Create(@SYNS_AttrIdentifier, SYNS_XML_AttrIdentifier);
  1629. AddAttribute(fIdentifierAttri);
  1630. fKeyAttri := TSynHighlighterAttributes.Create(@SYNS_AttrKey, SYNS_XML_AttrKey);
  1631. fKeyAttri.Style := [fsBold];
  1632. AddAttribute(fKeyAttri);
  1633. fNumberAttri := TSynHighlighterAttributes.Create(@SYNS_AttrNumber, SYNS_XML_AttrNumber);
  1634. AddAttribute(fNumberAttri);
  1635. fSpaceAttri := TSynHighlighterAttributes.Create(@SYNS_AttrSpace, SYNS_XML_AttrSpace);
  1636. AddAttribute(fSpaceAttri);
  1637. fStringAttri := TSynHighlighterAttributes.Create(@SYNS_AttrString, SYNS_XML_AttrString);
  1638. AddAttribute(fStringAttri);
  1639. fSymbolAttri := TSynHighlighterAttributes.Create(@SYNS_AttrSymbol, SYNS_XML_AttrSymbol);
  1640. AddAttribute(fSymbolAttri);
  1641. fMeasurementUnitAttri := TSynHighlighterAttributes.Create(@SYNS_AttrMeasurementUnitValue, SYNS_XML_AttrMeasurementUnitValue);
  1642. AddAttribute(fMeasurementUnitAttri);
  1643. fSelectorAttri := TSynHighlighterAttributes.Create(@SYNS_AttrSelectorValue, SYNS_XML_AttrSelectorValue);
  1644. AddAttribute(fSelectorAttri);
  1645. SetAttributesOnChange(@DefHighlightChange);
  1646. InitIdent;
  1647. MakeMethodTables;
  1648. fDefaultFilter := SYNS_FilterCSS;
  1649. fRange := [];
  1650. end;
  1651. procedure TSynCssSyn.SetLine(const NewValue: String; LineNumber: Integer);
  1652. begin
  1653. inherited;
  1654. fLine := PChar(NewValue);
  1655. Run := 0;
  1656. fLineNumber := LineNumber;
  1657. Next;
  1658. end;
  1659. procedure TSynCssSyn.SymbolProc;
  1660. begin
  1661. if rsInDeclarationBlock in fRange then
  1662. FTokenID := tkSymbol
  1663. else
  1664. FTokenID := tkIdentifier;
  1665. Inc(Run);
  1666. end;
  1667. procedure TSynCssSyn.ColonProc;
  1668. begin
  1669. if not(rsInDeclarationBlock in fRange) then
  1670. FTokenID := tkSelector
  1671. else
  1672. FTokenID := tkSymbol;
  1673. Inc(Run);
  1674. end;
  1675. procedure TSynCssSyn.SelectorProc;
  1676. begin
  1677. if not(rsInDeclarationBlock in fRange) then
  1678. FTokenID := tkSelector
  1679. else
  1680. FTokenID := tkIdentifier;
  1681. Inc(Run);
  1682. end;
  1683. procedure TSynCssSyn.PercentProc;
  1684. begin
  1685. if rsInDeclarationBlock in fRange then
  1686. FTokenID := tkMeasurementUnit
  1687. else
  1688. FTokenID := tkIdentifier;
  1689. Inc(Run);
  1690. end;
  1691. procedure TSynCssSyn.CurlyOpenProc;
  1692. begin
  1693. FTokenID := tkSymbol;
  1694. Inc(Run);
  1695. fRange := fRange + [rsInDeclarationBlock];
  1696. end;
  1697. procedure TSynCssSyn.CurlyCloseProc;
  1698. begin
  1699. FTokenID := tkSymbol;
  1700. Inc(Run);
  1701. fRange := fRange - [rsInDeclarationBlock];
  1702. end;
  1703. procedure TSynCssSyn.CRProc;
  1704. begin
  1705. FTokenID := tkSpace;
  1706. Inc(Run);
  1707. if FLine[Run] = #10 then
  1708. Inc(Run);
  1709. end;
  1710. procedure TSynCssSyn.CStyleCommentProc;
  1711. begin
  1712. if FLine[Run] = #0 then
  1713. FTokenID := tkNull
  1714. else begin
  1715. FTokenID := tkComment;
  1716. repeat
  1717. if (fLine[Run] = '*') and (fLine[Run + 1] = '/') then begin
  1718. FRange := fRange - [rsCStyle];
  1719. Inc(Run, 2);
  1720. Break;
  1721. end;
  1722. Inc(Run);
  1723. until FLine[Run] in [#0, #10, #13];
  1724. end;
  1725. end;
  1726. procedure TSynCssSyn.DashProc;
  1727. begin
  1728. if (FLine[Run - 1] = ' ') then begin
  1729. if (FLine[Run + 1] in ['0'..'9', 'a'..'z', 'A'..'Z']) then
  1730. FTokenID := tkNumber
  1731. else if (FLine[Run + 1] = '.') and (FLine[Run + 2] in ['0'..'9', 'a'..'z', 'A'..'Z']) then begin
  1732. FTokenID := tkNumber;
  1733. Inc(Run);
  1734. end;
  1735. end else
  1736. FTokenID := tkIdentifier;
  1737. Inc(Run);
  1738. end;
  1739. procedure TSynCssSyn.IdentProc;
  1740. begin
  1741. FTokenID := IdentKind((FLine + Run));
  1742. Inc(Run, FStringLen);
  1743. while Identifiers[FLine[Run]] do
  1744. Inc(Run);
  1745. end;
  1746. procedure TSynCssSyn.HashProc;
  1747. begin
  1748. if (rsInDeclarationBlock in fRange) then begin
  1749. IntegerProc;
  1750. exit;
  1751. end;
  1752. Inc(Run);
  1753. FTokenID := tkSelector;
  1754. end;
  1755. procedure TSynCssSyn.IntegerProc;
  1756. begin
  1757. Inc(Run);
  1758. if not(rsInDeclarationBlock in fRange) then begin
  1759. FTokenID := tkIdentifier;
  1760. exit;
  1761. end;
  1762. FTokenID := tkNumber;
  1763. while FLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f'] do
  1764. Inc(Run);
  1765. end;
  1766. procedure TSynCssSyn.LFProc;
  1767. begin
  1768. FTokenID := tkSpace;
  1769. Inc(Run);
  1770. end;
  1771. procedure TSynCssSyn.NullProc;
  1772. begin
  1773. FTokenID := tkNull;
  1774. end;
  1775. procedure TSynCssSyn.NumberProc;
  1776. begin
  1777. Inc(Run);
  1778. FTokenID := tkNumber;
  1779. while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do begin
  1780. if ((FLine[Run] = '.') and (FLine[Run + 1] = '.')) or
  1781. ((FLine[Run] = 'e') and ((FLine[Run + 1] = 'x') or (FLine[Run + 1] = 'm'))) then
  1782. Break;
  1783. Inc(Run);
  1784. end;
  1785. end;
  1786. procedure TSynCssSyn.RoundOpenProc;
  1787. begin
  1788. Inc(Run);
  1789. FTokenID := tkSymbol;
  1790. end;
  1791. procedure TSynCssSyn.SlashProc;
  1792. begin
  1793. Inc(Run);
  1794. if fLine[Run] = '*' then begin
  1795. FTokenID := tkComment;
  1796. FRange := fRange + [rsCStyle];
  1797. Inc(Run);
  1798. if not (FLine[Run] in [#0, #10, #13]) then
  1799. CStyleCommentProc;
  1800. end else
  1801. FTokenID := tkIdentifier;
  1802. end;
  1803. procedure TSynCssSyn.SpaceProc;
  1804. begin
  1805. Inc(Run);
  1806. FTokenID := tkSpace;
  1807. while FLine[Run] in [#1..#9, #11, #12, #14..#32] do
  1808. Inc(Run);
  1809. end;
  1810. procedure TSynCssSyn.StringProc;
  1811. begin
  1812. FTokenID := tkString;
  1813. if (FLine[Run + 1] = #39) and (FLine[Run + 2] = #39) then
  1814. Inc(Run, 2);
  1815. repeat
  1816. case FLine[Run] of
  1817. #0, #10, #13: Break;
  1818. end;
  1819. Inc(Run);
  1820. until FLine[Run] = #39;
  1821. if FLine[Run] <> #0 then
  1822. Inc(Run);
  1823. end;
  1824. procedure TSynCssSyn.UnknownProc;
  1825. begin
  1826. {$IFDEF SYN_MBCSSUPPORT}
  1827. if FLine[Run] in LeadBytes then
  1828. Inc(Run,2)
  1829. else
  1830. {$ENDIF}
  1831. Inc(Run);
  1832. while (fLine[Run] in [#128..#191]) OR // continued utf8 subcode
  1833. ((fLine[Run]<>#0) and (fProcTable[fLine[Run]] = @UnknownProc)) do inc(Run);
  1834. FTokenID := tkUnknown;
  1835. end;
  1836. procedure TSynCssSyn.Next;
  1837. begin
  1838. FTokenPos := Run;
  1839. if rsCStyle in fRange then
  1840. CStyleCommentProc
  1841. else
  1842. FProcTable[FLine[Run]]();
  1843. end;
  1844. function TSynCssSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
  1845. begin
  1846. case Index of
  1847. SYN_ATTR_COMMENT : Result := FCommentAttri;
  1848. SYN_ATTR_IDENTIFIER: Result := FIdentifierAttri;
  1849. SYN_ATTR_KEYWORD : Result := FKeyAttri;
  1850. SYN_ATTR_STRING : Result := FStringAttri;
  1851. SYN_ATTR_WHITESPACE: Result := FSpaceAttri;
  1852. SYN_ATTR_SYMBOL : Result := FSymbolAttri;
  1853. SYN_ATTR_NUMBER : Result := fNumberAttri;
  1854. else
  1855. Result := nil;
  1856. end;
  1857. end;
  1858. function TSynCssSyn.GetEol: Boolean;
  1859. begin
  1860. Result := (FTokenID = tkNull);
  1861. end;
  1862. function TSynCssSyn.GetRange: Pointer;
  1863. begin
  1864. Result := {%H-}Pointer(Integer(fRange));
  1865. end;
  1866. function TSynCssSyn.GetToken: string;
  1867. var
  1868. Len: LongInt;
  1869. begin
  1870. Result := '';
  1871. Len := Run - FTokenPos;
  1872. SetString(Result, (FLine + FTokenPos), Len);
  1873. end;
  1874. procedure TSynCssSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer);
  1875. begin
  1876. TokenLength:=Run-fTokenPos;
  1877. TokenStart:=FLine + fTokenPos;
  1878. end;
  1879. function TSynCssSyn.GetTokenID: TtkTokenKind;
  1880. begin
  1881. Result := FTokenId;
  1882. end;
  1883. function TSynCssSyn.GetTokenAttribute: TSynHighlighterAttributes;
  1884. begin
  1885. case GetTokenID of
  1886. tkComment : Result := FCommentAttri;
  1887. tkIdentifier: Result := FIdentifierAttri;
  1888. tkKey : Result := FKeyAttri;
  1889. tkNumber : Result := FNumberAttri;
  1890. tkSpace : Result := FSpaceAttri;
  1891. tkString : Result := FStringAttri;
  1892. tkSymbol : Result := FSymbolAttri;
  1893. tkMeasurementUnit: Result := fMeasurementUnitAttri;
  1894. tkSelector : Result := fSelectorAttri;
  1895. tkUnknown : Result := FIdentifierAttri;
  1896. else
  1897. Result := nil;
  1898. end;
  1899. end;
  1900. function TSynCssSyn.GetTokenKind: integer;
  1901. begin
  1902. Result := Ord(fTokenId);
  1903. end;
  1904. function TSynCssSyn.GetTokenPos: Integer;
  1905. begin
  1906. Result := FTokenPos;
  1907. end;
  1908. procedure TSynCssSyn.ReSetRange;
  1909. begin
  1910. FRange := [];
  1911. end;
  1912. procedure TSynCssSyn.SetRange(Value: Pointer);
  1913. begin
  1914. FRange := TRangeStates({%H-}Cardinal(Value));
  1915. end;
  1916. function TSynCssSyn.GetIdentChars: TSynIdentChars;
  1917. begin
  1918. Result := TSynValidStringChars + ['-'];
  1919. end;
  1920. class function TSynCssSyn.GetLanguageName: string;
  1921. begin
  1922. Result := SYNS_LangCSS;
  1923. end;
  1924. function TSynCssSyn.GetSampleSource: String;
  1925. begin
  1926. Result := '/* Syntax highlighting */'#13#10 +
  1927. 'body'#13#10 +
  1928. '{'#13#10 +
  1929. ' font-family: "Arial";'#13#10 +
  1930. ' font-size: 12pt;'#13#10 +
  1931. '}';
  1932. end;
  1933. function TSynCssSyn.KeyHash2(ToHash: PChar): Integer;
  1934. begin
  1935. Result := KeyHash(ToHash);
  1936. end;
  1937. initialization
  1938. MakeIdentTable;
  1939. RegisterPlaceableHighlighter(TSynCssSyn);
  1940. end.