From 3391d5813f762ce921648f46092cccf64ed2a9ee Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 4 Mar 2018 09:33:24 +0000 Subject: [PATCH] extrasyn: initial commit (additional synedit highlighters from https://bugs.freepascal.org/view.php?id=18248) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6219 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/extrasyn/Images/TDBSYNEDIT.png | Bin 0 -> 253 bytes components/extrasyn/Images/TSYN8051SYN.png | Bin 0 -> 245 bytes .../extrasyn/Images/TSYNADSP21XXSYN.png | Bin 0 -> 224 bytes components/extrasyn/Images/TSYNASMSYN.png | Bin 0 -> 223 bytes .../extrasyn/Images/TSYNAUTOCOMPLETE.png | Bin 0 -> 256 bytes .../extrasyn/Images/TSYNAUTOCORRECT.png | Bin 0 -> 191 bytes components/extrasyn/Images/TSYNAWKSYN.png | Bin 0 -> 219 bytes components/extrasyn/Images/TSYNBAANSYN.png | Bin 0 -> 215 bytes components/extrasyn/Images/TSYNBATSYN.png | Bin 0 -> 335 bytes components/extrasyn/Images/TSYNCACHESYN.png | Bin 0 -> 227 bytes components/extrasyn/Images/TSYNCACSYN.png | Bin 0 -> 213 bytes components/extrasyn/Images/TSYNCOBOLSYN.png | Bin 0 -> 221 bytes .../Images/TSYNCOMPLETIONPROPOSAL.png | Bin 0 -> 245 bytes components/extrasyn/Images/TSYNCPMSYN.png | Bin 0 -> 227 bytes components/extrasyn/Images/TSYNCPPSYN.png | Bin 0 -> 218 bytes components/extrasyn/Images/TSYNCSSSYN.png | Bin 0 -> 274 bytes components/extrasyn/Images/TSYNCSSYN.png | Bin 0 -> 225 bytes components/extrasyn/Images/TSYNDFMSYN.png | Bin 0 -> 218 bytes components/extrasyn/Images/TSYNDMLSYN.png | Bin 0 -> 254 bytes components/extrasyn/Images/TSYNDOTSYN.png | Bin 0 -> 218 bytes components/extrasyn/Images/TSYNEDIT.png | Bin 0 -> 228 bytes .../extrasyn/Images/TSYNEDITOPTIONSDIALOG.png | Bin 0 -> 261 bytes components/extrasyn/Images/TSYNEDITPRINT.png | Bin 0 -> 251 bytes .../extrasyn/Images/TSYNEDITPRINTPREVIEW.png | Bin 0 -> 264 bytes .../Images/TSYNEDITPYTHONBEHAVIOUR.png | Bin 0 -> 275 bytes .../extrasyn/Images/TSYNEDITREGEXSEARCH.png | Bin 0 -> 303 bytes components/extrasyn/Images/TSYNEDITSEARCH.png | Bin 0 -> 285 bytes .../extrasyn/Images/TSYNEXPORTERHTML.png | Bin 0 -> 230 bytes .../extrasyn/Images/TSYNEXPORTERRTF.png | Bin 0 -> 218 bytes .../extrasyn/Images/TSYNEXPORTERTEX.png | Bin 0 -> 229 bytes components/extrasyn/Images/TSYNFORTRANSYN.png | Bin 0 -> 213 bytes components/extrasyn/Images/TSYNFOXPROSYN.png | Bin 0 -> 217 bytes components/extrasyn/Images/TSYNGALAXYSYN.png | Bin 0 -> 216 bytes components/extrasyn/Images/TSYNGENERALSYN.png | Bin 0 -> 218 bytes .../extrasyn/Images/TSYNGWSCRIPTSYN.png | Bin 0 -> 226 bytes components/extrasyn/Images/TSYNHASKELLSYN.png | Bin 0 -> 212 bytes components/extrasyn/Images/TSYNHC11SYN.png | Bin 0 -> 219 bytes .../Images/TSYNHIGHLIGHTERMANAGER.png | Bin 0 -> 216 bytes components/extrasyn/Images/TSYNHP48SYN.png | Bin 0 -> 229 bytes components/extrasyn/Images/TSYNHTMLSYN.png | Bin 0 -> 218 bytes components/extrasyn/Images/TSYNIDLSYN.png | Bin 0 -> 207 bytes components/extrasyn/Images/TSYNINISYN.png | Bin 0 -> 205 bytes components/extrasyn/Images/TSYNINNOSYN.png | Bin 0 -> 330 bytes components/extrasyn/Images/TSYNJAVASYN.png | Bin 0 -> 224 bytes components/extrasyn/Images/TSYNJSCRIPTSYN.png | Bin 0 -> 212 bytes components/extrasyn/Images/TSYNKIXSYN.png | Bin 0 -> 211 bytes components/extrasyn/Images/TSYNLDRSYN.png | Bin 0 -> 213 bytes components/extrasyn/Images/TSYNLUASYN.png | Bin 0 -> 225 bytes components/extrasyn/Images/TSYNM3SYN.png | Bin 0 -> 216 bytes .../extrasyn/Images/TSYNMACRORECORDER.png | Bin 0 -> 218 bytes components/extrasyn/Images/TSYNMEMO.png | Bin 0 -> 236 bytes .../extrasyn/Images/TSYNMODELICASYN.png | Bin 0 -> 213 bytes components/extrasyn/Images/TSYNMSGSYN.png | Bin 0 -> 224 bytes components/extrasyn/Images/TSYNMULTISYN.png | Bin 0 -> 212 bytes components/extrasyn/Images/TSYNPASSYN.png | Bin 0 -> 225 bytes components/extrasyn/Images/TSYNPERLSYN.png | Bin 0 -> 220 bytes components/extrasyn/Images/TSYNPHPSYN.png | Bin 0 -> 216 bytes .../extrasyn/Images/TSYNPROGRESSSYN.png | Bin 0 -> 225 bytes components/extrasyn/Images/TSYNPROLOGSYN.png | Bin 0 -> 234 bytes components/extrasyn/Images/TSYNPYTHONSYN.png | Bin 0 -> 294 bytes components/extrasyn/Images/TSYNRCSYN.png | Bin 0 -> 215 bytes components/extrasyn/Images/TSYNRUBYSYN.png | Bin 0 -> 226 bytes components/extrasyn/Images/TSYNSDDSYN.png | Bin 0 -> 219 bytes components/extrasyn/Images/TSYNSMLSYN.png | Bin 0 -> 215 bytes components/extrasyn/Images/TSYNSQLSYN.png | Bin 0 -> 217 bytes components/extrasyn/Images/TSYNSTSYN.png | Bin 0 -> 214 bytes components/extrasyn/Images/TSYNTCLTKSYN.png | Bin 0 -> 210 bytes components/extrasyn/Images/TSYNTEXSYN.png | Bin 0 -> 230 bytes .../Images/TSYNUNIXSHELLSCRIPTSYN.png | Bin 0 -> 214 bytes components/extrasyn/Images/TSYNUNREALSYN.png | Bin 0 -> 221 bytes components/extrasyn/Images/TSYNURIOPENER.png | Bin 0 -> 268 bytes components/extrasyn/Images/TSYNURISYN.png | Bin 0 -> 216 bytes .../extrasyn/Images/TSYNVBSCRIPTSYN.png | Bin 0 -> 222 bytes components/extrasyn/Images/TSYNVBSYN.png | Bin 0 -> 222 bytes components/extrasyn/Images/TSYNVRML97SYN.png | Bin 0 -> 350 bytes components/extrasyn/Images/TSYNXMLSYN.png | Bin 0 -> 215 bytes components/extrasyn/Images/tsynEIFFELsyn.png | Bin 0 -> 344 bytes .../SynHighlighter8051.pas | 551 ++ .../SyneditHighlighters/SynHighlighterLua.pas | 1448 +++++ .../SynHighlighterProlog.pas | 2245 ++++++++ .../extrasyn/SyneditHighlighters/synedit.inc | 56 + .../syneditstrconstextra.pas | 317 ++ .../synhighlighteradsp21xx.pas | 1425 +++++ .../SyneditHighlighters/synhighlighterasm.pas | 565 ++ .../SyneditHighlighters/synhighlighterawk.pas | 620 ++ .../synhighlighterbaan.pas | 1385 +++++ .../SyneditHighlighters/synhighlightercac.pas | 1395 +++++ .../synhighlightercache.pas | 1710 ++++++ .../synhighlightercobol.pas | 2339 ++++++++ .../SyneditHighlighters/synhighlightercs.pas | 1588 ++++++ .../SyneditHighlighters/synhighlighterdml.pas | 1859 ++++++ .../SyneditHighlighters/synhighlighterdot.pas | 1378 +++++ .../synhighlightereiffel.pas | 1423 +++++ .../synhighlighterfortran.pas | 979 ++++ .../synhighlighterfoxpro.pas | 1587 ++++++ .../synhighlightergalaxy.pas | 451 ++ .../synhighlightergeneral.pas | 806 +++ .../SyneditHighlighters/synhighlightergws.pas | 1065 ++++ .../synhighlighterhaskell.pas | 1147 ++++ .../synhighlighterhp48.pas | 975 ++++ .../SyneditHighlighters/synhighlighteridl.pas | 924 +++ .../synhighlighterinno.pas | 967 ++++ .../SyneditHighlighters/synhighlighterkix.pas | 1354 +++++ .../synhighlighterldraw.pas | 579 ++ .../SyneditHighlighters/synhighlighterm3.pas | 758 +++ .../synhighlightermodelica.pas | 968 ++++ .../synhighlighterprogress.pas | 1169 ++++ .../SyneditHighlighters/synhighlighterrc.pas | 1231 ++++ .../synhighlighterruby.pas | 794 +++ .../SyneditHighlighters/synhighlightersdd.pas | 726 +++ .../SyneditHighlighters/synhighlightersml.pas | 955 ++++ .../SyneditHighlighters/synhighlighterst.pas | 1148 ++++ .../synhighlightertcltk.pas | 800 +++ .../synhighlighterunreal.pas | 1953 +++++++ .../SyneditHighlighters/synhighlighteruri.pas | 736 +++ .../synhighlightervbscript.pas | 1030 ++++ .../synhighlightervrml97.pas | 5028 +++++++++++++++++ .../extrasyn/TestHighlighters/Mat Lab 6.hgl | 531 ++ components/extrasyn/TestHighlighters/Ruby.hgl | 1146 ++++ .../TestHighlighters/TestSynHighlighter.lpi | 910 +++ .../TestHighlighters/TestSynHighlighter.lpr | 21 + components/extrasyn/TestHighlighters/lua.hgl | 169 + .../extrasyn/TestHighlighters/unit1.lfm | 669 +++ .../extrasyn/TestHighlighters/unit1.pas | 158 + components/extrasyn/extrahighlighters.lpk | 180 + components/extrasyn/extrahighlighters.pas | 26 + .../extrasyn/extrahighlighters_dsgn.lpk | 45 + .../extrasyn/extrahighlighters_dsgn.pas | 22 + components/extrasyn/images.lrs | 412 ++ components/extrasyn/images.rc | 37 + components/extrasyn/uhighlighterreg.pas | 46 + 131 files changed, 52806 insertions(+) create mode 100644 components/extrasyn/Images/TDBSYNEDIT.png create mode 100644 components/extrasyn/Images/TSYN8051SYN.png create mode 100644 components/extrasyn/Images/TSYNADSP21XXSYN.png create mode 100644 components/extrasyn/Images/TSYNASMSYN.png create mode 100644 components/extrasyn/Images/TSYNAUTOCOMPLETE.png create mode 100644 components/extrasyn/Images/TSYNAUTOCORRECT.png create mode 100644 components/extrasyn/Images/TSYNAWKSYN.png create mode 100644 components/extrasyn/Images/TSYNBAANSYN.png create mode 100644 components/extrasyn/Images/TSYNBATSYN.png create mode 100644 components/extrasyn/Images/TSYNCACHESYN.png create mode 100644 components/extrasyn/Images/TSYNCACSYN.png create mode 100644 components/extrasyn/Images/TSYNCOBOLSYN.png create mode 100644 components/extrasyn/Images/TSYNCOMPLETIONPROPOSAL.png create mode 100644 components/extrasyn/Images/TSYNCPMSYN.png create mode 100644 components/extrasyn/Images/TSYNCPPSYN.png create mode 100644 components/extrasyn/Images/TSYNCSSSYN.png create mode 100644 components/extrasyn/Images/TSYNCSSYN.png create mode 100644 components/extrasyn/Images/TSYNDFMSYN.png create mode 100644 components/extrasyn/Images/TSYNDMLSYN.png create mode 100644 components/extrasyn/Images/TSYNDOTSYN.png create mode 100644 components/extrasyn/Images/TSYNEDIT.png create mode 100644 components/extrasyn/Images/TSYNEDITOPTIONSDIALOG.png create mode 100644 components/extrasyn/Images/TSYNEDITPRINT.png create mode 100644 components/extrasyn/Images/TSYNEDITPRINTPREVIEW.png create mode 100644 components/extrasyn/Images/TSYNEDITPYTHONBEHAVIOUR.png create mode 100644 components/extrasyn/Images/TSYNEDITREGEXSEARCH.png create mode 100644 components/extrasyn/Images/TSYNEDITSEARCH.png create mode 100644 components/extrasyn/Images/TSYNEXPORTERHTML.png create mode 100644 components/extrasyn/Images/TSYNEXPORTERRTF.png create mode 100644 components/extrasyn/Images/TSYNEXPORTERTEX.png create mode 100644 components/extrasyn/Images/TSYNFORTRANSYN.png create mode 100644 components/extrasyn/Images/TSYNFOXPROSYN.png create mode 100644 components/extrasyn/Images/TSYNGALAXYSYN.png create mode 100644 components/extrasyn/Images/TSYNGENERALSYN.png create mode 100644 components/extrasyn/Images/TSYNGWSCRIPTSYN.png create mode 100644 components/extrasyn/Images/TSYNHASKELLSYN.png create mode 100644 components/extrasyn/Images/TSYNHC11SYN.png create mode 100644 components/extrasyn/Images/TSYNHIGHLIGHTERMANAGER.png create mode 100644 components/extrasyn/Images/TSYNHP48SYN.png create mode 100644 components/extrasyn/Images/TSYNHTMLSYN.png create mode 100644 components/extrasyn/Images/TSYNIDLSYN.png create mode 100644 components/extrasyn/Images/TSYNINISYN.png create mode 100644 components/extrasyn/Images/TSYNINNOSYN.png create mode 100644 components/extrasyn/Images/TSYNJAVASYN.png create mode 100644 components/extrasyn/Images/TSYNJSCRIPTSYN.png create mode 100644 components/extrasyn/Images/TSYNKIXSYN.png create mode 100644 components/extrasyn/Images/TSYNLDRSYN.png create mode 100644 components/extrasyn/Images/TSYNLUASYN.png create mode 100644 components/extrasyn/Images/TSYNM3SYN.png create mode 100644 components/extrasyn/Images/TSYNMACRORECORDER.png create mode 100644 components/extrasyn/Images/TSYNMEMO.png create mode 100644 components/extrasyn/Images/TSYNMODELICASYN.png create mode 100644 components/extrasyn/Images/TSYNMSGSYN.png create mode 100644 components/extrasyn/Images/TSYNMULTISYN.png create mode 100644 components/extrasyn/Images/TSYNPASSYN.png create mode 100644 components/extrasyn/Images/TSYNPERLSYN.png create mode 100644 components/extrasyn/Images/TSYNPHPSYN.png create mode 100644 components/extrasyn/Images/TSYNPROGRESSSYN.png create mode 100644 components/extrasyn/Images/TSYNPROLOGSYN.png create mode 100644 components/extrasyn/Images/TSYNPYTHONSYN.png create mode 100644 components/extrasyn/Images/TSYNRCSYN.png create mode 100644 components/extrasyn/Images/TSYNRUBYSYN.png create mode 100644 components/extrasyn/Images/TSYNSDDSYN.png create mode 100644 components/extrasyn/Images/TSYNSMLSYN.png create mode 100644 components/extrasyn/Images/TSYNSQLSYN.png create mode 100644 components/extrasyn/Images/TSYNSTSYN.png create mode 100644 components/extrasyn/Images/TSYNTCLTKSYN.png create mode 100644 components/extrasyn/Images/TSYNTEXSYN.png create mode 100644 components/extrasyn/Images/TSYNUNIXSHELLSCRIPTSYN.png create mode 100644 components/extrasyn/Images/TSYNUNREALSYN.png create mode 100644 components/extrasyn/Images/TSYNURIOPENER.png create mode 100644 components/extrasyn/Images/TSYNURISYN.png create mode 100644 components/extrasyn/Images/TSYNVBSCRIPTSYN.png create mode 100644 components/extrasyn/Images/TSYNVBSYN.png create mode 100644 components/extrasyn/Images/TSYNVRML97SYN.png create mode 100644 components/extrasyn/Images/TSYNXMLSYN.png create mode 100644 components/extrasyn/Images/tsynEIFFELsyn.png create mode 100644 components/extrasyn/SyneditHighlighters/SynHighlighter8051.pas create mode 100644 components/extrasyn/SyneditHighlighters/SynHighlighterLua.pas create mode 100644 components/extrasyn/SyneditHighlighters/SynHighlighterProlog.pas create mode 100644 components/extrasyn/SyneditHighlighters/synedit.inc create mode 100644 components/extrasyn/SyneditHighlighters/syneditstrconstextra.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighteradsp21xx.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterasm.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterawk.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterbaan.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightercac.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightercache.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightercobol.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightercs.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterdml.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterdot.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightereiffel.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterfortran.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterfoxpro.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightergalaxy.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightergeneral.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightergws.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterhaskell.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterhp48.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighteridl.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterinno.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterkix.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterldraw.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterm3.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightermodelica.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterprogress.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterrc.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterruby.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightersdd.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightersml.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterst.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightertcltk.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighterunreal.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlighteruri.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightervbscript.pas create mode 100644 components/extrasyn/SyneditHighlighters/synhighlightervrml97.pas create mode 100644 components/extrasyn/TestHighlighters/Mat Lab 6.hgl create mode 100644 components/extrasyn/TestHighlighters/Ruby.hgl create mode 100644 components/extrasyn/TestHighlighters/TestSynHighlighter.lpi create mode 100644 components/extrasyn/TestHighlighters/TestSynHighlighter.lpr create mode 100644 components/extrasyn/TestHighlighters/lua.hgl create mode 100644 components/extrasyn/TestHighlighters/unit1.lfm create mode 100644 components/extrasyn/TestHighlighters/unit1.pas create mode 100644 components/extrasyn/extrahighlighters.lpk create mode 100644 components/extrasyn/extrahighlighters.pas create mode 100644 components/extrasyn/extrahighlighters_dsgn.lpk create mode 100644 components/extrasyn/extrahighlighters_dsgn.pas create mode 100644 components/extrasyn/images.lrs create mode 100644 components/extrasyn/images.rc create mode 100644 components/extrasyn/uhighlighterreg.pas diff --git a/components/extrasyn/Images/TDBSYNEDIT.png b/components/extrasyn/Images/TDBSYNEDIT.png new file mode 100644 index 0000000000000000000000000000000000000000..5aced1d4f7d0e0bbab9d07c3645342899e1902f6 GIT binary patch literal 253 zcmVCKa2&@9 zKc(cmaMxBL5P>kW7^IYB0A?-}jm^sCoB{0nZc__g@(M`kQ6`CeDQRW5shG-(9-0e>OaxqHk zgG@m%6){)D1BubivLvAmam)I=7C%VXq3}2S#oc)VMYEyUnFjKo00000NkvXXu0mjf Da2aZ; literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYN8051SYN.png b/components/extrasyn/Images/TSYN8051SYN.png new file mode 100644 index 0000000000000000000000000000000000000000..d43be8d21a62c695bc0279b04592b9c4313f26b2 GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWoCO|{#S9GG!XV7ZFl&wkP;j}Y zi(`nz>9Zjhg$^rlc)$De{*wNAxjCY53)bxG`MfSck#~ug@I80D5 zUhP*GyLD+YmkPs*(r1TXU7sK`>%BnA`MT$sH>OY9yyJoR%8R!r98C$f))Wi25a)it z`^fK7`$T)^oWD_dN+t1^71D&9y3^`X6<;PQ|2&odIHyV|&*b1tJ_V`iXF>zSRM-wg r%-WWO>3)0(OMy(lNmf+{an^LB{Ts51Xf+k literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNADSP21XXSYN.png b/components/extrasyn/Images/TSYNADSP21XXSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..a701697873eb4b73be5529486bb3a5de4f1fce46 GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW%ROBjLn`JRo#M#XV!*>ZSM>j~ zJvA00i@1cO4kp$rPW^C2WlP%ybKSoix4vzy%w4UbD6rO)VZwwJC-&~QmQE?VlIH&Q zXe{HQR5gM0^=>7i7th{&wodgmdKI;Vst00L1}#sB~S literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNASMSYN.png b/components/extrasyn/Images/TSYNASMSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..4d32a28678695837ff9ca93631a09ba389ec8796 GIT binary patch literal 223 zcmV<503iQ~P)LdD@C1RQ}p1>_lv8M~f%S-1d$PwYEB=My+IU-q*epCP55$Wv8OtOCb ZJ^_%pf_u8)s^|a!002ovPDHLkV1leiUR(eG literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNAUTOCOMPLETE.png b/components/extrasyn/Images/TSYNAUTOCOMPLETE.png new file mode 100644 index 0000000000000000000000000000000000000000..20b9005d6ccccc903e00c353efc3e9668f3d50eb GIT binary patch literal 256 zcmV+b0ssDqP)xvZsn;-ZnB3m|~1j%t)r5=6C+{VpVcQl9=tbq$i4i-~N8NL{!Q)zuw2_mYdf z;JlIfTBIHQU@cBg>P)%Gql-9WKq2YZ-4X^)%O<$LxI15&jG~xWH%Y_*0000$8q+UrPr+lXdG;X9Ynikpx*Y z4f!|MFT7SMEPZ^o?Y-Ml$NpTC9Rh~0-f?pa^EP}+y0K}#hRpKG3`gYdE?C+6EQ&jG q*V!tk!_PKf$O_MV-ug%O1xv_TPvZk-z6XFVV(@hJb6Mw<&;$VD;!5xU literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNAWKSYN.png b/components/extrasyn/Images/TSYNAWKSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..9f764829e1c3627616f105c71bb1c299b9dcba46 GIT binary patch literal 219 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWi#%N%Ln`JR4RPc;OJrYY*Cn(xc%jo&u$+UvNH&%tXTC&P;U3x;;tvZqYH}cjjwG~ z`n5p8aoSCtdDCCHi`rgd32d#N@iw{n?=1Bj`-G?M?5gh2O0m>Fe6US~XI-simFUE5 zKf`_<&6u8#oYO9ezgFd7J#~T;Y?e*D@%0Oqls{;nzE+eUu9*gbG){TttQD$#Qm}5_Y{G^udi$^*hIKFcJTctE7+JfQ!`up-*3!3Vm%d&$U O%;4$j=d#Wzp$PyxGghGh literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNBATSYN.png b/components/extrasyn/Images/TSYNBATSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..3218308464f09f32ef5a9b8a3c87298c27ed0517 GIT binary patch literal 335 zcmV-V0kHmwP)uSLwTWjWOk!CtY zbXcvI`;in1fKm!3*yh1w*srYp&9ktd+tdC(mNp^g_?iReTuLdeH4(Ak6n}#~a9O{+ zYa0lF7)r#Ai`HI-j6}pb)1l`&S-M5ugmJF4N4>NIIQ6K6Sf;f?1R@l{G0K%euVP4$ zr>W`*o}O#fu4WJIY^{mh>9?3v%bZBm3RQ@6r_iWVsKgs=T&CEnv`(ancHgPiCp&85 z4SDQKL^_a|XYzR zNLNx4LHBDM`CEl&?kaHa#qp(S$_j1g`-k+^8h7%^Cod{h735xILp dTj2cl`vLEMf_>HuxBUPB002ovPDHLkV1m2eU}pdT literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNCACSYN.png b/components/extrasyn/Images/TSYNCACSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..8011530baffff7bb5550eb49161545e6bb5f0ca1 GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWb39!fLn`K+opPG5*?@=Txafc1 zAD`YTnmA;gUYNP`mk{5*#J!a>1d6v_N!7m1{%GqO1}CSbB6rs;tM&0?wBRs4GwD4G zqlf$UEw4qN{G07~r+!{7ui~tKJiiVp1j?L_o_{sZ;d+R&xb33+o|2W^?WTPa;cXph z%Rcoat1q^eRfvmoo5v)7ajsJ5zXQuT)F)UhuD>nVy)H1!?EfD-##H92Nn}ZW-$&%XInR1aZ>AyeL__9>`tOO@{e7&>)}P-4 X1Z{+U`)Z%#00000NkvXXu0mjfhw)&k literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNCOMPLETIONPROPOSAL.png b/components/extrasyn/Images/TSYNCOMPLETIONPROPOSAL.png new file mode 100644 index 0000000000000000000000000000000000000000..1e82f15ef069f69223d48ce1c8c412acebfab182 GIT binary patch literal 245 zcmVs32vW_uS)WJEdP<214_6zewS{L7JIJ?9jm{8NU_j@kvvaYc zkXR@=dI6LY2D-)591-)xEejW^iXZ@kU04XY?|VgQtzBCHXzf|6AVFjnui7F*%of*m v{-v(OqeYx3C?v=4ZVL-*>fgA(_;Rp{VY}i zAR`H6~Aktce$+vc6Vr^SuYXi7M#Y zCEv`nh7_TT0`97atU98eIYo3a#v@#7CTDtrIJH!+f*cY4VhIO*~dA{>u# d&A5L3egS)Egn7EaeL4UD002ovPDHLkV1j(_Uzz{_ literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNCPPSYN.png b/components/extrasyn/Images/TSYNCPPSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..e20054254b03514bed67e0e30126a117bbab960e GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW3q4&NLn`JRopPJ6*?`CSZRUU9 zA4Q)70(Y53GS4-!7wP(tsVBg7Xx6=_n{NL*u;(TlLleu)nR%&nLud+IJswBs@p4LYP)4C^kw_sWy^ejqRhe%#rZxDeX4Lo`8nhpoN}%O7N?1ArhwB=sXY_wzCZfQ5t^ z%x>z4ZRSfi^}UOZ%Bh`Wed9tJoSD2dk|pB4NH|M@>mUy?xrlKk0Hur-_l22BA~>#O za-RzcGXtPws`*f@NeO^E+z-lRZklJ&zu)e^6quou!MAj_`HlbrBvt>lImv27+EwBm zxt;~wL4suKpSLeuG!u$O`qM2$7gv|Phi`EX^E#E7=eivB)hrTcxsos>@=-m8z5o4w Y0c(RF{%f3{VgLXD07*qoM6N<$g2lpi0RR91 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNCSSYN.png b/components/extrasyn/Images/TSYNCSSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..86a467310bdf9f4a8597dba5b6f18eeb351070dc GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWD?D8sLn`JRo#M^cY{27kJoLS< z#m@~MucQ8{>UKwQtU2*{#*qZYj_Qwd`itk-ck~xBFgP|P^VCVMs&(0R;&oAX)p_$I zZ_oMWRSccnys2l8JhBou3^5jNV=L2JbL?H-!=^tXN5zj#Wx1#kT-zj&JZ0}vF30dF z?dy6r+439L>j-A0ePVf*(N(|8Vb9(-JxwwX_sI+SW*4~>Dg5^RTkgJO7W?W6zaM{R YlCEf~U$)^;0?^G2p00i_>zopr06D2z9RL6T literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNDFMSYN.png b/components/extrasyn/Images/TSYNDFMSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..6da5e93c5ff7759c00b4685cefc3144d8dc2980f GIT binary patch literal 218 zcmV<0044v4P)9sX0QxLCR77xT(Xea}*s=6zT0DU^> zXPE`F=7_noM0hfbrxIFI?CApW%VlyD;M1&07*qoM6N<$f|J`_FaQ7m literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNDMLSYN.png b/components/extrasyn/Images/TSYNDMLSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..31f7c78e1e8df6c282e511d4ba97514ff780d43d GIT binary patch literal 254 zcmVyeVBK^&o!zb~Y*JiugYjn^9T1Cnl>Y~)|<#sB~S07*qoM6N<$ Eg6^$t1poj5 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNDOTSYN.png b/components/extrasyn/Images/TSYNDOTSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..9e53e97893f8bf4446df1b87f8a9baaa881b9100 GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz93q4&NLn`K+4UXnJpuo|5^mqKs z+6)=yQw4=5e=QZvs+{85Qug4+Atx8#_!&FrWqM`)+w1ap-;t%QuQsGCKjHGaSp2li zDz>hY6&-usexzlI2b5;Jcq&#b>&r-;npfHB`m8Q2N96m8;4?LQKX#Y|9Qot6?5td!}ZtHxqS4xO#IAY(t;?mukKK}0D|)fKaC`-e5X3z_*JJ9u5Il4M06~JP%9FC#M=%z7 zU$(TnehuW@$`Nbfl8iBaaBV5hDpH68 zCHdvvcO`G6s^K+?=+(FAM{X?)X88$RX*OqiWAS0>jDp%C{68cPT2osT1?e~S-yM;1 eo-`!)$L|aNuX~5Vg^-{C0000OA&3?6T0&U~+H6ajrV&vi01zao zs-&64XAb~ai4nF677^Q@Yx$M{-XoGZ=U>+YYR8{6?fV`=D5ZoD0Hic@Eyf7IGDSXw zlSjUrs&*+?MXg8Hp|16NyQX;Utw)~XGrHC`{Z62+qFQV(Rp5*w5osthifVCV){G*O z4W+B-?$mP5KJ{MF@E+aA^&TCdiTUtDJ5=<1)<)Am8S=mX>}8-g{_dju^5@(l00000 LNkvXXu0mjfKI?DZ literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNEDITPRINT.png b/components/extrasyn/Images/TSYNEDITPRINT.png new file mode 100644 index 0000000000000000000000000000000000000000..079740b38f5503893d1ce638cc9ab68de909cf3a GIT binary patch literal 251 zcmVF&YvGo~h{L=*JJqtv3J=h(LPp@}(^I z^{@*7e?XLIfrz3d?cxGKL@q8thc4D=5!s?Q2#br1+;y?FVDls0f05CGI|TrkS;w(J zartX~6EoLZb=)^XL|P=0LOPxF(f)o z?V_tQ2@xTga|TdK5s^?O=!NG~HK$ZZNJ_LYE+qgQ{`>CBXA+)2!Azo*a`>m@%exY0 zMzYds7Lp{Rsneb6XEuJfQy1$ZRO$ZiqMdWaibaY$DyKxaZ0vd2!om-C*{XAvr6FXcvL={78S_JY@+gu&yQfIzs9cRxKutJC#!*qOhs z&mq)8z25J=e6E{XF`&F9%*fa5tnj#CTM~fu;%g~Uv1qE==%q;Uah$~f|HsA6(d6Rl Z35+tdLy$~~rJ`oW)z9!Ag%q+`s?n^I`Gt((Xgow;k`b1<$Q``nI!pt~o z&4r6@>*(dMF+3wcq};a3xXn=pH|}IEb}#3v;B0d&@xLvIIDEP(F(}BqM$@@i)b&E* jK64<^&E!2m%-5JXSNpEg*`Jh|9- zyNTF3<|Bp#@Jv=HlM`4i^p0Z`Nw(LV)n(E5);h3=vQ60N1hv?Spca+LJT(xyDav@= z#k>DVR*Nl)HfnnHi;vAY{wVaZZLQ3OR|;H2PI1>41gk;mGN5gYJ~oD>&vHWTB?|U3 grxww9`z?C%4U*qxj1Mq7!~g&Q07*qoM6N<$f)CzbVgLXD literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNEXPORTERRTF.png b/components/extrasyn/Images/TSYNEXPORTERRTF.png new file mode 100644 index 0000000000000000000000000000000000000000..2f9126473bd75c05d2c147be33314aeea9c1aa65 GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW3q4&NLn`JhoqSuUL4m_%`mz6g z`)aCJObI+B{kU08rcqU~!`7QYZ!c4S@Oi%G1*<+Cmus(BdPZpCp{FjTtcIe`l#7I( zluI<<(mC^dtJA%h1S_Lu<-HLSljp~+Q4C}KDNv@7=KJmc#AM@r3M?H`U({?lrkvsad(vW$@+&&62Y6p?kL@^q Szo{7LSO!m5KbLh*2~7Z=Pg-&S literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNEXPORTERTEX.png b/components/extrasyn/Images/TSYNEXPORTERTEX.png new file mode 100644 index 0000000000000000000000000000000000000000..39981af40dee4a4d560595e5bf2d28b715e39351 GIT binary patch literal 229 zcmV^P)@I2t>iky~UIFEF7^VlAm2J48p4hi9#UXR7B*kqmi-O-eEvsW=M1@V8k4R>Q6L?df00000NkvXXu0mjfiH>Ci literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNFORTRANSYN.png b/components/extrasyn/Images/TSYNFORTRANSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..c5896338fab51d020b872337c9b65a56e4f5fbad GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWb39!fLn`JRopO-xumOj&@6`W# ze~aD=^ez%nir{}7q;=H4FHoSVB0RZHZ*QHz{3<2}$EH=M(q?|+_^8CI&*;SRWFNnA0dc=Olw=p8wI{zOPrK_G%Z#sR^X~W9ysiE#yrfMEK z<1_Do>*PHzSw4OZiexoRs^n8KTihw=sPJ{+ziOpRw~W_4`TOfH!{O+P((BEW%Yg1= N@O1TaS?83{1OVQFR&@XX literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNFOXPROSYN.png b/components/extrasyn/Images/TSYNFOXPROSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..23820ec9155a857ffd0e9f68efcc352b4324e0fa GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW3p`yMLn`JRo#M#X62Ren`bc%R z`g@%Yo}Y}Zg^JSIpDM2{;&8NCeO9ksuHNMRE@lSDrd6jBE8nXh?dI8|!XY@pUe>j1 zUs0mYWwjZu^OY|x4t>hO{&Vu;#nmob9^5+ez}0Q5?suU*Mp5e@M+(ODnKkLgu32NZ z=zgTqot}>@inAWg*ArMi{hZbb!PDw4kCIF*l{lB!U)ip%wAfbIYu@_%`sb|bN{?M` R%m%uZ!PC{xWt~$(6958kRcinM literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNGALAXYSYN.png b/components/extrasyn/Images/TSYNGALAXYSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..0d85da48139902e239e26fe552270691f9938a8e GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW^F3W0Ln`JRopMpk!GOnE_;~$l z{r+}CpX{T}dnDZ7Z7P#yeK`Brry03*iSu%p7#y3<`0$7Bb*}Tf^#7gmiK_wZ=0yT3 zTc$=dU0GNncB%J)a^K}L2`SnI!ps~qddFuY$)ar|Srin7JaB3}mu`ug>dXX4|3=8L{HNU4b zHno(j%ubJH*Xt2cO%wdPLHU2V-mS!?_miu81>Y8>Y$^GBM6l(|nn@fp{e|ml#QC)Q zPn7csUOjV8`J9J)byb7Ko|HZ&`NTSPPVk(c)I$ztaD0e0sv_VRIdO4 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNGWSCRIPTSYN.png b/components/extrasyn/Images/TSYNGWSCRIPTSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..6242b3512f05015ec5933aeae95b958875df9cc3 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWD?MEtLn`JRo#M#Xs=(v2yses9 zeg6K8oLNDCLdE@hyb|KFyEz>91YbTb^SN>OAal0mRgr8OFOzRg|tZ@FSvc-+75@|gjId-mXJ=msav$}7EwzG@* z<%%N$z8{t`A9=gmdKI;Vst0PuxaGXMYp literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNHC11SYN.png b/components/extrasyn/Images/TSYNHC11SYN.png new file mode 100644 index 0000000000000000000000000000000000000000..252e991f1898f6fcd4fd7ac025ec652759314c6c GIT binary patch literal 219 zcmV<103`p3P)fyQzNQqQAiUGsKD+Hd1aGzhfFMC;ribdW%RCQx zj+w>?@(5F5qXq~P(h=PAPmJ6Y(j}#o0ivy**YCAvIsL?sB^OT>UC(Cb#MevZDHtQdxsotx&CSu8{z?%4?g;A_>ngr~em_iB VczHp)>~sJC002ovPDHLkV1m@rTay3) literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNHIGHLIGHTERMANAGER.png b/components/extrasyn/Images/TSYNHIGHLIGHTERMANAGER.png new file mode 100644 index 0000000000000000000000000000000000000000..a323bf745576c665409ac02ba24288da0c0ba55d GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW^F3W0Ln`JRopP4%hyq7TyYGGJ znol>IBa;QSa`~;rFTbeylq}d(v3#-q*;~w;XE8B2Hl-b#Ep;z>S(nGhe|;9JLhn+G z%qx$qy5^S}6k7gZv+J38SL2;{(q9~(b;8y4Y)=1*E1%*-R1EEkf2~{Dy5o|@D^J_X zDCr{{%RaLNXHKfOa{QCDvZqPnp&WZ>_q8J(3lzRC`?p*9Yvp5=_s8Fhd&*aS&YPWa Q0q9f)Pgg&ebxsLQ0OTZGF#rGn literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNHP48SYN.png b/components/extrasyn/Images/TSYNHP48SYN.png new file mode 100644 index 0000000000000000000000000000000000000000..0058b315e403f510dd2c0d2e8369b24ac358280d GIT binary patch literal 229 zcmV^P)_j8T)crSkTC_}nQe18#&IKfA3FdD5;VrpMYGr~0F&oL z0?Fx`o|?Tv%L;J-6Vm?SzNMJ z)bIL{0zj4`Wr--P@3V+leTaT!31MU=9^pz;^mGAXDmK1?93ng+spzmD5J^G$qW)VE fraja!KL38-Y&eN=m^($f00000NkvXXu0mjf(1>0F literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNHTMLSYN.png b/components/extrasyn/Images/TSYNHTMLSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..a0e859baac578361122eeaf4ad21b15cff9f78c0 GIT binary patch literal 218 zcmV<0044v4P)VP6b`BO(co{_%f_SIBeNH_e6d!s306~JP%A4x7o281x zv6K6?C21p7WCWo+!sd}95V^)RBFmd7T}YkvgJ{mJ|H-&^QP=L~V%*a%hUp>p2)fj~ za_z#i>WF$}is)ta>!tD(#0Yn&NK9H2BZ3X7H}&5gk-Imv7ruXfKib=V Ub=izaMF0Q*07*qoM6N<$g4RG?d;kCd literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNIDLSYN.png b/components/extrasyn/Images/TSYNIDLSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..7844da0fcaaf88fdcb1e149b04c8a33fca9fc434 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW(>z@qLn`K+of62`V8G$reRJ>8 z$=CZeg=F$xwVNGlr;Z=j7&8c{tXQ>2bM;)Nh?HubZSQ9)HQC%V z-Jy}EEcaqQhxC%AX5#j->xGIo$(IW}(p&UhIepIVgcFxElAcK{F#P5`amVyaj7|dYLtbTHe(U&gl{SNb%8FHUrd-uij9X%#+$H!VFl}m% z`n5twxyPB}!M}I{!|Uqno-W#vzw?P3xAE48f+hRaxL@r0u%_@xMXGROnwEb-=d!|O z(jAvip9mFDzEh?)af_N8OJk4u*Y|xMMe~AB{(fD~{`qN1sZqs`0-*aCJYD@<);T3K F0RS1%Q?&p9 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNINNOSYN.png b/components/extrasyn/Images/TSYNINNOSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..a4cd1c4c80acccd23100189f2b97a2cf50a88be5 GIT binary patch literal 330 zcmV-Q0k!^#P)$$x%6w@h zkRa9r$3%|*$`yIHESO|n6dQnkQit8y*QrLHYr@kp`^NMj(NlPe|FgvR%!LGhI^hF2 cU%$WN4>$eT!H4VZCjbBd07*qoM6N<$f>&0UfB*mh literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNJAVASYN.png b/components/extrasyn/Images/TSYNJAVASYN.png new file mode 100644 index 0000000000000000000000000000000000000000..970bd7c8b93eb906014b6878e98e786eaff9682d GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW%ROBjLn`JRopO+`#el=5z4w3a z-%lSKHpP}@t&n>X;2A6zyh6g!X7f?|=-YWL>vLHdnpmQ<=WOZttFqzdmT5f-`~e&8 zbbhsO4|8l1S^l)n?aP8k``o^)yz`ygE3@0LTmdKI;Vst0DqudApigX literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNJSCRIPTSYN.png b/components/extrasyn/Images/TSYNJSCRIPTSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..96c2038d39c8d88d06f405b50f2f89a3dd05fd84 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWvproLLn`JRonk1~Y{28JD)(J& zPK@jyg`-FMG@Z9@SkSM;9xQM#bL;VY-{j9k-)3-_u;AJ(xmREGPP(56n#Qwmv8vJG zv%wQ4SiO^cWbHjEX|B?lIZI|J3vJf4=?D#&=zs9^!mHLDm2!&TvlKmN9NPS|sadza{+Z3^85|}o*!_87*?W^sXCLhgYREYI^ ziNrFa$;Um!0&P7{w)QNP(^D-L#99*mq=U#if>Gr<^dv3BZG_lN_sdjab_jxt_(%oOThBt9c z+UFPVuaIZjuCOq#!BT0G<&1oanTaM#?5@=Nx4g8|?0A3uJ-eZCMXiW(Vm#2D N44$rjF6*2UngH4TS6%=B literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNLUASYN.png b/components/extrasyn/Images/TSYNLUASYN.png new file mode 100644 index 0000000000000000000000000000000000000000..1d2c0f85f15f123a7659c937945d57250fb32073 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWoCO|{#S9GG!XV7ZFl&wkP;j!R zi(`nz>9ZlH`5F{>UQhbF{qyP92RniVx#I4$x^G+dR>Do-{-N)wy`_sPI$0SwgnBsm z+*W?=$zt17bVmBYq++hXN1YZt7dHm0UuxIzjI8N=wbb5t*YQg0P<@?^DwX2P95(2t zb+DfFRIExpf9|oW^dwV#-Lm(1I%S=`ZmdKI;Vst04zgN;Q#;t literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNM3SYN.png b/components/extrasyn/Images/TSYNM3SYN.png new file mode 100644 index 0000000000000000000000000000000000000000..3b28c0bcce09b3f1494d394e929716dbef7fa395 GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW^F3W0Ln`JRopO+`#eu`Qd**+! z{d?q2OyXopynguG0`}$SnYsjySnKYNt@@i__mzdAi6wMu{HeXipX4eDXwFyTFyGP3 z5*hSKB&}e!W8|0G5Rdsuz5;3Mf>b!Hf9(mA61}9oY{J^4cf2bmyRaO-xUbF5HRY^e zaeC(mgJZ%uYc>D9Wcqm0D3aAusis3^*2O0sOB6pZ{8z1XDQ9Zfr@FuQzVXymCRW#; Q1v-_%)78&qol`;+0Oy@oApigX literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNMACRORECORDER.png b/components/extrasyn/Images/TSYNMACRORECORDER.png new file mode 100644 index 0000000000000000000000000000000000000000..0038e48fe2925c84306c1c3c434256be7b0dfcf0 GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW3q4&NLn`K+opO=yhyn-8P4EBG ze?IMHmwL<@k_@N^yB4saUoF^0UHGkM8ZCxi=&gG#uP; RZ4%J244$rjF6*2UngHj{RmlJV literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNMEMO.png b/components/extrasyn/Images/TSYNMEMO.png new file mode 100644 index 0000000000000000000000000000000000000000..28cb960adb8ba36ca34bf04df9d6f4dbfaaba00f GIT binary patch literal 236 zcmVlZTU36toJZPoZz8ea*LTG(57W!CJ66h_FrOp0A9ENfFMC6bu$Wfs#(oq zF%nZ)n`QjEu4XxxFQw%9fT@iDB1sa+wHLm1${8CeHlK(3nj#w6)d>yFfEmcXksoyA zS literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNMSGSYN.png b/components/extrasyn/Images/TSYNMSGSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..3ee16bad472f847df15d57217f29c4961208526c GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW%ROBjLn`JRopMm9#el=PdGmkW zx=I^^=!s3;uMfr?k^C&xwN~JWaqXLpFTb@{UKM5F5DE#scjbfLJgrGrlqzMVKl*)o zqB!|hHs||i^7E@=mUbB2=J{&aoTTiSW{@%UMazfR{I^{lf-jwjJu7Uv>5{uY^Ae7- zMdraSVe%Ktr*#M(t6mdKI;Vst0CPE8vj6}9 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNMULTISYN.png b/components/extrasyn/Images/TSYNMULTISYN.png new file mode 100644 index 0000000000000000000000000000000000000000..e0406ce7abf1c88a1fda6c56545858fdfa8d1524 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWvproLLn`JRopMm9L4m_%`m+Ch z`)aIB6jw?-Rn)uc^Sfq&DvM$G>&ly@{{`-qFf%lk%{-?j|@8w%=g$7Qnsoyp+o L>gTe~DWM4fk!e#^ literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNPASSYN.png b/components/extrasyn/Images/TSYNPASSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..c38e501af21bc6eea21c9efbdff1035304860783 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWD?D8sLn`JRopO+`#el;l-R$4? zucwbYi%PQ`&hwqteZ}CsO*jzpwaYP|b+$mN}0#xv8hNw+_6?7Y;@ zX4F#oVU5+Ibv}Y=%RYBxtEZ$}InIgG3U}-&*d1`_a7L2L2j^GLf4{p($Q^bn`1k8B ZBiFgQTBccNvw&`9@O1TaS?83{1OSCUTJ8V< literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNPERLSYN.png b/components/extrasyn/Images/TSYNPERLSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..66c27fdb489a388f2c868a8b5e7ddd504be86a87 GIT binary patch literal 220 zcmV<203-j2P)2y5EX{+J%yb@cwKTfZ0pjJQ@)Y=p;W$Z1TH_;}g4CP(?~d^HJ_X|X^ZNui W?s$7#8Vafa0000#*|9|6&f=Ct)p)RSpPaiw|IsGBhX^q=#qc=xS&uuZ{H%^L~r5((|eOqr= zMZ=3UKe@uYU2o?53B>D94HQsrlh)jMB_y+lgKx>bEA{0qM>&mI@Auzlp5akhQGRzq Q0nn)op00i_>zopr0H35;TL1t6 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNPROGRESSSYN.png b/components/extrasyn/Images/TSYNPROGRESSSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..15b03089dd715fbf7c37071abfa05c195513dda8 GIT binary patch literal 225 zcmV<703QE|P)-00arDD!ZV+!TldGUcgujr)$!Kas(UAF2|2+{YkKsUa b|N4Cb`=W$>q&q<300000NkvXXu0mjf0)Jms literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNPROLOGSYN.png b/components/extrasyn/Images/TSYNPROLOGSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..e2c11f4f245c27463c8850696f5e8a8b6977eec7 GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWoCO|{#S9GG!XV7ZFl&wkP;ic? zi(`nz>9bQ#^Bqy(aMkDhAN%`hy4cx>WM(_7?!?6^P1l(-IQAOvpSF39^g(w^70yPD zr3?)%E?bYR-FPp}RQS&9J8$JbF^jDgc)4#$@$#UO<@$fKwdRFsUMab2I?ubqEL+R0 zAZqa|L(3%0oneEP)ZVQ$<%!&;pwMHN7_824+|xE&?5 za-1p};Hpb6qULr%abes$!Fsjn$&~opijRc&|jqx%h&McaH3hEF7vL81vFjU8HSss#! zrn9AhQprup_vIed!!S?KPydb9GipCA2PJA#)wKSF*bXf)41-zoD?8~Flmt(1Y6^u)dQ7e7$gKhLe8jQ{`u07*qoM6N<$g7iIm8~^|S literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNRCSYN.png b/components/extrasyn/Images/TSYNRCSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..4ab12032496814c5f2544bad3012925dc46bd3e2 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW^E_P~Ln`JRopMm9MS;h8vh4rc zzn*?vaM~gB?yB~)t|>2+a~Zh~S?eB8-~86`LzXrJhfqq|u9afD&*XfP@i^QwsmK1| z8kUzmD(&|p8@qFEKi8Al{_4=fb=iUnw=Pu*X!$*vwuie+a`k%mcSn>%a-5I0re78O zdP3yl85x^J+P+20g^yhKeyX{{>H)JszHbi)S5W?|{nm%xsQnYVZ@=GqHbYBcZ;nt5 P(4`EXu6{1-oD!MO{nYoq z;!iIR=_*R31m$-rNk+~)&Qjl^@NH4=!#B_QA1#(=aF~$relEZB*7axiGZZMg*xi?T zn9{)D&=kWV*72}ukCyg1)ongkThH~kJX2ZnwnRsL^Tjo3Gh5cQRd;CmzJ9WL_TCDX zyOYk;9&Js(Dp;D@6=2+~Zm`z#T}ji0XQK0(Bp&*ScUESLbu3V zmjrihc1}Pcm!j|Ndi0Ti8)- TwO=V5=voF(S3j3^P6t?zE#URAlVb>)p++->DA_q|ct^s1w3 zsmqr%sq+RsZg(;pe|!syWVKX^F%vSs_@pC6;cLMExgASyFH@-AUuS=6ZB6z>)o;>3 Pmoj*|`njxgN@xNA8p&8G literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNSQLSYN.png b/components/extrasyn/Images/TSYNSQLSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..1c41eacff69145a57b8086a29e38c373f75617f4 GIT binary patch literal 217 zcmV;~04D#5P)NklP$7b6P&8w{dAV`pz>88B*)qf|M zpXUhjXoz(eK|+Fb)aObN-rUrZx^R$m&B|Rw^IlhpZfvB|9E8EQ_822m7oo}S&Nq TUKfOX00000NkvXXu0mjfFOOhJ literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNSTSYN.png b/components/extrasyn/Images/TSYNSTSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..61c5d6cedff116f85258fb7bb90b4773ba267064 GIT binary patch literal 214 zcmV;{04e{8P)Ncbv%EicJUlx%VLEMWi9)}-4h_YqvktZwJ1d*~*!UCeHY`K^wBOYrfc3jv{2FI3a8x_H_wb2sk zqO$skzEUF6Oz;fDrx7zP5HByCt6=hjpFrK3`IzaHK>WKSwmM!Zynp>Z0e}g3dvZA} Qy#N3J07*qoM6N<$f-_uL!~g&Q literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNTCLTKSYN.png b/components/extrasyn/Images/TSYNTCLTKSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..82d2ac0d96076944a484ef63be4994e376c9c8d8 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubWGd*1#Ln`JRopO+`L4n6P`f*Su+kP z&$`4?ZsiaYY2@G7|Ki-F7RT(Gmf#6B!T;ZJ9G|W!_I&<*<_@cpT5W0DW}qV(JYD@< J);T3K0RS(}Pa>i+5EE1dCw~@1{Tg$TKdPX>|=^}vT3?}%S(0F zlpY8EOfh>!MW&)R%KN2?*4)}AB)F(@g|f?uw773~SOjz4@BG)pd1(E{iW2p5MLpBK zle?zxOqdaVs#tvDRrfDbRg-2J&N~q6`_W&#qkp=e_6fm>;2aP``y5(_jX1UFvwa?onTrQ%?wx~CjlSc;c!XSNp`@V; z&#EKpnIYmf(|N>Dn&3z&{=}Rqc9#O0IO5 z;DNnUbf0|{*F16Cfa^i<@s58xzMr)?U6fV4`s{DXR|5b5 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNURIOPENER.png b/components/extrasyn/Images/TSYNURIOPENER.png new file mode 100644 index 0000000000000000000000000000000000000000..12c87a735ade84b23bbf6953336acf7da87df75b GIT binary patch literal 268 zcmV+n0rUQeP){1_qwka`pVCYNOjevFFgVmhzPSZk!?kPArKJ&)LZ7+NA2~u{F>@DvR3ps z7C>m*7@Y58Y;6d2O6uJ0D}qH>;mji&sJ*OHg{5vwky+o75kLl92NZBBT>V7n1lw$h z=f@%&TZ@g*B$_Vq#z2-*f>YaUQ&dWcnQs6Ek#qKr+{s=$6#y-Zg9NK zpI;Mh8szWPcp)J8a$T`{u;K)BgT0HCl!{~5ZnJx!zwM1S$0-A2m4`3qE?znBbLsrX zYaA-fYVNJ8)*HQ2`+cxBYaVBcjA)vTeW6JQzg|k~E~5kCt#i9L7b>>=QFLFM6sB>s zzokqhzM)H7^1Wruiw~wZHmnFJZf5L!yx3`O|K^YXHBEb~!#V!m)!xKda;C1->(rGl Qpi>zD>7Ubur|TIh)rqq%y^$2!; zwsxNIJn++Ry`pWpN3Qlg3^;NpXesBNrtV;IK|#LC*N}Vec}XH+r4g$qq*l(djv#kNwH=3p>znLt3KdN&o-=07*qoM6N<$g6DOfegFUf literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/TSYNXMLSYN.png b/components/extrasyn/Images/TSYNXMLSYN.png new file mode 100644 index 0000000000000000000000000000000000000000..90f215833dbfb4f91c57c5a05a574bf3387dcb2c GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1SGw${mubW^E_P~Ln`JRopO-xumX?s+m-+C zemT9DIjYs?P=w_fb}fO*87*y18rLiy6;`*?hQS*)8aW2hKb z)WRYZWEbnSrQzR=%9^GhT9@9J-sme!v+sMoThDDLcbVSR^re0$D+F);*~y*0R{5H; z_mSLXA3O9+kJ`s7*u{lKIreQhuACS&OJ<@<%H9?K*Ks_LT`2bb_Iqjj!!^|}gqoXy PE@kj^^>bP0l+XkKwdYs3 literal 0 HcmV?d00001 diff --git a/components/extrasyn/Images/tsynEIFFELsyn.png b/components/extrasyn/Images/tsynEIFFELsyn.png new file mode 100644 index 0000000000000000000000000000000000000000..c6398a741398e9b9ff1724f27c4550189db4e13e GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*O%l>?NMQuI#sXganl(+qZv|0t!i%xJHyX=jZ08 z=9Mrw7o{eaq^2m8XO?6rxO@5rgg5eu0~Kxdba4#vIDT|mq)>|jkIQAvclA%r8Of`bo%pKqUR+ft_~n~?)mNN{$|Z8G7|x{3T=dK6 z_7lk?UR+;m*4pg3&s?@pBP;LA`Rj|*ZJXsX>`wley*1y`GuEI-)oI4EcWV9;|6e`u zh`g#MW9O@CYsR@lQtIYM%^)emD_jCAo;iN)sd$hk;+Hjl+5UMamtIz{%SrLO^83{M gDf{2<+g8KyBsAQw{^Hptpz|3#UHx3vIVCg!0Hk1lb^rhX literal 0 HcmV?d00001 diff --git a/components/extrasyn/SyneditHighlighters/SynHighlighter8051.pas b/components/extrasyn/SyneditHighlighters/SynHighlighter8051.pas new file mode 100644 index 000000000..9f512dedb --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/SynHighlighter8051.pas @@ -0,0 +1,551 @@ +{------------------------------------------------------------------------------- +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: SynHighlighter8051.pas, the Initial +Author of this file is Zhou Kan. +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: SynHighlighter8051.pas,v 1.00 2005/01/24 17:58:27 Kan Exp $ + +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 8051 Assembler highlighter for SynEdit) +@author(Zhou Kan [textrush@tom.com]) +@created(June 2004) +@lastmod(2005-01-24) +The SynHighlighter8051 unit provides SynEdit with a 8051 Assembler (*.a51;*.asm;*.s03) highlighter. +The highlighter formats 8051 source code highlighting keywords, strings, numbers and characters. +} + +unit SynHighlighter8051; + +//SynEdit.inc is the synedit.inc from laz 1.2.0 synedit package source if it has changed +//in newer version you might need to copy it again. Remember to redclare the syn_lazarus define. +{$I synedit.inc} + +interface + +uses + SysUtils, Classes, Graphics, SynEditHighlighter, SynEditTypes, + SynEditStrConst, SynHighlighterHashEntries; + +type + TtkTokenKind = (tkComment, tkDirective, tkIdentifier, tkKey, tkNull, + tkNumber, tkRegister, tkSpace, tkString, tkSymbol, tkUnknown); //Kan + + TProcTableProc = procedure of object; + +type + TSyn8051Syn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fCommentAttri: TSynHighlighterAttributes; + fDirectiveAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fRegisterAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fKeywords: TSynHashEntryList; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + procedure CommentProc; + procedure CRProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure NullProc; + procedure NumberProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure SingleQuoteStringProc; + procedure SymbolProc; + procedure UnknownProc; + procedure DoAddKeyword(AKeyword: string; AKind: integer); + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored :boolean; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + class function GetLanguageName :string; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property DirectiveAttri: TSynHighlighterAttributes read fDirectiveAttri write fDirectiveAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property RegisterAttri: TSynHighlighterAttributes read fRegisterAttri write fRegisterAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation +uses + SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +//Keywords +const + OpCodes: string = + 'acall,add,addc,ajmp,anl,call,cjne,clr,cpl,da,dec,div,djnz,inc,jb,jbc,jc,jmp,' + + 'jnc,jnb,jnz,jz,lcall,ljmp,mov,movc,movx,mul,nop,orl,pop,push,ret,reti,rl,rlc,' + + 'rr,rrc,setb,sjmp,subb,swap,xch,xrl'; + + RegCodes: string = + 'a,ab,acc,b,c,dph,dpl,dptr,r0,r1,r2,r3,r4,r5,r6,r7,sp,psw'; + + DirectCodes: string = + 'aseg,bseg,common,cseg,db,dbit,ds,dseg,dw,end,endif,endmod,else,equ,extern,' + + 'extrn,high,iseg,low,lstpag,module,name,org,page,pagsiz,public,rseg,segment,' + + 'set,titel,titl,using,xseg'; + +procedure MakeIdentTable; +var + c: char; +begin + FillChar(Identifiers, SizeOf(Identifiers), 0); + for c := 'a' to 'z' do + Identifiers[c] := True; + for c := 'A' to 'Z' do + Identifiers[c] := True; + for c := '0' to '9' do + Identifiers[c] := True; + Identifiers['_'] := True; + + FillChar(mHashTable, SizeOf(mHashTable), 0); + for c := 'a' to 'z' do + mHashTable[c] := 1 + Ord(c) - Ord('a'); + for c := 'A' to 'Z' do + mHashTable[c] := 1 + Ord(c) - Ord('A'); + for c := '0' to '9' do + mHashTable[c] := 27 + Ord(c) - Ord('0'); +end; + +function TSyn8051Syn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while Identifiers[ToHash^] do + begin +{$IFOPT Q-} + Result := 7 * Result + mHashTable[ToHash^]; +{$ELSE} + Result := (7 * Result + mHashTable[ToHash^]) and $FFFFFF; +{$ENDIF} + inc(ToHash); + end; + Result := Result and $3FF; + fStringLen := ToHash - fToIdent; +end; + +function TSyn8051Syn.KeyComp(const aKey: String): Boolean; +var + i: integer; + pKey1, pKey2: PChar; +begin + pKey1 := fToIdent; + // Note: fStringLen is always > 0 ! + pKey2 := pointer(aKey); + for i := 1 to fStringLen do + begin + if mHashTable[pKey1^] <> mHashTable[pKey2^] then + begin + Result := FALSE; + exit; + end; + Inc(pKey1); + Inc(pKey2); + end; + Result := TRUE; +end; + +procedure TSyn8051Syn.DoAddKeyword(AKeyword: string; AKind: integer); +var + HashValue: integer; +begin + HashValue := KeyHash(PChar(AKeyword)); + fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind); +end; + +function TSyn8051Syn.IdentKind(MayBe: PChar): TtkTokenKind; +var + Entry: TSynHashEntry; +begin + fToIdent := MayBe; + Entry := fKeywords[KeyHash(MayBe)]; + while Assigned(Entry) do + begin + if Entry.KeywordLen > fStringLen then + break + else if Entry.KeywordLen = fStringLen then + if KeyComp(Entry.Keyword) then + begin + Result := TtkTokenKind(Entry.Kind); + exit; + end; + Entry := Entry.Next; + end; + Result := tkIdentifier; +end; + +procedure TSyn8051Syn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0 : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NullProc; + #10 : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LFProc; + #13 : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CRProc; + #34 : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}StringProc; + #39 : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SingleQuoteStringProc; + '>' : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}GreaterProc; + '<' : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LowerProc; + '/' : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SlashProc; + 'A'..'Z', 'a'..'z', '_': + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}IdentProc; + '0'..'9': + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NumberProc; + #1..#9, #11, #12, #14..#32: + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SpaceProc; + ';': + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CommentProc; + '.', ':', '&', '{', '}', '=', '^', '-', '+', '(', ')', '*', '#': + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SymbolProc; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}UnknownProc; + end; +end; + +constructor TSyn8051Syn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fKeywords := TSynHashEntryList.Create; + + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Foreground := clGreen; + AddAttribute(fCommentAttri); + + fDirectiveAttri := TSynHighLighterAttributes.Create(SYNS_AttrDirective); + fDirectiveAttri.Foreground := $00A00000; + AddAttribute(fDirectiveAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + fIdentifierAttri.Foreground := clWindowText; + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Foreground := clBlue; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighLighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clPurple; + AddAttribute(fNumberAttri); + + fRegisterAttri := TSynHighLighterAttributes.Create(SYNS_AttrRegister); + fRegisterAttri.Foreground := $00C05000; + AddAttribute(fRegisterAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrWhitespace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clMaroon; + AddAttribute(fStringAttri); + + fSymbolAttri := TSynHighLighterAttributes.Create(SYNS_AttrSymbol); + fSymbolAttri.Foreground := clNavy; + AddAttribute(fSymbolAttri); + + MakeMethodTables; + + //Keywords list //Kan + EnumerateKeywords(Ord(tkKey), OpCodes, IdentChars, {$IFDEF FPC}@{$ENDIF}DoAddKeyword); + EnumerateKeywords(Ord(tkRegister), RegCodes, IdentChars, {$IFDEF FPC}@{$ENDIF}DoAddKeyword); + EnumerateKeywords(Ord(tkDirective), DirectCodes, IdentChars, {$IFDEF FPC}@{$ENDIF}DoAddKeyword); + + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + fDefaultFilter:= SYNS_FilterX86Asm; +end; + +destructor TSyn8051Syn.Destroy; +begin + fKeywords.Free; + inherited Destroy; +end; + +procedure TSyn8051Syn.SetLine(const NewValue :String; LineNumber :Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSyn8051Syn.CommentProc; +begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSyn8051Syn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then Inc(Run); +end; + +procedure TSyn8051Syn.GreaterProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] = '=' then Inc(Run); +end; + +procedure TSyn8051Syn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSyn8051Syn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSyn8051Syn.LowerProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] in ['=', '>'] then Inc(Run); +end; + +procedure TSyn8051Syn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSyn8051Syn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'a'..'f', 'h', 'A'..'F', 'H'] do + Inc(Run); +end; + +procedure TSyn8051Syn.SlashProc; +begin + Inc(Run); + if fLine[Run] = '/' then begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end else + fTokenID := tkSymbol; +end; + +procedure TSyn8051Syn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + Inc(Run); + until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]); +end; + +procedure TSyn8051Syn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then + inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSyn8051Syn.SingleQuoteStringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #39) and (FLine[Run + 2] = #39) then + inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSyn8051Syn.SymbolProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSyn8051Syn.UnknownProc; +begin + {$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run,2) + else + {$ENDIF} + Inc(Run); + fTokenID := tkIdentifier; +end; + +procedure TSyn8051Syn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +class function TSyn8051Syn.GetLanguageName :string; +begin + Result := SYNS_Lang8051; +end; + +function TSyn8051Syn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSyn8051Syn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSyn8051Syn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSyn8051Syn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSyn8051Syn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkDirective: Result := fDirectiveAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkRegister: Result := fRegisterAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSyn8051Syn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSyn8051Syn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSyn8051Syn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSyn8051Syn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSyn8051Syn.IsFilterStored :boolean; +begin + Result := (fDefaultFilter <> SYNS_FilterX86Asm); +end; + +initialization + MakeIdentTable; + {$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSyn8051Syn); + {$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/SynHighlighterLua.pas b/components/extrasyn/SyneditHighlighters/SynHighlighterLua.pas new file mode 100644 index 000000000..1c5884aae --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/SynHighlighterLua.pas @@ -0,0 +1,1448 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterLua.pas, the Initial +Author of this file is Zhou Kan. +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: SynHighlighterLua.pas,v 1.00 2005/01/24 17:58:27 Kan Exp $ + +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 Lua Script highlighter for SynEdit) +@author(Zhou Kan [textrush@tom.com]) +@created(June 2004) +@lastmod(2005-01-24) +The SynHighlighterLua unit provides SynEdit with a Lua Script (*.lua) highlighter. +The highlighter formats Lua Script source code highlighting keywords, strings, numbers and characters. +} + +unit SynHighlighterLua; + + //SynEdit.inc is the synedit.inc from laz 1.2.0 synedit package source if it has changed + //in newer version you might need to copy it again. REmeber to redclare the syn_lazarus define. +{$I synedit.inc} + +interface + +uses + SysUtils, Classes, Graphics, SynEditHighlighter, SynEditTypes, SynEditStrConst; + +type + TtkTokenKind = ( + tkComment, + tkFunction, + tkIdentifier, + tkKey, + tkNull, + tkNumber, + tkSpace, + tkString, + tkSymbol, + tkUnknown); + + TRangeState = (rsUnKnown, rsComment, rsString, rsQuoteString, rsMultilineString); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +const + MaxKey = 185; + +type + TSynLuaSyn = class(TSynCustomHighlighter) + private + fLineRef: string; + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + fRange: TRangeState; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0 .. MaxKey] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fFunctionAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func17: TtkTokenKind; + function Func19: TtkTokenKind; + function Func21: TtkTokenKind; + function Func22: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func34: TtkTokenKind; + function Func35: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func46: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func60: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func92: TtkTokenKind; + function Func94: TtkTokenKind; + function Func95: TtkTokenKind; + function Func97: TtkTokenKind; + function Func99: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func105: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func112: TtkTokenKind; + function Func113: TtkTokenKind; + function Func114: TtkTokenKind; + function Func116: TtkTokenKind; + function Func117: TtkTokenKind; + function Func125: TtkTokenKind; + function Func130: TtkTokenKind; + function Func132: TtkTokenKind; + function Func135: TtkTokenKind; + function Func137: TtkTokenKind; + function Func138: TtkTokenKind; + function Func141: TtkTokenKind; + function Func143: TtkTokenKind; + function Func144: TtkTokenKind; + function Func147: TtkTokenKind; + function Func149: TtkTokenKind; + function Func185: TtkTokenKind; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure NullProc; + procedure SpaceProc; + procedure CRProc; + procedure LFProc; + procedure IdentProc; + procedure NumberProc; + procedure UnknownProc; + procedure CommentProc; + procedure StringProc; + procedure QuoteStringProc; + procedure StringEndProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure GreaterProc; + procedure LowerProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure ColonProc; + procedure CommaProc; + procedure SemiColonProc; + procedure PointProc; + procedure DirectiveProc; + procedure EqualProc; + procedure PlusProc; + procedure StarProc; + procedure SlashProc; + procedure ModSymbolProc; + procedure AndSymbolProc; + procedure NotSymbolProc; + procedure OrSymbolProc; + procedure TildeProc; + procedure ArrowProc; + procedure QuestionProc; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + constructor Create(AOwner: TComponent); override; + function GetRange: Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart :PChar; out TokenLength :integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + class function GetLanguageName :string; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property FunctionAttri: TSynHighlighterAttributes read fFunctionAttri write fFunctionAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable : array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', 'a'..'z', 'A'..'Z', '0'..'9': Identifiers[I] := True; + else + Identifiers[I] := False; + end; + case I in ['_', 'A'..'Z', 'a'..'z'] of + True: + begin + if (I > #64) and (I < #91) then + mHashTable[I] := Ord(I) - 64 + else if (I > #96) then + mHashTable[I] := Ord(I) - 95; + end; + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynLuaSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := {$IFDEF FPC}@{$ENDIF}AltFunc; + Inc(pF); + end; + fIdentFuncTable[17] := {$IFDEF FPC}@{$ENDIF}Func17; + fIdentFuncTable[19] := {$IFDEF FPC}@{$ENDIF}Func19; + fIdentFuncTable[21] := {$IFDEF FPC}@{$ENDIF}Func21; + fIdentFuncTable[22] := {$IFDEF FPC}@{$ENDIF}Func22; + fIdentFuncTable[25] := {$IFDEF FPC}@{$ENDIF}Func25; + fIdentFuncTable[26] := {$IFDEF FPC}@{$ENDIF}Func26; + fIdentFuncTable[31] := {$IFDEF FPC}@{$ENDIF}Func31; + fIdentFuncTable[32] := {$IFDEF FPC}@{$ENDIF}Func32; + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF}Func33; + fIdentFuncTable[34] := {$IFDEF FPC}@{$ENDIF}Func34; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF}Func35; + fIdentFuncTable[37] := {$IFDEF FPC}@{$ENDIF}Func37; + fIdentFuncTable[38] := {$IFDEF FPC}@{$ENDIF}Func38; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF}Func39; + fIdentFuncTable[40] := {$IFDEF FPC}@{$ENDIF}Func40; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF}Func41; + fIdentFuncTable[42] := {$IFDEF FPC}@{$ENDIF}Func42; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF}Func44; + fIdentFuncTable[45] := {$IFDEF FPC}@{$ENDIF}Func45; + fIdentFuncTable[46] := {$IFDEF FPC}@{$ENDIF}Func46; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF}Func47; + fIdentFuncTable[48] := {$IFDEF FPC}@{$ENDIF}Func48; + fIdentFuncTable[49] := {$IFDEF FPC}@{$ENDIF}Func49; + fIdentFuncTable[50] := {$IFDEF FPC}@{$ENDIF}Func50; + fIdentFuncTable[51] := {$IFDEF FPC}@{$ENDIF}Func51; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF}Func52; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF}Func53; + fIdentFuncTable[56] := {$IFDEF FPC}@{$ENDIF}Func56; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF}Func57; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF}Func60; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF}Func62; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF}Func63; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF}Func66; + fIdentFuncTable[67] := {$IFDEF FPC}@{$ENDIF}Func67; + fIdentFuncTable[70] := {$IFDEF FPC}@{$ENDIF}Func70; + fIdentFuncTable[71] := {$IFDEF FPC}@{$ENDIF}Func71; + fIdentFuncTable[73] := {$IFDEF FPC}@{$ENDIF}Func73; + fIdentFuncTable[74] := {$IFDEF FPC}@{$ENDIF}Func74; + fIdentFuncTable[75] := {$IFDEF FPC}@{$ENDIF}Func75; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF}Func76; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF}Func78; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF}Func79; + fIdentFuncTable[80] := {$IFDEF FPC}@{$ENDIF}Func80; + fIdentFuncTable[81] := {$IFDEF FPC}@{$ENDIF}Func81; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF}Func82; + fIdentFuncTable[83] := {$IFDEF FPC}@{$ENDIF}Func83; + fIdentFuncTable[84] := {$IFDEF FPC}@{$ENDIF}Func84; + fIdentFuncTable[88] := {$IFDEF FPC}@{$ENDIF}Func88; + fIdentFuncTable[89] := {$IFDEF FPC}@{$ENDIF}Func89; + fIdentFuncTable[90] := {$IFDEF FPC}@{$ENDIF}Func90; + fIdentFuncTable[92] := {$IFDEF FPC}@{$ENDIF}Func92; + fIdentFuncTable[94] := {$IFDEF FPC}@{$ENDIF}Func94; + fIdentFuncTable[95] := {$IFDEF FPC}@{$ENDIF}Func95; + fIdentFuncTable[97] := {$IFDEF FPC}@{$ENDIF}Func97; + fIdentFuncTable[99] := {$IFDEF FPC}@{$ENDIF}Func99; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF}Func101; + fIdentFuncTable[102] := {$IFDEF FPC}@{$ENDIF}Func102; + fIdentFuncTable[105] := {$IFDEF FPC}@{$ENDIF}Func105; + fIdentFuncTable[107] := {$IFDEF FPC}@{$ENDIF}Func107; + fIdentFuncTable[108] := {$IFDEF FPC}@{$ENDIF}Func108; + fIdentFuncTable[110] := {$IFDEF FPC}@{$ENDIF}Func110; + fIdentFuncTable[111] := {$IFDEF FPC}@{$ENDIF}Func111; + fIdentFuncTable[112] := {$IFDEF FPC}@{$ENDIF}Func112; + fIdentFuncTable[113] := {$IFDEF FPC}@{$ENDIF}Func113; + fIdentFuncTable[114] := {$IFDEF FPC}@{$ENDIF}Func114; + fIdentFuncTable[116] := {$IFDEF FPC}@{$ENDIF}Func116; + fIdentFuncTable[117] := {$IFDEF FPC}@{$ENDIF}Func117; + fIdentFuncTable[125] := {$IFDEF FPC}@{$ENDIF}Func125; + fIdentFuncTable[130] := {$IFDEF FPC}@{$ENDIF}Func130; + fIdentFuncTable[132] := {$IFDEF FPC}@{$ENDIF}Func132; + fIdentFuncTable[135] := {$IFDEF FPC}@{$ENDIF}Func135; + fIdentFuncTable[137] := {$IFDEF FPC}@{$ENDIF}Func137; + fIdentFuncTable[138] := {$IFDEF FPC}@{$ENDIF}Func138; + fIdentFuncTable[141] := {$IFDEF FPC}@{$ENDIF}Func141; + fIdentFuncTable[143] := {$IFDEF FPC}@{$ENDIF}Func143; + fIdentFuncTable[144] := {$IFDEF FPC}@{$ENDIF}Func144; + fIdentFuncTable[147] := {$IFDEF FPC}@{$ENDIF}Func147; + fIdentFuncTable[149] := {$IFDEF FPC}@{$ENDIF}Func149; + fIdentFuncTable[185] := {$IFDEF FPC}@{$ENDIF}Func185; +end; + +function TSynLuaSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', 'a'..'z', 'A'..'Z', '0'..'9'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynLuaSyn.KeyComp(const aKey :string) :Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynLuaSyn.Func17: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func19: TtkTokenKind; +begin + if KeyComp('deg') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func21: TtkTokenKind; +begin + if KeyComp('do') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func22: TtkTokenKind; +begin + if KeyComp('and') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func25: TtkTokenKind; +begin + if KeyComp('PI') then Result := tkFunction else + if KeyComp('abs') then Result := tkFunction else + if KeyComp('in') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func26: TtkTokenKind; +begin + if KeyComp('end') then Result := tkKey else + if KeyComp('rad') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func31: TtkTokenKind; +begin + if KeyComp('tag') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func32: TtkTokenKind; +begin + if KeyComp('read') then Result := tkFunction else + if KeyComp('call') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func33: TtkTokenKind; +begin + if KeyComp('ceil') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func34: TtkTokenKind; +begin + if KeyComp('date') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func35: TtkTokenKind; +begin + if KeyComp('mod') then Result := tkFunction else + if KeyComp('or') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func37: TtkTokenKind; +begin + if KeyComp('log') then Result := tkFunction else + if KeyComp('log10') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func38: TtkTokenKind; +begin + if KeyComp('nil') then Result := tkKey else + if KeyComp('tan') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func39: TtkTokenKind; +begin + if KeyComp('min') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func40: TtkTokenKind; +begin + if KeyComp('atan') then Result := tkFunction else + if KeyComp('cos') then Result := tkFunction else + if KeyComp('atan2') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func41: TtkTokenKind; +begin + if KeyComp('max') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func42: TtkTokenKind; +begin + if KeyComp('break') then Result := tkKey else + if KeyComp('for') then Result := tkKey else + if KeyComp('acos') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func44: TtkTokenKind; +begin + if KeyComp('debug') then Result := tkFunction else + if KeyComp('seek') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func45: TtkTokenKind; +begin + if KeyComp('else') then Result := tkKey else + if KeyComp('sin') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func46: TtkTokenKind; +begin + if KeyComp('ascii') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func47: TtkTokenKind; +begin + if KeyComp('asin') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func48: TtkTokenKind; +begin + if KeyComp('local') then Result := tkKey else + if KeyComp('exp') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func49: TtkTokenKind; +begin + if KeyComp('clock') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func50: TtkTokenKind; +begin + if KeyComp('getn') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func51: TtkTokenKind; +begin + if KeyComp('then') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func52: TtkTokenKind; +begin + if KeyComp('not') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func53: TtkTokenKind; +begin + if KeyComp('gsub') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func56: TtkTokenKind; +begin + if KeyComp('_ALERT') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func57: TtkTokenKind; +begin + if KeyComp('dofile') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func60: TtkTokenKind; +begin + if KeyComp('gcinfo') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func62: TtkTokenKind; +begin + if KeyComp('elseif') then Result := tkKey else + if KeyComp('exit') then Result := tkFunction else + if KeyComp('while') then Result := tkKey else + if KeyComp('rename') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func63: TtkTokenKind; +begin + if KeyComp('foreach') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func66: TtkTokenKind; +begin + if KeyComp('_STDIN') then Result := tkFunction else + if KeyComp('ldexp') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func67: TtkTokenKind; +begin + if KeyComp('next') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func70: TtkTokenKind; +begin + if KeyComp('type') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func71: TtkTokenKind; +begin + if KeyComp('random') then Result := tkFunction else + if KeyComp('repeat') then Result := tkKey else + if KeyComp('floor') then Result := tkFunction else + if KeyComp('flush') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func73: TtkTokenKind; +begin + if KeyComp('foreachi') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func74: TtkTokenKind; +begin + if KeyComp('frexp') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func75: TtkTokenKind; +begin + if KeyComp('globals') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func76: TtkTokenKind; +begin + if KeyComp('newtag') then Result := tkFunction else + if KeyComp('sort') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func78: TtkTokenKind; +begin + if KeyComp('sqrt') then Result := tkFunction else + if KeyComp('settag') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func79: TtkTokenKind; +begin + if KeyComp('format') then Result := tkFunction else + if KeyComp('getenv') then Result := tkFunction else + if KeyComp('error') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func80: TtkTokenKind; +begin + if KeyComp('_INPUT') then Result := tkFunction else + if KeyComp('write') then Result := tkFunction else + if KeyComp('rawget') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func81: TtkTokenKind; +begin + if KeyComp('until') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func82: TtkTokenKind; +begin + if KeyComp('print') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func83: TtkTokenKind; +begin + if KeyComp('getinfo') then Result := tkFunction else + if KeyComp('getlocal') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func84: TtkTokenKind; +begin + if KeyComp('_STDERR') then Result := tkFunction else + if KeyComp('getargs') then Result := tkFunction else + if KeyComp('remove') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func88: TtkTokenKind; +begin + if KeyComp('assert') then Result := tkFunction else + if KeyComp('readfrom') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func89: TtkTokenKind; +begin + if KeyComp('tmpname') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func90: TtkTokenKind; +begin + if KeyComp('execute') then Result := tkFunction else + if KeyComp('openfile') then Result := tkFunction else + if KeyComp('getglobal') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func92: TtkTokenKind; +begin + if KeyComp('rawset') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func94: TtkTokenKind; +begin + if KeyComp('strchar') then Result := tkFunction else + if KeyComp('strlen') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func95: TtkTokenKind; +begin + if KeyComp('setlocal') then Result := tkFunction else + if KeyComp('closefile') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func97: TtkTokenKind; +begin + if KeyComp('strfind') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func99: TtkTokenKind; +begin + if KeyComp('_STDOUT') then Result := tkFunction else + if KeyComp('appendto') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func101: TtkTokenKind; +begin + if KeyComp('setlocale') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func102: TtkTokenKind; +begin + if KeyComp('setglobal') then Result := tkFunction else + if KeyComp('return') then Result := tkKey else + if KeyComp('strrep') then Result := tkFunction else + if KeyComp('_VERSION') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func105: TtkTokenKind; +begin + if KeyComp('strsub') then Result := tkFunction else + if KeyComp('tremove') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func107: TtkTokenKind; +begin + if KeyComp('foreachvar') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func108: TtkTokenKind; +begin + if KeyComp('randomseed') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func110: TtkTokenKind; +begin + if KeyComp('function') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func111: TtkTokenKind; +begin + if KeyComp('nextvar') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func112: TtkTokenKind; +begin + if KeyComp('tinsert') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func113: TtkTokenKind; +begin + if KeyComp('_OUTPUT') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func114: TtkTokenKind; +begin + if KeyComp('dostring') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func116: TtkTokenKind; +begin + if KeyComp('tonumber') then Result := tkFunction else + if KeyComp('strbyte') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func117: TtkTokenKind; +begin + if KeyComp('writeto') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func125: TtkTokenKind; +begin + if KeyComp('rawgettable') then Result := tkFunction else + if KeyComp('collectgarbage') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func130: TtkTokenKind; +begin + if KeyComp('tostring') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func132: TtkTokenKind; +begin + if KeyComp('setcallhook') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func135: TtkTokenKind; +begin + if KeyComp('rawgetglobal') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func137: TtkTokenKind; +begin + if KeyComp('gettagmethod') then Result := tkFunction else + if KeyComp('rawsettable') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func138: TtkTokenKind; +begin + if KeyComp('strlower') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func141: TtkTokenKind; +begin + if KeyComp('strupper') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func143: TtkTokenKind; +begin + if KeyComp('_ERRORMESSAGE') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func144: TtkTokenKind; +begin + if KeyComp('setlinehook') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func147: TtkTokenKind; +begin + if KeyComp('rawsetglobal') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func149: TtkTokenKind; +begin + if KeyComp('settagmethod') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.Func185: TtkTokenKind; +begin + if KeyComp('copytagmethods') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynLuaSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynLuaSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey <= MaxKey then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynLuaSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NullProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LFProc; + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CRProc; + #1..#9, #11, #12, #14..#32 : fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SpaceProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}IdentProc; + '0'..'9': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NumberProc; + '''': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}StringProc; + '"': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}QuoteStringProc; + '-': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CommentProc; + '}': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}BraceCloseProc; + '{': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}BraceOpenProc; + '>': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}GreaterProc; + '<': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LowerProc; + ')': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}RoundCloseProc; + '(': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}RoundOpenProc; + ']': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SquareCloseProc; + '[': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SquareOpenProc; + ':': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}ColonProc; + ',': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CommaProc; + ';': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SemiColonProc; + '.': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}PointProc; + '#': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}DirectiveProc; + '=': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}EqualProc; + '+': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}PlusProc; + '*': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}StarProc; + '/': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SlashProc; + '%': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}ModSymbolProc; + '&': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}AndSymbolProc; + '!': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NotSymbolProc; + '|': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}OrSymbolProc; + '~': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}TildeProc; + '^': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}ArrowProc; + '?': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}QuestionProc; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}UnknownProc; + end; +end; + +constructor TSynLuaSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrComment, SYNS_XML_AttrComment); + fCommentAttri.Foreground := clGreen; + AddAttribute(fCommentAttri); + + fFunctionAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrFunction, SYNS_XML_AttrFunction); + fFunctionAttri.Foreground := $00C05000; + AddAttribute(fFunctionAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrIdentifier, SYNS_XML_AttrIdentifier); + fIdentifierAttri.Foreground := clWindowText; + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrReservedWord, SYNS_XML_AttrReservedWord); + fKeyAttri.Foreground := clBlue; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrNumber, SYNS_XML_AttrNumber); + fNumberAttri.Foreground := clPurple; + AddAttribute(fNumberAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrSpace, SYNS_XML_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrString, SYNS_XML_AttrString); + fStringAttri.Foreground := clMaroon; + AddAttribute(fStringAttri); + + fSymbolAttri := TSynHighLighterAttributes.Create({$IFDEF FPC}@{$ENDIF}SYNS_AttrSymbol, SYNS_XML_AttrSymbol); + fSymbolAttri.Foreground := clNavy; + AddAttribute(fSymbolAttri); + + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterLua; +end; + +procedure TSynLuaSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + Inc(Run); + until not (fLine[Run] in [#1..#32]); +end; + +procedure TSynLuaSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynLuaSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then + Inc(Run); +end; + +procedure TSynLuaSyn.LFProc; +begin + fTokenID := tkSpace; + Inc(Run); +end; + +procedure TSynLuaSyn.CommentProc; +begin + case fLine[Run + 1] of + '-': + begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + '=', '>': + begin + Inc(Run, 2); + fTokenID := tkSymbol; + end + else + begin + fTokenID := tkSymbol; + Inc(Run); {subtract} + end; + end; +end; + +procedure TSynLuaSyn.StringProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then + begin + if fLine[Run + 1] in [#39, '\'] then + Inc(Run); + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13, #39]; + if fLine[Run] = #39 then + Inc(Run); +end; + +procedure TSynLuaSyn.QuoteStringProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then + begin + case fLine[Run + 1] of + #34, '\': + Inc(Run); + #00: + begin + Inc(Run); + fRange := rsMultilineString; + Exit; + end; + end; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13, #34]; + if FLine[Run] = #34 then + Inc(Run); +end; + +procedure TSynLuaSyn.StringEndProc; +begin + fTokenID := tkString; + + case FLine[Run] of + #0: + begin + NullProc; + Exit; + end; + #10: + begin + LFProc; + Exit; + end; + #13: + begin + CRProc; + Exit; + end; + end; + + fRange := rsUnknown; + + repeat + case FLine[Run] of + #0, #10, #13: Break; + '\': + begin + case fLine[Run + 1] of + #34, '\': + Inc(Run); + #00: + begin + Inc(Run); + fRange := rsMultilineString; + Exit; + end; + end; + end; + #34: Break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13, #34]; + if FLine[Run] = #34 then + Inc(Run); +end; + +procedure TSynLuaSyn.BraceCloseProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynLuaSyn.BraceOpenProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynLuaSyn.GreaterProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {greater than or equal to} + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + Inc(Run, 3) + else {shift right} + Inc(Run, 2); + end; + else {greater than} + Inc(run); + end; +end; + +procedure TSynLuaSyn.LowerProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {less than or equal to} + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + Inc(Run, 3) + else {shift left} + Inc(Run, 2); + end; + else Inc(Run); {less than} + end; +end; + +procedure TSynLuaSyn.RoundCloseProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynLuaSyn.RoundOpenProc; +begin + Inc(Run); + FTokenID := tkSymbol; +end; + +procedure TSynLuaSyn.SquareCloseProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynLuaSyn.SquareOpenProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynLuaSyn.ColonProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + ':': Inc(Run, 2); {scope resolution operator} + else {colon} + Inc(Run); + end; +end; + +procedure TSynLuaSyn.CommaProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynLuaSyn.SemiColonProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynLuaSyn.PointProc; +begin + fTokenID := tkSymbol; + if (FLine[Run + 1] = '.') and (FLine[Run + 2] = '.') then {ellipse} + Inc(Run, 3) + else if FLine[Run + 1] in ['0'..'9'] then // float + begin + Dec(Run); // numberproc must see the point + NumberProc; + end + else {point} + Inc(Run); +end; + +procedure TSynLuaSyn.DirectiveProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynLuaSyn.EqualProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {logical equal} + else {assign} + Inc(Run); + end; +end; + +procedure TSynLuaSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + Inc(Run, fStringLen); + while Identifiers[fLine[Run]] do Inc(Run); +end; + +procedure TSynLuaSyn.PlusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {add assign} + '+': Inc(Run, 2); {increment} + else {add} + Inc(Run); + end; +end; + +procedure TSynLuaSyn.StarProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {multiply assign} + else Inc(Run); {star} + end; +end; + +procedure TSynLuaSyn.SlashProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {multiply assign} + else Inc(Run); {star} + end; +end; + +procedure TSynLuaSyn.ModSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {mod assign} + else Inc(Run); {mod} + end; +end; + +procedure TSynLuaSyn.AndSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); // and assign + '&': Inc(Run, 2); // logical and + else Inc(Run); // and + end; +end; + +procedure TSynLuaSyn.NotSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {not equal} + else Inc(Run); {not} + end; +end; + +procedure TSynLuaSyn.OrSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': Inc(Run, 2); {or assign} + '|': Inc(Run, 2); {logical or} + else Inc(Run); {or} + end; +end; + +procedure TSynLuaSyn.TildeProc; +begin + Inc(Run); {bitwise complement} + fTokenId := tkSymbol; +end; + +procedure TSynLuaSyn.ArrowProc; +begin + Inc(Run); {bitwise complement} + fTokenId := tkSymbol; +end; + +procedure TSynLuaSyn.QuestionProc; +begin + fTokenID := tkSymbol; {conditional} + Inc(Run); +end; + +procedure TSynLuaSyn.NumberProc; +begin + Inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', '.', 'u', 'U', 'l', 'L', 'x', 'X', 'e', 'E', 'f', 'F'] do //Kan + //['0'..'9', 'A'..'F', 'a'..'f', '.', 'u', 'U', 'l', 'L', 'x', 'X'] do //Commented by Kan + begin + case FLine[Run] of + '.': if FLine[Run + 1] = '.' then break; + end; + Inc(Run); + end; +end; + +procedure TSynLuaSyn.UnknownProc; +begin + {$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run,2) + else + {$ENDIF} + Inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynLuaSyn.SetLine(const NewValue :String; LineNumber :Integer); +begin + fLineRef := NewValue; + fLine := PChar(fLineRef); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynLuaSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsMultilineString: StringEndProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +class function TSynLuaSyn.GetLanguageName :string; +begin + Result := SYNS_LangLua; +end; + +function TSynLuaSyn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_STRING : Result := fStringAttri; + SYN_ATTR_WHITESPACE : Result := fSpaceAttri; + SYN_ATTR_SYMBOL : Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynLuaSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynLuaSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynLuaSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynLuaSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynLuaSyn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkFunction: Result := fFunctionAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynLuaSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynLuaSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynLuaSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', 'a'..'z', 'A'..'Z', '0'..'9']; +end; + +function TSynLuaSyn.IsFilterStored :Boolean; +begin + Result := (fDefaultFilter <> SYNS_FilterLua); +end; + +procedure TSynLuaSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynLuaSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynLuaSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +initialization + MakeIdentTable; + {$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynLuaSyn); + {$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/SynHighlighterProlog.pas b/components/extrasyn/SyneditHighlighters/SynHighlighterProlog.pas new file mode 100644 index 000000000..d0d00ebcb --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/SynHighlighterProlog.pas @@ -0,0 +1,2245 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterProlog.pas, the Initial +Author of this file is Zhou Kan. +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: SynHighlighterProlog.pas,v 1.00 2005/01/24 17:58:27 Kan Exp $ + +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 Prolog highlighter for SynEdit) +@author(Zhou Kan [textrush@tom.com]) +@created(June 2004) +@lastmod(2005-01-24) +The SynHighlighterProlog unit provides SynEdit with a Prolog (*.pl;*.pro) highlighter. +The highlighter formats Prolog source code highlighting keywords, strings, numbers and characters. +} + +unit SynHighlighterProlog; + +//SynEdit.inc is the synedit.inc from laz 1.2.0 synedit package source if it has changed +//in newer version you might need to copy it again. REmeber to redclare the syn_lazarus define. +{$I synedit.inc} + +interface + +uses + SysUtils, Classes, Graphics, SynEditHighlighter, SynEditTypes, SynEditStrConst; + +Type + TtkTokenKind = (tkComment, tkDirective, tkIdentifier, tkKey, + tkNull, tkNumber, tkSpace, tkString, tkSymbol, tkUnknown); + + TRangeState = (rsAnsiC, rsUnKnown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynPrologSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0..332] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fDirectiveAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func6: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func27: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func34: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func85: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func91: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func94: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func98: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func103: TtkTokenKind; + function Func104: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func109: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func112: TtkTokenKind; + function Func114: TtkTokenKind; + function Func115: TtkTokenKind; + function Func116: TtkTokenKind; + function Func117: TtkTokenKind; + function Func119: TtkTokenKind; + function Func120: TtkTokenKind; + function Func121: TtkTokenKind; + function Func122: TtkTokenKind; + function Func123: TtkTokenKind; + function Func124: TtkTokenKind; + function Func125: TtkTokenKind; + function Func127: TtkTokenKind; + function Func128: TtkTokenKind; + function Func129: TtkTokenKind; + function Func130: TtkTokenKind; + function Func131: TtkTokenKind; + function Func132: TtkTokenKind; + function Func133: TtkTokenKind; + function Func135: TtkTokenKind; + function Func136: TtkTokenKind; + function Func137: TtkTokenKind; + function Func138: TtkTokenKind; + function Func139: TtkTokenKind; + function Func140: TtkTokenKind; + function Func141: TtkTokenKind; + function Func143: TtkTokenKind; + function Func145: TtkTokenKind; + function Func146: TtkTokenKind; + function Func147: TtkTokenKind; + function Func148: TtkTokenKind; + function Func149: TtkTokenKind; + function Func150: TtkTokenKind; + function Func152: TtkTokenKind; + function Func153: TtkTokenKind; + function Func154: TtkTokenKind; + function Func155: TtkTokenKind; + function Func156: TtkTokenKind; + function Func157: TtkTokenKind; + function Func158: TtkTokenKind; + function Func159: TtkTokenKind; + function Func161: TtkTokenKind; + function Func163: TtkTokenKind; + function Func164: TtkTokenKind; + function Func165: TtkTokenKind; + function Func166: TtkTokenKind; + function Func168: TtkTokenKind; + function Func169: TtkTokenKind; + function Func170: TtkTokenKind; + function Func173: TtkTokenKind; + function Func174: TtkTokenKind; + function Func175: TtkTokenKind; + function Func176: TtkTokenKind; + function Func178: TtkTokenKind; + function Func179: TtkTokenKind; + function Func181: TtkTokenKind; + function Func182: TtkTokenKind; + function Func183: TtkTokenKind; + function Func184: TtkTokenKind; + function Func186: TtkTokenKind; + function Func187: TtkTokenKind; + function Func188: TtkTokenKind; + function Func189: TtkTokenKind; + function Func190: TtkTokenKind; + function Func191: TtkTokenKind; + function Func192: TtkTokenKind; + function Func194: TtkTokenKind; + function Func195: TtkTokenKind; + function Func196: TtkTokenKind; + function Func198: TtkTokenKind; + function Func199: TtkTokenKind; + function Func201: TtkTokenKind; + function Func203: TtkTokenKind; + function Func205: TtkTokenKind; + function Func206: TtkTokenKind; + function Func207: TtkTokenKind; + function Func208: TtkTokenKind; + function Func209: TtkTokenKind; + function Func210: TtkTokenKind; + function Func211: TtkTokenKind; + function Func213: TtkTokenKind; + function Func215: TtkTokenKind; + function Func218: TtkTokenKind; + function Func222: TtkTokenKind; + function Func223: TtkTokenKind; + function Func225: TtkTokenKind; + function Func226: TtkTokenKind; + function Func227: TtkTokenKind; + function Func228: TtkTokenKind; + function Func231: TtkTokenKind; + function Func233: TtkTokenKind; + function Func235: TtkTokenKind; + function Func237: TtkTokenKind; + function Func242: TtkTokenKind; + function Func243: TtkTokenKind; + function Func244: TtkTokenKind; + function Func246: TtkTokenKind; + function Func250: TtkTokenKind; + function Func254: TtkTokenKind; + function Func262: TtkTokenKind; + function Func264: TtkTokenKind; + function Func271: TtkTokenKind; + function Func275: TtkTokenKind; + function Func279: TtkTokenKind; + function Func284: TtkTokenKind; + function Func301: TtkTokenKind; + function Func332: TtkTokenKind; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure BackSlashProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure CRProc; + procedure ColonProc; + procedure CommaProc; + procedure DotProc; + procedure EqualProc; + procedure GreaterProc; + procedure IdentProc; + procedure InfoProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NullProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure SepcialString; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure StarProc; + procedure StringProc; + procedure TildeProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure AnsiCProc; //Kan + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEOL: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart :PChar; out TokenLength :integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + function GetRange: Pointer; override; + procedure SetRange(Value: Pointer); override; + procedure ReSetRange; override; + class function GetLanguageName :string; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property DirectiveAttri: TSynHighlighterAttributes read fDirectiveAttri write fDirectiveAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation +uses SynEditStrConstExtra; +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable : array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + Case I in ['_', 'A'..'Z', 'a'..'z'] of + True: + begin + if (I > #64) and (I < #91) then + mHashTable[I] := Ord(I) - 64 + else + if (I > #96) then mHashTable[I] := Ord(I) - 95; + end; + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynPrologSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := {$IFDEF FPC}@{$ENDIF}AltFunc; + Inc(pF); + end; + fIdentFuncTable[6] := {$IFDEF FPC}@{$ENDIF}Func6; + fIdentFuncTable[25] := {$IFDEF FPC}@{$ENDIF}Func25; + fIdentFuncTable[26] := {$IFDEF FPC}@{$ENDIF}Func26; + fIdentFuncTable[27] := {$IFDEF FPC}@{$ENDIF}Func27; + fIdentFuncTable[28] := {$IFDEF FPC}@{$ENDIF}Func28; + fIdentFuncTable[29] := {$IFDEF FPC}@{$ENDIF}Func29; + fIdentFuncTable[30] := {$IFDEF FPC}@{$ENDIF}Func30; + fIdentFuncTable[32] := {$IFDEF FPC}@{$ENDIF}Func32; + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF}Func33; + fIdentFuncTable[34] := {$IFDEF FPC}@{$ENDIF}Func34; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF}Func35; + fIdentFuncTable[36] := {$IFDEF FPC}@{$ENDIF}Func36; + fIdentFuncTable[37] := {$IFDEF FPC}@{$ENDIF}Func37; + fIdentFuncTable[38] := {$IFDEF FPC}@{$ENDIF}Func38; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF}Func39; + fIdentFuncTable[40] := {$IFDEF FPC}@{$ENDIF}Func40; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF}Func41; + fIdentFuncTable[42] := {$IFDEF FPC}@{$ENDIF}Func42; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF}Func44; + fIdentFuncTable[45] := {$IFDEF FPC}@{$ENDIF}Func45; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF}Func47; + fIdentFuncTable[48] := {$IFDEF FPC}@{$ENDIF}Func48; + fIdentFuncTable[50] := {$IFDEF FPC}@{$ENDIF}Func50; + fIdentFuncTable[51] := {$IFDEF FPC}@{$ENDIF}Func51; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF}Func52; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF}Func53; + fIdentFuncTable[54] := {$IFDEF FPC}@{$ENDIF}Func54; + fIdentFuncTable[55] := {$IFDEF FPC}@{$ENDIF}Func55; + fIdentFuncTable[56] := {$IFDEF FPC}@{$ENDIF}Func56; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF}Func57; + fIdentFuncTable[59] := {$IFDEF FPC}@{$ENDIF}Func59; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF}Func60; + fIdentFuncTable[61] := {$IFDEF FPC}@{$ENDIF}Func61; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF}Func62; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF}Func63; + fIdentFuncTable[64] := {$IFDEF FPC}@{$ENDIF}Func64; + fIdentFuncTable[65] := {$IFDEF FPC}@{$ENDIF}Func65; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF}Func66; + fIdentFuncTable[67] := {$IFDEF FPC}@{$ENDIF}Func67; + fIdentFuncTable[68] := {$IFDEF FPC}@{$ENDIF}Func68; + fIdentFuncTable[69] := {$IFDEF FPC}@{$ENDIF}Func69; + fIdentFuncTable[70] := {$IFDEF FPC}@{$ENDIF}Func70; + fIdentFuncTable[71] := {$IFDEF FPC}@{$ENDIF}Func71; + fIdentFuncTable[72] := {$IFDEF FPC}@{$ENDIF}Func72; + fIdentFuncTable[73] := {$IFDEF FPC}@{$ENDIF}Func73; + fIdentFuncTable[74] := {$IFDEF FPC}@{$ENDIF}Func74; + fIdentFuncTable[75] := {$IFDEF FPC}@{$ENDIF}Func75; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF}Func76; + fIdentFuncTable[77] := {$IFDEF FPC}@{$ENDIF}Func77; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF}Func78; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF}Func79; + fIdentFuncTable[80] := {$IFDEF FPC}@{$ENDIF}Func80; + fIdentFuncTable[81] := {$IFDEF FPC}@{$ENDIF}Func81; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF}Func82; + fIdentFuncTable[83] := {$IFDEF FPC}@{$ENDIF}Func83; + fIdentFuncTable[85] := {$IFDEF FPC}@{$ENDIF}Func85; + fIdentFuncTable[86] := {$IFDEF FPC}@{$ENDIF}Func86; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF}Func87; + fIdentFuncTable[88] := {$IFDEF FPC}@{$ENDIF}Func88; + fIdentFuncTable[89] := {$IFDEF FPC}@{$ENDIF}Func89; + fIdentFuncTable[90] := {$IFDEF FPC}@{$ENDIF}Func90; + fIdentFuncTable[91] := {$IFDEF FPC}@{$ENDIF}Func91; + fIdentFuncTable[92] := {$IFDEF FPC}@{$ENDIF}Func92; + fIdentFuncTable[93] := {$IFDEF FPC}@{$ENDIF}Func93; + fIdentFuncTable[94] := {$IFDEF FPC}@{$ENDIF}Func94; + fIdentFuncTable[96] := {$IFDEF FPC}@{$ENDIF}Func96; + fIdentFuncTable[97] := {$IFDEF FPC}@{$ENDIF}Func97; + fIdentFuncTable[98] := {$IFDEF FPC}@{$ENDIF}Func98; + fIdentFuncTable[99] := {$IFDEF FPC}@{$ENDIF}Func99; + fIdentFuncTable[100] := {$IFDEF FPC}@{$ENDIF}Func100; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF}Func101; + fIdentFuncTable[103] := {$IFDEF FPC}@{$ENDIF}Func103; + fIdentFuncTable[104] := {$IFDEF FPC}@{$ENDIF}Func104; + fIdentFuncTable[106] := {$IFDEF FPC}@{$ENDIF}Func106; + fIdentFuncTable[107] := {$IFDEF FPC}@{$ENDIF}Func107; + fIdentFuncTable[108] := {$IFDEF FPC}@{$ENDIF}Func108; + fIdentFuncTable[109] := {$IFDEF FPC}@{$ENDIF}Func109; + fIdentFuncTable[110] := {$IFDEF FPC}@{$ENDIF}Func110; + fIdentFuncTable[111] := {$IFDEF FPC}@{$ENDIF}Func111; + fIdentFuncTable[112] := {$IFDEF FPC}@{$ENDIF}Func112; + fIdentFuncTable[114] := {$IFDEF FPC}@{$ENDIF}Func114; + fIdentFuncTable[115] := {$IFDEF FPC}@{$ENDIF}Func115; + fIdentFuncTable[116] := {$IFDEF FPC}@{$ENDIF}Func116; + fIdentFuncTable[117] := {$IFDEF FPC}@{$ENDIF}Func117; + fIdentFuncTable[119] := {$IFDEF FPC}@{$ENDIF}Func119; + fIdentFuncTable[120] := {$IFDEF FPC}@{$ENDIF}Func120; + fIdentFuncTable[121] := {$IFDEF FPC}@{$ENDIF}Func121; + fIdentFuncTable[122] := {$IFDEF FPC}@{$ENDIF}Func122; + fIdentFuncTable[123] := {$IFDEF FPC}@{$ENDIF}Func123; + fIdentFuncTable[124] := {$IFDEF FPC}@{$ENDIF}Func124; + fIdentFuncTable[125] := {$IFDEF FPC}@{$ENDIF}Func125; + fIdentFuncTable[127] := {$IFDEF FPC}@{$ENDIF}Func127; + fIdentFuncTable[128] := {$IFDEF FPC}@{$ENDIF}Func128; + fIdentFuncTable[129] := {$IFDEF FPC}@{$ENDIF}Func129; + fIdentFuncTable[130] := {$IFDEF FPC}@{$ENDIF}Func130; + fIdentFuncTable[131] := {$IFDEF FPC}@{$ENDIF}Func131; + fIdentFuncTable[132] := {$IFDEF FPC}@{$ENDIF}Func132; + fIdentFuncTable[133] := {$IFDEF FPC}@{$ENDIF}Func133; + fIdentFuncTable[135] := {$IFDEF FPC}@{$ENDIF}Func135; + fIdentFuncTable[136] := {$IFDEF FPC}@{$ENDIF}Func136; + fIdentFuncTable[137] := {$IFDEF FPC}@{$ENDIF}Func137; + fIdentFuncTable[138] := {$IFDEF FPC}@{$ENDIF}Func138; + fIdentFuncTable[139] := {$IFDEF FPC}@{$ENDIF}Func139; + fIdentFuncTable[140] := {$IFDEF FPC}@{$ENDIF}Func140; + fIdentFuncTable[141] := {$IFDEF FPC}@{$ENDIF}Func141; + fIdentFuncTable[143] := {$IFDEF FPC}@{$ENDIF}Func143; + fIdentFuncTable[145] := {$IFDEF FPC}@{$ENDIF}Func145; + fIdentFuncTable[146] := {$IFDEF FPC}@{$ENDIF}Func146; + fIdentFuncTable[147] := {$IFDEF FPC}@{$ENDIF}Func147; + fIdentFuncTable[148] := {$IFDEF FPC}@{$ENDIF}Func148; + fIdentFuncTable[149] := {$IFDEF FPC}@{$ENDIF}Func149; + fIdentFuncTable[150] := {$IFDEF FPC}@{$ENDIF}Func150; + fIdentFuncTable[152] := {$IFDEF FPC}@{$ENDIF}Func152; + fIdentFuncTable[153] := {$IFDEF FPC}@{$ENDIF}Func153; + fIdentFuncTable[154] := {$IFDEF FPC}@{$ENDIF}Func154; + fIdentFuncTable[155] := {$IFDEF FPC}@{$ENDIF}Func155; + fIdentFuncTable[156] := {$IFDEF FPC}@{$ENDIF}Func156; + fIdentFuncTable[157] := {$IFDEF FPC}@{$ENDIF}Func157; + fIdentFuncTable[158] := {$IFDEF FPC}@{$ENDIF}Func158; + fIdentFuncTable[159] := {$IFDEF FPC}@{$ENDIF}Func159; + fIdentFuncTable[161] := {$IFDEF FPC}@{$ENDIF}Func161; + fIdentFuncTable[163] := {$IFDEF FPC}@{$ENDIF}Func163; + fIdentFuncTable[164] := {$IFDEF FPC}@{$ENDIF}Func164; + fIdentFuncTable[165] := {$IFDEF FPC}@{$ENDIF}Func165; + fIdentFuncTable[166] := {$IFDEF FPC}@{$ENDIF}Func166; + fIdentFuncTable[168] := {$IFDEF FPC}@{$ENDIF}Func168; + fIdentFuncTable[169] := {$IFDEF FPC}@{$ENDIF}Func169; + fIdentFuncTable[170] := {$IFDEF FPC}@{$ENDIF}Func170; + fIdentFuncTable[173] := {$IFDEF FPC}@{$ENDIF}Func173; + fIdentFuncTable[174] := {$IFDEF FPC}@{$ENDIF}Func174; + fIdentFuncTable[175] := {$IFDEF FPC}@{$ENDIF}Func175; + fIdentFuncTable[176] := {$IFDEF FPC}@{$ENDIF}Func176; + fIdentFuncTable[178] := {$IFDEF FPC}@{$ENDIF}Func178; + fIdentFuncTable[179] := {$IFDEF FPC}@{$ENDIF}Func179; + fIdentFuncTable[181] := {$IFDEF FPC}@{$ENDIF}Func181; + fIdentFuncTable[182] := {$IFDEF FPC}@{$ENDIF}Func182; + fIdentFuncTable[183] := {$IFDEF FPC}@{$ENDIF}Func183; + fIdentFuncTable[184] := {$IFDEF FPC}@{$ENDIF}Func184; + fIdentFuncTable[186] := {$IFDEF FPC}@{$ENDIF}Func186; + fIdentFuncTable[187] := {$IFDEF FPC}@{$ENDIF}Func187; + fIdentFuncTable[188] := {$IFDEF FPC}@{$ENDIF}Func188; + fIdentFuncTable[189] := {$IFDEF FPC}@{$ENDIF}Func189; + fIdentFuncTable[190] := {$IFDEF FPC}@{$ENDIF}Func190; + fIdentFuncTable[191] := {$IFDEF FPC}@{$ENDIF}Func191; + fIdentFuncTable[192] := {$IFDEF FPC}@{$ENDIF}Func192; + fIdentFuncTable[194] := {$IFDEF FPC}@{$ENDIF}Func194; + fIdentFuncTable[195] := {$IFDEF FPC}@{$ENDIF}Func195; + fIdentFuncTable[196] := {$IFDEF FPC}@{$ENDIF}Func196; + fIdentFuncTable[198] := {$IFDEF FPC}@{$ENDIF}Func198; + fIdentFuncTable[199] := {$IFDEF FPC}@{$ENDIF}Func199; + fIdentFuncTable[201] := {$IFDEF FPC}@{$ENDIF}Func201; + fIdentFuncTable[203] := {$IFDEF FPC}@{$ENDIF}Func203; + fIdentFuncTable[205] := {$IFDEF FPC}@{$ENDIF}Func205; + fIdentFuncTable[206] := {$IFDEF FPC}@{$ENDIF}Func206; + fIdentFuncTable[207] := {$IFDEF FPC}@{$ENDIF}Func207; + fIdentFuncTable[208] := {$IFDEF FPC}@{$ENDIF}Func208; + fIdentFuncTable[209] := {$IFDEF FPC}@{$ENDIF}Func209; + fIdentFuncTable[210] := {$IFDEF FPC}@{$ENDIF}Func210; + fIdentFuncTable[211] := {$IFDEF FPC}@{$ENDIF}Func211; + fIdentFuncTable[213] := {$IFDEF FPC}@{$ENDIF}Func213; + fIdentFuncTable[215] := {$IFDEF FPC}@{$ENDIF}Func215; + fIdentFuncTable[218] := {$IFDEF FPC}@{$ENDIF}Func218; + fIdentFuncTable[222] := {$IFDEF FPC}@{$ENDIF}Func222; + fIdentFuncTable[223] := {$IFDEF FPC}@{$ENDIF}Func223; + fIdentFuncTable[225] := {$IFDEF FPC}@{$ENDIF}Func225; + fIdentFuncTable[226] := {$IFDEF FPC}@{$ENDIF}Func226; + fIdentFuncTable[227] := {$IFDEF FPC}@{$ENDIF}Func227; + fIdentFuncTable[228] := {$IFDEF FPC}@{$ENDIF}Func228; + fIdentFuncTable[231] := {$IFDEF FPC}@{$ENDIF}Func231; + fIdentFuncTable[233] := {$IFDEF FPC}@{$ENDIF}Func233; + fIdentFuncTable[235] := {$IFDEF FPC}@{$ENDIF}Func235; + fIdentFuncTable[237] := {$IFDEF FPC}@{$ENDIF}Func237; + fIdentFuncTable[242] := {$IFDEF FPC}@{$ENDIF}Func242; + fIdentFuncTable[243] := {$IFDEF FPC}@{$ENDIF}Func243; + fIdentFuncTable[244] := {$IFDEF FPC}@{$ENDIF}Func244; + fIdentFuncTable[246] := {$IFDEF FPC}@{$ENDIF}Func246; + fIdentFuncTable[250] := {$IFDEF FPC}@{$ENDIF}Func250; + fIdentFuncTable[254] := {$IFDEF FPC}@{$ENDIF}Func254; + fIdentFuncTable[262] := {$IFDEF FPC}@{$ENDIF}Func262; + fIdentFuncTable[264] := {$IFDEF FPC}@{$ENDIF}Func264; + fIdentFuncTable[271] := {$IFDEF FPC}@{$ENDIF}Func271; + fIdentFuncTable[275] := {$IFDEF FPC}@{$ENDIF}Func275; + fIdentFuncTable[279] := {$IFDEF FPC}@{$ENDIF}Func279; + fIdentFuncTable[284] := {$IFDEF FPC}@{$ENDIF}Func284; + fIdentFuncTable[301] := {$IFDEF FPC}@{$ENDIF}Func301; + fIdentFuncTable[332] := {$IFDEF FPC}@{$ENDIF}Func332; +end; + +function TSynPrologSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + Inc(Result, mHashTable[ToHash^]); + Inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynPrologSyn.KeyComp(const aKey :string) :Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else Result := False; +end; + +function TSynPrologSyn.Func6: TtkTokenKind; +begin + if KeyComp('e') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func25: TtkTokenKind; +begin + if KeyComp('abs') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func26: TtkTokenKind; +begin + if KeyComp('tab') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func27: TtkTokenKind; +begin + if KeyComp('pi') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func28: TtkTokenKind; +begin + if KeyComp('nl') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func29: TtkTokenKind; +begin + if KeyComp('arg') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func30: TtkTokenKind; +begin + if KeyComp('flag') then Result := tkKey else + if KeyComp('is') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func32: TtkTokenKind; +begin + if KeyComp('see') then Result := tkKey else + if KeyComp('call') then Result := tkKey else + if KeyComp('read') then Result := tkKey else + if KeyComp('fail') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func33: TtkTokenKind; +begin + if KeyComp('ceil') then Result := tkDirective else + if KeyComp('op') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func34: TtkTokenKind; +begin + if KeyComp('make') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func35: TtkTokenKind; +begin + if KeyComp('get0') then Result := tkKey else + if KeyComp('mod') then Result := tkDirective else + if KeyComp('get') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func36: TtkTokenKind; +begin + if KeyComp('bagof') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func37: TtkTokenKind; +begin + if KeyComp('log') then Result := tkDirective else + if KeyComp('name') then Result := tkKey else + if KeyComp('log10') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func38: TtkTokenKind; +begin + if KeyComp('tan') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func39: TtkTokenKind; +begin + if KeyComp('rem') then Result := tkDirective else + if KeyComp('min') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func40: TtkTokenKind; +begin + if KeyComp('catch') then Result := tkKey else + if KeyComp('cos') then Result := tkDirective else + if KeyComp('real') then Result := tkDirective else + if KeyComp('atan') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func41: TtkTokenKind; +begin + if KeyComp('max') then Result := tkDirective else + if KeyComp('once') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func42: TtkTokenKind; +begin + if KeyComp('edit') then Result := tkKey else + if KeyComp('acos') then Result := tkDirective else + if KeyComp('break') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func44: TtkTokenKind; +begin + if KeyComp('var') then Result := tkKey else + if KeyComp('debug') then Result := tkKey else + if KeyComp('seek') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func45: TtkTokenKind; +begin + if KeyComp('nth0') then Result := tkKey else + if KeyComp('nth1') then Result := tkKey else + if KeyComp('sin') then Result := tkDirective else + if KeyComp('halt') then Result := tkKey else + if KeyComp('help') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func47: TtkTokenKind; +begin + if KeyComp('asin') then Result := tkDirective else + if KeyComp('chdir') then Result := tkKey else + if KeyComp('seen') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func48: TtkTokenKind; +begin + if KeyComp('exp') then Result := tkDirective else + if KeyComp('block') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func50: TtkTokenKind; +begin + if KeyComp('succ') then Result := tkKey else + if KeyComp('leash') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func51: TtkTokenKind; +begin + if KeyComp('time') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func52: TtkTokenKind; +begin + if KeyComp('trace') then Result := tkKey else + if KeyComp('not') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func53: TtkTokenKind; +begin + if KeyComp('tell') then Result := tkKey else + if KeyComp('sign') then Result := tkDirective else + if KeyComp('erase') then Result := tkKey else + if KeyComp('atom') then Result := tkKey else + if KeyComp('merge') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func54: TtkTokenKind; +begin + if KeyComp('open') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func55: TtkTokenKind; +begin + if KeyComp('told') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func56: TtkTokenKind; +begin + if KeyComp('last') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func57: TtkTokenKind; +begin + if KeyComp('delete') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func59: TtkTokenKind; +begin + if KeyComp('close') then Result := tkKey else + if KeyComp('float') then Result := tkDirective else + if KeyComp('skip') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func60: TtkTokenKind; +begin + if KeyComp('put') then Result := tkKey else + if KeyComp('xor') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func61: TtkTokenKind; +begin + if KeyComp('shell') then Result := tkKey else + if KeyComp('abort') then Result := tkKey else + if KeyComp('index') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func62: TtkTokenKind; +begin + if KeyComp('append') then Result := tkKey else + if KeyComp('sleep') then Result := tkKey else + if KeyComp('exit') then Result := tkKey else + if KeyComp('member') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func63: TtkTokenKind; +begin + if KeyComp('spy') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func64: TtkTokenKind; +begin + if KeyComp('please') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func65: TtkTokenKind; +begin + if KeyComp('findall') then Result := tkKey else + if KeyComp('char_code') then Result := tkKey else + if KeyComp('seeing') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func66: TtkTokenKind; +begin + if KeyComp('ceiling') then Result := tkDirective else + if KeyComp('get_code') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func67: TtkTokenKind; +begin + if KeyComp('clause') then Result := tkKey else + if KeyComp('dde_poke') then Result := tkKey else + if KeyComp('atomic') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func68: TtkTokenKind; +begin + if KeyComp('at_halt') then Result := tkKey else + if KeyComp('true') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func69: TtkTokenKind; +begin + if KeyComp('get_char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func70: TtkTokenKind; +begin + if KeyComp('forall') then Result := tkKey else + if KeyComp('setof') then Result := tkKey else + if KeyComp('select') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func71: TtkTokenKind; +begin + if KeyComp('repeat') then Result := tkKey else + if KeyComp('random') then Result := tkDirective else + if KeyComp('recorda') then Result := tkKey else + if KeyComp('floor') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func72: TtkTokenKind; +begin + if KeyComp('unix') then Result := tkKey else + if KeyComp('peek_code') then Result := tkKey else + if KeyComp('plus') then Result := tkKey else + if KeyComp('length') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func73: TtkTokenKind; +begin + if KeyComp('phrase') then Result := tkKey else + if KeyComp('abolish') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func74: TtkTokenKind; +begin + if KeyComp('ignore') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func75: TtkTokenKind; +begin + if KeyComp('include') then Result := tkKey else + if KeyComp('apply') then Result := tkKey else + if KeyComp('peek_char') then Result := tkKey else + if KeyComp('nodebug') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func76: TtkTokenKind; +begin + if KeyComp('setarg') then Result := tkKey else + if KeyComp('dynamic') then Result := tkKey else + if KeyComp('sort') then Result := tkKey else + if KeyComp('module') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func77: TtkTokenKind; +begin + if KeyComp('is_set') then Result := tkKey else + if KeyComp('round') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func78: TtkTokenKind; +begin + if KeyComp('same_file') then Result := tkKey else + if KeyComp('sqrt') then Result := tkDirective else + if KeyComp('compare') then Result := tkKey else + if KeyComp('union') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func79: TtkTokenKind; +begin + if KeyComp('number') then Result := tkKey else + if KeyComp('format') then Result := tkKey else + if KeyComp('getenv') then Result := tkKey else + if KeyComp('tracing') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func80: TtkTokenKind; +begin + if KeyComp('write') then Result := tkKey else + if KeyComp('recorded') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func81: TtkTokenKind; +begin + if KeyComp('between') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func82: TtkTokenKind; +begin + if KeyComp('threads') then Result := tkKey else + if KeyComp('read_link') then Result := tkKey else + if KeyComp('print') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func83: TtkTokenKind; +begin + if KeyComp('notrace') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func85: TtkTokenKind; +begin + if KeyComp('ground') then Result := tkKey else + if KeyComp('integer') then Result := tkDirective else + if KeyComp('debugging') then Result := tkKey else + if KeyComp('flatten') then Result := tkKey else + if KeyComp('visible') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func86: TtkTokenKind; +begin + if KeyComp('telling') then Result := tkKey else + if KeyComp('get_time') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func87: TtkTokenKind; +begin + if KeyComp('writef') then Result := tkKey else + if KeyComp('memberchk') then Result := tkKey else + if KeyComp('time_file') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func88: TtkTokenKind; +begin + if KeyComp('assert') then Result := tkKey else + if KeyComp('profile') then Result := tkKey else + if KeyComp('tmp_file') then Result := tkKey else + if KeyComp('explain') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func89: TtkTokenKind; +begin + if KeyComp('prolog') then Result := tkKey else + if KeyComp('gensym') then Result := tkKey else + if KeyComp('throw') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func90: TtkTokenKind; +begin + if KeyComp('msort') then Result := tkKey else + if KeyComp('nonvar') then Result := tkKey else + if KeyComp('asserta') then Result := tkKey else + if KeyComp('win_exec') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func91: TtkTokenKind; +begin + if KeyComp('setenv') then Result := tkKey else + if KeyComp('get_byte') then Result := tkKey else + if KeyComp('put_code') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func92: TtkTokenKind; +begin + if KeyComp('retract') then Result := tkKey else + if KeyComp('access_file') then Result := tkKey else + if KeyComp('read_term') then Result := tkKey else + if KeyComp('load_files') then Result := tkKey else + if KeyComp('subset') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func93: TtkTokenKind; +begin + if KeyComp('delete_file') then Result := tkKey else + if KeyComp('string') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func94: TtkTokenKind; +begin + if KeyComp('cputime') then Result := tkDirective else + if KeyComp('is_list') then Result := tkKey else + if KeyComp('nospy') then Result := tkKey else + if KeyComp('put_char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func96: TtkTokenKind; +begin + if KeyComp('recordz') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func97: TtkTokenKind; +begin + if KeyComp('import') then Result := tkKey else + if KeyComp('listing') then Result := tkKey else + if KeyComp('peek_byte') then Result := tkKey else + if KeyComp('maplist') then Result := tkKey else + if KeyComp('autoload') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func98: TtkTokenKind; +begin + if KeyComp('writeq') then Result := tkKey else + if KeyComp('rename_file') then Result := tkKey else + if KeyComp('qcompile') then Result := tkKey else + if KeyComp('sub_atom') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func99: TtkTokenKind; +begin + if KeyComp('size_file') then Result := tkKey else + if KeyComp('reverse') then Result := tkKey else + if KeyComp('checklist') then Result := tkKey else + if KeyComp('on_signal') then Result := tkKey else + if KeyComp('sformat') then Result := tkKey else + if KeyComp('read_clause') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func100: TtkTokenKind; +begin + if KeyComp('require') then Result := tkKey else + if KeyComp('merge_set') then Result := tkKey else + if KeyComp('hash_term') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func101: TtkTokenKind; +begin + if KeyComp('code_type') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func103: TtkTokenKind; +begin + if KeyComp('dwim_match') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func104: TtkTokenKind; +begin + if KeyComp('export') then Result := tkKey else + if KeyComp('prompt1') then Result := tkKey else + if KeyComp('prompt') then Result := tkKey else + if KeyComp('file_base_name') then Result := tkKey else + if KeyComp('functor') then Result := tkKey else + if KeyComp('char_type') then Result := tkKey else + if KeyComp('volatile') then Result := tkKey else + if KeyComp('atom_codes') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func106: TtkTokenKind; +begin + if KeyComp('dde_execute') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func107: TtkTokenKind; +begin + if KeyComp('atom_chars') then Result := tkKey else + if KeyComp('apropos') then Result := tkKey else + if KeyComp('compiling') then Result := tkKey else + if KeyComp('swritef') then Result := tkKey else + if KeyComp('profiler') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func108: TtkTokenKind; +begin + if KeyComp('write_ln') then Result := tkKey else + if KeyComp('thread_self') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func109: TtkTokenKind; +begin + if KeyComp('sublist') then Result := tkKey else + if KeyComp('compound') then Result := tkKey else + if KeyComp('expand_goal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func110: TtkTokenKind; +begin + if KeyComp('truncate') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func111: TtkTokenKind; +begin + if KeyComp('consult') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func112: TtkTokenKind; +begin + if KeyComp('subtract') then Result := tkKey else + if KeyComp('nth_clause') then Result := tkKey else + if KeyComp('resource') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func114: TtkTokenKind; +begin + if KeyComp('thread_join') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func115: TtkTokenKind; +begin + if KeyComp('set_tty') then Result := tkKey else + if KeyComp('atom_concat') then Result := tkKey else + if KeyComp('assertz') then Result := tkKey else + if KeyComp('concat_atom') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func116: TtkTokenKind; +begin + if KeyComp('multifile') then Result := tkKey else + if KeyComp('put_byte') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func117: TtkTokenKind; +begin + if KeyComp('foreign_file') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func119: TtkTokenKind; +begin + if KeyComp('unknown') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func120: TtkTokenKind; +begin + if KeyComp('thread_create') then Result := tkKey else + if KeyComp('retractall') then Result := tkKey else + if KeyComp('keysort') then Result := tkKey else + if KeyComp('exception') then Result := tkKey else + if KeyComp('portray') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func121: TtkTokenKind; +begin + if KeyComp('style_check') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func122: TtkTokenKind; +begin + if KeyComp('line_count') then Result := tkKey else + if KeyComp('nospyall') then Result := tkKey else + if KeyComp('protocol') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func123: TtkTokenKind; +begin + if KeyComp('source_file') then Result := tkKey else + if KeyComp('copy_term') then Result := tkKey else + if KeyComp('predsort') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func124: TtkTokenKind; +begin + if KeyComp('protocola') then Result := tkKey else + if KeyComp('use_module') then Result := tkKey else + if KeyComp('thread_exit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func125: TtkTokenKind; +begin + if KeyComp('garbage_collect') then Result := tkKey else + if KeyComp('atom_length') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func127: TtkTokenKind; +begin + if KeyComp('limit_stack') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func128: TtkTokenKind; +begin + if KeyComp('tty_put') then Result := tkKey else + if KeyComp('unsetenv') then Result := tkKey else + if KeyComp('dde_request') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func129: TtkTokenKind; +begin + if KeyComp('tty_goto') then Result := tkKey else + if KeyComp('set_stream') then Result := tkKey else + if KeyComp('message_hook') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func130: TtkTokenKind; +begin + if KeyComp('expand_term') then Result := tkKey else + if KeyComp('thread_signal') then Result := tkKey else + if KeyComp('number_codes') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func131: TtkTokenKind; +begin + if KeyComp('prolog_edit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func132: TtkTokenKind; +begin + if KeyComp('set_input') then Result := tkKey else + if KeyComp('wildcard_match') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func133: TtkTokenKind; +begin + if KeyComp('interactor') then Result := tkKey else + if KeyComp('mutex_lock') then Result := tkKey else + if KeyComp('make_fat_filemap') then Result := tkKey else + if KeyComp('number_chars') then Result := tkKey else + if KeyComp('meta_predicate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func135: TtkTokenKind; +begin + if KeyComp('fileerrors') then Result := tkKey else + if KeyComp('ensure_loaded') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func136: TtkTokenKind; +begin + if KeyComp('free_variables') then Result := tkKey else + if KeyComp('int_to_atom') then Result := tkKey else + if KeyComp('current_flag') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func137: TtkTokenKind; +begin + if KeyComp('atom_prefix') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func138: TtkTokenKind; +begin + if KeyComp('sub_string') then Result := tkKey else + if KeyComp('exists_file') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func139: TtkTokenKind; +begin + if KeyComp('ttyflush') then Result := tkKey else + if KeyComp('current_op') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func140: TtkTokenKind; +begin + if KeyComp('write_term') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func141: TtkTokenKind; +begin + if KeyComp('get_single_char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func143: TtkTokenKind; +begin + if KeyComp('expand_file_name') then Result := tkKey else + if KeyComp('numbervars') then Result := tkKey else + if KeyComp('trim_stacks') then Result := tkKey else + if KeyComp('dwim_predicate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func145: TtkTokenKind; +begin + if KeyComp('file_search_path') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func146: TtkTokenKind; +begin + if KeyComp('mutex_create') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func147: TtkTokenKind; +begin + if KeyComp('thread_at_exit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func148: TtkTokenKind; +begin + if KeyComp('list_to_set') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func149: TtkTokenKind; +begin + if KeyComp('attach_console') then Result := tkKey else + if KeyComp('statistics') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func150: TtkTokenKind; +begin + if KeyComp('atom_to_term') then Result := tkKey else + if KeyComp('current_key') then Result := tkKey else + if KeyComp('term_to_atom') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func152: TtkTokenKind; +begin + if KeyComp('with_mutex') then Result := tkKey else + if KeyComp('default_module') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func153: TtkTokenKind; +begin + if KeyComp('noprotocol') then Result := tkKey else + if KeyComp('read_history') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func154: TtkTokenKind; +begin + if KeyComp('at_end_of_stream') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func155: TtkTokenKind; +begin + if KeyComp('string_concat') then Result := tkKey else + if KeyComp('convert_time') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func156: TtkTokenKind; +begin + if KeyComp('rl_read_init_file') then Result := tkKey else + if KeyComp('expand_answer') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func157: TtkTokenKind; +begin + if KeyComp('show_profile') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func158: TtkTokenKind; +begin + if KeyComp('print_message') then Result := tkKey else + if KeyComp('proper_list') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func159: TtkTokenKind; +begin + if KeyComp('current_atom') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func161: TtkTokenKind; +begin + if KeyComp('expand_query') then Result := tkKey else + if KeyComp('write_canonical') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func163: TtkTokenKind; +begin + if KeyComp('intersection') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func164: TtkTokenKind; +begin + if KeyComp('qsave_program') then Result := tkKey else + if KeyComp('character_count') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func165: TtkTokenKind; +begin + if KeyComp('goal_expansion') then Result := tkKey else + if KeyComp('rl_add_history') then Result := tkKey else + if KeyComp('stack_parameter') then Result := tkKey else + if KeyComp('string_length') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func166: TtkTokenKind; +begin + if KeyComp('set_prolog_flag') then Result := tkKey else + if KeyComp('open_resource') then Result := tkKey else + if KeyComp('profile_count') then Result := tkKey else + if KeyComp('set_output') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func168: TtkTokenKind; +begin + if KeyComp('current_thread') then Result := tkKey else + if KeyComp('protocolling') then Result := tkKey else + if KeyComp('export_list') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func169: TtkTokenKind; +begin + if KeyComp('line_position') then Result := tkKey else + if KeyComp('format_predicate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func170: TtkTokenKind; +begin + if KeyComp('mutex_unlock') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func173: TtkTokenKind; +begin + if KeyComp('thread_get_message') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func174: TtkTokenKind; +begin + if KeyComp('current_signal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func175: TtkTokenKind; +begin + if KeyComp('copy_stream_data') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func176: TtkTokenKind; +begin + if KeyComp('absolute_file_name') then Result := tkKey else + if KeyComp('open_shared_object') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func178: TtkTokenKind; +begin + if KeyComp('char_conversion') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func179: TtkTokenKind; +begin + if KeyComp('preprocessor') then Result := tkKey else + if KeyComp('thread_peek_message') then Result := tkKey else + if KeyComp('reset_profiler') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func181: TtkTokenKind; +begin + if KeyComp('close_shared_object') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func182: TtkTokenKind; +begin + if KeyComp('initialization') then Result := tkKey else + if KeyComp('current_module') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func183: TtkTokenKind; +begin + if KeyComp('string_to_atom') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func184: TtkTokenKind; +begin + if KeyComp('source_location') then Result := tkKey else + if KeyComp('thread_send_message') then Result := tkKey else + if KeyComp('wait_for_input') then Result := tkKey else + if KeyComp('context_module') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func186: TtkTokenKind; +begin + if KeyComp('term_expansion') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func187: TtkTokenKind; +begin + if KeyComp('portray_clause') then Result := tkKey else + if KeyComp('make_library_index') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func188: TtkTokenKind; +begin + if KeyComp('current_stream') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func189: TtkTokenKind; +begin + if KeyComp('discontiguous') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func190: TtkTokenKind; +begin + if KeyComp('flush_output') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func191: TtkTokenKind; +begin + if KeyComp('current_input') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func192: TtkTokenKind; +begin + if KeyComp('prolog_list_goal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func194: TtkTokenKind; +begin + if KeyComp('current_mutex') then Result := tkKey else + if KeyComp('string_to_list') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func195: TtkTokenKind; +begin + if KeyComp('prolog_file_type') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func196: TtkTokenKind; +begin + if KeyComp('current_predicate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func198: TtkTokenKind; +begin + if KeyComp('mutex_unlock_all') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func199: TtkTokenKind; +begin + if KeyComp('mutex_trylock') then Result := tkKey else + if KeyComp('open_null_stream') then Result := tkKey else + if KeyComp('file_directory_name') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func201: TtkTokenKind; +begin + if KeyComp('mutex_destroy') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func203: TtkTokenKind; +begin + if KeyComp('float_integer_part') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func205: TtkTokenKind; +begin + if KeyComp('at_initialization') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func206: TtkTokenKind; +begin + if KeyComp('is_absolute_file_name') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func207: TtkTokenKind; +begin + if KeyComp('file_name_extension') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func208: TtkTokenKind; +begin + if KeyComp('clause_property') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func209: TtkTokenKind; +begin + if KeyComp('prolog_skip_level') then Result := tkKey else + if KeyComp('load_foreign_library') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func210: TtkTokenKind; +begin + if KeyComp('dde_current_service') then Result := tkKey else + if KeyComp('current_functor') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func211: TtkTokenKind; +begin + if KeyComp('tty_get_capability') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func213: TtkTokenKind; +begin + if KeyComp('dde_register_service') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func215: TtkTokenKind; +begin + if KeyComp('expand_file_search_path') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func218: TtkTokenKind; +begin + if KeyComp('library_directory') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func222: TtkTokenKind; +begin + if KeyComp('print_message_lines') then Result := tkKey else + if KeyComp('call_with_depth_limit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func223: TtkTokenKind; +begin + if KeyComp('stream_property') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func225: TtkTokenKind; +begin + if KeyComp('current_output') then Result := tkKey else + if KeyComp('current_prolog_flag') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func226: TtkTokenKind; +begin + if KeyComp('arithmetic_function') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func227: TtkTokenKind; +begin + if KeyComp('float_fractional_part') then Result := tkDirective else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func228: TtkTokenKind; +begin + if KeyComp('exists_directory') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func231: TtkTokenKind; +begin + if KeyComp('predicate_property') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func233: TtkTokenKind; +begin + if KeyComp('prolog_load_context') then Result := tkKey else + if KeyComp('module_transparent') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func235: TtkTokenKind; +begin + if KeyComp('prolog_to_os_filename') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func237: TtkTokenKind; +begin + if KeyComp('open_dde_conversation') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func242: TtkTokenKind; +begin + if KeyComp('close_dde_conversation') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func243: TtkTokenKind; +begin + if KeyComp('prolog_current_frame') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func244: TtkTokenKind; +begin + if KeyComp('dde_current_connection') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func246: TtkTokenKind; +begin + if KeyComp('unload_foreign_library') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func250: TtkTokenKind; +begin + if KeyComp('dde_unregister_service') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func254: TtkTokenKind; +begin + if KeyComp('set_stream_position') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func262: TtkTokenKind; +begin + if KeyComp('prolog_frame_attribute') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func264: TtkTokenKind; +begin + if KeyComp('call_shared_object_function') then Result := tkKey else + if KeyComp('unify_with_occurs_check') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func271: TtkTokenKind; +begin + if KeyComp('redefine_system_predicate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func275: TtkTokenKind; +begin + if KeyComp('current_format_predicate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func279: TtkTokenKind; +begin + if KeyComp('current_foreign_library') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func284: TtkTokenKind; +begin + if KeyComp('current_char_conversion') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func301: TtkTokenKind; +begin + if KeyComp('prolog_trace_interception') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.Func332: TtkTokenKind; +begin + if KeyComp('current_arithmetic_function') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynPrologSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynPrologSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 333 then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynPrologSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}AndSymbolProc; + #39: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}AsciiCharProc; + '\': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}BackSlashProc; + '}': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}BraceCloseProc; + '{': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}BraceOpenProc; + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CRProc; + ':': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}ColonProc; + ',': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CommaProc; + '`': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}DotProc; + '=': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}EqualProc; + '>': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}GreaterProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}IdentProc; + '!': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}InfoProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LFProc; + '<': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LowerProc; + '-': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}MinusProc; + '%': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}ModSymbolProc; + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NullProc; + '|': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}OrSymbolProc; + '+': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}PlusProc; + '.': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}PointProc; + '(': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}RoundOpenProc; + ')': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}RoundCloseProc; + ';': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SemiColonProc; + '/': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SpaceProc; + ']': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SquareCloseProc; + '[': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SquareOpenProc; + '*': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}StarProc; + #34: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}StringProc; + '$': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SepcialString; + '~': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}TildeProc; + else fProcTable[I] := {$IFDEF FPC}@{$ENDIF}UnknownProc; + end; +end; + +constructor TSynPrologSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Foreground := clGreen; + AddAttribute(fCommentAttri); + + fDirectiveAttri := TSynHighLighterAttributes.Create(SYNS_AttrDirective); + fDirectiveAttri.Foreground := $00C05000; + AddAttribute(fDirectiveAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + fIdentifierAttri.Foreground := clWindowText; + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Foreground := clBlue; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighLighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clPurple; + AddAttribute(fNumberAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrWhiteSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clMaroon; + AddAttribute(fStringAttri); + + fSymbolAttri := TSynHighLighterAttributes.Create(SYNS_AttrSymbol); + fSymbolAttri.Foreground := clNavy; + AddAttribute(fSymbolAttri); + + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterProlog; +end; + +procedure TSynPrologSyn.SetLine(const NewValue :String; LineNumber :Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +function TSynPrologSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +procedure TSynPrologSyn.ReSetRange; +begin + fRange := rsUnknown; +end; + +class function TSynPrologSyn.GetLanguageName :string; +begin + Result := SYNS_LangProlog; +end; + +procedure TSynPrologSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynPrologSyn.AndSymbolProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.AsciiCharProc; +begin + fTokenID := tkString; + repeat + case FLine[Run] of + #0, #10, #13: Break; + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then Inc(Run); +end; + +procedure TSynPrologSyn.BackSlashProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.BraceCloseProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.BraceOpenProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.CRProc; +begin + fTokenID := tkSpace; + Case FLine[Run + 1] of + #10: Inc(Run, 2); + else Inc(Run); + end; +end; + +procedure TSynPrologSyn.ColonProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.CommaProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.DotProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.EqualProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.GreaterProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + Inc(Run, fStringLen); + while Identifiers[fLine[Run]] do Inc(Run); +end; + +procedure TSynPrologSyn.InfoProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.LFProc; +begin + fTokenID := tkSpace; + Inc(Run); +end; + +procedure TSynPrologSyn.LowerProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.MinusProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.ModSymbolProc; +begin + Inc(Run); + fTokenId := tkComment; +end; + +procedure TSynPrologSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynPrologSyn.OrSymbolProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.PlusProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.PointProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.RoundCloseProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.RoundOpenProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.SemiColonProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.AnsiCProc; //Comment handle //Kan +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + Exit; + end; + #10: + begin + LFProc; + Exit; + end; + #13: + begin + CRProc; + Exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + Inc(Run, 2); + fRange := rsUnKnown; + Break; + end + else + Inc(Run); + #10: Break; + #13: Break; + else + Inc(Run); + end; +end; + +procedure TSynPrologSyn.SlashProc; +begin + if FLine[Run + 1] = '*' then + begin + fTokenID := tkComment; + fRange := rsAnsiC; + Inc(Run); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + Inc(Run, 2); + fRange := rsUnknown; + Break; + end + else + Inc(Run); + #10: Break; + #13: Break; + else + Inc(Run); + end; + end + else + begin + Inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynPrologSyn.SpaceProc; +begin + Inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do + Inc(Run); +end; + +procedure TSynPrologSyn.SquareCloseProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.SquareOpenProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.StarProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then + Inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: Break; + #92: + if FLine[Run + 1] = #10 then Inc(Run); + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then Inc(Run); +end; + +procedure TSynPrologSyn.SepcialString; +begin + fTokenID := tkString; + repeat + case FLine[Run] of + #0, #10, #13: Break; + end; + Inc(Run); + until FLine[Run] = '$'; + if FLine[Run] <> #0 then Inc(Run); +end; + +procedure TSynPrologSyn.TildeProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynPrologSyn.UnknownProc; +begin + {$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else + {$ENDIF} + Inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynPrologSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsAnsiC: AnsiCProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynPrologSyn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_STRING : Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + else Result := nil; + end; +end; + +function TSynPrologSyn.GetEOL: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynPrologSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynPrologSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynPrologSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynPrologSyn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkDirective: Result := fDirectiveAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynPrologSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynPrologSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynPrologSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; +end; + +function TSynPrologSyn.IsFilterStored :Boolean; +begin + Result := (fDefaultFilter <> SYNS_FilterProlog); +end; + +initialization + MakeIdentTable; + {$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynPrologSyn); + {$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synedit.inc b/components/extrasyn/SyneditHighlighters/synedit.inc new file mode 100644 index 000000000..25bbe24ed --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synedit.inc @@ -0,0 +1,56 @@ +(******************************************************************************) +(* SynEdit Include File. This file was adapted from Brad Stowers' DFS.INC *) +(* file and used with permission. This will help reduce headaches when new *) +(* versions of Delphi and C++Builder are released, among other things. *) +(******************************************************************************) +(* Brad Stowers: bstowers@pobox.com *) +(* Delphi Free Stuff: http://delphifreestuff.com/ *) +(* February 24, 1999 *) +(******************************************************************************) +(* *) +(* Complete Boolean Evaluation compiler directive is turned off by including *) +(* this file. *) +(* *) +(* Here is a brief explanation of what each of the defines mean: *) +(* SYN_WIN32 : Compilation target is 32-bit Windows *) +(******************************************************************************) + +{$IFDEF FPC} + {$MODE OBJFPC} + {$DEFINE SYN_LAZARUS} +{$ENDIF} + +{$DEFINE SYNEDIT_INCLUDE} + +{$IFdef MSWindows} + {$DEFINE SYN_WIN32} +{$ENDIF} + +{------------------------------------------------------------------------------} +{ Common compiler defines } +{------------------------------------------------------------------------------} + +// defaults are short evaluation of boolean values and long strings + +// lazarus change no $B- +{$H+} + +{------------------------------------------------------------------------------} +{ Please change this to suit your needs } +{------------------------------------------------------------------------------} + +// support for multibyte character sets +{.$DEFINE SYN_MBCSSUPPORT} + +// additional tests for debugging + +{.$DEFINE SYN_DEVELOPMENT_CHECKS} + +{$IFDEF SYN_DEVELOPMENT_CHECKS} + +{$R+,Q+,S+,T+} + +{$ENDIF} + +// $Id: synedit.inc 42184 2013-07-23 18:44:37Z martin $ + diff --git a/components/extrasyn/SyneditHighlighters/syneditstrconstextra.pas b/components/extrasyn/SyneditHighlighters/syneditstrconstextra.pas new file mode 100644 index 000000000..88ae442a4 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/syneditstrconstextra.pas @@ -0,0 +1,317 @@ +unit SynEditStrConstExtra; + +Interface +uses SynEditStrConst; + +ResourceString + + SYNS_AttrSingleString = 'Single Quoted String'; + SYNS_AttrURI = 'URI'; + SYNS_AttrVisitedURI = 'Visited URI'; + SYNS_AttrVrmlAppearance = 'Vrml_Appearance'; + SYNS_AttrVrmlAttribute = 'Vrml_Attribute'; + SYNS_AttrVrmlDefinition = 'Vrml_Definition'; + SYNS_AttrVrmlEvent = 'Vrml_Event'; + SYNS_AttrVrmlGrouping = 'Vrml_Grouping'; + SYNS_AttrVrmlInterpolator = 'Vrml_Interpolator'; + SYNS_AttrVrmlLight = 'Vrml_Light'; + SYNS_AttrVrmlNode = 'Vrml_Node'; + SYNS_AttrVrmlParameter = 'Vrml_Parameter'; + SYNS_AttrVrmlProto = 'Vrml_Proto'; + SYNS_AttrVrmlSensor = 'Vrml_Sensor'; + SYNS_AttrVrmlShape = 'Vrml_Shape'; + SYNS_AttrVrmlShape_Hint = 'Vrml_Shape_Hint'; + SYNS_AttrVrmlTime_dependent = 'Vrml_Time_dependent'; + SYNS_AttrVrmlViewpoint = 'Vrml_Viewpoint'; + SYNS_AttrVrmlWorldInfo = 'Vrml_WorldInfo'; + SYNS_AttrX3DDocType = 'X3DDocType'; + SYNS_AttrX3DHeader = 'X3DHeader'; + SYNS_AttrAttribute = 'Attribute'; + SYNS_AttrArrowHead = 'Arrow Head'; + SYNS_AttrDirections = 'Direction'; + SYNS_AttrShape = 'Shape'; + + // names for highlighter attributes + SYNS_AttrAreaAIdentifier = 'Area A Identifier'; + SYNS_AttrAsm = 'Asm'; + SYNS_AttrAsmComment = 'Asm Comment'; + SYNS_AttrAsmKey = 'Asm Key'; + SYNS_AttrBasicTypes = 'Basic Types'; + SYNS_AttrBoolean = 'Boolean value'; + SYNS_AttrColor = 'Color Value'; + SYNS_AttrDebugLines = 'Debugging Lines'; + SYNS_AttrFirstTri = 'FirstTri'; + SYNS_AttrFourthTri = 'FourthTri'; + SYNS_AttrIndicator = 'Indicator Area'; + SYNS_AttrLace = 'Lace'; + SYNS_AttrLine = 'Line'; + SYNS_AttrOperatorAndSymbols = 'Operator And Symbols'; + SYNS_AttrOpLine = 'OpLine'; + SYNS_AttrPredefined = 'Predefined'; + SYNS_AttrQuad = 'Quad'; + SYNS_AttrResultValue = 'Result Value'; + SYNS_AttrSecondTri = 'SecondTri'; + SYNS_AttrSequence = 'Sequence Number Area'; + SYNS_AttrTagArea = 'Tag Area'; + SYNS_AttrThirdTri = 'ThirdTri'; + SYNS_AttrTriangle = 'Triangle'; + //SYNS_AttrAssembler = 'Assembler'; + //SYNS_AttrBlock = 'Block'; + //SYNS_AttrBrackets = 'Brackets'; + //SYNS_AttrCDATASection = 'CDATA Section'; + //SYNS_AttrCharacter = 'Character'; + //SYNS_AttrClass = 'Class'; + //SYNS_AttrComment = 'Comment'; + //SYNS_AttrCondition = 'Condition'; + //SYNS_AttrConditionalComment = 'Conditional Comment'; + //SYNS_AttrDataType = 'Data Type'; + //SYNS_AttrDefaultPackage = 'Default Packages'; + //SYNS_AttrDelimitedIdentifier = 'Delimited Identifier'; + //SYNS_AttrDir = 'Direction'; + //SYNS_AttrDirections = 'Directions'; + //SYNS_AttrDirective = 'Directive'; + //SYNS_AttrDOCTYPESection = 'DOCTYPE Section'; + //SYNS_AttrDocumentation = 'Documentation'; + //SYNS_AttrElementName = 'Element Name'; + //SYNS_AttrEmbedSQL = 'Embedded SQL'; + //SYNS_AttrEmbedText = 'Embedded Text'; + //SYNS_AttrEntityReference = 'Entity Reference'; + //SYNS_AttrEscapeAmpersand = 'Escape Ampersand'; + //SYNS_AttrEvent = 'Event'; + //SYNS_AttrException = 'Exception'; + //SYNS_AttrFloat = 'Float'; + //SYNS_AttrForm = 'Form'; + //SYNS_AttrFunction = 'Function'; + //SYNS_AttrHexadecimal = 'Hexadecimal'; + //SYNS_AttrIcon = 'Icon Reference'; + //SYNS_AttrIdentifier = 'Identifier'; + //SYNS_AttrIllegalChar = 'Illegal Char'; + //SYNS_AttrInclude = 'Include'; + //SYNS_AttrIndirect = 'Indirect'; + //SYNS_AttrInvalidSymbol = 'Invalid Symbol'; + //SYNS_AttrInternalFunction = 'Internal Function'; + //SYNS_AttrKey = 'Key'; + //SYNS_AttrLabel = 'Label'; + //SYNS_AttrMacro = 'Macro'; + //SYNS_AttrMarker = 'Marker'; + //SYNS_AttrMathMode = 'Math Mode'; + //SYNS_AttrMessage = 'Message'; + //SYNS_AttrMiscellaneous = 'Miscellaneous'; + //SYNS_AttrNamespaceAttrName = 'Namespace Attribute Name'; + //SYNS_AttrNamespaceAttrValue = 'Namespace Attribute Value'; + //SYNS_AttrNonReservedKeyword = 'Non-reserved Keyword'; + //SYNS_AttrNull = 'Null'; + //SYNS_AttrNumber = 'Number'; + //SYNS_AttrOctal = 'Octal'; + //SYNS_AttrOperator = 'Operator'; + //SYNS_AttrPLSQL = 'PL/SQL Reserved Word'; + //SYNS_AttrPragma = 'Pragma'; + //SYNS_AttrPreprocessor = 'Preprocessor'; + //SYNS_AttrProcessingInstr = 'Processing Instruction'; + //SYNS_AttrQualifier = 'Qualifier'; + //SYNS_AttrRegister = 'Register'; + //SYNS_AttrReservedWord = 'Reserved Word'; + //SYNS_AttrRoundBracket = 'Round Bracket'; + //SYNS_AttrRpl = 'Rpl'; + //SYNS_AttrRplKey = 'Rpl Key'; + //SYNS_AttrRplComment = 'Rpl Comment'; + //SYNS_AttrSASM = 'SASM'; + //SYNS_AttrSASMComment = 'SASM Comment'; + //SYNS_AttrSASMKey = 'SASM Key'; + //SYNS_AttrSecondReservedWord = 'Second Reserved Word'; + //SYNS_AttrSection = 'Section'; + //SYNS_AttrShape = 'Shape'; + //SYNS_AttrSingleString = 'Single Quoted String'; + //SYNS_AttrSpace = 'Space'; + //SYNS_AttrSpecialVariable = 'Special Variable'; + //SYNS_AttrSQLKey = 'SQL Keyword'; + //SYNS_AttrSQLPlus = 'SQL*Plus Command'; + //SYNS_AttrSquareBracket = 'Square Bracket'; + //SYNS_AttrString = 'String'; + //SYNS_AttrSymbol = 'Symbol'; + //SYNS_AttrSyntaxError = 'Syntax Error'; + //SYNS_AttrSystem = 'System Functions and Variables'; + //SYNS_AttrSystemValue = 'System Value'; + //SYNS_AttrTableName = 'Table Name'; + //SYNS_AttrTerminator = 'Terminator'; + //SYNS_AttrTeXCommand = 'TeX Command'; + //SYNS_AttrText = 'Text'; + //SYNS_AttrTextMathMode = 'Text in Math Mode'; + //SYNS_AttrUnknownWord = 'Unknown Word'; + //SYNS_AttrURI = 'URI'; + //SYNS_AttrUser = 'User Functions and Variables'; + //SYNS_AttrUserFunction = 'User Functions'; + //SYNS_AttrValue = 'Value'; + //SYNS_AttrVariable = 'Variable'; + //SYNS_AttrVisitedURI = 'Visited URI'; + //SYNS_AttrVrmlAppearance = 'Vrml_Appearance'; + //SYNS_AttrVrmlAttribute = 'Vrml_Attribute'; + //SYNS_AttrVrmlDefinition = 'Vrml_Definition'; + //SYNS_AttrVrmlEvent = 'Vrml_Event'; + //SYNS_AttrVrmlGrouping = 'Vrml_Grouping'; + //SYNS_AttrVrmlInterpolator = 'Vrml_Interpolator'; + //SYNS_AttrVrmlLight = 'Vrml_Light'; + //SYNS_AttrVrmlNode = 'Vrml_Node'; + //SYNS_AttrVrmlParameter = 'Vrml_Parameter'; + //SYNS_AttrVrmlProto = 'Vrml_Proto'; + //SYNS_AttrVrmlSensor = 'Vrml_Sensor'; + //SYNS_AttrVrmlShape = 'Vrml_Shape'; + //SYNS_AttrVrmlShape_Hint = 'Vrml_Shape_Hint'; + //SYNS_AttrVrmlTime_dependent = 'Vrml_Time_dependent'; + //SYNS_AttrVrmlViewpoint = 'Vrml_Viewpoint'; + //SYNS_AttrVrmlWorldInfo = 'Vrml_WorldInfo'; + //SYNS_AttrWhitespace = 'Whitespace'; + //SYNS_AttrX3DDocType = 'X3DDocType'; + //SYNS_AttrX3DHeader = 'X3DHeader'; + //// names of exporter output formats + //SYNS_ExporterFormatHTML = 'HTML'; + //SYNS_ExporterFormatRTF = 'RTF'; + //SYNS_ExporterFormatTeX = 'TeX'; + //// TCustomSynEdit scroll hint window caption + //SYNS_ScrollInfoFmt = '%d - %d'; + //SYNS_ScrollInfoFmtTop = 'Top Line: %d'; + //// TSynEditPrintPreview page number + //SYNS_PreviewScrollInfoFmt = 'Page: %d'; + //// strings for property editors etc + //SYNS_EDuplicateShortcut = 'Shortcut already exists'; + //SYNS_ShortcutNone = ''; + //SYNS_DuplicateShortcutMsg = 'The keystroke "%s" is already assigned ' + + //'to another editor command. (%s)'; + //SYNS_DuplicateShortcutMsg2 = 'The keystroke "%s" is already assigned ' + + //'to another editor command.'#13#10'The ' + + //'shortcut for this item has not been changed.'; + + //// Filters used for open/save dialog + + SYNS_FilterHP = 'HP48 Files (*.s,*.sou,*.a,*.hp)|*.S;*.SOU;*.A;*.HP'; + SYNS_FilterRuby = 'Ruby Files (*.rb;*.rbw)|*.rb;*.rbw'; + SYNS_FilterRC = 'Resource Files (*.rc)|*.rc'; + SYNS_FilterST = 'Structured Text Files (*.st)|*.st'; + SYNS_FilterURI = 'All Files (*.*)|*.*'; + SYNS_FilterVrml97 = 'Vrml97/X3D World (*.wrl;*.wrml;*.vrl;*.vrml;*.x3d)|*.wrl;*.wrml;*.vrl;*.vrml;*.x3d'; + SYNS_FilterCS = 'C# Files (*.cs)|*.cs'; + SYNS_FilterInno = 'Inno Setup Scripts (*.iss)|*.iss'; + SYNS_FilterCOBOL = 'COBOL Files (*.cbl;*.cob)|*.cbl;*.cob'; + SYNS_FilterHaskell = 'Haskell Files (*.hs;*.lhs)|*.hs;*.lhs'; + SYNS_FilterDOT = 'DOT Graph Drawing Description (*.dot)|*.dot'; + SYNS_FilterEiffel = 'Eiffel (*.e;*.ace)|*.e;*.ace'; + SYNS_FilterLDraw = 'LEGO LDraw Files (*.ldr)|*.ldr'; + SYNS_FilterLua = 'Lua Script File (*.Lua)|*.Lua'; + SYNS_FilterProlog = 'Prolog Files (*.pl;*.pro;*.prl)|*.pl;*.pro;*.prl'; + //SYNS_FilterX86Assembly = 'x86 Assembly Files (*.asm)|*.asm'; + //SYNS_FilterPascal = 'Pascal Files (*.pas;*.pp;*.dpr;*.dpk;*.inc)|*.pas;*.pp;*.dpr;*.dpk;*.inc'; + //SYNS_FilterHP48 = 'HP48 Files (*.s;*.sou;*.a;*.hp)|*.s;*.sou;*.a;*.hp'; + //SYNS_FilterCAClipper = 'CA-Clipper Files (*.prg;*.ch;*.inc)|*.prg;*.ch;*.inc'; + //SYNS_FilterCORBAIDL = 'CORBA IDL Files (*.idl)|*.idl'; + //SYNS_FilterCPM = 'CPM Reports (*.rdf;*.rif;*.rmf;*.rxf)|*.rdf;*.rif;*.rmf;*.rxf'; + //SYNS_FilterCPP = 'C/C++ Files (*.c;*.cpp;*.h;*.hpp)|*.c;*.cpp;*.h;*.hpp'; + //SYNS_FilterCS = 'C# Files (*.cs)|*.cs'; + //SYNS_FilterJava = 'Java Files (*.java)|*.java'; + //SYNS_FilterPerl = 'Perl Files (*.pl;*.pm;*.cgi)|*.pl;*.pm;*.cgi'; + //SYNS_FilterAWK = 'AWK Scripts (*.awk)|*.awk'; + //SYNS_FilterHTML = 'HTML Documents (*.htm;*.html)|*.htm;*.html'; + //SYNS_FilterVBScript = 'VBScript Files (*.vbs)|*.vbs'; + //SYNS_FilterGalaxy = 'Galaxy Files (*.gtv;*.galrep;*.txt)|*.gtv;*.galrep;*.txt'; + //SYNS_FilterPython = 'Python Files (*.py)|*.py'; + //SYNS_FilterSQL = 'SQL Files (*.sql)|*.sql'; + //SYNS_FilterTclTk = 'Tcl/Tk Files (*.tcl)|*.tcl'; + //SYNS_FilterRTF = 'Rich Text Format Documents (*.rtf)|*.rtf'; + //SYNS_FilterBatch = 'MS-DOS Batch Files (*.bat;*.cmd)|*.bat;*.cmd'; + //SYNS_FilterDFM = 'Borland Form Files (*.dfm;*.xfm)|*.dfm;*.xfm'; + //SYNS_FilterX86Assembly = 'x86 Assembly Files (*.asm)|*.asm'; + //SYNS_FilterGembase = 'GEMBASE Files (*.dml;*.gem)|*.dml;*.gem'; + //SYNS_FilterINI = 'INI Files (*.ini)|*.ini'; + //SYNS_FilterSML = 'Standard ML Files (*.sml)|*.sml'; + //SYNS_FilterVisualBASIC = 'Visual Basic Files (*.bas)|*.bas'; + //SYNS_FilterADSP21xx = 'DSP Files (*.dsp;*.inc)|*.dsp;*.inc'; + //SYNS_FilterPHP = 'PHP Files (*.php;*.php3;*.phtml;*.inc)|*.php;*.php3;*.phtml;*.inc'; + //SYNS_FilterCache = 'Cache Files (*.mac;*.inc;*.int)|*.mac;*.inc;*.int'; + //SYNS_FilterCSS = 'Cascading Stylesheets (*.css)|*.css'; + //SYNS_FilterJScript = 'Javascript Files (*.js)|*.js'; + //SYNS_FilterKIX = 'KiXtart Scripts (*.kix)|*.kix'; + //SYNS_FilterBaan = 'Baan 4GL Files (*.cln)|*.cln'; + //SYNS_FilterFoxpro = 'Foxpro Files (*.prg)|*.prg'; + //SYNS_FilterFortran = 'Fortran Files (*.for)|*.for'; + //SYNS_FilterAsm68HC11 = '68HC11 Assembler Files (*.hc11;*.asm;*.asc)|*.hc11;*.asm;*.asc'; + //SYNS_FilterProgress = 'Progress Files (*.w;*.p;*.i)|*.w;*.p;*.i'; + //SYNS_FilterModelica = 'Modelica Files (*.mo)|*.mo'; + //SYNS_FilterModula3 = 'Modula-3 Files (*.m3)|*.m3'; + //SYNS_FilterSDD = 'Semanta DD Files (*.sdd)|*.sdd'; + //SYNS_FilterXML = 'XML Files (*.xml;*.xsd;*.xsl;*.xslt;*.dtd)|*.xml;*.xsd;*.xsl;*.xslt;*.dtd'; + //SYNS_FilterGWS = 'GW-TEL Scripts (*.gws)|*.gws'; + //SYNS_FilterSynGenMsgfiles = 'Msg Files (*.msg)|*.msg'; + //SYNS_FilterST = 'Structured Text Files (*.st)|*.st'; + //SYNS_FilterTeX = 'TeX Files (*.tex)|*.tex'; + //SYNS_FilterRC = 'Resource Files (*.rc)|*.rc'; + //SYNS_FilterRuby = 'Ruby Files (*.rb;*.rbw)|*.rb;*.rbw'; + //SYNS_FilterUNIXShellScript = 'UNIX Shell Scripts (*.sh)|*.sh'; + //SYNS_FilterURI = 'All Files (*.*)|*.*'; + //SYNS_FilterVrml97 = 'Vrml97/X3D World (*.wrl;*.wrml;*.vrl;*.vrml;*.x3d)|*.wrl;*.wrml;*.vrl;*.vrml;*.x3d'; + + //// Language names. Maybe somebody wants them translated / more detailed... + + SYNS_LangCS = 'CSharp'; + SYNS_LangInno = 'Inno Setup Script'; + SYNS_LangST = 'Structured Text'; + SYNS_LangCOBOL = 'COBOL'; + SYNS_LangRC = 'Resource'; + SYNS_LangRuby = 'Ruby'; + SYNS_LangHaskell = 'Haskell'; + SYNS_LangDOT = 'DOT Graph Drawing Description language'; + SYNS_LangEiffel = 'Eiffel'; + SYNS_LangLDraw = 'LEGO LDraw'; + SYNS_LangURI = 'URI'; + SYNS_LangVrml97 = 'Vrml97'; + SYNS_LangLua = 'Lua Script'; + SYNS_Lang8051 = '8051 Assembler'; + SYNS_LangProlog = 'Prolog'; + //SYNS_LangHP48 = 'HP48'; + //SYNS_LangCAClipper = 'CA-Clipper'; + //SYNS_LangCPM = 'COAS Product Manager Report'; + //SYNS_LangCPP = 'C/C++'; + //SYNS_LangCS = 'C#'; + //SYNS_LangJava = 'Java'; + //SYNS_LangPerl = 'Perl'; + //SYNS_LangBatch = 'MS-DOS Batch'; + //SYNS_LangDfm = 'Borland Forms'; + //SYNS_LangAWK = 'AWK'; + //SYNS_LangCORBAIDL = 'CORBA IDL'; + //SYNS_LangHTML = 'HTML'; + //SYNS_LangVBSScript = 'MS VBScript'; + //SYNS_LangGalaxy = 'Galaxy'; + //SYNS_LangGeneral = 'General'; + //SYNS_LangPascal = 'Object Pascal'; + //SYNS_LangX86Asm = 'x86 Assembly'; + //SYNS_LangPython = 'Python'; + //SYNS_LangTclTk = 'Tcl/Tk'; + //SYNS_LangSQL = 'SQL'; + //SYNS_LangGembase = 'Gembase'; + //SYNS_LangINI = 'INI'; + //SYNS_LangSML = 'Standard ML'; + //SYNS_LangVisualBASIC = 'Visual Basic'; + //SYNS_LangADSP21xx = 'ADSP21xx'; + //SYNS_LangPHP = 'PHP'; + //SYNS_LangSybaseSQL = 'Sybase SQL'; + //SYNS_LangGeneralMulti = 'General Multi-Highlighter'; + //SYNS_LangCache = 'Cache Object Script'; + //SYNS_LangCSS = 'Cascading Style Sheet'; + //SYNS_LangJScript = 'JavaScript'; + //SYNS_LangKIX = 'KiXtart'; + //SYNS_LangBaan = 'Baan 4GL'; + //SYNS_LangFoxpro = 'Foxpro'; + //SYNS_LangFortran = 'Fortran'; + //SYNS_Lang68HC11 = '68HC11 Assembler'; + //SYNS_LangProgress = 'Progress'; + //SYNS_LangModelica = 'Modelica'; + //SYNS_LangModula3 = 'Modula 3'; + //SYNS_LangSDD = 'Semanta Data Dictionary'; + //SYNS_LangXML = 'XML'; + //SYNS_LangGWS = 'GW-TEL'; + //SYNS_LangSynGenMsgfiles = 'SynGen Msg'; + //SYNS_LangUnreal = 'Unreal'; + //SYNS_LangTeX = 'TeX'; + //SYNS_LangNameUNIXShellScript = 'UNIX Shell Script'; + +implementation + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighteradsp21xx.pas b/components/extrasyn/SyneditHighlighters/synhighlighteradsp21xx.pas new file mode 100644 index 000000000..ef864df57 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighteradsp21xx.pas @@ -0,0 +1,1425 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterADSP21xx.pas, released 2000-04-17. +The Original Code is based on the wbADSP21xxSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Wynand Breytenbach. +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: SynHighlighterADSP21xx.pas,v 1.17 2005/01/28 16:53:20 maelh Exp $ + +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 ADSP21xx highlighter for SynEdit) +@author(Wynand Breytenbach, converted to SynEdit by David Muir ) +@created(1999) +@lastmod(2000-06-23) +The SynHighlighterADSP21xx unit provides a ADSP21xx DSP assembler highlighter for SynEdit. +} +unit SynHighlighterADSP21xx; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TTokenKind = (tkComment, tkCondition, tkIdentifier, tkKey, tkNull, tkNumber, + tkRegister, tkSpace, tkString, tkSymbol, tkUnknown); + + TRangeState = (rsUnKnown, rsPascalComment, rsCComment, rsHexNumber, + rsBinaryNumber, rsInclude); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TTokenKind of object; + + TSynADSP21xxSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fIdentFuncTable: array[0..191] of TIdentFuncTableFunc; + fTokenPos: Integer; + FTokenID: TTokenKind; + fNumberAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fRegisterAttri: TSynHighlighterAttributes; + fConditionAttri: TSynHighlighterAttributes; + fNullAttri: TSynHighlighterAttributes; + fUnknownAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func2: TTokenKind; + function Func4: TTokenKind; + function Func7: TTokenKind; + function Func8: TTokenKind; + function Func9: TTokenKind; + function Func12: TTokenKind; + function Func13: TTokenKind; + function Func15: TTokenKind; + function Func17: TTokenKind; + function Func18: TTokenKind; + function Func19: TTokenKind; + function Func20: TTokenKind; + function Func21: TTokenKind; + function Func22: TTokenKind; + function Func23: TTokenKind; + function Func24: TTokenKind; + function Func25: TTokenKind; + function Func26: TTokenKind; + function Func27: TTokenKind; + function Func28: TTokenKind; + function Func29: TTokenKind; + function Func30: TTokenKind; + function Func31: TTokenKind; + function Func32: TTokenKind; + function Func33: TTokenKind; + function Func35: TTokenKind; + function Func36: TTokenKind; + function Func37: TTokenKind; + function Func38: TTokenKind; + function Func39: TTokenKind; + function Func40: TTokenKind; + function Func41: TTokenKind; + function Func42: TTokenKind; + function Func43: TTokenKind; + function Func44: TTokenKind; + function Func45: TTokenKind; + function Func46: TTokenKind; + function Func47: TTokenKind; + function Func49: TTokenKind; + function Func50: TTokenKind; + function Func52: TTokenKind; + function Func53: TTokenKind; + function Func54: TTokenKind; + function Func55: TTokenKind; + function Func57: TTokenKind; + function Func58: TTokenKind; + function Func60: TTokenKind; + function Func61: TTokenKind; + function Func62: TTokenKind; + function Func63: TTokenKind; + function Func64: TTokenKind; + function Func65: TTokenKind; + function Func66: TTokenKind; + function Func67: TTokenKind; + function Func68: TTokenKind; + function Func69: TTokenKind; + function Func70: TTokenKind; + function Func71: TTokenKind; + function Func72: TTokenKind; + function Func73: TTokenKind; + function Func74: TTokenKind; + function Func75: TTokenKind; + function Func76: TTokenKind; + function Func79: TTokenKind; + function Func80: TTokenKind; + function Func81: TTokenKind; + function Func82: TTokenKind; + function Func83: TTokenKind; + function Func84: TTokenKind; + function Func88: TTokenKind; + function Func89: TTokenKind; + function Func90: TTokenKind; + function Func92: TTokenKind; + function Func94: TTokenKind; + function Func95: TTokenKind; + function Func98: TTokenKind; + function Func99: TTokenKind; + function Func107: TTokenKind; + function Func113: TTokenKind; + function Func145: TTokenKind; + function AltFunc: TTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TTokenKind; + procedure MakeMethodTables; + procedure PascalCommentProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure CCommentProc; + procedure CRProc; + procedure ExclamationProc; + procedure IdentProc; + procedure IntegerProc; + procedure IncludeCloseProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure BinaryNumber; + procedure HexNumber; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetCapabilities: TSynHighlighterCapabilities; override; + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TTokenKind; + procedure SetLine(const NewValue: string; LineNumber:Integer); override; + function GetToken: string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + property IdentChars; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property ConditionAttri: TSynHighlighterAttributes read fConditionAttri + write fConditionAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property RegisterAttri: TSynHighlighterAttributes read fRegisterAttri + write fRegisterAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst,SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + i, J: Char; +begin + for i := #0 to #255 do + begin + Case i of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[i] := True; + else Identifiers[i] := False; + end; + J := UpCase(i); + Case i of + '0'..'9','a'..'z', 'A'..'Z', '_': mHashTable[i] := Ord(J) - 64; + else mHashTable[Char(i)] := 0; + end; + end; +end; + +procedure TSynADSP21xxSyn.InitIdent; +var + i: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + + fIdentFuncTable[2] := @Func2; + fIdentFuncTable[4] := @Func4; + fIdentFuncTable[7] := @Func7; + fIdentFuncTable[8] := @Func8; + fIdentFuncTable[9] := @Func9; + fIdentFuncTable[12] := @Func12; + fIdentFuncTable[13] := @Func13; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[18] := @Func18; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[20] := @Func20; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[24] := @Func24; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[27] := @Func27; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[44] := @Func44; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[46] := @Func46; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[55] := @Func55; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[61] := @Func61; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[90] := @Func90; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[94] := @Func94; + fIdentFuncTable[95] := @Func95; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[113] := @Func113; + fIdentFuncTable[145] := @Func145; +end; + +function TSynADSP21xxSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + while ToHash^ in ['_', '0'..'9'] do + inc(ToHash); + fStringLen := ToHash - fToIdent; +end; + +function TSynADSP21xxSyn.KeyComp(const aKey: string): Boolean; +var + i: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else + Result := False; +end; + +function TSynADSP21xxSyn.Func2: TTokenKind; +begin + if KeyComp('b') then + begin + if FLine[Run+1] = '#'then + begin + Result := tkNumber; + fRange := rsBinaryNumber; + end + else + begin + Result := tkIdentifier; + end + end + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func4: TTokenKind; +begin + if KeyComp('ac') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func7: TTokenKind; +begin + if KeyComp('af') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func8: TTokenKind; +begin + if KeyComp('h') then + begin + if FLine[Run+1] = '#'then + begin + Result := tkNumber; + fRange := rsHexNumber; + end + else + begin + Result := tkIdentifier; + end + end + else if KeyComp('ce') then Result := tkCondition else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func9: TTokenKind; +begin + if KeyComp('i0') then Result := tkRegister + else if KeyComp('i1') then Result := tkRegister + else if KeyComp('i2') then Result := tkRegister + else if KeyComp('i3') then Result := tkRegister + else if KeyComp('i4') then Result := tkRegister + else if KeyComp('i5') then Result := tkRegister + else if KeyComp('i6') then Result := tkRegister + else if KeyComp('i7') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func12: TTokenKind; +begin + if KeyComp('l0') then Result := tkRegister + else if KeyComp('l1') then Result := tkRegister + else if KeyComp('l2') then Result := tkRegister + else if KeyComp('l3') then Result := tkRegister + else if KeyComp('l4') then Result := tkRegister + else if KeyComp('l5') then Result := tkRegister + else if KeyComp('l6') then Result := tkRegister + else if KeyComp('l7') then Result := tkRegister + else if KeyComp('ge') then Result := tkCondition + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func13: TTokenKind; +begin + if KeyComp('m0') then Result := tkRegister + else if KeyComp('m1') then Result := tkRegister + else if KeyComp('m2') then Result := tkRegister + else if KeyComp('m3') then Result := tkRegister + else if KeyComp('m4') then Result := tkRegister + else if KeyComp('m5') then Result := tkRegister + else if KeyComp('m6') then Result := tkRegister + else if KeyComp('m7') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func15: TTokenKind; +begin + if KeyComp('If') then Result := tkKey + else if KeyComp('bm') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func17: TTokenKind; +begin + if KeyComp('dm') then Result := tkRegister + else if KeyComp('le') then Result := tkCondition + else if KeyComp('hi') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func18: TTokenKind; +begin + if KeyComp('ifc') then Result := tkRegister + else if KeyComp('fl0') then Result := tkRegister + else if KeyComp('fl1') then Result := tkRegister + else if KeyComp('fl2') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func19: TTokenKind; +begin + if KeyComp('Do') then Result := tkKey + else if KeyComp('and') then Result := tkKey + else if KeyComp('ne') then Result := tkCondition + else if KeyComp('mf') then Result := tkCondition + else if KeyComp('pc') then Result := tkRegister + else if KeyComp('ar') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func20: TTokenKind; +begin + if KeyComp('ena') then Result := tkKey + else if KeyComp('cache') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func21: TTokenKind; +begin + if KeyComp('Of') then Result := tkKey + else if KeyComp('sb') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func22: TTokenKind; +begin + if KeyComp('abs') then Result := tkRegister + else if KeyComp('eq') then Result := tkCondition + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func23: TTokenKind; +begin + if KeyComp('In') then Result := tkKey + else if KeyComp('av') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func24: TTokenKind; +begin + if KeyComp('io') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func25: TTokenKind; +begin + if KeyComp('ax0') then Result := tkRegister + else if KeyComp('ax1') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func26: TTokenKind; +begin + if KeyComp('ay0') then Result := tkRegister + else if KeyComp('ay1') then Result := tkRegister + else if KeyComp('neg') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func27: TTokenKind; +begin + if KeyComp('by') then Result := tkKey + else if KeyComp('gt') then Result := tkCondition + else if KeyComp('lo') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func28: TTokenKind; +begin + if KeyComp('call') then Result := tkKey + else if KeyComp('si') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func29: TTokenKind; +begin + if KeyComp('pm') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func30: TTokenKind; +begin + if KeyComp('idle') then Result := tkKey + else if KeyComp('ifdef') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func31: TTokenKind; +begin + if KeyComp('seg') then Result := tkRegister + else if KeyComp('mr') then Result := tkRegister + else if KeyComp('mr0') then Result := tkRegister + else if KeyComp('mr1') then Result := tkRegister + else if KeyComp('mr2') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func32: TTokenKind; +begin + if KeyComp('ram') then Result := tkRegister + else if KeyComp('lt') then Result := tkCondition + else if KeyComp('dis') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func33: TTokenKind; +begin + if KeyComp('Or') then Result := tkKey + else if KeyComp('circ') then Result := tkRegister + else if KeyComp('name') then Result := tkKey + else if KeyComp('clr') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func35: TTokenKind; +begin + if KeyComp('mv') then Result := tkCondition else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func36: TTokenKind; +begin + if KeyComp('rnd') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func37: TTokenKind; +begin + if KeyComp('mx0') then Result := tkRegister + else if KeyComp('mx1') then Result := tkRegister + else if KeyComp('sr') then Result := tkRegister + else if KeyComp('sr0') then Result := tkRegister + else if KeyComp('sr1') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func38: TTokenKind; +begin + if KeyComp('my0') then Result := tkRegister + else if KeyComp('my1') then Result := tkRegister + else if KeyComp('ss') then Result := tkCondition + else if KeyComp('endif') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func39: TTokenKind; +begin + if KeyComp('for') then Result := tkKey + else if KeyComp('shl') then Result := tkKey + else if KeyComp('clear') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func40: TTokenKind; +begin + if KeyComp('sat') then Result := tkKey + else if KeyComp('su') then Result := tkRegister + else if KeyComp('us') then Result := tkCondition + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func41: TTokenKind; +begin + if KeyComp('var') then Result := tkKey + else if KeyComp('else') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func42: TTokenKind; +begin + if KeyComp('emode') then + Result := tkRegister + else if KeyComp('rx0') then + Result := tkRegister + else if KeyComp('rx1') then + Result := tkRegister + else if KeyComp('uu') then + Result := tkCondition + else + Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func43: TTokenKind; +begin + if KeyComp('local') then Result := tkKey + else if KeyComp('define') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func44: TTokenKind; +begin + if KeyComp('set') then Result := tkKey + else if KeyComp('tx0') then Result := tkRegister + else if KeyComp('tx1') then Result := tkRegister + else if KeyComp('ifndef') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func45: TTokenKind; +begin + if KeyComp('Shr') then Result := tkKey + else if KeyComp('nop') then Result := tkKey + else if KeyComp('exp') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func46: TTokenKind; +begin + if KeyComp('rom') then Result := tkKey + else if KeyComp('aux') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func47: TTokenKind; +begin + if KeyComp('rti') then Result := tkKey + else if KeyComp('pop') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func49: TTokenKind; +begin + if KeyComp('cntl') then Result := tkKey + else if KeyComp('global') then Result := tkKey + else if KeyComp('not') then Result := tkCondition + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func50: TTokenKind; +begin + if KeyComp('macro') then Result := tkKey + else if KeyComp('undef') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func52: TTokenKind; +begin + if KeyComp('init') then Result := tkKey + else if KeyComp('boot') then Result := tkKey + else if KeyComp('divq') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func53: TTokenKind; +begin + if KeyComp('imask') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func54: TTokenKind; +begin + if KeyComp('divs') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func55: TTokenKind; +begin + if KeyComp('endmod') then Result := tkKey + else if KeyComp('cntr') then Result := tkRegister + else if KeyComp('pass') then Result := tkKey + else if KeyComp('trap') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func57: TTokenKind; +begin + if KeyComp('xor') then Result := tkKey + else if KeyComp('rts') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func58: TTokenKind; +begin + if KeyComp('icntl') then Result := tkRegister + else if KeyComp('loop') then Result := tkKey + else if KeyComp('regbank') then Result := tkKey + else if KeyComp('sts') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func60: TTokenKind; +begin + if KeyComp('jump') then Result := tkKey + else if KeyComp('expadj') then Result := tkKey + else if KeyComp('norm') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func61: TTokenKind; +begin + if KeyComp('astat') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func62: TTokenKind; +begin + if KeyComp('shift') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func63: TTokenKind; +begin + if KeyComp('ashift') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func64: TTokenKind; +begin + if KeyComp('push') then Result := tkKey + else if KeyComp('test') then Result := tkKey + else if KeyComp('true') then Result := tkKey + else if KeyComp('clrbit') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func65: TTokenKind; +begin + if KeyComp('timer') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func66: TTokenKind; +begin + if KeyComp('toggle') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func67: TTokenKind; +begin + if KeyComp('reset') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func68: TTokenKind; +begin + if KeyComp('include') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func69: TTokenKind; +begin + if KeyComp('port') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func70: TTokenKind; +begin + if KeyComp('module') then Result := tkKey + else if KeyComp('tglbit') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func71: TTokenKind; +begin + if KeyComp('const') then Result := tkKey + else if KeyComp('newpage') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func72: TTokenKind; +begin + if KeyComp('static') then Result := tkKey + else if KeyComp('modify') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func73: TTokenKind; +begin + if KeyComp('endmacro') then Result := tkKey + else if KeyComp('mstat') then Result := tkRegister + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func74: TTokenKind; +begin + if KeyComp('lshift') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func75: TTokenKind; +begin + if KeyComp('setbit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func76: TTokenKind; +begin + if KeyComp('Until') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func79: TTokenKind; +begin + if KeyComp('sstat') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func80: TTokenKind; +begin + if KeyComp('flag_in') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func81: TTokenKind; +begin + if KeyComp('m_mode') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func82: TTokenKind; +begin + if KeyComp('entry') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func83: TTokenKind; +begin + if KeyComp('segment') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func84: TTokenKind; +begin + if KeyComp('abstract') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func88: TTokenKind; +begin + if KeyComp('sec_reg') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func89: TTokenKind; +begin + if KeyComp('forever') then Result := tkCondition else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func90: TTokenKind; +begin + if KeyComp('ar_sat') then Result := tkKey + else if KeyComp('go_mode') then Result := tkKey + else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func92: TTokenKind; +begin + if KeyComp('DMOVLAY') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func94: TTokenKind; +begin + if KeyComp('alt_reg') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func95: TTokenKind; +begin + if KeyComp('testbit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func98: TTokenKind; +begin + if KeyComp('av_latch') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func99: TTokenKind; +begin + if KeyComp('external') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func107: TTokenKind; +begin + if KeyComp('bit_rev') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func113: TTokenKind; +begin + if KeyComp('flag_out') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.Func145: TTokenKind; +begin + if KeyComp('topofpcstack') then Result := tkRegister else Result := tkIdentifier; +end; + +function TSynADSP21xxSyn.AltFunc: TTokenKind; +begin + Result := tkIdentifier +end; + +function TSynADSP21xxSyn.IdentKind(MayBe: PChar): TTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 192 then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynADSP21xxSyn.MakeMethodTables; +var + i: Char; +begin + for i := #0 to #255 do + case i of + #0: fProcTable[i] := @NullProc; + #10: fProcTable[i] := @LFProc; + #13: fProcTable[i] := @CRProc; + #1..#9, #11, #12, #14..#32: fProcTable[i] := @SpaceProc; + '$': fProcTable[i] := @IntegerProc; + #39: fProcTable[I] := @StringProc; + '0'..'9': fProcTable[i] := @NumberProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[i] := @IdentProc; + '{': fProcTable[i] := @BraceOpenProc; + '}': fProcTable[i] := @BraceCloseProc; + '/': fProcTable[i] := @SlashProc; + '>': fProcTable[i] := @IncludeCloseProc; + '!': fProcTable[i] := @ExclamationProc; + else fProcTable[i] := @UnknownProc; + end; +end; + +constructor TSynADSP21xxSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.ForeGround := clTeal; + fCommentAttri.Style:= [fsItalic]; + AddAttribute(fCommentAttri); + + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.ForeGround := clOlive; + AddAttribute(fNumberAttri); + + fRegisterAttri := TSynHighlighterAttributes.Create(SYNS_AttrRegister); + fRegisterAttri.ForeGround := clBlue; + AddAttribute(fRegisterAttri); + + fConditionAttri := TSynHighlighterAttributes.Create(SYNS_AttrCondition); + fConditionAttri.ForeGround := clFuchsia; + AddAttribute(fConditionAttri); + + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + + fNullAttri := TSynHighlighterAttributes.Create(SYNS_AttrNull); + AddAttribute(fNullAttri); + + fUnknownAttri := TSynHighlighterAttributes.Create(SYNS_AttrUnknownWord); + AddAttribute(fUnknownAttri); + + SetAttributesOnChange(@DefHighlightChange); + + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterADSP21xx; +end; + +procedure TSynADSP21xxSyn.SetLine(const NewValue: string; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + Next; +end; + +procedure TSynADSP21xxSyn.BraceCloseProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynADSP21xxSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #39) and (FLine[Run + 2] = #39) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynADSP21xxSyn.PascalCommentProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + #13: + begin + CRProc; + exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '}': + begin + fRange := rsUnKnown; + inc(Run); + break; + end; + #10: break; + #13: break; + else inc(Run); + end; +end; + +procedure TSynADSP21xxSyn.CCommentProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: begin + NullProc; + exit; + end; + #10:begin + LFProc; + exit; + end; + #13:begin + CRProc; + exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '*': + begin + if FLine[Run+1] = '/' then + begin + fRange := rsUnknown; + inc(Run, 2); + break; + end + else + Inc(Run); + end; + #10: break; + #13: break; + else inc(Run); + end; +end; + +procedure TSynADSP21xxSyn.BraceOpenProc; +begin + fTokenID := tkComment; + fRange := rsPascalComment; + inc(Run); + while FLine[Run] <> #0 do + case FLine[Run] of + '}': + begin + fRange := rsUnKnown; + inc(Run); + break; + end; + #10: break; + #13: break; + else inc(Run); + end; +end; + + +procedure TSynADSP21xxSyn.IncludeCloseProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynADSP21xxSyn.CRProc; +begin + fTokenID := tkSpace; + Case FLine[Run + 1] of + #10: inc(Run, 2); + else inc(Run); + end; +end; + +procedure TSynADSP21xxSyn.ExclamationProc; +begin + fTokenID := tkComment; + repeat + inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynADSP21xxSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + inc(Run); +end; + +procedure TSynADSP21xxSyn.IntegerProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f'] do inc(Run); +end; + +procedure TSynADSP21xxSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynADSP21xxSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynADSP21xxSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f','x','X','.'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynADSP21xxSyn.HexNumber; +begin + inc(Run); + fTokenID := tkNumber; + fRange := rsUnKnown; + while FLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f'] do + begin + inc(Run); + end; +end; + +procedure TSynADSP21xxSyn.BinaryNumber; +begin + inc(Run); + fRange := rsUnKnown; + while FLine[Run] in ['0'..'1'] do + begin + inc(Run); + end; + if FLine[Run] in ['2'..'9', 'A'..'F', 'a'..'f'] then + fTokenID := tkIdentifier + else + fTokenID := tkNumber; +end; + +procedure TSynADSP21xxSyn.SlashProc; +begin + if FLine[Run + 1] = '*' then + begin + fTokenID := tkComment; + fRange := rsCComment; + inc(Run, 2); + while FLine[Run] <> #0 do + case FLine[Run] of + '*': begin + if FLine[Run+1] = '/' then + begin + inc(Run, 2); + fRange := rsUnknown; + break; + end + else inc(Run); + end; + #10: break; + #13: break; + else inc(Run); + end; + end + else + begin + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynADSP21xxSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynADSP21xxSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynADSP21xxSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsPascalComment: PascalCommentProc; + rsCComment: CCommentProc; + rsHexNumber: HexNumber; + rsBinaryNumber: BinaryNumber; + else + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; +end; + +function TSynADSP21xxSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynADSP21xxSyn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSynADSP21xxSyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynADSP21xxSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength:=Run-fTokenPos; + TokenStart:=FLine + fTokenPos; +end; +{$ENDIF} + +function TSynADSP21xxSyn.GetTokenID: TTokenKind; +begin + Result := fTokenId; +end; + +function TSynADSP21xxSyn.GetTokenKind: integer; +begin + Result := Ord(GetTokenID); +end; + +function TSynADSP21xxSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkRegister: Result := fRegisterAttri; + tkCondition: Result := fConditionAttri; + tkUnknown: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynADSP21xxSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynADSP21xxSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +procedure TSynADSP21xxSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynADSP21xxSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +function TSynADSP21xxSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynADSP21xxSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterADSP21xx; +end; + +class function TSynADSP21xxSyn.GetLanguageName: string; +begin + Result := SYNS_LangADSP21xx; +end; + +class function TSynADSP21xxSyn.GetCapabilities: TSynHighlighterCapabilities; +begin + Result := inherited GetCapabilities + [hcUserSettings]; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynADSP21xxSyn); +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterasm.pas b/components/extrasyn/SyneditHighlighters/synhighlighterasm.pas new file mode 100644 index 000000000..1b2708923 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterasm.pas @@ -0,0 +1,565 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterASM.pas, released 2000-04-18. +The Original Code is based on the nhAsmSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Nick Hoddinott. +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: SynHighlighterAsm.pas,v 1.15 2005/01/28 16:53:20 maelh Exp $ + +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 x86 Assembler highlighter for SynEdit) +@author(Nick Hoddinott , converted to SynEdit by David Muir ) +@created(7 November 1999, converted to SynEdit April 18, 2000) +@lastmod(April 18, 2000) +The SynHighlighterASM unit provides SynEdit with a x86 Assembler (.asm) highlighter. +The highlighter supports all x86 op codes, Intel MMX and AMD 3D NOW! op codes. +Thanks to Martin Waldenburg, Hideo Koiso. +} +unit SynHighlighterAsm; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + SynHighlighterHashEntries, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, + tkString, tkSymbol, tkUnknown); + + TProcTableProc = procedure of object; + +type + TSynAsmSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fKeywords: TSynHashEntryList; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + procedure CommentProc; + procedure CRProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure NullProc; + procedure NumberProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure SingleQuoteStringProc; + procedure SymbolProc; + procedure UnknownProc; + procedure DoAddKeyword(AKeyword: string; AKind: integer); + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +const + OpCodes: string = 'aaa,aad,aam,adc,add,and,arpl,bound,bsf,bsr,bswap,bt,btc,' + + 'btr,bts,call,cbw,cdq,clc,cld,cli,clts,cmc,cmp,cmps,cmpsb,cmpsd,cmpsw,' + + 'cmpxchg,cwd,cwde,daa,das,dec,div,emms,enter,f2xm1,fabs,fadd,faddp,fbld,' + + 'fbstp,fchs,fclex,fcmovb,fcmovbe,fcmove,fcmovnb,fcmovnbe,fcmovne,fcmovnu,' + + 'fcmovu,fcom,fcomi,fcomip,fcomp,fcompp,fcos,fdecstp,fdiv,fdivp,fdivr,' + + 'fdivrp,femms,ffree,fiadd,ficom,ficomp,fidiv,fidivr,fild,fimul,fincstp,' + + 'finit,fist,fistp,fisub,fisubr,fld,fld1,fldcw,fldenv,fldl2e,fldl2t,fldlg2,' + + 'fldln2,fldpi,fldz,fmul,fmulp,fnclex,fninit,fnop,fnsave,fnstcw,fnstenv,' + + 'fnstsw,fpatan,fprem1,fptan,frndint,frstor,fsave,fscale,fsin,fsincos,' + + 'fsqrt,fst,fstcw,fstenv,fstp,fstsw,fsub,fsubp,fsubr,fsubrp,ftst,' + + 'fucom,fucomi,fucomip,fucomp,fucompp,fwait,fxch,fxtract,fyl2xp1,hlt,idiv,' + + 'imul,in,inc,ins,insb,insd,insw,int,into,invd,invlpg,iret,iretd,iretw,' + + 'ja,jae,jb,jbe,jc,jcxz,je,jecxz,jg,jge,jl,jle,jmp,jna,jnae,jnb,jnbe,jnc,' + + 'jne,jng,jnge,jnl,jnle,jno,jnp,jns,jnz,jo,jp,jpe,jpo,js,jz,lahf,lar,lds,' + + 'lea,leave,les,lfs,lgdt,lgs,lidt,lldt,lmsw,lock,lods,lodsb,lodsd,lodsw,' + + 'loop,loope,loopne,loopnz,loopz,lsl,lss,ltr,mov,movd,movq, movs,movsb,' + + 'movsd,movsw,movsx,movzx,mul,neg,nop,not,or,out,outs,outsb,outsd,outsw,' + + 'packssdw,packsswb,packuswb,paddb,paddd,paddsb,paddsw,paddusb,paddusw,' + + 'paddw,pand,pandn,pavgusb,pcmpeqb,pcmpeqd,pcmpeqw,pcmpgtb,pcmpgtd,pcmpgtw,' + + 'pf2id,pfacc,pfadd,pfcmpeq,pfcmpge,pfcmpgt,pfmax,pfmin,pfmul,pfrcp,' + + 'pfrcpit1,pfrcpit2,pfrsqit1,pfrsqrt,pfsub,pfsubr,pi2fd,pmaddwd,pmulhrw,' + + 'pmulhw,pmullw,pop,popa,popad,popaw,popf,popfd,popfw,por,prefetch,prefetchw,' + + 'pslld,psllq,psllw,psrad,psraw,psrld,psrlq,psrlw,psubb,psubd,psubsb,' + + 'psubsw,psubusb,psubusw,psubw,punpckhbw,punpckhdq,punpckhwd,punpcklbw,' + + 'punpckldq,punpcklwd,push,pusha,pushad,pushaw,pushf,pushfd,pushfw,pxor,' + + 'rcl,rcr,rep,repe,repne,repnz,repz,ret,rol,ror,sahf,sal,sar,sbb,scas,' + + 'scasb,scasd,scasw,seta,setae,setb,setbe,setc,sete,setg,setge,setl,setle,' + + 'setna,setnae,setnb,setnbe,setnc,setne,setng,setnge,setnl,setnle,setno,' + + 'setnp,setns,setnz,seto,setp,setpo,sets,setz,sgdt,shl,shld,shr,shrd,sidt,' + + 'sldt,smsw,stc,std,sti,stos,stosb,stosd,stosw,str,sub,test,verr,verw,' + + 'wait,wbinvd,xadd,xchg,xlat,xlatb,xor'; + +procedure MakeIdentTable; +var + c: char; +begin + FillChar(Identifiers, SizeOf(Identifiers), 0); + for c := 'a' to 'z' do + Identifiers[c] := TRUE; + for c := 'A' to 'Z' do + Identifiers[c] := TRUE; + for c := '0' to '9' do + Identifiers[c] := TRUE; + Identifiers['_'] := TRUE; + + FillChar(mHashTable, SizeOf(mHashTable), 0); + for c := 'a' to 'z' do + mHashTable[c] := 1 + Ord(c) - Ord('a'); + for c := 'A' to 'Z' do + mHashTable[c] := 1 + Ord(c) - Ord('A'); + for c := '0' to '9' do + mHashTable[c] := 27 + Ord(c) - Ord('0'); +end; + +function TSynAsmSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while Identifiers[ToHash^] do begin +{$IFOPT Q-} + Result := 7 * Result + mHashTable[ToHash^]; +{$ELSE} + Result := (7 * Result + mHashTable[ToHash^]) and $FFFFFF; +{$ENDIF} + inc(ToHash); + end; + Result := Result and $3FF; + fStringLen := ToHash - fToIdent; +end; + +function TSynAsmSyn.KeyComp(const aKey: String): Boolean; +var + i: integer; + pKey1, pKey2: PChar; +begin + pKey1 := fToIdent; + // Note: fStringLen is always > 0 ! + pKey2 := pointer(aKey); + for i := 1 to fStringLen do + begin + if mHashTable[pKey1^] <> mHashTable[pKey2^] then + begin + Result := FALSE; + exit; + end; + Inc(pKey1); + Inc(pKey2); + end; + Result := TRUE; +end; + +procedure TSynAsmSyn.DoAddKeyword(AKeyword: string; AKind: integer); +var + HashValue: integer; +begin + HashValue := KeyHash(PChar(AKeyword)); + fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind); +end; + +function TSynAsmSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + Entry: TSynHashEntry; +begin + fToIdent := MayBe; + Entry := fKeywords[KeyHash(MayBe)]; + while Assigned(Entry) do begin + if Entry.KeywordLen > fStringLen then + break + else if Entry.KeywordLen = fStringLen then + if KeyComp(Entry.Keyword) then begin + Result := TtkTokenKind(Entry.Kind); + exit; + end; + Entry := Entry.Next; + end; + Result := tkIdentifier; +end; + +procedure TSynAsmSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0 : fProcTable[I] := @NullProc; + #10 : fProcTable[I] := @LFProc; + #13 : fProcTable[I] := @CRProc; + #34 : fProcTable[I] := @StringProc; + #39 : fProcTable[I] := @SingleQuoteStringProc; + '>' : fProcTable[I] := @GreaterProc; + '<' : fProcTable[I] := @LowerProc; + '/' : fProcTable[I] := @SlashProc; + + 'A'..'Z', 'a'..'z', '_': + fProcTable[I] := @IdentProc; + '0'..'9': + fProcTable[I] := @NumberProc; + #1..#9, #11, #12, #14..#32: + fProcTable[I] := @SpaceProc; + '#', ';': + fProcTable[I] := @CommentProc; + '.', ':', '&', '{', '}', '=', '^', '-', '+', '(', ')', '*': + fProcTable[I] := @SymbolProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynAsmSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fKeywords := TSynHashEntryList.Create; + + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + + MakeMethodTables; + EnumerateKeywords(Ord(tkKey), OpCodes, IdentChars, @DoAddKeyword); + SetAttributesOnChange(@DefHighlightChange); + fDefaultFilter := SYNS_FilterX86Asm; +end; + +destructor TSynAsmSyn.Destroy; +begin + fKeywords.Free; + inherited Destroy; +end; + +procedure TSynAsmSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynAsmSyn.CommentProc; +begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynAsmSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then Inc(Run); +end; + +procedure TSynAsmSyn.GreaterProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] = '=' then Inc(Run); +end; + +procedure TSynAsmSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynAsmSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynAsmSyn.LowerProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] in ['=', '>'] then Inc(Run); +end; + +procedure TSynAsmSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynAsmSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'a'..'f', 'h', 'A'..'F', 'H'] do + Inc(Run); +end; + +procedure TSynAsmSyn.SlashProc; +begin + Inc(Run); + if fLine[Run] = '/' then begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end else + fTokenID := tkSymbol; +end; + +procedure TSynAsmSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + Inc(Run); + until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]); +end; + +procedure TSynAsmSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then + inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynAsmSyn.SingleQuoteStringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #39) and (FLine[Run + 2] = #39) then + inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynAsmSyn.SymbolProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynAsmSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkIdentifier; +end; + +procedure TSynAsmSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynAsmSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynAsmSyn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSynAsmSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynAsmSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynAsmSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynAsmSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynAsmSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynAsmSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynAsmSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +class function TSynAsmSyn.GetLanguageName: string; +begin + Result := SYNS_LangX86Asm; +end; + +function TSynAsmSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterX86Asm; +end; + +function TSynAsmSyn.GetSampleSource: string; +begin + Result := '; x86 assembly sample source'#13#10 + + ' CODE SEGMENT BYTE PUBLIC'#13#10 + + ' ASSUME CS:CODE'#13#10 + + #13#10 + + ' PUSH SS'#13#10 + + ' POP DS'#13#10 + + ' MOV AX, AABBh'#13#10 + + ' MOV BYTE PTR ES:[DI], 255'#13#10 + + ' JMP SHORT AsmEnd'#13#10 + + #13#10 + + ' welcomeMsg DB ''Hello World'', 0'#13#10 + + #13#10 + + ' AsmEnd:'#13#10 + + ' MOV AX, 0'#13#10 + + #13#10 + + ' CODE ENDS'#13#10 + + 'END'; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynAsmSyn); +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterawk.pas b/components/extrasyn/SyneditHighlighters/synhighlighterawk.pas new file mode 100644 index 000000000..aa5d98649 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterawk.pas @@ -0,0 +1,620 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterAWK.pas, released 2000-06-18. +The Original Code is based on the hkAWKSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Hideo Koiso. +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: SynHighlighterAWK.pas,v 1.10 2004/07/13 00:00:29 markonjezic Exp $ + +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 AWK Script highlighter for SynEdit) +@author(Hideo Koiso , converted to SynEdit by David Muir ) +@created(7 November 1999, converted to SynEdit April 18, 2000) +@lastmod(June 19, 2000) +The SynHighlighterAWK unit provides SynEdit with a AWK Script (.awk) highlighter. +} +unit SynHighlighterAWK; + +interface + +{$I synedit.inc} + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + SysUtils, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkInterFunc, tkKey, tkNull, + tkNumber, tkSpace, tkString, tkSymbol, tkSysVar, tkUnknown); + + TProcTableProc = procedure of object; + + { TSynAWKSyn } + + TSynAWKSyn = class(TSynCustomHighLighter) + private + AWKSyntaxList: TStringList; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: Longint; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fInterFuncAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fSysVarAttri: TSynHighlighterAttributes; + fLineNumber: Integer; + procedure AndProc; + procedure CommentProc; + procedure CRProc; + procedure ExclamProc; + procedure FieldRefProc; + procedure IdentProc; + procedure LFProc; + procedure MakeMethodTables; + procedure MakeSyntaxList; + procedure MinusProc; + procedure NullProc; + procedure OpInputProc; + procedure OrProc; + procedure PlusProc; + procedure QuestionProc; + procedure SpaceProc; + procedure StringProc; + procedure SymbolProc; + procedure NumberProc; + procedure BraceProc; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: String; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + function GetToken: string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart :PChar; out TokenLength :integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetLine(const NewValue: string; LineNumber: Integer); override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property InterFuncAttri: TSynHighlighterAttributes read fInterFuncAttri + write fInterFuncAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property SysVarAttri: TSynHighlighterAttributes read fSysVarAttri + write fSysVarAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + end; + +implementation + +uses + SynEditStrConst; + +procedure TSynAWKSyn.MakeSyntaxList; +begin + with AWKSyntaxList do begin + Sorted := True; + + { *** Preferably sort and put previously. *** } + AddObject('ARGC', TObject(tkSysVar)); + AddObject('ARGIND', TObject(tkSysVar)); { GNU Extention } + AddObject('ARGV', TObject(tkSysVar)); + AddObject('atan2', TObject(tkInterFunc)); + AddObject('BEGIN', TObject(tkKey)); + AddObject('break', TObject(tkKey)); + AddObject('close', TObject(tkInterFunc)); + AddObject('continue', TObject(tkKey)); + AddObject('CONVFMT', TObject(tkSysVar)); { POSIX Extention } + AddObject('cos', TObject(tkInterFunc)); + AddObject('delete', TObject(tkInterFunc)); + AddObject('do', TObject(tkKey)); + AddObject('else', TObject(tkKey)); + AddObject('END', TObject(tkKey)); + AddObject('ENVIRON', TObject(tkSysVar)); + AddObject('ERRNO', TObject(tkSysVar)); { GNU Extention } + AddObject('exit', TObject(tkKey)); + AddObject('exp', TObject(tkInterFunc)); + AddObject('FIELDWIDTH', TObject(tkSysVar)); { GNU Extention } + AddObject('FILENAME', TObject(tkSysVar)); + AddObject('FNR', TObject(tkSysVar)); + AddObject('for', TObject(tkKey)); + AddObject('FS', TObject(tkSysVar)); + AddObject('function', TObject(tkKey)); + AddObject('getline', TObject(tkKey)); + AddObject('gsub', TObject(tkInterFunc)); + AddObject('if', TObject(tkKey)); + AddObject('IGNORECASE', TObject(tkSysVar)); + AddObject('index', TObject(tkInterFunc)); + AddObject('int', TObject(tkInterFunc)); + AddObject('jindex', TObject(tkInterFunc)); { jgawk } + AddObject('jlength', TObject(tkInterFunc)); { jgawk } + AddObject('jsubstr', TObject(tkInterFunc)); { jgawk } + AddObject('length', TObject(tkInterFunc)); + AddObject('log', TObject(tkInterFunc)); + AddObject('match', TObject(tkInterFunc)); + AddObject('next', TObject(tkUnknown)); { & next file (GNU Extention) } + AddObject('NF', TObject(tkSysVar)); + AddObject('NR', TObject(tkSysVar)); + AddObject('OFMT', TObject(tkSysVar)); + AddObject('OFS', TObject(tkSysVar)); + AddObject('ORS', TObject(tkSysVar)); + AddObject('print', TObject(tkKey)); + AddObject('printf', TObject(tkInterFunc)); + AddObject('rand', TObject(tkInterFunc)); + AddObject('return', TObject(tkKey)); + AddObject('RLENGTH', TObject(tkSysVar)); + AddObject('RS', TObject(tkSysVar)); + AddObject('RSTART', TObject(tkSysVar)); + AddObject('sin', TObject(tkInterFunc)); + AddObject('split', TObject(tkInterFunc)); + AddObject('sprintf', TObject(tkInterFunc)); + AddObject('sqrt', TObject(tkInterFunc)); + AddObject('srand', TObject(tkInterFunc)); + AddObject('strftime', TObject(tkInterFunc)); { GNU Extention } + AddObject('sub', TObject(tkInterFunc)); + AddObject('SUBSEP', TObject(tkSysVar)); + AddObject('substr', TObject(tkInterFunc)); + AddObject('system', TObject(tkInterFunc)); + AddObject('systime', TObject(tkInterFunc)); { GNU Extention } + AddObject('tolower', TObject(tkInterFunc)); + AddObject('toupper', TObject(tkInterFunc)); + AddObject('while', TObject(tkKey)); + end; +end; + +procedure TSynAWKSyn.MakeMethodTables; +var + i: Char; +begin + for i := #0 to #255 do begin + case i of + #0: + fProcTable[i] := @NullProc; + #10: + fProcTable[i] := @LFProc; + #13: + fProcTable[i] := @CRProc; + #1..#9, #11, #12, #14..#32: + fProcTable[i] := @SpaceProc; + '"', #$27: + fProcTable[i] := @StringProc; { "..." } + '(', ')', '[', ']': + fProcTable[i] := @BraceProc; { (, ), [ and ] } + '#': + fProcTable[i] := @CommentProc; { # ... } + '$': + fProcTable[i] := @FieldRefProc; { $0 .. $9 } + '+': + fProcTable[i] := @PlusProc; { +, ++ and += } + '-': + fProcTable[i] := @MinusProc; { -, -- and -= } + '!': + fProcTable[i] := @ExclamProc; { ! and !~ } + '?': + fProcTable[i] := @QuestionProc; { ?: } + '|': + fProcTable[i] := @OrProc; { || } + '&': + fProcTable[i] := @AndProc; { && } + '*', '/', '%', '^', '<', '=', '>': + fProcTable[i] := @OpInputProc; { *=, /=, %= ... etc. } + 'a'..'z', 'A'..'Z': + fProcTable[i] := @IdentProc; + '0'..'9': + fProcTable[i] := @NumberProc; + else + fProcTable[i] := @SymbolProc; + end; + end; +end; + +procedure TSynAWKSyn.BraceProc; +begin + fTokenID := tkIdentifier; + Inc(Run); +end; + +procedure TSynAWKSyn.NumberProc; +begin + fTokenID := tkNumber; + Inc(Run); + while (fLine[Run] in ['0'..'9']) do begin + Inc(Run); + end; +end; + +procedure TSynAWKSyn.IdentProc; +var + i: Integer; + idx: Integer; + s: string; +begin + i := Run; + while (fLine[i] in ['a'..'z', 'A'..'Z']) do begin + Inc(i); + end; + SetLength(s, (i - Run)); + StrLCopy(PChar(s), (fLine + Run), (i - Run)); + Run := i; + if AWKSyntaxList.Find(s, idx) and (AWKSyntaxList.Strings[idx] = s) then begin + fTokenID := TtkTokenKind(AWKSyntaxList.Objects[idx]); + if (fTokenID = tkUnKnown) then begin + fTokenID := tkKey; + if (fLine[i] = ' ') then begin + while (fLine[i] = ' ') do begin + Inc(i); + end; + if (fLine[i + 0] = 'f') and + (fLine[i + 1] = 'i') and + (fLine[i + 2] = 'l') and + (fLine[i + 3] = 'e') and + (fLine[i + 4] in [#0..#32, ';']) then begin + Run := (i + 4); + end; + end; + end; + end + else begin + fTokenID := tkIdentifier; + end; +end; + +procedure TSynAWKSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +procedure TSynAWKSyn.StringProc; +begin + repeat + Inc(Run); + if (fLine[Run] = '"') and (fLine[Run - 1] <> '\') then begin + fTokenID := tkString; + Inc(Run); + Exit; + end; + until (fLine[Run] in [#0..#31]); + fTokenID := tkIdentifier; +end; + +procedure TSynAWKSyn.CommentProc; +begin + fTokenID := tkComment; + while not (fLine[Run] in [#0, #10, #13]) do begin + Inc(Run); + end; +end; + +procedure TSynAWKSyn.FieldRefProc; +begin + Inc(Run); + if (fLine[Run] in ['0'..'9']) and + not (fLine[Run + 1] in ['0'..'9', 'a'..'z', 'A'..'Z']) then begin + fTokenID := tkSymbol; + Inc(Run); + end + else begin + fTokenID := tkIdentifier; + end; +end; + +procedure TSynAWKSyn.SymbolProc; +begin + fTokenID := tkSymbol; + Inc(Run); +end; + +procedure TSynAWKSyn.PlusProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if (fLine[Run] in ['+', '=']) then begin + Inc(Run); + end; +end; + +procedure TSynAWKSyn.MinusProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if (fLine[Run] in ['-', '=']) then begin + Inc(Run); + end; +end; + +procedure TSynAWKSyn.OpInputProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if (fLine[Run] = '=') then begin + Inc(Run); + end; +end; + +procedure TSynAWKSyn.ExclamProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if (fLine[Run] in ['=', '~']) then begin + Inc(Run); + end; +end; + +procedure TSynAWKSyn.QuestionProc; +begin + Inc(Run); + if (fLine[Run] = ':') then begin + fTokenID := tkSymbol; + Inc(Run); + end + else begin + fTokenID := tkIdentifier; + end; +end; + +procedure TSynAWKSyn.OrProc; +begin + Inc(Run); + if (fLine[Run] = '|') then begin + fTokenID := tkSymbol; + Inc(Run); + end + else begin + fTokenID := tkIdentifier; + end; +end; + +procedure TSynAWKSyn.AndProc; +begin + Inc(Run); + if (fLine[Run] = '&') then begin + fTokenID := tkSymbol; + Inc(Run); + end + else begin + fTokenID := tkIdentifier; + end; +end; + +constructor TSynAWKSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Foreground := clBlue; + AddAttribute(fCommentAttri); + + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fInterFuncAttri := TSynHighlighterAttributes.Create(SYNS_AttrInternalFunction); + fInterFuncAttri.Foreground := $00408080; + fInterFuncAttri.Style := [fsBold]; + AddAttribute(fInterFuncAttri); + + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Foreground := $00FF0080; + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clTeal; + AddAttribute(fStringAttri); + + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + fSymbolAttri.Style := [fsBold]; + AddAttribute(fSymbolAttri); + + fSysVarAttri := TSynHighlighterAttributes.Create(SYNS_AttrSystemValue); + fSysVarAttri.Foreground := $000080FF; + fSysVarAttri.Style := [fsBold]; + AddAttribute(fSysVarAttri); + + SetAttributesOnChange(@DefHighlightChange); + + AWKSyntaxList := TStringList.Create; + MakeSyntaxList; + + MakeMethodTables; + fDefaultFilter := SYNS_FilterAWK; +end; + +destructor TSynAWKSyn.Destroy; +begin + AWKSyntaxList.Free; + + inherited Destroy; +end; + +procedure TSynAWKSyn.SetLine(const NewValue: string; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynAWKSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then Inc(Run); +end; + +procedure TSynAWKSyn.LFProc; +begin + fTokenID := tkSpace; + Inc(Run); +end; + +procedure TSynAWKSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynAWKSyn.SpaceProc; +begin + Inc(Run); + fTokenID := tkSpace; + + while (fLine[Run] in [#1..#9, #11, #12, #14..#32]) do begin + Inc(Run); + end; +end; + +function TSynAWKSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynAWKSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynAWKSyn.GetToken: string; +var + len: Longint; +begin + len := (Run - fTokenPos); + SetString(Result, (fLine + fTokenPos), len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynAWKSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynAWKSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynAWKSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkInterFunc: Result := fInterFuncAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkSysVar: Result := fSysVarAttri; + else + Result := nil; + end; +end; + +function TSynAWKSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynAWKSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynAWKSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['0'..'9', 'a'..'z', 'A'..'Z'] + TSynSpecialChars; +end; + +function TSynAWKSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterAWK; +end; + +class function TSynAWKSyn.GetLanguageName: string; +begin + Result := SYNS_LangAWK; +end; + +function TSynAWKSyn.GetSampleSource :string; +begin + Result := + 'BEGIN { FS='':''; print "This is the first line\n" }' + LineEnding + + '{ print "LINE",NR,$1 }' + LineEnding + + 'END { print "This is the last line\n" }'; +end; + + +initialization + RegisterPlaceableHighlighter(TSynAWKSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterbaan.pas b/components/extrasyn/SyneditHighlighters/synhighlighterbaan.pas new file mode 100644 index 000000000..34113fc74 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterbaan.pas @@ -0,0 +1,1385 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterBaan.pas, released 2000-04-21. +The Original Code is based on the mwBaanSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is "riceball". +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: SynHighlighterBaan.pas,v 1.14 2005/01/28 16:53:20 maelh Exp $ + +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 Baan syntax highlighter for SynEdit) +@author(riceball , converted to SynEdit by Bruno Mikkelsen ) +@created(2000, converted to SynEdit 2000-04-21) +@lastmod(2000-04-21) +The SynHighlighterBaan unit provides SynEdit with a Baan syntax highlighter. +Thanks to Martin Waldenburg. +} +unit SynHighlighterBaan; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, Classes; + +type + TtkTokenKind = (tkComment, tkDirective, tkIdentifier, tkKey, tkNull, tkNumber, + tkSpace, tkString, tkSymbol, tkUnknown, tkVariable); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynBaanSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fIdentFuncTable: array[0..183] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fDirectiveAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fVariableAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func15: TtkTokenKind; + function Func19: TtkTokenKind; + function Func27: TtkTokenKind; + function Func28: TtkTokenKind; + function Func30: TtkTokenKind; + function Func35: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func89: TtkTokenKind; + function Func91: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func96: TtkTokenKind; + function Func98: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func103: TtkTokenKind; + function Func104: TtkTokenKind; + function Func105: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func114: TtkTokenKind; + function Func117: TtkTokenKind; + function Func118: TtkTokenKind; + function Func122: TtkTokenKind; + function Func123: TtkTokenKind; + function Func124: TtkTokenKind; + function Func125: TtkTokenKind; + function Func126: TtkTokenKind; + function Func129: TtkTokenKind; + function Func133: TtkTokenKind; + function Func135: TtkTokenKind; + function Func141: TtkTokenKind; + function Func145: TtkTokenKind; + function Func153: TtkTokenKind; + function Func154: TtkTokenKind; + function Func160: TtkTokenKind; + function Func183: TtkTokenKind; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure AtSymbolProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure CRProc; + procedure ColonProc; + procedure CommaProc; + procedure DirectiveProc; + procedure EqualProc; + procedure ErectProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NotSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure PlusProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure StarProc; + procedure StringProc; + procedure TildeProc; + procedure XOrSymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property DirectiveAttri: TSynHighlighterAttributes read fDirectiveAttri + write fDirectiveAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property VariableAttri: TSynHighlighterAttributes read fVariableAttri + write fVariableAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '.', '$', '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I in ['_', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynBaanSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[27] := @Func27; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[44] := @Func44; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[91] := @Func91; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[100] := @Func100; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[103] := @Func103; + fIdentFuncTable[104] := @Func104; + fIdentFuncTable[105] := @Func105; + fIdentFuncTable[106] := @Func106; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[108] := @Func108; + fIdentFuncTable[114] := @Func114; + fIdentFuncTable[117] := @Func117; + fIdentFuncTable[118] := @Func118; + fIdentFuncTable[122] := @Func122; + fIdentFuncTable[123] := @Func123; + fIdentFuncTable[124] := @Func124; + fIdentFuncTable[125] := @Func125; + fIdentFuncTable[126] := @Func126; + fIdentFuncTable[129] := @Func129; + fIdentFuncTable[133] := @Func133; + fIdentFuncTable[135] := @Func135; + fIdentFuncTable[141] := @Func141; + fIdentFuncTable[145] := @Func145; + fIdentFuncTable[153] := @Func153; + fIdentFuncTable[154] := @Func154; + fIdentFuncTable[160] := @Func160; + fIdentFuncTable[183] := @Func183; +end; + +function TSynBaanSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['.', '$', '_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynBaanSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynBaanSyn.Func15: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func19: TtkTokenKind; +begin + if KeyComp('do') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func27: TtkTokenKind; +begin + if KeyComp('cdecl') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func28: TtkTokenKind; +begin + if KeyComp('case') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func30: TtkTokenKind; +begin + if KeyComp('char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func35: TtkTokenKind; +begin + if KeyComp('catch') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func37: TtkTokenKind; +begin + if KeyComp('break') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func38: TtkTokenKind; +begin + if KeyComp('endif') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func39: TtkTokenKind; +begin + if KeyComp('for') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func40: TtkTokenKind; +begin + if KeyComp('table') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func41: TtkTokenKind; +begin + if KeyComp('else') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func42: TtkTokenKind; +begin + if KeyComp('new') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func43: TtkTokenKind; +begin + if KeyComp('false') then Result := tkKey else + if KeyComp('int') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func44: TtkTokenKind; +begin + if KeyComp('bool') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func47: TtkTokenKind; +begin + if KeyComp('defined') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func48: TtkTokenKind; +begin + if KeyComp('long') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func50: TtkTokenKind; +begin + if KeyComp('void') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func51: TtkTokenKind; +begin + if KeyComp('delete') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func52: TtkTokenKind; +begin + if KeyComp('pascal') then Result := tkKey else + if KeyComp('from') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func53: TtkTokenKind; +begin + if KeyComp('enum') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func54: TtkTokenKind; +begin + if KeyComp('class') then Result := tkKey else + if KeyComp('float') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func56: TtkTokenKind; +begin + if KeyComp('domain') then Result := tkKey else + if KeyComp('friend') then Result := tkKey else + if KeyComp('this') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func57: TtkTokenKind; +begin + if KeyComp('goto') then Result := tkKey else + if KeyComp('auto') then Result := tkKey else + if KeyComp('while') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func58: TtkTokenKind; +begin + if KeyComp('_cdecl') then Result := tkKey else + if KeyComp('signed') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func59: TtkTokenKind; +begin + if KeyComp('double') then Result := tkKey else + if KeyComp('where') then Result := tkKey else + if KeyComp('null') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func63: TtkTokenKind; +begin + if KeyComp('try') then Result := tkKey else + if KeyComp('public') then Result := tkKey else + if KeyComp('inline') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func64: TtkTokenKind; +begin + if KeyComp('true') then Result := tkKey else + if KeyComp('select') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func69: TtkTokenKind; +begin + if KeyComp('default') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func70: TtkTokenKind; +begin + if KeyComp('using') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func71: TtkTokenKind; +begin + if KeyComp('stdcall') then Result := tkKey else + if KeyComp('const') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func72: TtkTokenKind; +begin + if KeyComp('static') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func73: TtkTokenKind; +begin + if KeyComp('union') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func74: TtkTokenKind; +begin + if KeyComp('mutable') then Result := tkKey else + if KeyComp('fastcall') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func77: TtkTokenKind; +begin + if KeyComp('namespace') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func78: TtkTokenKind; +begin + if KeyComp('date.num') then Result := tkVariable else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func79: TtkTokenKind; +begin + if KeyComp('finally') then Result := tkKey else + if KeyComp('typeid') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func80: TtkTokenKind; +begin + if KeyComp('sizeof') then Result := tkKey else + if KeyComp('short') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func81: TtkTokenKind; +begin + if KeyComp('typedef') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func82: TtkTokenKind; +begin + if KeyComp('strip$') then Result := tkKey else + if KeyComp('switch') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func83: TtkTokenKind; +begin + if KeyComp('selectdo') then Result := tkKey else + if KeyComp('_pascal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func84: TtkTokenKind; +begin + if KeyComp('throw') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func86: TtkTokenKind; +begin + if KeyComp('brp.open') then Result := tkVariable else + if KeyComp('extern') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func87: TtkTokenKind; +begin + if KeyComp('__far') then Result := tkKey else + if KeyComp('endselect') then Result := tkKey else + if KeyComp('string') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func89: TtkTokenKind; +begin + if KeyComp('__cdecl') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func91: TtkTokenKind; +begin + if KeyComp('private') then Result := tkKey else + if KeyComp('import') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func92: TtkTokenKind; +begin + if KeyComp('template') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func93: TtkTokenKind; +begin + if KeyComp('__based') then Result := tkKey else + if KeyComp('unsigned') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func96: TtkTokenKind; +begin + if KeyComp('volatile') then Result := tkKey else + if KeyComp('return') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func98: TtkTokenKind; +begin + if KeyComp('export') then Result := tkKey else + if KeyComp('explicit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func99: TtkTokenKind; +begin + if KeyComp('typename') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func100: TtkTokenKind; +begin + if KeyComp('__near') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func101: TtkTokenKind; +begin + if KeyComp('register') then Result := tkKey else + if KeyComp('struct') then Result := tkKey else + if KeyComp('continue') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func102: TtkTokenKind; +begin + if KeyComp('_stdcall') then Result := tkKey else + if KeyComp('function') then Result := tkKey else + if KeyComp('sql.close') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func103: TtkTokenKind; +begin + if KeyComp('virtual') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func104: TtkTokenKind; +begin + if KeyComp('__self') then Result := tkKey else + if KeyComp('wchar_t') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func105: TtkTokenKind; +begin + if KeyComp('__int32') then Result := tkKey else + if KeyComp('__int16') then Result := tkKey else + if KeyComp('__int8') then Result := tkKey else + if KeyComp('__int64') then Result := tkKey else + if KeyComp('_fastcall') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func106: TtkTokenKind; +begin + if KeyComp('protected') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func107: TtkTokenKind; +begin + if KeyComp('static_ca') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func108: TtkTokenKind; +begin + if KeyComp('operator') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func114: TtkTokenKind; +begin + if KeyComp('__pascal') then Result := tkKey else + if KeyComp('__pascal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func117: TtkTokenKind; +begin + if KeyComp('__loadds') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func118: TtkTokenKind; +begin + if KeyComp('__thread') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func122: TtkTokenKind; +begin + if KeyComp('_import') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func123: TtkTokenKind; +begin + if KeyComp('reinterpr') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func124: TtkTokenKind; +begin + if KeyComp('__fastcal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func125: TtkTokenKind; +begin + if KeyComp('__try') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func126: TtkTokenKind; +begin + if KeyComp('__segname') then Result := tkKey else + if KeyComp('__declspe') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func129: TtkTokenKind; +begin + if KeyComp('__rtti') then Result := tkKey else + if KeyComp('_export') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func133: TtkTokenKind; +begin + if KeyComp('__stdcall') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func135: TtkTokenKind; +begin + if KeyComp('__except') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func141: TtkTokenKind; +begin + if KeyComp('interrupt') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func145: TtkTokenKind; +begin + if KeyComp('__segment') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func153: TtkTokenKind; +begin + if KeyComp('__import') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func154: TtkTokenKind; +begin + if KeyComp('__fortran') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func160: TtkTokenKind; +begin + if KeyComp('__export') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.Func183: TtkTokenKind; +begin + if KeyComp('__interrup') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynBaanSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynBaanSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 184 then Result := fIdentFuncTable[HashKey]() else Result := tkIdentifier; +end; + +procedure TSynBaanSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := @AndSymbolProc; + #39: fProcTable[I] := @AsciiCharProc; + '@': fProcTable[I] := @AtSymbolProc; + '}': fProcTable[I] := @BraceCloseProc; + '{': fProcTable[I] := @BraceOpenProc; + #13: fProcTable[I] := @CRProc; + ':': fProcTable[I] := @ColonProc; + ',': fProcTable[I] := @CommaProc; + '#': fProcTable[I] := @DirectiveProc; + '=': fProcTable[I] := @EqualProc; + '|': fProcTable[I] := @ErectProc; + '>': fProcTable[I] := @GreaterProc; + 'A'..'Z', 'a'..'z', '_', '.', '$': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @LowerProc; + '-': fProcTable[I] := @MinusProc; + '%': fProcTable[I] := @ModSymbolProc; + '!': fProcTable[I] := @NotSymbolProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + '+': fProcTable[I] := @PlusProc; + ')': fProcTable[I] := @RoundCloseProc; + '(': fProcTable[I] := @RoundOpenProc; + ';': fProcTable[I] := @SemiColonProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + ']': fProcTable[I] := @SquareCloseProc; + '[': fProcTable[I] := @SquareOpenProc; + '*': fProcTable[I] := @StarProc; + #34: fProcTable[I] := @StringProc; + '~': fProcTable[I] := @TildeProc; + '^': fProcTable[I] := @XOrSymbolProc; + else fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynBaanSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fDirectiveAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective); + AddAttribute(fDirectiveAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fVariableAttri := TSynHighlighterAttributes.Create(SYNS_AttrVariable); + AddAttribute(fVariableAttri); + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterBaan; +end; + +procedure TSynBaanSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynBaanSyn.AndSymbolProc; +begin + case FLine[Run + 1] of + '=': {and assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '&': {logical and} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {and} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.AsciiCharProc; +begin + fTokenID := tkString; + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynBaanSyn.AtSymbolProc; +begin + fTokenID := tkSymbol; + inc(Run); +end; + +procedure TSynBaanSyn.BraceCloseProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynBaanSyn.BraceOpenProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynBaanSyn.CRProc; +begin + fTokenID := tkSpace; + Case FLine[Run + 1] of + #10: inc(Run, 2); + else inc(Run); + end; +end; + +procedure TSynBaanSyn.ColonProc; +begin + Case FLine[Run + 1] of + ':': {scope resolution operator} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {colon} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.CommaProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynBaanSyn.DirectiveProc; +begin + fTokenID := tkDirective; + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #0; +end; + +procedure TSynBaanSyn.EqualProc; +begin + case FLine[Run + 1] of + '=': {logical equal} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {assign} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.ErectProc; +begin + inc(Run, 1); {Bann Comments} + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; //case + inc(Run); + end; //while +end; + +procedure TSynBaanSyn.GreaterProc; +begin + Case FLine[Run + 1] of + '=': {greater than or equal to} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + inc(Run, 3) + else {shift right} + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {greater than} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynBaanSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynBaanSyn.LowerProc; +begin + case FLine[Run + 1] of + '=': {less than or equal to} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + inc(Run, 3) + else {shift left} + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {less than} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.MinusProc; +begin + case FLine[Run + 1] of + '=': {subtract assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '-': {decrement} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '>': {arrow} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {subtract} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.ModSymbolProc; +begin + case FLine[Run + 1] of + '=': {mod assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {mod} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.NotSymbolProc; +begin + case FLine[Run + 1] of + '=': {not equal} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {not} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynBaanSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', '.', 'u', 'U', 'l', 'L', 'x', 'X', 'e', 'E', 'f', 'F'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynBaanSyn.PlusProc; +begin + case FLine[Run + 1] of + '=': {add assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '+': {increment} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {subtract} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.RoundCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynBaanSyn.RoundOpenProc; +begin + inc(Run); + FTokenID := tkSymbol; +end; + +procedure TSynBaanSyn.SemiColonProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynBaanSyn.SlashProc; +begin + case FLine[Run + 1] of + '=': {division assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {division} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynBaanSyn.SquareCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynBaanSyn.SquareOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynBaanSyn.StarProc; +begin + case FLine[Run + 1] of + '=': {multiply assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {star} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + #92: + if FLine[Run + 1] = #10 then inc(Run); + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynBaanSyn.TildeProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynBaanSyn.XOrSymbolProc; +begin + Case FLine[Run + 1] of + '=': {xor assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {xor} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynBaanSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynBaanSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynBaanSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynBaanSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynBaanSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynBaanSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength:=Run-fTokenPos; + TokenStart:=FLine + fTokenPos; +end; +{$ENDIF} + +function TSynBaanSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynBaanSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkDirective: Result := fDirectiveAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkVariable: Result := fVariableAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynBaanSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynBaanSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynBaanSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['.', '$', '_', '0'..'9', 'a'..'z', 'A'..'Z'] + TSynSpecialChars; +end; + +function TSynBaanSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterBaan; +end; + +class function TSynBaanSyn.GetLanguageName: string; +begin + Result := SYNS_LangBaan; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynBaanSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightercac.pas b/components/extrasyn/SyneditHighlighters/synhighlightercac.pas new file mode 100644 index 000000000..ede220bc8 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightercac.pas @@ -0,0 +1,1395 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterCAC.pas, released 2000-04-21. +The Original Code is based on the cwCACSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Carlos Wijders. +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: SynHighlighterCAC.pas,v 1.11 2005/01/28 16:53:21 maelh Exp $ + +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 CA-Clipper syntax highlighter for SynEdit) +@author(Carlos Wijders , converted to SynEdit by Bruno Mikkelsen ) +@created(1998-12-27, converted to SynEdit 2000-04-21) +@lastmod(2000-06-23) +The SynHighlighterCAC unit provides SynEdit with a CA-Clipper syntax highlighter. +Thanks to Primoz Gabrijelcic, Andy Jeffries. +} +unit SynHighlighterCAC; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkComment, tkDirective, tkIdentifier, tkKey, tkNull, tkNumber, + tkSpace, tkString, tkOperator, tkUnknown); + + TRangeState = (rsANil, rsCStyle, rsUnknown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TSynCACSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fLineNumber: Integer; + fStringAttri: TSynHighlighterAttributes; + fOperatorAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fDirecAttri: TSynHighlighterAttributes; + + fIdentFuncTable: array[0..124] of TIdentFuncTableFunc; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func10: TtkTokenKind; + function Func15: TtkTokenKind; + function Func19: TtkTokenKind; + function Func21: TtkTokenKind; + function Func22: TtkTokenKind; + function Func23: TtkTokenKind; + function Func24: TtkTokenKind; + function Func26: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func34: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func46: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func89: TtkTokenKind; + function Func91: TtkTokenKind; + function Func94: TtkTokenKind; + function Func96: TtkTokenKind; + function Func98: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func105: TtkTokenKind; + function Func116: TtkTokenKind; + function Func124: TtkTokenKind; + procedure StarProc; + procedure CRProc; + procedure IdentProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure SlashProc; + procedure SpaceProc; + procedure SymbolProc; + procedure StringProc; + procedure DirectiveProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure CStyleProc; + protected + function IsFilterStored: Boolean; override; + function GetSampleSource: string; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: string; LineNumber: Integer); override; + function GetToken: string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property OperatorAttri: TSynHighlighterAttributes read fOperatorAttri + write fOperatorAttri; + property DirecAttri: TSynHighlighterAttributes read fDirecAttri + write fDirecAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'a'..'z', 'A'..'Z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynCACSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[10] := @Func10; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[24] := @Func24; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[34] := @Func34; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[44] := @Func44; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[46] := @Func46; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[55] := @Func55; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[91] := @Func91; + fIdentFuncTable[94] := @Func94; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[100] := @Func100; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[105] := @Func105; + fIdentFuncTable[116] := @Func116; + fIdentFuncTable[124] := @Func124; +end; + +function TSynCACSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in TSynValidStringChars do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynCACSyn.KeyComp(const aKey: string): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynCACSyn.Func10: TtkTokenKind; +begin + if KeyComp('AADD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func15: TtkTokenKind; +begin + if KeyComp('IF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func19: TtkTokenKind; +begin + if KeyComp('AND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func21: TtkTokenKind; +begin + if KeyComp('AT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func22: TtkTokenKind; +begin + if KeyComp('GO') then Result := tkKey else + if KeyComp('ABS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func23: TtkTokenKind; +begin + if KeyComp('BOF') then Result := tkKey else + if KeyComp('ASC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func24: TtkTokenKind; +begin + if KeyComp('IIF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func26: TtkTokenKind; +begin + if KeyComp('EOF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func28: TtkTokenKind; +begin + if KeyComp('READ') then Result := tkKey else + if KeyComp('CALL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func29: TtkTokenKind; +begin + if KeyComp('CHR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func30: TtkTokenKind; +begin + if KeyComp('DAY') then Result := tkKey else + if KeyComp('DATE') then Result := tkKey else + if KeyComp('COL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func31: TtkTokenKind; +begin + if KeyComp('PACK') then Result := tkKey else + if KeyComp('LEN') then Result := tkKey else + if KeyComp('DIR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func32: TtkTokenKind; +begin + if KeyComp('GET') then Result := tkKey else + if KeyComp('FILE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func33: TtkTokenKind; +begin + if KeyComp('FIND') then Result := tkKey else + if KeyComp('OR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func34: TtkTokenKind; +begin + if KeyComp('LOG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func35: TtkTokenKind; +begin + if KeyComp('VAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func36: TtkTokenKind; +begin + if KeyComp('FIELD') then Result := tkKey else + if KeyComp('MIN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func37: TtkTokenKind; +begin + if KeyComp('BEGIN') then Result := tkKey else + if KeyComp('BREAK') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func38: TtkTokenKind; +begin + if KeyComp('ENDIF') then Result := tkKey else + if KeyComp('CANCEL') then Result := tkKey else + if KeyComp('MAX') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func39: TtkTokenKind; +begin + if KeyComp('CLEAR') then Result := tkKey else + if KeyComp('FOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func40: TtkTokenKind; +begin + if KeyComp('SEEK') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func41: TtkTokenKind; +begin + if KeyComp('ELSE') then Result := tkKey else + if KeyComp('LOCK') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func42: TtkTokenKind; +begin + if KeyComp('ENDDO') then Result := tkKey else + if KeyComp('CTOD') then Result := tkKey else + if KeyComp('DOW') then Result := tkKey else + if KeyComp('DTOC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func43: TtkTokenKind; +begin + if KeyComp('LOCAL') then Result := tkKey else + if KeyComp('INT') then Result := tkKey else + if KeyComp('EJECT') then Result := tkKey else + if KeyComp('ZAP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func44: TtkTokenKind; +begin + if KeyComp('SPACE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func45: TtkTokenKind; +begin + if KeyComp('SAY') then Result := tkKey else + if KeyComp('EXP') then Result := tkKey else + if KeyComp('CDOW') then Result := tkKey else + if KeyComp('USE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func46: TtkTokenKind; +begin + if KeyComp('PCOL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func47: TtkTokenKind; +begin + if KeyComp('FLOCK') then Result := tkKey else + if KeyComp('TIME') then Result := tkKey else + if KeyComp('SAVE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func48: TtkTokenKind; +begin + if KeyComp('DECLARE') then Result := tkKey else + if KeyComp('ERASE') then Result := tkKey else + if KeyComp('JOIN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func49: TtkTokenKind; +begin + if KeyComp('NOT') then Result := tkKey else + if KeyComp('YEAR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func51: TtkTokenKind; +begin + if KeyComp('RECALL') then Result := tkKey else + if KeyComp('DELETE') then Result := tkKey else + if KeyComp('ENDCASE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func52: TtkTokenKind; +begin + if KeyComp('INIT') then Result := tkKey else + if KeyComp('CREATE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func53: TtkTokenKind; +begin + if KeyComp('WAIT') then Result := tkKey else + if KeyComp('SUM') then Result := tkKey else + if KeyComp('RUN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func54: TtkTokenKind; +begin + if KeyComp('CLOSE') then Result := tkKey else + if KeyComp('NOTE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func55: TtkTokenKind; +begin + if KeyComp('DELETED') then Result := tkKey else + if KeyComp('SKIP') then Result := tkKey else + if KeyComp('RECNO') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func56: TtkTokenKind; +begin + if KeyComp('ROW') then Result := tkKey else + if KeyComp('INDEX') then Result := tkKey else + if KeyComp('LOCATE') then Result := tkKey else + if KeyComp('RENAME') then Result := tkKey else + if KeyComp('ELSEIF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func57: TtkTokenKind; +begin + if KeyComp('WHILE') then Result := tkKey else + if KeyComp('STR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func58: TtkTokenKind; +begin + if KeyComp('EXIT') then Result := tkKey else + if KeyComp('DTOS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func59: TtkTokenKind; +begin + if KeyComp('RLOCK') then Result := tkKey else + if KeyComp('COPY') then Result := tkKey else + if KeyComp('AVERAGE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func60: TtkTokenKind; +begin + if KeyComp('REPLACE') then Result := tkKey else + if KeyComp('LIST') then Result := tkKey else + if KeyComp('TRIM') then Result := tkKey else + if KeyComp('WORD') then Result := tkKey else + if KeyComp('FOUND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func63: TtkTokenKind; +begin + if KeyComp('PUBLIC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func64: TtkTokenKind; +begin + if KeyComp('SELECT') then Result := tkKey else + if KeyComp('SELECT') then Result := tkKey else + if KeyComp('INKEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func65: TtkTokenKind; +begin + if KeyComp('RELEASE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func66: TtkTokenKind; +begin + if KeyComp('TYPE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func67: TtkTokenKind; +begin + if KeyComp('UPDATE') then Result := tkKey else + if KeyComp('QUIT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func68: TtkTokenKind; +begin + if KeyComp('TOTAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func69: TtkTokenKind; +begin + if KeyComp('TEXT') then Result := tkKey else + if KeyComp('FIELDNAME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func70: TtkTokenKind; +begin + if KeyComp('MONTH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func72: TtkTokenKind; +begin + if KeyComp('ROUND') then Result := tkKey else + if KeyComp('LTRIM') then Result := tkKey else + if KeyComp('MEMVAR') then Result := tkKey else + if KeyComp('SORT') then Result := tkKey else + if KeyComp('STATIC') then Result := tkKey else + if KeyComp('PROW') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func73: TtkTokenKind; +begin + if KeyComp('LOWER') then Result := tkKey else + if KeyComp('COUNT') then Result := tkKey else + if KeyComp('COMMIT') then Result := tkKey else + if KeyComp('CMONTH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func74: TtkTokenKind; +begin + if KeyComp('SQRT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func76: TtkTokenKind; +begin + if KeyComp('UPPER') then Result := tkKey else + if KeyComp('UNLOCK') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func77: TtkTokenKind; +begin + if KeyComp('STORE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func78: TtkTokenKind; +begin + if KeyComp('RTRIM') then Result := tkKey else + if KeyComp('LASTREC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func79: TtkTokenKind; +begin + if KeyComp('EMPTY') then Result := tkKey else + if KeyComp('FCOUNT') then Result := tkKey else + if KeyComp('SECONDS') then Result := tkKey else + if KeyComp('REINDEX') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func80: TtkTokenKind; +begin + if KeyComp('INPUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func81: TtkTokenKind; +begin + if KeyComp('KEYBOARD') then Result := tkKey else + if KeyComp('DEVPOS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func86: TtkTokenKind; +begin + if KeyComp('DISPLAY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func87: TtkTokenKind; +begin + if KeyComp('ANNOUNCE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func89: TtkTokenKind; +begin + if KeyComp('PCOUNT') then Result := tkKey else + if KeyComp('REPLICATE') then Result := tkKey else + if KeyComp('SEQUENCE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func91: TtkTokenKind; +begin + if KeyComp('PRIVATE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func94: TtkTokenKind; +begin + if KeyComp('SETPOS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func96: TtkTokenKind; +begin + if KeyComp('RETURN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func98: TtkTokenKind; +begin + if KeyComp('PROMPT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func99: TtkTokenKind; +begin + if KeyComp('RECCOUNT') then Result := tkKey else + if KeyComp('EXTERNAL') then Result := tkKey else + if KeyComp('SUBSTR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func100: TtkTokenKind; +begin + if KeyComp('RESTORE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func101: TtkTokenKind; +begin + if KeyComp('CONTINUE') then Result := tkKey else + if KeyComp('VALTYPE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func102: TtkTokenKind; +begin + if KeyComp('FUNCTION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func105: TtkTokenKind; +begin + if KeyComp('REQUEST') then Result := tkKey else + if KeyComp('PROCEDURE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func116: TtkTokenKind; +begin + if KeyComp('PARAMETERS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.Func124: TtkTokenKind; +begin + if KeyComp('TRANSFORM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCACSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynCACSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 125 then Result := fIdentFuncTable[HashKey]() else Result := tkIdentifier; +end; + +procedure TSynCACSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '@': fProcTable[I] := @SymbolProc; + '&': fProcTable[I] := @SymbolProc; + '{': fProcTable[I] := @SymbolProc; + '}': fProcTable[I] := @SymbolProc; + #13: fProcTable[I] := @CRProc; + ':': fProcTable[I] := @SymbolProc; + ',': fProcTable[I] := @SymbolProc; + '#': fProcTable[I] := @DirectiveProc; + '=': fProcTable[I] := @SymbolProc; + '>': fProcTable[I] := @SymbolProc; + 'A'..'Z', 'a'..'z': fProcTable[I] := @IdentProc; + '$': fProcTable[I] := @SymbolProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @SymbolProc; + '-': fProcTable[I] := @SymbolProc; + '!': fProcTable[I] := @SymbolProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + '+': fProcTable[I] := @SymbolProc; + '.': fProcTable[I] := @SymbolProc; + '?': fProcTable[I] := @SymbolProc; + ')': fProcTable[I] := @SymbolProc; + '(': fProcTable[I] := @SymbolProc; + ';': fProcTable[I] := @SymbolProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + ']': fProcTable[I] := @SymbolProc; + '[': fProcTable[I] := @SymbolProc; + '*': fProcTable[I] := @StarProc; + #39, #34: fProcTable[I] := @StringProc; + else fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynCACSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fOperatorAttri := TSynHighlighterAttributes.Create(SYNS_AttrOperator); + AddAttribute(fOperatorAttri); + fDirecAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor); + AddAttribute(fDirecAttri); + InitIdent; + SetAttributesOnChange(@DefHighlightChange); + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterCAClipper; +end; + +procedure TSynCACSyn.SetLine(const NewValue: string; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynCACSyn.CStyleProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + + #13: + begin + CRProc; + exit; + end; + end; + + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + fRange := rsUnknown; + inc(Run, 2); + break; + end else inc(Run); + #10: break; + #13: break; + else inc(Run); + end; +end; + +procedure TSynCACSyn.CRProc; +begin + fTokenID := tkSpace; + case FLine[Run + 1] of + #10: inc(Run, 2); + else inc(Run); + end; +end; + +procedure TSynCACSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynCACSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynCACSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynCACSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynCACSyn.SlashProc; +begin + case FLine[Run + 1] of + '/': + begin + inc(Run, 2); + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; + end; + '*': + begin + fTokenID := tkComment; + fRange := rsCStyle; + inc(Run, 2); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + fRange := rsUnknown; + inc(Run, 2); + break; + end else inc(Run); + #10: break; + #13: break; + else inc(Run); + end; + end; + else + begin + inc(Run); + fTokenID := tkOperator; + end; + end; +end; + +procedure TSynCACSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynCACSyn.SymbolProc; +begin + inc(Run); + fTokenID := tkOperator; +end; + +procedure TSynCACSyn.StringProc; +var + ActiveStr: string[1]; +begin + fTokenID := tkString; + ActiveStr := FLine[Run]; + if ((FLine[Run + 1] = #39) and (FLine[Run + 2] = #39)) or + ((FLine[Run + 1] = #34) and (FLine[Run + 2] = #34)) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until (FLine[Run] = ActiveStr); + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynCACSyn.DirectiveProc; +begin + fTokenID := tkDirective; + repeat + case FLine[Run] of + #0, #10, #13: break; + '/': if FLine[Run + 1] = '/' then break; + #34, #39: break; + end; + inc(Run); + until FLine[Run] = #0; +end; + +procedure TSynCACSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynCACSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsCStyle: CStyleProc; + else fProcTable[fLine[Run]]; + end; +end; + +function TSynCACSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + else + Result := nil; + end; +end; + +function TSynCACSyn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSynCACSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynCACSyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynCACSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength:=Run-fTokenPos; + TokenStart:=FLine + fTokenPos; +end; +{$ENDIF} + +function TSynCACSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynCACSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkDirective: Result := fDirecAttri; + tkOperator: Result := fOperatorAttri; + tkUnknown: Result := fOperatorAttri; + else Result := nil; + end; +end; + +function TSynCACSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynCACSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynCACSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynCACSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynCACSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterCAClipper; +end; + +function TSynCACSyn.GetSampleSource :string; +begin + Result := '*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±'+lineEnding+ + '*+'+LineEnding+ + '*+ Function hppbrtday()'+LineEnding+ + '*+'+LineEnding+ + '*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±'+LineEnding+ + '*+'+LineEnding+ + 'procedure hppbrtdy()'+LineEnding+ + ''+LineEnding+ + '// Compile and run this only on your brithday!'+LineEnding+ + '// e-mail: cautere@innet.be (Jos Cautereels)'+LineEnding+LineEnding+ + 'local i'+LineEnding+ + 'local a := { { 392, 3 }, { 392, 1 }, { 440, 4 }, { 392, 4 }, ;'+LineEnding+ + ' { 523.3, 4 }, { 493.9, 8 }, { 392, 3 }, { 392, 1 }, ;'+LineEnding+ + ' { 440, 4 }, { 392, 4 }, { 523.3, 4 }, { 493.9, 8 }, ;'+LineEnding+ + ' { 393, 3 }, { 392, 1 }, { 784, 4 }, { 659.2, 4 }, ;'+LineEnding+ + ' { 523.3, 4 }, { 493, 4 }, { 440, 4 }, { 698.4, 3 }, ;'+LineEnding+ + ' { 698.4, 1 }, { 659.2, 4 }, { 523.3, 4 }, { 587.4, 4 }, ;'+LineEnding+ + ' { 523.4, 8 } }'+LineEnding+LineEnding+ + 'for i := 1 to len( a )'+LineEnding+ + ' tone( a[ i, 1 ], a[ i, 2 ] * 2 )'+LineEnding+ + 'next'+LineEnding+LineEnding+ + 'return'+LineEnding+LineEnding+ + '*+ EOF: HPPBRTDY.PRG'+LineEnding+ + '* #define BITR2L'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* This is an original work of Peter Townsend and is hereby placed into the *'+LineEnding+ + '* public domain. *'+LineEnding+ + '* E-mail: cephas@tpgi.com.au *'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* WARNING! Some of these functions assume that bits 1-8 run left to right, *'+LineEnding+ + '* not right to left as is normally the case. This allows for long *'+LineEnding+ + '* strings of bits to be contiguous (ie, bit 9 is next to bit 8). *'+LineEnding+ + '* For instance, I store a logical value for every day of the *'+LineEnding+ + '* year in 46 bytes (1=.T., 0=.F., 366 days / 8 bits = 46 bytes). *'+LineEnding+ + '* If you wish to use the functions in a right to left context, *'+LineEnding+ + '* uncomment the #define at the start of the file. *'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* ByteAnd - AND two bytes together. *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - first byte. *'+LineEnding+ + '* - second byte. *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - the result of the AND. *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION ByteAnd(cByte1, cByte2)'+LineEnding+ + ' LOCAL nCntr, nRetVal'+LineEnding+ + ' nRetVal := 0'+LineEnding+ + ' FOR nCntr := 1 TO 8'+LineEnding+ + ' nRetVal *= 2'+LineEnding+ + '#ifdef BITR2L'+LineEnding+ + ' IF BitOn(cByte1, 9 - nCntr) .AND. BitOn(cByte2, 9 - nCntr)'+LineEnding+ + '#else'+LineEnding+ + ' IF BitOn(cByte1, nCntr) .AND. BitOn(cByte2, nCntr)'+LineEnding+ + '#endif'+LineEnding+ + ' nRetVal += 1'+LineEnding+ + ' ENDIF'+LineEnding+ + ' NEXT'+LineEnding+ + 'RETURN(CHR(nRetVal))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* ByteOr - OR two bytes together. *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - first byte. *'+LineEnding+ + '* - second byte. *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - the result of the OR. *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION ByteOr(cByte1, cByte2)'+LineEnding+ + ' LOCAL nCntr, nRetVal'+LineEnding+ + ' nRetVal := 0'+LineEnding+ + ' FOR nCntr := 1 TO 8'+LineEnding+ + ' nRetVal *= 2'+LineEnding+ + '#ifdef BITR2L'+LineEnding+ + ' IF BitOn(cByte1, 9 - nCntr) .OR. BitOn(cByte2, 9 - nCntr)'+LineEnding+ + '#else'+LineEnding+ + ' IF BitOn(cByte1, nCntr) .OR. BitOn(cByte2, nCntr)'+LineEnding+ + '#endif'+LineEnding+ + ' nRetVal += 1'+LineEnding+ + ' ENDIF'+LineEnding+ + ' NEXT'+LineEnding+ + 'RETURN(CHR(nRetVal))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* ByteXOr - XOR two bytes together. *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - first byte. *'+LineEnding+ + '* - second byte. *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - the result of the XOR. *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION ByteXOr(cByte1, cByte2)'+LineEnding+ + ' LOCAL nCntr, nRetVal, lOneOn, lTwoOn'+LineEnding+ + ' nRetVal := 0'+LineEnding+ + ' FOR nCntr := 1 TO 8'+LineEnding+ + ' nRetVal *= 2'+LineEnding+ + '#ifdef BITR2L'+LineEnding+ + ' lOneOn := BitOn(cByte1, 9 - nCntr)'+LineEnding+ + ' lTwoOn := BitOn(cByte2, 9 - nCntr)'+LineEnding+ + '#else'+LineEnding+ + ' lOneOn := BitOn(cByte1, nCntr)'+LineEnding+ + ' lTwoOn := BitOn(cByte2, nCntr)'+LineEnding+ + '#endif'+LineEnding+ + ' IF (lOneOn .AND. (! lTwoOn)) .OR. ((! lOneOn) .AND. lTwoOn)'+LineEnding+ + ' nRetVal += 1'+LineEnding+ + ' ENDIF'+LineEnding+ + ' NEXT'+LineEnding+ + 'RETURN(CHR(nRetVal))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* BitOn - Is the nth bit of a byte a 1? *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to check *'+LineEnding+ + '* - number of bit to check *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - Is the nth bit on? *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION BitOn(cByte, nPosn)'+LineEnding+ + ' LOCAL nVal'+LineEnding+ + '#ifdef BITR2L'+LineEnding+ + ' nPosn := 9 - nPosn'+LineEnding+ + '#endif'+LineEnding+ + ' nVal := INT(ASC(cByte) / (2^(8-nPosn)))'+LineEnding+ + 'RETURN(MOD(nVal, 2) == 1)'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* BitOff - Is the nth bit of a byte a 0? *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to check *'+LineEnding+ + '* - number of bit to check *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - Is the nth bit off? *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION BitOff(cByte, nPosn)'+LineEnding+ + 'RETURN(! BitOn(cByte, nPosn))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* ByteLftSh - Left shift the bits of a byte by n bits *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to left shift *'+LineEnding+ + '* - number of bits by which to move byte left *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - The left-shifted byte *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION ByteLftSh(cByte, nPosns)'+LineEnding+ + ' LOCAL nVal'+LineEnding+ + ' nVal := MOD((ASC(cByte) * (2^nPosns)), 256)'+LineEnding+ + 'RETURN(CHR(nVal))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* ByteRytSh - Right shift the bits of a byte by n bits *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to right shift *'+LineEnding+ + '* - number of bits by which to move byte right *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - The right-shifted byte *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION ByteRytSh(cByte, nPosns)'+LineEnding+ + ' LOCAL nVal'+LineEnding+ + ' nVal := INT((ASC(cByte) / (2^nPosns)))'+LineEnding+ + 'RETURN(CHR(nVal))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* BitTurnOn - Turn on the nth bit of a byte *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to manipulate *'+LineEnding+ + '* - the number of the bit to turn on *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - The manipulated byte *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION BitTurnOn(cByte, nPosn)'+LineEnding+ + '#ifdef BITR2L'+LineEnding+ + ' nPosn := 9 - nPosn'+LineEnding+ + '#endif'+LineEnding+ + 'RETURN(ByteOr(cByte, CHR(2^(8-nPosn))))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* BitTurnOff - Turn off the nth bit of a byte *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to manipulate *'+LineEnding+ + '* - the number of the bit to turn off *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - The manipulated byte *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION BitTurnOff(cByte, nPosn)'+LineEnding+ + '#ifdef BITR2L'+LineEnding+ + ' nPosn := 9 - nPosn'+LineEnding+ + '#endif'+LineEnding+ + 'RETURN(ByteAnd(cByte, CHR(255 - (2^(8-nPosn)))))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* BitFlip - Flip the nth bit of a byte *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to manipulate *'+LineEnding+ + '* - the number of the bit to flip *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - The manipulated byte *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION BitFlip(cByte, nPosn)'+LineEnding+ + 'RETURN(IF(BitOn(cByte, nPosn), BitTurnOff(cByte, nPosn), BitTurnOn(cByte, nPosn)))'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* ByteFlip - Flip all of the bits in a byte *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to manipulate *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - The manipulated byte *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION ByteFlip(cByte)'+LineEnding+ + ' LOCAL nCntr, cRetVal'+LineEnding+ + ' cRetVal := cByte'+LineEnding+ + ' FOR nCntr := 1 TO 8'+LineEnding+ + ' cRetVal := BitFlip(cRetVal, nCntr)'+LineEnding+ + ' NEXT'+LineEnding+ + 'RETURN(cRetVal)'+LineEnding+ + '* ========================================================================= *'+LineEnding+ + '* ByteShow - Convert each bit of a byte into a byte for display *'+LineEnding+ + '* *'+LineEnding+ + '* Parameters: - byte to display *'+LineEnding+ + '* *'+LineEnding+ + '* Returns : - An 8-byte string *'+LineEnding+ + '* ------------------------------------------------------------------------- *'+LineEnding+ + 'FUNCTION ByteShow(cByte)'+LineEnding+ + ' LOCAL nCntr, cByteStr := ""'+LineEnding+ + ' FOR nCntr := 1 TO 8'+LineEnding+ + '#ifdef BITR2L'+LineEnding+ + ' cByteStr += IF(BitOn(cByte, 9 - nCntr), "1", "0")'+LineEnding+ + '#else'+LineEnding+ + ' cByteStr += IF(BitOn(cByte, nCntr), "1", "0")'+LineEnding+ + '#endif'+LineEnding+ + ' NEXT'+LineEnding+ + 'RETURN(cByteStr)'+LineEnding+ + ''+LineEnding + ; +end {SAMPLE SOURCE CODE} ; + +class function TSynCACSyn.GetLanguageName: string; +begin + Result := SYNS_LangCAClipper; +end; + +procedure TSynCACSyn.StarProc; +begin +// if Run is 0 there could be an access violation + if (Run = 0) or (fLine[Run - 1] in [#0, #10, #13]) then + begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end else begin + + inc(Run); + fTokenID := tkOperator; + end; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynCACSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightercache.pas b/components/extrasyn/SyneditHighlighters/synhighlightercache.pas new file mode 100644 index 000000000..afc514a2d --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightercache.pas @@ -0,0 +1,1710 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterCache.pas, released 2000-04-21. +The Original Code is based on the mwCacheSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Pavel Krehula. +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: SynHighlighterCache.pas,v 1.14 2005/01/28 16:53:21 maelh Exp $ + +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 Cache object script files highlighter for SynEdit) +@author(Pavel Krehula , converted to SynEdit by Bruno Mikkelsen ) +@created(1999-12-17, converted to SynEdit 2000-04-21) +@lastmod(2000-06-23) +The SynHighlighterCache unit provides SynEdit with a Cache object script files highlighter. +Thanks to Martin Waldenburg. +} + +unit SynHighlighterCache; + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = (tkClass, tkComment, tkFunction, tkIdentifier, tkKey, tkNull, + tkNumber, tkDirective, tkSpace, tkString, tkSymbol, tkIndirect, tkLabel, + tkMacro, tkUserFunction, tkEmbedSQL, tkEmbedText, tkUnknown); + + TRangeState = (rsUnKnown, rsSQL, rsHTML, rsCommand); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynCacheSyn = class(TSynCustomHighlighter) + private + fBrace: LongInt; + fFirstBrace: Boolean; + fRange: TRangeState; + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fIdentFuncTable: array[0..151] of TIdentFuncTableFunc; + fClassAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fFunctionAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fDirectiveAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fIndirectAttri: TSynHighlighterAttributes; + fLabelAttri: TSynHighlighterAttributes; + fMacroAttri: TSynHighlighterAttributes; + fUserFunctionAttri: TSynHighlighterAttributes; + fEmbedSQLAttri: TSynHighlighterAttributes; + fEmbedTextAttri: TSynHighlighterAttributes; + + FCanKey: boolean; // if true, the next token can be a keyword + + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func1: TtkTokenKind; + function Func2: TtkTokenKind; + function Func3: TtkTokenKind; + function Func4: TtkTokenKind; + function Func5: TtkTokenKind; + function Func6: TtkTokenKind; + function Func7: TtkTokenKind; + function Func8: TtkTokenKind; + function Func9: TtkTokenKind; + function Func10: TtkTokenKind; + function Func11: TtkTokenKind; + function Func12: TtkTokenKind; + function Func13: TtkTokenKind; + function Func14: TtkTokenKind; + function Func15: TtkTokenKind; + function Func16: TtkTokenKind; + function Func17: TtkTokenKind; + function Func18: TtkTokenKind; + function Func19: TtkTokenKind; + function Func20: TtkTokenKind; + function Func21: TtkTokenKind; + function Func23: TtkTokenKind; + function Func24: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func27: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func34: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func46: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func73: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func91: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func94: TtkTokenKind; + function Func95: TtkTokenKind; + function Func98: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func103: TtkTokenKind; + function Func104: TtkTokenKind; + function Func105: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func114: TtkTokenKind; + function Func115: TtkTokenKind; + function Func116: TtkTokenKind; + function Func117: TtkTokenKind; + function Func123: TtkTokenKind; + function Func126: TtkTokenKind; + function Func127: TtkTokenKind; + function Func128: TtkTokenKind; + function Func130: TtkTokenKind; + function Func142: TtkTokenKind; + function Func143: TtkTokenKind; + function Func144: TtkTokenKind; + function Func151: TtkTokenKind; + procedure CRProc; + procedure CommentProc; + procedure IdentProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + procedure IndirectProc; + procedure SymbolProc; + procedure FuncProc; + procedure DirectiveProc; + procedure EmbeddedProc; + + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + //procedure SetLine(NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + property IdentChars; + published + property ClassAttri: TSynHighlighterAttributes read fClassAttri + write fClassAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property FunctionAttri: TSynHighlighterAttributes read fFunctionAttri + write fFunctionAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property PreprocesorAttri: TSynHighlighterAttributes read fDirectiveAttri + write fDirectiveAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property IndirectAttri: TSynHighlighterAttributes read fIndirectAttri + write fIndirectAttri; + property LabelAttri: TSynHighlighterAttributes read fLabelAttri + write fLabelAttri; + property MacroAttri: TSynHighlighterAttributes read fMacroAttri + write fMacroAttri; + property UserFunctionAttri: TSynHighlighterAttributes + read fUserFunctionAttri write fUserFunctionAttri; + property EmbededSQLandHTMLAttri: TSynHighlighterAttributes + read fEmbedSQLAttri write fEmbedSQLAttri; + property EmbededTextAttri: TSynHighlighterAttributes read fEmbedTextAttri + write fEmbedTextAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst; +{$ENDIF} + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +//------------------------------------------------------------------------------ +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do begin + Case I of + '0'..'9', 'a'..'z', 'A'..'Z', '%', '^': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpperCase(I)[1]; + Case I in ['A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := {$IFDEF FPC}@{$ENDIF}AltFunc; + Inc(pF); + end; + fIdentFuncTable[1] := {$IFDEF FPC}@{$ENDIF} Func1; + fIdentFuncTable[2] := {$IFDEF FPC}@{$ENDIF} Func2; + fIdentFuncTable[3] := {$IFDEF FPC}@{$ENDIF} Func3; + fIdentFuncTable[4] := {$IFDEF FPC}@{$ENDIF} Func4; + fIdentFuncTable[5] := {$IFDEF FPC}@{$ENDIF} Func5; + fIdentFuncTable[6] := {$IFDEF FPC}@{$ENDIF} Func6; + fIdentFuncTable[7] := {$IFDEF FPC}@{$ENDIF} Func7; + fIdentFuncTable[8] := {$IFDEF FPC}@{$ENDIF} Func8; + fIdentFuncTable[9] := {$IFDEF FPC}@{$ENDIF} Func9; + fIdentFuncTable[10] := {$IFDEF FPC}@{$ENDIF} Func10; + fIdentFuncTable[11] := {$IFDEF FPC}@{$ENDIF} Func11; + fIdentFuncTable[12] := {$IFDEF FPC}@{$ENDIF} Func12; + fIdentFuncTable[13] := {$IFDEF FPC}@{$ENDIF} Func13; + fIdentFuncTable[14] := {$IFDEF FPC}@{$ENDIF} Func14; + fIdentFuncTable[15] := {$IFDEF FPC}@{$ENDIF} Func15; + fIdentFuncTable[16] := {$IFDEF FPC}@{$ENDIF} Func16; + fIdentFuncTable[17] := {$IFDEF FPC}@{$ENDIF} Func17; + fIdentFuncTable[18] := {$IFDEF FPC}@{$ENDIF} Func18; + fIdentFuncTable[19] := {$IFDEF FPC}@{$ENDIF} Func19; + fIdentFuncTable[20] := {$IFDEF FPC}@{$ENDIF} Func20; + fIdentFuncTable[21] := {$IFDEF FPC}@{$ENDIF} Func21; + fIdentFuncTable[23] := {$IFDEF FPC}@{$ENDIF} Func23; + fIdentFuncTable[24] := {$IFDEF FPC}@{$ENDIF} Func24; + fIdentFuncTable[25] := {$IFDEF FPC}@{$ENDIF} Func25; + fIdentFuncTable[26] := {$IFDEF FPC}@{$ENDIF} Func26; + fIdentFuncTable[27] := {$IFDEF FPC}@{$ENDIF} Func27; + fIdentFuncTable[28] := {$IFDEF FPC}@{$ENDIF} Func28; + fIdentFuncTable[29] := {$IFDEF FPC}@{$ENDIF} Func29; + fIdentFuncTable[30] := {$IFDEF FPC}@{$ENDIF} Func30; + fIdentFuncTable[31] := {$IFDEF FPC}@{$ENDIF} Func31; + fIdentFuncTable[32] := {$IFDEF FPC}@{$ENDIF} Func32; + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF} Func33; + fIdentFuncTable[34] := {$IFDEF FPC}@{$ENDIF} Func34; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF} Func35; + fIdentFuncTable[36] := {$IFDEF FPC}@{$ENDIF} Func36; + fIdentFuncTable[37] := {$IFDEF FPC}@{$ENDIF} Func37; + fIdentFuncTable[38] := {$IFDEF FPC}@{$ENDIF} Func38; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF} Func39; + fIdentFuncTable[40] := {$IFDEF FPC}@{$ENDIF} Func40; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[42] := {$IFDEF FPC}@{$ENDIF} Func42; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF} Func44; + fIdentFuncTable[45] := {$IFDEF FPC}@{$ENDIF} Func45; + fIdentFuncTable[46] := {$IFDEF FPC}@{$ENDIF} Func46; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF} Func47; + fIdentFuncTable[48] := {$IFDEF FPC}@{$ENDIF} Func48; + fIdentFuncTable[49] := {$IFDEF FPC}@{$ENDIF} Func49; + fIdentFuncTable[50] := {$IFDEF FPC}@{$ENDIF} Func50; + fIdentFuncTable[51] := {$IFDEF FPC}@{$ENDIF} Func51; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF} Func52; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF} Func53; + fIdentFuncTable[54] := {$IFDEF FPC}@{$ENDIF} Func54; + fIdentFuncTable[56] := {$IFDEF FPC}@{$ENDIF} Func56; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF} Func57; + fIdentFuncTable[58] := {$IFDEF FPC}@{$ENDIF} Func58; + fIdentFuncTable[59] := {$IFDEF FPC}@{$ENDIF} Func59; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF} Func60; + fIdentFuncTable[61] := {$IFDEF FPC}@{$ENDIF} Func61; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF} Func62; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF} Func63; + fIdentFuncTable[64] := {$IFDEF FPC}@{$ENDIF} Func64; + fIdentFuncTable[65] := {$IFDEF FPC}@{$ENDIF} Func65; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[67] := {$IFDEF FPC}@{$ENDIF} Func67; + fIdentFuncTable[68] := {$IFDEF FPC}@{$ENDIF} Func68; + fIdentFuncTable[69] := {$IFDEF FPC}@{$ENDIF} Func69; + fIdentFuncTable[70] := {$IFDEF FPC}@{$ENDIF} Func70; + fIdentFuncTable[71] := {$IFDEF FPC}@{$ENDIF} Func71; + fIdentFuncTable[73] := {$IFDEF FPC}@{$ENDIF} Func73; + fIdentFuncTable[75] := {$IFDEF FPC}@{$ENDIF} Func75; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF} Func76; + fIdentFuncTable[77] := {$IFDEF FPC}@{$ENDIF} Func77; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF} Func78; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF} Func79; + fIdentFuncTable[80] := {$IFDEF FPC}@{$ENDIF} Func80; + fIdentFuncTable[81] := {$IFDEF FPC}@{$ENDIF} Func81; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF} Func82; + fIdentFuncTable[83] := {$IFDEF FPC}@{$ENDIF} Func83; + fIdentFuncTable[84] := {$IFDEF FPC}@{$ENDIF} Func84; + fIdentFuncTable[85] := {$IFDEF FPC}@{$ENDIF} Func85; + fIdentFuncTable[86] := {$IFDEF FPC}@{$ENDIF} Func86; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF} Func87; + fIdentFuncTable[88] := {$IFDEF FPC}@{$ENDIF} Func88; + fIdentFuncTable[89] := {$IFDEF FPC}@{$ENDIF} Func89; + fIdentFuncTable[90] := {$IFDEF FPC}@{$ENDIF} Func90; + fIdentFuncTable[91] := {$IFDEF FPC}@{$ENDIF} Func91; + fIdentFuncTable[92] := {$IFDEF FPC}@{$ENDIF} Func92; + fIdentFuncTable[93] := {$IFDEF FPC}@{$ENDIF} Func93; + fIdentFuncTable[94] := {$IFDEF FPC}@{$ENDIF} Func94; + fIdentFuncTable[95] := {$IFDEF FPC}@{$ENDIF} Func95; + fIdentFuncTable[98] := {$IFDEF FPC}@{$ENDIF} Func98; + fIdentFuncTable[100] := {$IFDEF FPC}@{$ENDIF} Func100; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF} Func101; + fIdentFuncTable[102] := {$IFDEF FPC}@{$ENDIF} Func102; + fIdentFuncTable[103] := {$IFDEF FPC}@{$ENDIF} Func103; + fIdentFuncTable[104] := {$IFDEF FPC}@{$ENDIF} Func104; + fIdentFuncTable[105] := {$IFDEF FPC}@{$ENDIF} Func105; + fIdentFuncTable[106] := {$IFDEF FPC}@{$ENDIF} Func106; + fIdentFuncTable[107] := {$IFDEF FPC}@{$ENDIF} Func107; + fIdentFuncTable[108] := {$IFDEF FPC}@{$ENDIF} Func108; + fIdentFuncTable[110] := {$IFDEF FPC}@{$ENDIF} Func110; + fIdentFuncTable[111] := {$IFDEF FPC}@{$ENDIF} Func111; + fIdentFuncTable[114] := {$IFDEF FPC}@{$ENDIF} Func114; + fIdentFuncTable[115] := {$IFDEF FPC}@{$ENDIF} Func115; + fIdentFuncTable[116] := {$IFDEF FPC}@{$ENDIF} Func116; + fIdentFuncTable[117] := {$IFDEF FPC}@{$ENDIF} Func117; + fIdentFuncTable[123] := {$IFDEF FPC}@{$ENDIF} Func123; + fIdentFuncTable[126] := {$IFDEF FPC}@{$ENDIF} Func126; + fIdentFuncTable[127] := {$IFDEF FPC}@{$ENDIF} Func127; + fIdentFuncTable[128] := {$IFDEF FPC}@{$ENDIF} Func128; + fIdentFuncTable[130] := {$IFDEF FPC}@{$ENDIF} Func130; + fIdentFuncTable[142] := {$IFDEF FPC}@{$ENDIF} Func142; + fIdentFuncTable[143] := {$IFDEF FPC}@{$ENDIF} Func143; + fIdentFuncTable[144] := {$IFDEF FPC}@{$ENDIF} Func144; + fIdentFuncTable[151] := {$IFDEF FPC}@{$ENDIF} Func151; +end; + +//------------------------------------------------------------------------------ +function TSynCacheSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['0'..'9', 'a'..'z', 'A'..'Z', '^', '$', '&'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +//------------------------------------------------------------------------------ +function TSynCacheSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then begin + Result := True; + for i := 1 to fStringLen do begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +//------------------------------------------------------------------------------ +function TSynCacheSyn.Func1: TtkTokenKind; +begin + if KeyComp('$a') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func2: TtkTokenKind; +begin + if KeyComp('b') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func3: TtkTokenKind; +begin + if KeyComp('$c') then Result := tkKey else + if KeyComp('c') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func4: TtkTokenKind; +begin + if KeyComp('d') then Result := tkKey else + if KeyComp('$d') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func5: TtkTokenKind; +begin + if KeyComp('$e') then Result := tkKey else + if KeyComp('e') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func6: TtkTokenKind; +begin + if KeyComp('$f') then Result := tkKey else + if KeyComp('f') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func7: TtkTokenKind; +begin + if KeyComp('$g') then Result := tkKey else + if KeyComp('^$g') then Result := tkKey else + if KeyComp('g') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func8: TtkTokenKind; +begin + if KeyComp('$ec') then Result := tkKey else + if KeyComp('h') then Result := tkKey else + if KeyComp('$h') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func9: TtkTokenKind; +begin + if KeyComp('$i') then Result := tkKey else + if KeyComp('$i') then Result := tkKey else + if KeyComp('i') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func10: TtkTokenKind; +begin + if KeyComp('^$j') then Result := tkKey else + if KeyComp('$j') then Result := tkKey else + if KeyComp('j') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func11: TtkTokenKind; +begin + if KeyComp('k') then Result := tkKey else + if KeyComp('$k') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func12: TtkTokenKind; +begin + if KeyComp('^$l') then Result := tkKey else + if KeyComp('l') then Result := tkKey else + if KeyComp('$l') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func13: TtkTokenKind; +begin + if KeyComp('m') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func14: TtkTokenKind; +begin + if KeyComp('$lb') then Result := tkKey else + if KeyComp('$n') then Result := tkKey else + if KeyComp('n') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func15: TtkTokenKind; +begin + if KeyComp('$na') then Result := tkKey else + if KeyComp('if') then Result := tkKey else + if KeyComp('$o') then Result := tkKey else + if KeyComp('o') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func16: TtkTokenKind; +begin + if KeyComp('$p') then Result := tkKey else + if KeyComp('p') then Result := tkKey else + if KeyComp('$ld') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func17: TtkTokenKind; +begin + if KeyComp('$q') then Result := tkKey else + if KeyComp('q') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func18: TtkTokenKind; +begin + if KeyComp('r') then Result := tkKey else + if KeyComp('^$r') then Result := tkKey else + if KeyComp('$r') then Result := tkKey else + if KeyComp('$lf') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func19: TtkTokenKind; +begin + if KeyComp('$lg') then Result := tkKey else + if KeyComp('$s') then Result := tkKey else + if KeyComp('s') then Result := tkKey else + if KeyComp('do') then Result := tkKey else + if KeyComp('$s') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func20: TtkTokenKind; +begin + if KeyComp('$fn') then Result := tkKey else + if KeyComp('$t') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func21: TtkTokenKind; +begin + if KeyComp('$li') then Result := tkKey else + if KeyComp('u') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func23: TtkTokenKind; +begin + if KeyComp('w') then Result := tkKey else + if KeyComp('tc') then Result := tkKey else + if KeyComp('$in') then Result := tkKey else + if KeyComp('$re') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func24: TtkTokenKind; +begin + if KeyComp('$es') then Result := tkKey else + if KeyComp('$ll') then Result := tkKey else + if KeyComp('$io') then Result := tkKey else + if KeyComp('x') then Result := tkKey else + if KeyComp('$x') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func25: TtkTokenKind; +begin + if KeyComp('$et') then Result := tkKey else + if KeyComp('$y') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func26: TtkTokenKind; +begin + if KeyComp('$data') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func27: TtkTokenKind; +begin + if KeyComp('job') then Result := tkKey else + if KeyComp('$za') then Result := tkKey else + if KeyComp('$job') then Result := tkKey else + if KeyComp('^$job') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func28: TtkTokenKind; +begin + if KeyComp('$zb') then Result := tkKey else + if KeyComp('zb') then Result := tkKey else + if KeyComp('read') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func29: TtkTokenKind; +begin + if KeyComp('$ql') then Result := tkKey else + if KeyComp('$zc') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func30: TtkTokenKind; +begin + if KeyComp('hang') then Result := tkKey else + if KeyComp('$char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func31: TtkTokenKind; +begin + if KeyComp('$vi') then Result := tkKey else + if KeyComp('$ze') then Result := tkKey else + if KeyComp('vi') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func32: TtkTokenKind; +begin + if KeyComp('$get') then Result := tkKey else + if KeyComp('$tl') then Result := tkKey else + if KeyComp('$ecode') then Result := tkKey else + if KeyComp('$zf') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func33: TtkTokenKind; +begin + if KeyComp('$find') then Result := tkKey else + if KeyComp('$name') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func34: TtkTokenKind; +begin + if KeyComp('$zh') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func35: TtkTokenKind; +begin + if KeyComp('$zi') then Result := tkKey else + if KeyComp('zi') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func36: TtkTokenKind; +begin + if KeyComp('$qs') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func37: TtkTokenKind; +begin + if KeyComp('zk') then Result := tkKey else + if KeyComp('break') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func38: TtkTokenKind; +begin + if KeyComp('$piece') then Result := tkKey else + if KeyComp('zl') then Result := tkKey else + if KeyComp('$tr') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func39: TtkTokenKind; +begin + if KeyComp('$st') then Result := tkKey else + if KeyComp('$st') then Result := tkKey else + if KeyComp('$zla') then Result := tkKey else + if KeyComp('for') then Result := tkKey else + if KeyComp('ts') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func40: TtkTokenKind; +begin + if KeyComp('zn') then Result := tkKey else + if KeyComp('$zn') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func41: TtkTokenKind; +begin + if KeyComp('$key') then Result := tkKey else + if KeyComp('else') then Result := tkKey else + if KeyComp('halt') then Result := tkKey else + if KeyComp('$zo') then Result := tkKey else + if KeyComp('^$lock') then Result := tkKey else + if KeyComp('lock') then Result := tkKey else + if KeyComp('$zlc') then Result := tkKey else + if KeyComp('$ascii') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func42: TtkTokenKind; +begin + if KeyComp('zp') then Result := tkKey else + if KeyComp('$zp') then Result := tkKey else + if KeyComp('new') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func43: TtkTokenKind; +begin + if KeyComp('zq') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func44: TtkTokenKind; +begin + if KeyComp('$zr') then Result := tkKey else + if KeyComp('kill') then Result := tkKey else + if KeyComp('set') then Result := tkKey else + if KeyComp('zr') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func45: TtkTokenKind; +begin + if KeyComp('zs') then Result := tkKey else + if KeyComp('use') then Result := tkKey else + if KeyComp('$zs') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func46: TtkTokenKind; +begin + if KeyComp('$zt') then Result := tkKey else + if KeyComp('$zt') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func47: TtkTokenKind; +begin + if KeyComp('$zu') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func48: TtkTokenKind; +begin + if KeyComp('$zabs') then Result := tkKey else + if KeyComp('merge') then Result := tkKey else + if KeyComp('$zv') then Result := tkKey else + if KeyComp('&sql') then begin + Result := tkEmbedSQL; + fRange := rsSQL; + end else + if KeyComp('$device') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func49: TtkTokenKind; +begin + if KeyComp('^$global') then Result := tkKey else + if KeyComp('$zw') then Result := tkKey else + if KeyComp('zw') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func50: TtkTokenKind; +begin + if KeyComp('$zcrc') then Result := tkKey else + if KeyComp('$zio') then Result := tkKey else + if KeyComp('$zwa') then Result := tkKey else + if KeyComp('$zse') then Result := tkKey else + if KeyComp('open') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func51: TtkTokenKind; +begin + if KeyComp('$zcsc') then Result := tkKey else + if KeyComp('$zpi') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func52: TtkTokenKind; +begin + if KeyComp('$zz') then Result := tkKey else + if KeyComp('$zeof') then Result := tkKey else + if KeyComp('$zwc') then Result := tkKey else + if KeyComp('$zln') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func53: TtkTokenKind; +begin + if KeyComp('$zjob') then Result := tkKey else + if KeyComp('tro') then Result := tkKey else + if KeyComp('&html') then begin + Result := tkEmbedSQL; + fRange := rsHTML; + end else + if KeyComp('$zsec') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func54: TtkTokenKind; +begin + if KeyComp('$stack') then Result := tkKey else + if KeyComp('$zis') then Result := tkKey else + if KeyComp('$zth') then Result := tkKey else + if KeyComp('$stack') then Result := tkKey else + if KeyComp('close') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func56: TtkTokenKind; +begin + if KeyComp('$zdate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func57: TtkTokenKind; +begin + if KeyComp('goto') then Result := tkKey else + if KeyComp('$zcyc') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func58: TtkTokenKind; +begin + if KeyComp('zload') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func59: TtkTokenKind; +begin + if KeyComp('view') then Result := tkKey else + if KeyComp('$estack') then Result := tkKey else + if KeyComp('$zname') then Result := tkKey else + if KeyComp('$view') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func60: TtkTokenKind; +begin + if KeyComp('$list') then Result := tkKey else + if KeyComp('$etrap') then Result := tkKey else + if KeyComp('$zlog') then Result := tkKey else + if KeyComp('$order') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func61: TtkTokenKind; +begin + if KeyComp('$ztan') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func62: TtkTokenKind; +begin + if KeyComp('$zchild') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func63: TtkTokenKind; +begin + if KeyComp('$next') then Result := tkKey else + if KeyComp('zbreak') then Result := tkKey else + if KeyComp('$zcos') then Result := tkKey else + if KeyComp('$zhex') then Result := tkKey else + if KeyComp('$zmode') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func64: TtkTokenKind; +begin + if KeyComp('$zzdec') then Result := tkKey else + if KeyComp('$test') then Result := tkKey else + if KeyComp('$select') then Result := tkKey else + if KeyComp('$zcot') then Result := tkKey else + if KeyComp('$zdateh') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func65: TtkTokenKind; +begin + if KeyComp('$zts') then Result := tkKey else + if KeyComp('$zwp') then Result := tkKey else + if KeyComp('$random') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func66: TtkTokenKind; +begin + if KeyComp('$length') then Result := tkKey else + if KeyComp('$zseek') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func67: TtkTokenKind; +begin + if KeyComp('quit') then Result := tkKey else + if KeyComp('$zerr') then Result := tkKey else + if KeyComp('$quit') then Result := tkKey else + if KeyComp('$zwbp') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func68: TtkTokenKind; +begin + if KeyComp('$zsin') then Result := tkKey else + if KeyComp('$zlchar') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func69: TtkTokenKind; +begin + if KeyComp('$text') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func70: TtkTokenKind; +begin + if KeyComp('zkill') then Result := tkKey else + if KeyComp('$zincr') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func71: TtkTokenKind; +begin + if KeyComp('$zexp') then Result := tkKey else + if KeyComp('$zcvt') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func73: TtkTokenKind; +begin + if KeyComp('zsave') then Result := tkKey else + if KeyComp('$ztime') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func75: TtkTokenKind; +begin + if KeyComp('write') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func76: TtkTokenKind; +begin + if KeyComp('$zbitand') then Result := tkKey else + if KeyComp('$tlevel') then Result := tkKey else + if KeyComp('$zpos') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func77: TtkTokenKind; +begin + if KeyComp('print') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func78: TtkTokenKind; +begin + if KeyComp('xecute') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func79: TtkTokenKind; +begin + if KeyComp('$zlascii') then Result := tkKey else + if KeyComp('$zwchar') then Result := tkKey else + if KeyComp('$fnumber') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func80: TtkTokenKind; +begin + if KeyComp('$zsqr') then Result := tkKey else + if KeyComp('$zsearch') then Result := tkKey else + if KeyComp('$zwpack') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func81: TtkTokenKind; +begin + if KeyComp('ztrap') then Result := tkKey else + if KeyComp('$ztimeh') then Result := tkKey else + if KeyComp('$ztrap') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func82: TtkTokenKind; +begin + if KeyComp('$inumber') then Result := tkKey else + if KeyComp('$zwbpack') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func83: TtkTokenKind; +begin + if KeyComp('$zarctan') then Result := tkKey else + if KeyComp('$qlength') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func84: TtkTokenKind; +begin + if KeyComp('$znspace') then Result := tkKey else + if KeyComp('znspace') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func85: TtkTokenKind; +begin + if KeyComp('$storage') then Result := tkKey else + if KeyComp('$zarccos') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func86: TtkTokenKind; +begin + if KeyComp('$zorder') then Result := tkKey else + if KeyComp('$zorder') then Result := tkKey else + if KeyComp('$query') then Result := tkKey else + if KeyComp('$listdata') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func87: TtkTokenKind; +begin + if KeyComp('zsync') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func88: TtkTokenKind; +begin + if KeyComp('$zutil') then Result := tkKey else + if KeyComp('$zbitlen') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func89: TtkTokenKind; +begin + if KeyComp('$zbitget') then Result := tkKey else + if KeyComp('$znext') then Result := tkKey else + if KeyComp('$zzhex') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func90: TtkTokenKind; +begin + if KeyComp('$zboolean') then Result := tkKey else + if KeyComp('$zbitor') then Result := tkKey else + if KeyComp('$zarcsin') then Result := tkKey else + if KeyComp('$zbitfind') then Result := tkKey else + if KeyComp('$zwidth') then Result := tkKey else + if KeyComp('$zwascii') then Result := tkKey else + if KeyComp('$horolog') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func91: TtkTokenKind; +begin + if KeyComp('$extract') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func92: TtkTokenKind; +begin + if KeyComp('$reverse') then Result := tkKey else + if KeyComp('$listget') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func93: TtkTokenKind; +begin + if KeyComp('zquit') then Result := tkKey else + if KeyComp('$listfind') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func94: TtkTokenKind; +begin + if KeyComp('trollback') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func95: TtkTokenKind; +begin + if KeyComp('$ziswide') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func98: TtkTokenKind; +begin + if KeyComp('$zsort') then Result := tkKey else + if KeyComp('tstart') then Result := tkKey else + if KeyComp('$principal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func100: TtkTokenKind; +begin + if KeyComp('$zparent') then Result := tkKey else + if KeyComp('$zerror') then Result := tkKey else + if KeyComp('$zwunp') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func101: TtkTokenKind; +begin + if KeyComp('$zbitset') then Result := tkKey else + if KeyComp('zwrite') then Result := tkKey else + if KeyComp('$increment') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func102: TtkTokenKind; +begin + if KeyComp('$zwbunp') then Result := tkKey else + if KeyComp('^$routine') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func103: TtkTokenKind; +begin + if KeyComp('$zdatetime') then Result := tkKey else + if KeyComp('$zpower') then Result := tkKey else + if KeyComp('zprint') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func104: TtkTokenKind; +begin + if KeyComp('zremove') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func105: TtkTokenKind; +begin + if KeyComp('$zreference') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func106: TtkTokenKind; +begin + if KeyComp('$zbitnot') then Result := tkKey else + if KeyComp('zzdump') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func107: TtkTokenKind; +begin + if KeyComp('tcommint') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func108: TtkTokenKind; +begin + if KeyComp('$zstrip') then Result := tkKey else + if KeyComp('$listbuild') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func110: TtkTokenKind; +begin + if KeyComp('$translate') then Result := tkKey else + if KeyComp('$justify') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func111: TtkTokenKind; +begin + if KeyComp('$zstorage') then Result := tkKey else + if KeyComp('zinsert') then Result := tkKey else + if KeyComp('$zdatetimeh') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func114: TtkTokenKind; +begin + if KeyComp('$zbitxor') then Result := tkKey else + if KeyComp('$zbitstr') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func115: TtkTokenKind; +begin + if KeyComp('$zwunpack') then Result := tkKey else + if KeyComp('$zzenkaku') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func116: TtkTokenKind; +begin + if KeyComp('$zhorolog') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func117: TtkTokenKind; +begin + if KeyComp('$zwbunpack') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func123: TtkTokenKind; +begin + if KeyComp('$zconvert') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func126: TtkTokenKind; +begin + if KeyComp('$listlength') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func127: TtkTokenKind; +begin + if KeyComp('$zincrement') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func128: TtkTokenKind; +begin + if KeyComp('$zversion') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func130: TtkTokenKind; +begin + if KeyComp('$zbitcount') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func142: TtkTokenKind; +begin + if KeyComp('$ztimestamp') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func143: TtkTokenKind; +begin + if KeyComp('$zposition') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func144: TtkTokenKind; +begin + if KeyComp('$qsubscript') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.Func151: TtkTokenKind; +begin + if KeyComp('$zprevious') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCacheSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +//------------------------------------------------------------------------------ +function TSynCacheSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if (HashKey < 152) and (HashKey>-1) then + Result := fIdentFuncTable[HashKey] {$IFDEF FPC}(){$ENDIF} + else Result := tkIdentifier; +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CRProc; + ';': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CommentProc; + 'A'..'Z', 'a'..'z', '%', '^': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} IdentProc; + '$': fProcTable[i] := {$IFDEF FPC}@{$ENDIF} FuncProc; + '@': fProcTable[i] := {$IFDEF FPC}@{$ENDIF} IndirectProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LFProc; + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NullProc; + '0'..'9': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NumberProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SpaceProc; + #34: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StringProc; + '(',')','+','-','[',']','.','<','>','''','=',',',':','/','\', + '?','!','_','*': fProcTable[i] := {$IFDEF FPC}@{$ENDIF} SymbolProc; + '#': fProcTable[i] := {$IFDEF FPC}@{$ENDIF} DirectiveProc; + '&': fProcTable[i] := {$IFDEF FPC}@{$ENDIF} EmbeddedProc; + + else fProcTable[I] := {$IFDEF FPC}@{$ENDIF} UnknownProc; + end; +end; + +//------------------------------------------------------------------------------ +constructor TSynCacheSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fClassAttri := TSynHighlighterAttributes.Create(SYNS_AttrClass); + AddAttribute(fClassAttri); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fFunctionAttri := TSynHighlighterAttributes.Create(SYNS_AttrFunction); + AddAttribute(fFunctionAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fDirectiveAttri := TSynHighlighterAttributes.Create(SYNS_AttrDir); + AddAttribute(fDirectiveAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fIndirectAttri := TSynHighlighterAttributes.Create(SYNS_AttrIndirect); + AddAttribute(fIndirectAttri); + fLabelAttri := TSynHighlighterAttributes.Create(SYNS_AttrLabel); + AddAttribute(fLabelAttri); + fMacroAttri := TSynHighlighterAttributes.Create(SYNS_AttrMacro); + AddAttribute(fMacroAttri); + fUserFunctionAttri := TSynHighlighterAttributes.Create(SYNS_AttrUserFunction); + AddAttribute(fUserFunctionAttri); + fEmbedSQLAttri := TSynHighlighterAttributes.Create(SYNS_AttrEmbedSQL); + AddAttribute(fEmbedSQLAttri); + fEmbedTextAttri := TSynHighlighterAttributes.Create(SYNS_AttrEmbedText); + AddAttribute(fEmbedTextAttri); + + SetAttributesOnChange({$ifdef FPC} @ {$endif}DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterCache; + fRange := rsUnknown; +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynCacheSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynCacheSyn.SetLine(const NewValue: string; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynCacheSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then inc(Run); + FRange := rsUnknown; +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.CommentProc; +begin + fTokenID := tkComment; + if FLine[Run+1]=';' then fTokenID := tkEmbedText; + + while FLine[Run] <> #0 do begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; +end; + +//------------------------------------------------------------------------------ +// higlight keywords and identifiers +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.IdentProc; +var + fir: char; +begin + if FTokenPos=0 then fTokenID := tkLabel + else begin + fir := FLine[ Run ]; + if fir in [ '^' ] then FCanKey := true; + + FRange := rsUnknown; + if FCanKey then fTokenID := IdentKind((fLine + Run)) + else begin + fTokenID := tkIdentifier; + while ( Identifiers[fLine[Run]] ) or ( FLine[Run] in ['0'..'9']) do inc(Run); + exit; + end; + FRange := rsCommand; + inc(Run, fStringLen); + if (not ( FLine[Run] in [ #32, ':', #0, #10, #13 ] )) and ( fir <> '^' ) then + fTokenID := tkIdentifier; + end; + while ( Identifiers[fLine[Run]] ) or ( FLine[Run] in ['0'..'9']) do inc(Run); +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.LFProc; +begin + fTokenID := tkSpace; + FCanKey := true; + inc(Run); +end; + +procedure TSynCacheSyn.NullProc; +begin + fTokenID := tkNull; +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.NumberProc; +begin + if (fTokenPos = 0) and (FLine[Run] in ['0'..'9']) then begin + fTokenID := tkLabel; + while Identifiers[fLine[Run]] do inc(Run); + FCanKey := false; + exit; + end; + + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do begin + case FLine[Run] of + '.': if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; + FRange := rsUnknown; +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.SpaceProc; +var + x: integer; +begin + x := Run; + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); + FCanKey := true; + if FRange = rsCommand then + FCanKey := (Run - x > 1); +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); + FRange := rsUnknown; +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.Next; +begin + fTokenPos := Run; + if FLine[Run] = #0 then NullProc + else + Case fRange of + rsSQL, + rsHTML: EmbeddedProc; + else fProcTable[fLine[Run]]; + end; +end; + +function TSynCacheSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynCacheSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynCacheSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynCacheSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynCacheSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynCacheSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkClass: Result := fClassAttri; + tkComment: Result := fCommentAttri; + tkFunction: Result := fFunctionAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkDirective: Result := fDirectiveAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkIndirect: Result := fIndirectAttri; + tkUnknown: Result := fIdentifierAttri; + tkLabel: Result := fLabelAttri; + tkMacro: Result := fMacroAttri; + tkUserFunction: Result := fUserFunctionAttri; + tkEmbedSQL: Result := fEmbedSQLAttri; + tkEmbedText: Result := fEmbedTextAttri; + else Result := nil; + end; +end; + +function TSynCacheSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynCacheSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynCacheSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynCacheSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +//------------------------------------------------------------------------------ +function TSynCacheSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['0'..'9', 'a'..'z', 'A'..'Z', '^', '%'] + TSynSpecialChars; +end; + +function TSynCacheSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterCache; +end; + +class function TSynCacheSyn.GetLanguageName: string; +begin + Result := SYNS_LangCache; +end; + +//------------------------------------------------------------------------------ +// highlight indirection syntax: @ident +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.IndirectProc; +begin + fTokenID := tkIndirect; + inc( Run ); + while Identifiers[ FLine[Run] ] do inc( Run ); + FRange := rsUnknown; +end; + +//------------------------------------------------------------------------------ +// highlight symbols +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.SymbolProc; +begin + fTokenID := tkSymbol; + inc( Run ); + FRange := rsUnknown; +end; + +//------------------------------------------------------------------------------ +// highlight user defined functions and macros +// function: $$ident +// macro : $$$ident +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.FuncProc; +begin + case FLine[Run] of + '$': case FLine[ Run+1 ] of + '$': case Fline[ Run+2 ] of + '$': fTokenID := tkMacro; + else fTokenID := tkUserFunction; + end; + else begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + if fTokenID = tkKey then fTokenID := tkFunction; + end; + end; + else fTokenID := tkIdentifier; + end; + while Identifiers[fLine[Run]] or (FLine[Run]='$' ) do inc(Run); + FRange := rsUnknown; +end; + +//------------------------------------------------------------------------------ +// highlight preprocesor directives and class syntax +// preprocesor: #identifier +// class : ##class +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.DirectiveProc; +var + i: integer; +begin + if FLine[Run+1]='#' then fTokenID := tkClass + else begin + for i:=fTokenPos downto 0 do + if not(FLine[i] in [ #32, '#' ]) then begin + fTokenID := tkSymbol; + inc( Run ); + exit; + end; + + fTokenID := tkDirective + end; + + inc( Run ); + while Identifiers[fLine[Run]] or (FLine[Run]='#') do inc(Run); + FRange := rsUnknown; +end; + +//------------------------------------------------------------------------------ +// highlight embeded SQL and HTML +// SQL : &sql( .... ) +// HTML : &html< ..... > +//------------------------------------------------------------------------------ +procedure TSynCacheSyn.EmbeddedProc; +begin + case fRange of + rsUnknown, rsCommand: begin + fTokenID := IdentKind( (fLine + Run) ); + if fTokenID <> tkEmbedSQL then begin + fTokenID := tkSymbol; + inc( Run ); + end else begin + fBrace := 1; + fFirstBrace := true; + inc( Run, fStringLen ); + end; + end; + rsSQL: begin + fTokenID := tkEmbedSQL; + while (FLine[Run] <> #0) and (fBrace<>0) do begin + case FLine[Run] of + '(': if not fFirstBrace then inc(fBrace) + else fFirstBrace := false; + ')': dec(fBrace); + end; + inc(Run); + end; + if fBrace=0 then fRange := rsUnknown; + end; + rsHTML: begin + fTokenID := tkEmbedSQL; + while (FLine[Run] <> #0) and (fBrace<>0) do begin + case FLine[Run] of + '<': if not fFirstBrace then inc(fBrace) + else fFirstBrace := false; + '>': dec(fBrace); + end; + inc(Run); + end; + if fBrace=0 then fRange := rsUnknown; + end; + end; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynCacheSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightercobol.pas b/components/extrasyn/SyneditHighlighters/synhighlightercobol.pas new file mode 100644 index 000000000..bfe28da78 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightercobol.pas @@ -0,0 +1,2339 @@ +{------------------------------------------------------------------------------- +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. + +Code template generated with SynGen. +The original code is: SynHighlighterCobol.pas, released 2002-08-26. +Description: COBOL Syntax Parser/Highlighter +The author of this file is Andrey Ustinov. +Copyright (c) 2002 Software Mining, http://www.softwaremining.com/, +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: SynHighlighterCobol.pas,v 1.6 2005/01/28 16:53:21 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} +unit SynHighlighterCobol; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + SysUtils, + Classes; + +type + TtkTokenKind = ( + tkComment, + tkIdentifier, + tkAIdentifier, + tkPreprocessor, + tkKey, + tkBoolean, + tkNull, + tkNumber, + tkSpace, + tkString, + tkSequence, + tkIndicator, + tkTagArea, + tkDebugLines, + tkUnknown); + + TRangeState = (rsUnknown, + rsQuoteString, rsApostString, + rsPseudoText, + rsQuoteStringMayBe, rsApostStringMayBe); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +const + MaxKey = 208; + +type + TSynCobolSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + fRange: TRangeState; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0 .. MaxKey] of TIdentFuncTableFunc; + fIndicator: Char; + + fCodeStartPos: LongInt; + fCodeMediumPos: LongInt; + fCodeEndPos: LongInt; + + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fAIdentifierAttri: TSynHighlighterAttributes; + fPreprocessorAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fBooleanAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSequenceAttri: TSynHighlighterAttributes; + fIndicatorAttri: TSynHighlighterAttributes; + fTagAreaAttri: TSynHighlighterAttributes; + fDebugLinesAttri: TSynHighlighterAttributes; + + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func2: TtkTokenKind; + function Func5: TtkTokenKind; + function Func6: TtkTokenKind; + function Func7: TtkTokenKind; + function Func9: TtkTokenKind; + function Func10: TtkTokenKind; + function Func11: TtkTokenKind; + function Func13: TtkTokenKind; + function Func15: TtkTokenKind; + function Func16: TtkTokenKind; + function Func17: TtkTokenKind; + function Func19: TtkTokenKind; + function Func21: TtkTokenKind; + function Func22: TtkTokenKind; + function Func23: TtkTokenKind; + function Func24: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func27: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func34: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func46: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func91: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func94: TtkTokenKind; + function Func95: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func98: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func103: TtkTokenKind; + function Func104: TtkTokenKind; + function Func105: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func112: TtkTokenKind; + function Func113: TtkTokenKind; + function Func114: TtkTokenKind; + function Func115: TtkTokenKind; + function Func116: TtkTokenKind; + function Func117: TtkTokenKind; + function Func119: TtkTokenKind; + function Func120: TtkTokenKind; + function Func121: TtkTokenKind; + function Func122: TtkTokenKind; + function Func123: TtkTokenKind; + function Func124: TtkTokenKind; + function Func125: TtkTokenKind; + function Func126: TtkTokenKind; + function Func127: TtkTokenKind; + function Func128: TtkTokenKind; + function Func130: TtkTokenKind; + function Func131: TtkTokenKind; + function Func132: TtkTokenKind; + function Func133: TtkTokenKind; + function Func134: TtkTokenKind; + function Func137: TtkTokenKind; + function Func138: TtkTokenKind; + function Func140: TtkTokenKind; + function Func141: TtkTokenKind; + function Func146: TtkTokenKind; + function Func147: TtkTokenKind; + function Func149: TtkTokenKind; + function Func150: TtkTokenKind; + function Func152: TtkTokenKind; + function Func153: TtkTokenKind; + function Func157: TtkTokenKind; + function Func160: TtkTokenKind; + function Func161: TtkTokenKind; + function Func163: TtkTokenKind; + function Func165: TtkTokenKind; + function Func167: TtkTokenKind; + function Func173: TtkTokenKind; + function Func174: TtkTokenKind; + function Func188: TtkTokenKind; + function Func208: TtkTokenKind; + procedure IdentProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure NullProc; + procedure SpaceProc; + procedure CRProc; + procedure LFProc; + procedure NumberProc; + procedure PointProc; + procedure StringOpenProc; + procedure StringProc; + procedure StringEndProc; + procedure FirstCharsProc; + procedure LastCharsProc; + procedure CommentProc; + procedure DebugProc; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + + procedure SetCodeStartPos(Value: LongInt); + procedure SetCodeMediumPos(Value: LongInt); + procedure SetCodeEndPos(Value: LongInt); + public + constructor Create(AOwner: TComponent); override; + class function GetLanguageName: string; override; + function GetRange: Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property AreaAIdentifierAttri: TSynHighlighterAttributes read fAIdentifierAttri write fAIdentifierAttri; + property PreprocessorAttri: TSynHighlighterAttributes read fPreprocessorAttri write fPreprocessorAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property BooleanAttri: TSynHighlighterAttributes read fBooleanAttri write fBooleanAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SequenceAttri: TSynHighlighterAttributes read fSequenceAttri write fSequenceAttri; + property IndicatorAttri: TSynHighlighterAttributes read fIndicatorAttri write fIndicatorAttri; + property TagAreaAttri: TSynHighlighterAttributes read fTagAreaAttri write fTagAreaAttri; + property DebugLinesAttri: TSynHighlighterAttributes read fDebugLinesAttri write fDebugLinesAttri; + + property AreaAStartPos: LongInt read fCodeStartPos write SetCodeStartPos; + property AreaBStartPos: LongInt read fCodeMediumPos write SetCodeMediumPos; + property CodeEndPos: LongInt read fCodeEndPos write SetCodeEndPos; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable : array[#0..#255] of Integer; + +const + StringChars: array[TRangeState] of Char = (#0, '"', '''', '=', '"', ''''); + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + case I of + '-', '0'..'9', 'a'..'z', 'A'..'Z', '.': Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['-', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynCobolSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[2] := @Func2; + fIdentFuncTable[5] := @Func5; + fIdentFuncTable[6] := @Func6; + fIdentFuncTable[7] := @Func7; + fIdentFuncTable[9] := @Func9; + fIdentFuncTable[10] := @Func10; + fIdentFuncTable[11] := @Func11; + fIdentFuncTable[13] := @Func13; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[16] := @Func16; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[24] := @Func24; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[27] := @Func27; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[34] := @Func34; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[44] := @Func44; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[46] := @Func46; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[55] := @Func55; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[61] := @Func61; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[90] := @Func90; + fIdentFuncTable[91] := @Func91; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[94] := @Func94; + fIdentFuncTable[95] := @Func95; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[100] := @Func100; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[103] := @Func103; + fIdentFuncTable[104] := @Func104; + fIdentFuncTable[105] := @Func105; + fIdentFuncTable[106] := @Func106; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[108] := @Func108; + fIdentFuncTable[110] := @Func110; + fIdentFuncTable[111] := @Func111; + fIdentFuncTable[112] := @Func112; + fIdentFuncTable[113] := @Func113; + fIdentFuncTable[114] := @Func114; + fIdentFuncTable[115] := @Func115; + fIdentFuncTable[116] := @Func116; + fIdentFuncTable[117] := @Func117; + fIdentFuncTable[119] := @Func119; + fIdentFuncTable[120] := @Func120; + fIdentFuncTable[121] := @Func121; + fIdentFuncTable[122] := @Func122; + fIdentFuncTable[123] := @Func123; + fIdentFuncTable[124] := @Func124; + fIdentFuncTable[125] := @Func125; + fIdentFuncTable[126] := @Func126; + fIdentFuncTable[127] := @Func127; + fIdentFuncTable[128] := @Func128; + fIdentFuncTable[130] := @Func130; + fIdentFuncTable[131] := @Func131; + fIdentFuncTable[132] := @Func132; + fIdentFuncTable[133] := @Func133; + fIdentFuncTable[134] := @Func134; + fIdentFuncTable[137] := @Func137; + fIdentFuncTable[138] := @Func138; + fIdentFuncTable[140] := @Func140; + fIdentFuncTable[141] := @Func141; + fIdentFuncTable[146] := @Func146; + fIdentFuncTable[147] := @Func147; + fIdentFuncTable[149] := @Func149; + fIdentFuncTable[150] := @Func150; + fIdentFuncTable[152] := @Func152; + fIdentFuncTable[153] := @Func153; + fIdentFuncTable[157] := @Func157; + fIdentFuncTable[160] := @Func160; + fIdentFuncTable[161] := @Func161; + fIdentFuncTable[163] := @Func163; + fIdentFuncTable[165] := @Func165; + fIdentFuncTable[167] := @Func167; + fIdentFuncTable[173] := @Func173; + fIdentFuncTable[174] := @Func174; + fIdentFuncTable[188] := @Func188; + fIdentFuncTable[208] := @Func208; +end; + +function TSynCobolSyn.KeyHash(ToHash: PChar): Integer; +var + fRun: LongInt; +begin + fRun := Run; + Result := 0; + + if (ToHash^ in ['a'..'z', 'A'..'Z']) and (fRun <= fCodeEndPos) then + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + inc(fRun); + + while (ToHash^ in ['-', '0'..'9', 'a'..'z', 'A'..'Z']) and (fRun <= fCodeEndPos) do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + inc(fRun); + end; + end; + + fStringLen := ToHash - fToIdent; +end; + +function TSynCobolSyn.KeyComp(const aKey :string) :Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else + Result := False; +end; + +function TSynCobolSyn.Func2: TtkTokenKind; +begin + if KeyComp('B-AND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func5: TtkTokenKind; +begin + if KeyComp('I-O') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func6: TtkTokenKind; +begin + if KeyComp('DB') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func7: TtkTokenKind; +begin + if KeyComp('CD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func9: TtkTokenKind; +begin + if KeyComp('DE') then Result := tkKey else + if KeyComp('ADD') then Result := tkKey else + if KeyComp('CF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func10: TtkTokenKind; +begin + if KeyComp('FD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func11: TtkTokenKind; +begin + if KeyComp('CH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func13: TtkTokenKind; +begin + if KeyComp('END-ADD') then Result := tkKey else + if KeyComp('ID') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func15: TtkTokenKind; +begin + if KeyComp('IF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func16: TtkTokenKind; +begin + if KeyComp('LD') then Result := tkKey else + if KeyComp('B-OR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func17: TtkTokenKind; +begin + if KeyComp('CBL') then Result := tkPreprocessor else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func19: TtkTokenKind; +begin + if KeyComp('END-IF') then Result := tkKey else + if KeyComp('AND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func21: TtkTokenKind; +begin + if KeyComp('OF') then Result := tkKey else + if KeyComp('AT') then Result := tkKey else + if KeyComp('EGI') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func22: TtkTokenKind; +begin + if KeyComp('RD') then Result := tkKey else + if KeyComp('GO') then Result := tkKey else + if KeyComp('PF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func23: TtkTokenKind; +begin + if KeyComp('IN') then Result := tkKey else + if KeyComp('END') then Result := tkKey else + if KeyComp('SD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func24: TtkTokenKind; +begin + if KeyComp('RF') then Result := tkKey else + if KeyComp('PH') then Result := tkKey else + if KeyComp('ARE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func25: TtkTokenKind; +begin + if KeyComp('AREA') then Result := tkKey else + if KeyComp('ALL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func26: TtkTokenKind; +begin + if KeyComp('RH') then Result := tkKey else + if KeyComp('FILE-ID') then Result := tkKey else + if KeyComp('DATA') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func27: TtkTokenKind; +begin + if KeyComp('BY') then Result := tkKey else + if KeyComp('DB-DATA-NAME') then Result := tkKey else + if KeyComp('EMI') then Result := tkKey else + if KeyComp('OFF') then Result := tkKey else + if KeyComp('CODE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func28: TtkTokenKind; +begin + if KeyComp('COMP-9') then Result := tkKey else + if KeyComp('COMP-8') then Result := tkKey else + if KeyComp('COMP-7') then Result := tkKey else + if KeyComp('DBCS') then Result := tkKey else + if KeyComp('COMP-1') then Result := tkKey else + if KeyComp('COMP-2') then Result := tkKey else + if KeyComp('COMP-0') then Result := tkKey else + if KeyComp('COMP-6') then Result := tkKey else + if KeyComp('COMP-5') then Result := tkKey else + if KeyComp('PIC') then Result := tkKey else + if KeyComp('BEEP') then Result := tkKey else + if KeyComp('CALL') then Result := tkKey else + if KeyComp('READ') then Result := tkKey else + if KeyComp('COMP-4') then Result := tkKey else + if KeyComp('COMP-3') then Result := tkKey else + if KeyComp('IS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func29: TtkTokenKind; +begin + if KeyComp('PAGE') then Result := tkKey else + if KeyComp('NO') then Result := tkKey else + if KeyComp('ON') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func30: TtkTokenKind; +begin + if KeyComp('COL') then Result := tkKey else + if KeyComp('DATE') then Result := tkKey else + if KeyComp('DAY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func31: TtkTokenKind; +begin + if KeyComp('BELL') then Result := tkKey else + if KeyComp('BIT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func32: TtkTokenKind; +var + I: Integer; +begin + if KeyComp('END-READ') then Result := tkKey else + if KeyComp('B-NOT') then Result := tkKey else + if KeyComp('FILE') then Result := tkKey else + if KeyComp('GET') then Result := tkKey else + if KeyComp('END-CALL') then Result := tkKey else + if KeyComp('LABEL') then + begin + I := Run + Length('LABEL'); + while fLine[I] = ' ' do + Inc(I); + if (StrLIComp( PChar(@fLine[I]), 'RECORD', Length('RECORD')) = 0) + and (I + Length('RECORD') - 1 <= fCodeEndPos) then + Result := tkKey + else + Result := tkPreprocessor; + end + else + Result := tkIdentifier; +end; + +function TSynCobolSyn.Func33: TtkTokenKind; +begin + if KeyComp('FIND') then Result := tkKey else + if KeyComp('OR') then Result := tkKey else + if KeyComp('NAME') then Result := tkKey else + if KeyComp('ESI') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func34: TtkTokenKind; +begin + if KeyComp('EGCS') then Result := tkKey else + if KeyComp('FREE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func35: TtkTokenKind; +begin + if KeyComp('TO') then Result := tkKey else + if KeyComp('CHAIN') then Result := tkKey else + if KeyComp('END-OF-PAGE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func36: TtkTokenKind; +begin + if KeyComp('EOP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func37: TtkTokenKind; +begin + if KeyComp('INDEX-5') then Result := tkKey else + if KeyComp('UP') then Result := tkKey else + if KeyComp('EXEC') then Result := tkKey else + if KeyComp('INDEX-4') then Result := tkKey else + if KeyComp('INDEX-3') then Result := tkKey else + if KeyComp('INDEX-6') then Result := tkKey else + if KeyComp('INDEX-9') then Result := tkKey else + if KeyComp('INDEX-8') then Result := tkKey else + if KeyComp('INDEX-7') then Result := tkKey else + if KeyComp('INDEX-1') then Result := tkKey else + if KeyComp('KEEP') then Result := tkKey else + if KeyComp('MODE') then Result := tkKey else + if KeyComp('INDEX-2') then Result := tkKey else + if KeyComp('LIKE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func38: TtkTokenKind; +begin + if KeyComp('CANCEL') then Result := tkKey else + if KeyComp('SAME') then Result := tkKey else + if KeyComp('B-LESS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func39: TtkTokenKind; +begin + if KeyComp('ENABLE') then Result := tkKey else + if KeyComp('FOR') then Result := tkKey else + if KeyComp('INDIC') then Result := tkKey else + if KeyComp('GOBACK') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func40: TtkTokenKind; +begin + if KeyComp('ANY') then Result := tkKey else + if KeyComp('LINE') then Result := tkKey else + if KeyComp('BLANK') then Result := tkKey else + if KeyComp('TABLE') then Result := tkKey else + if KeyComp('REEL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func41: TtkTokenKind; +begin + if KeyComp('ELSE') then Result := tkKey else + if KeyComp('LOCK') then Result := tkKey else + if KeyComp('KEY') then Result := tkKey else + if KeyComp('NO-ECHO') then Result := tkKey else + if KeyComp('CRT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func42: TtkTokenKind; +begin + if KeyComp('TAPE') then Result := tkKey else + if KeyComp('SEND') then Result := tkKey else + if KeyComp('FINAL') then Result := tkKey else + if KeyComp('COM-REG') then Result := tkKey else + if KeyComp('FETCH') then Result := tkKey else + if KeyComp('CHANGED') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func43: TtkTokenKind; +begin + if KeyComp('EJECT') then Result := tkPreprocessor else + if KeyComp('BLOCK') then Result := tkKey else + if KeyComp('DEBUG-SUB-3') then Result := tkKey else + if KeyComp('FALSE') then Result := tkBoolean else + if KeyComp('LEFT') then Result := tkKey else + if KeyComp('DISK') then Result := tkKey else + if KeyComp('DEBUG-SUB-2') then Result := tkKey else + if KeyComp('DEBUG-SUB-1') then Result := tkKey else + if KeyComp('THAN') then Result := tkKey else + if KeyComp('END-ENABLE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func44: TtkTokenKind; +begin + if KeyComp('AREAS') then Result := tkKey else + if KeyComp('SPACE') then Result := tkString else + if KeyComp('SET') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func45: TtkTokenKind; +begin + if KeyComp('RANGE') then Result := tkKey else + if KeyComp('DB-SET-NAME') then Result := tkKey else + if KeyComp('USE') then Result := tkPreprocessor else + if KeyComp('KANJI') then Result := tkKey else + if KeyComp('COMMA') then Result := tkKey else + if KeyComp('B-EXOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func46: TtkTokenKind; +begin + if KeyComp('END-SEND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func47: TtkTokenKind; +begin + if KeyComp('THEN') then Result := tkKey else + if KeyComp('ALSO') then Result := tkKey else + if KeyComp('COMP') then Result := tkKey else + if KeyComp('TIME') then Result := tkKey else + if KeyComp('COBOL') then Result := tkKey else + if KeyComp('TRACE') then Result := tkPreprocessor else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func48: TtkTokenKind; +begin + if KeyComp('HEADING') then Result := tkKey else + if KeyComp('LINAGE') then Result := tkKey else + if KeyComp('VALID') then Result := tkKey else + if KeyComp('BLINK') then Result := tkKey else + if KeyComp('MERGE') then Result := tkKey else + if KeyComp('FIXED') then Result := tkKey else + if KeyComp('NONE') then Result := tkKey else + if KeyComp('ACCEPT') then Result := tkKey else + if KeyComp('ERASE') then Result := tkKey else + if KeyComp('CYCLE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func49: TtkTokenKind; +begin + if KeyComp('GLOBAL') then Result := tkKey else + if KeyComp('NOT') then Result := tkKey else + if KeyComp('SIGN') then Result := tkKey else + if KeyComp('ESCAPE') then Result := tkKey else + if KeyComp('REALM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func50: TtkTokenKind; +begin + if KeyComp('AFTER') then Result := tkKey else + if KeyComp('WHEN') then Result := tkKey else + if KeyComp('BASIS') then Result := tkPreprocessor else + if KeyComp('OPEN') then Result := tkKey else + if KeyComp('BITS') then Result := tkKey else + if KeyComp('ACCESS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func51: TtkTokenKind; +begin + if KeyComp('DETAIL') then Result := tkKey else + if KeyComp('TOP') then Result := tkKey else + if KeyComp('BEFORE') then Result := tkKey else + if KeyComp('DELETE') then Result := tkPreprocessor else + if KeyComp('FULL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func52: TtkTokenKind; +begin + if KeyComp('LAST') then Result := tkKey else + if KeyComp('KEPT') then Result := tkKey else + if KeyComp('FORM') then Result := tkKey else + if KeyComp('COMP-X') then Result := tkKey else + if KeyComp('FROM') then Result := tkKey else + if KeyComp('END-ACCEPT') then Result := tkKey else + if KeyComp('DISABLE') then Result := tkKey else + if KeyComp('CODE-SET') then Result := tkKey else + if KeyComp('LEADING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func53: TtkTokenKind; +begin + if KeyComp('EXACT') then Result := tkKey else + if KeyComp('WAIT') then Result := tkKey else + if KeyComp('SUM') then Result := tkKey else + if KeyComp('USAGE') then Result := tkKey else + if KeyComp('READY') then Result := tkPreprocessor else + if KeyComp('DROP') then Result := tkKey else + if KeyComp('ENDING') then Result := tkKey else + if KeyComp('DEBUG-NAME') then Result := tkKey else + if KeyComp('RUN') then Result := tkKey else + if KeyComp('DIVIDE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func54: TtkTokenKind; +begin + if KeyComp('CORR') then Result := tkKey else + if KeyComp('CLOSE') then Result := tkKey else + if KeyComp('SEARCH') then Result := tkKey else + if KeyComp('CLASS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func55: TtkTokenKind; +begin + if KeyComp('SKIP1') then Result := tkPreprocessor else + if KeyComp('SKIP3') then Result := tkPreprocessor else + if KeyComp('SKIP2') then Result := tkPreprocessor else + if KeyComp('END-DELETE') then Result := tkKey else + if KeyComp('SHARED') then Result := tkKey else + if KeyComp('PADDING') then Result := tkKey else + if KeyComp('MOVE') then Result := tkKey else + if KeyComp('RELOAD') then Result := tkPreprocessor else + if KeyComp('LESS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func56: TtkTokenKind; +begin + if KeyComp('INDEX') then Result := tkKey else + if KeyComp('EQUAL') then Result := tkKey else + if KeyComp('MEMBER') then Result := tkKey else + if KeyComp('ALTER') then Result := tkKey else + if KeyComp('END-DISABLE') then Result := tkKey else + if KeyComp('EXCESS-3') then Result := tkKey else + if KeyComp('DOWN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func57: TtkTokenKind; +begin + if KeyComp('END-DIVIDE') then Result := tkKey else + if KeyComp('DAY-OF-WEEK') then Result := tkKey else + if KeyComp('AUTO') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func58: TtkTokenKind; +begin + if KeyComp('EXIT') then Result := tkKey else + if KeyComp('END-SEARCH') then Result := tkKey else + if KeyComp('INTO') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func59: TtkTokenKind; +begin + if KeyComp('LINES') then Result := tkKey else + if KeyComp('LINKAGE') then Result := tkKey else + if KeyComp('NULL') then Result := tkString else + if KeyComp('SIZE') then Result := tkKey else + if KeyComp('COPY') then Result := tkPreprocessor else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func60: TtkTokenKind; +begin + if KeyComp('DEBUG-LINE') then Result := tkKey else + if KeyComp('WITH') then Result := tkKey else + if KeyComp('ORDER') then Result := tkKey else + if KeyComp('REPLACE') then Result := tkPreprocessor else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func61: TtkTokenKind; +begin + if KeyComp('VALUE') then Result := tkKey else + if KeyComp('SYNC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func62: TtkTokenKind; +begin + if KeyComp('FILLER') then Result := tkKey else + if KeyComp('MANUAL') then Result := tkKey else + if KeyComp('STANDARD-1') then Result := tkKey else + if KeyComp('RIGHT') then Result := tkKey else + if KeyComp('STANDARD-4') then Result := tkKey else + if KeyComp('STANDARD-2') then Result := tkKey else + if KeyComp('STANDARD-3') then Result := tkKey else + if KeyComp('ENTER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func63: TtkTokenKind; +begin + if KeyComp('SWITCH-4') then Result := tkKey else + if KeyComp('SWITCH-5') then Result := tkKey else + if KeyComp('SWITCH-2') then Result := tkKey else + if KeyComp('SWITCH-8') then Result := tkKey else + if KeyComp('SWITCH-1') then Result := tkKey else + if KeyComp('LIMIT') then Result := tkKey else + if KeyComp('RECORD') then Result := tkKey else + if KeyComp('NEXT') then Result := tkKey else + if KeyComp('SPACES') then Result := tkString else + if KeyComp('COLOR') then Result := tkKey else + if KeyComp('SWITCH-6') then Result := tkKey else + if KeyComp('BACKWARD') then Result := tkKey else + if KeyComp('SWITCH-3') then Result := tkKey else + if KeyComp('USER') then Result := tkKey else + if KeyComp('SWITCH-7') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func64: TtkTokenKind; +begin + if KeyComp('DB-RECORD-NAME') then Result := tkKey else + if KeyComp('BOOLEAN') then Result := tkKey else + if KeyComp('TRUE') then Result := tkBoolean else + if KeyComp('TEST') then Result := tkKey else + if KeyComp('UNIT') then Result := tkKey else + if KeyComp('ZERO') then Result := tkString else + if KeyComp('SPACE-FILL') then Result := tkKey else + if KeyComp('SELECT') then Result := tkKey else + if KeyComp('SCREEN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func65: TtkTokenKind; +begin + if KeyComp('ALPHABET') then Result := tkKey else + if KeyComp('RANDOM') then Result := tkKey else + if KeyComp('EXCEEDS') then Result := tkKey else + if KeyComp('RELEASE') then Result := tkKey else + if KeyComp('INDEXED') then Result := tkKey else + if KeyComp('MODIFIED') then Result := tkKey else + if KeyComp('INDICATE') then Result := tkKey else + if KeyComp('CHAINING') then Result := tkKey else + if KeyComp('FINISH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func66: TtkTokenKind; +begin + if KeyComp('TITLE') then Result := tkPreprocessor else + if KeyComp('SHIFT-IN') then Result := tkKey else + if KeyComp('LENGTH') then Result := tkKey else + if KeyComp('UPON') then Result := tkKey else + if KeyComp('OTHER') then Result := tkKey else + if KeyComp('ONLY') then Result := tkKey else + if KeyComp('PROCEED') then Result := tkKey else + if KeyComp('TYPE') then Result := tkKey else + if KeyComp('TIMES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func67: TtkTokenKind; +begin + if KeyComp('THRU') then Result := tkKey else + if KeyComp('RESET') then Result := tkPreprocessor else + if KeyComp('DISPLAY-7') then Result := tkKey else + if KeyComp('AREA-VALUE') then Result := tkKey else + if KeyComp('PURGE') then Result := tkKey else + if KeyComp('UPDATE') then Result := tkKey else + if KeyComp('RECEIVE') then Result := tkKey else + if KeyComp('DISPLAY-5') then Result := tkKey else + if KeyComp('DISPLAY-1') then Result := tkKey else + if KeyComp('DISPLAY-4') then Result := tkKey else + if KeyComp('DEBUG-ITEM') then Result := tkKey else + if KeyComp('DISPLAY-2') then Result := tkKey else + if KeyComp('DISPLAY-6') then Result := tkKey else + if KeyComp('DISPLAY-9') then Result := tkKey else + if KeyComp('DISPLAY-3') then Result := tkKey else + if KeyComp('DISPLAY-8') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func68: TtkTokenKind; +begin + if KeyComp('GIVING') then Result := tkKey else + if KeyComp('PACKED-DECIMAL') then Result := tkKey else + if KeyComp('PLUS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func69: TtkTokenKind; +begin + if KeyComp('ASSIGN') then Result := tkKey else + if KeyComp('BINARY') then Result := tkKey else + if KeyComp('DEFAULT') then Result := tkKey else + if KeyComp('DYNAMIC') then Result := tkKey else + if KeyComp('QUEUE') then Result := tkKey else + if KeyComp('TEXT') then Result := tkKey else + if KeyComp('MESSAGE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func70: TtkTokenKind; +begin + if KeyComp('USING') then Result := tkKey else + if KeyComp('JUST') then Result := tkKey else + if KeyComp('TALLY') then Result := tkKey else + if KeyComp('ADDRESS') then Result := tkKey else + if KeyComp('APPLY') then Result := tkKey else + if KeyComp('VARIABLE') then Result := tkKey else + if KeyComp('STOP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func71: TtkTokenKind; +begin + if KeyComp('INVALID') then Result := tkKey else + if KeyComp('END-RECEIVE') then Result := tkKey else + if KeyComp('NATIVE') then Result := tkKey else + if KeyComp('SECURE') then Result := tkKey else + if KeyComp('USAGE-MODE') then Result := tkKey else + if KeyComp('JAPANESE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func72: TtkTokenKind; +begin + if KeyComp('EXTEND') then Result := tkKey else + if KeyComp('MODIFY') then Result := tkKey else + if KeyComp('SORT') then Result := tkKey else + if KeyComp('SUB-SCHEMA') then Result := tkKey else + if KeyComp('FIRST') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func73: TtkTokenKind; +begin + if KeyComp('COMMON') then Result := tkKey else + if KeyComp('COUNT') then Result := tkKey else + if KeyComp('SUB-QUEUE-3') then Result := tkKey else + if KeyComp('NORMAL') then Result := tkKey else + if KeyComp('COMMIT') then Result := tkKey else + if KeyComp('NUMBER') then Result := tkKey else + if KeyComp('SUB-QUEUE-1') then Result := tkKey else + if KeyComp('SUB-QUEUE-2') then Result := tkKey else + if KeyComp('REWIND') then Result := tkKey else + if KeyComp('FORMAT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func74: TtkTokenKind; +begin + if KeyComp('ACQUIRE') then Result := tkKey else + if KeyComp('CONNECT') then Result := tkKey else + if KeyComp('DB-FORMAT-NAME') then Result := tkKey else + if KeyComp('TENANT') then Result := tkKey else + if KeyComp('GREATER') then Result := tkKey else + if KeyComp('HIGH-VALUE') then Result := tkString else + if KeyComp('ERROR') then Result := tkKey else + if KeyComp('VALIDATE') then Result := tkKey else + if KeyComp('SUBFILE') then Result := tkKey else + if KeyComp('REPEATED') then Result := tkKey else + if KeyComp('ROLLBACK') then Result := tkKey else + if KeyComp('INITIAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func75: TtkTokenKind; +begin + if KeyComp('OWNER') then Result := tkKey else + if KeyComp('WRITE') then Result := tkKey else + if KeyComp('GENERATE') then Result := tkKey else + if KeyComp('EVERY') then Result := tkKey else + if KeyComp('EQUALS') then Result := tkKey else + if KeyComp('ADVANCING') then Result := tkKey else + if KeyComp('RENAMES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func76: TtkTokenKind; +begin + if KeyComp('ASCENDING') then Result := tkKey else + if KeyComp('UNTIL') then Result := tkKey else + if KeyComp('RERUN') then Result := tkKey else + if KeyComp('UNLOCK') then Result := tkKey else + if KeyComp('PRIOR') then Result := tkKey else + if KeyComp('DEBUGGING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func77: TtkTokenKind; +begin + if KeyComp('GROUP') then Result := tkKey else + if KeyComp('CHARACTER') then Result := tkKey else + if KeyComp('EXHIBIT') then Result := tkKey else + if KeyComp('LENGTH-CHECK') then Result := tkKey else + if KeyComp('RECORD-NAME') then Result := tkKey else + if KeyComp('STORE') then Result := tkKey else + if KeyComp('ALPHABETIC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func78: TtkTokenKind; +begin + if KeyComp('DEPENDING') then Result := tkKey else + if KeyComp('START') then Result := tkKey else + if KeyComp('NULLS') then Result := tkString else + if KeyComp('QUOTE') then Result := tkString else + if KeyComp('COLUMN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func79: TtkTokenKind; +begin + if KeyComp('WORDS') then Result := tkKey else + if KeyComp('EMPTY') then Result := tkKey else + if KeyComp('PALETTE') then Result := tkKey else + if KeyComp('REFERENCE') then Result := tkKey else + if KeyComp('OCCURS') then Result := tkKey else + if KeyComp('END-WRITE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func80: TtkTokenKind; +begin + if KeyComp('VALUES') then Result := tkKey else + if KeyComp('INPUT') then Result := tkKey else + if KeyComp('LOCALLY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func81: TtkTokenKind; +begin + if KeyComp('PRINTER-1') then Result := tkKey else + if KeyComp('SOURCE') then Result := tkKey else + if KeyComp('ROUNDED') then Result := tkKey else + if KeyComp('BEGINNING') then Result := tkKey else + if KeyComp('SERVICE') then Result := tkPreprocessor else + if KeyComp('DELIMITED') then Result := tkKey else + if KeyComp('STANDARD') then Result := tkKey else + if KeyComp('KEYBOARD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func82: TtkTokenKind; +begin + if KeyComp('ENTRY') then Result := tkKey else + if KeyComp('RECORDS') then Result := tkKey else + if KeyComp('LIMITS') then Result := tkKey else + if KeyComp('PROGRAM-ID') then Result := tkKey else + if KeyComp('END-START') then Result := tkKey else + if KeyComp('SWITCH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func83: TtkTokenKind; +begin + if KeyComp('MORE-LABELS') then Result := tkKey else + if KeyComp('WITHIN') then Result := tkKey else + if KeyComp('NEGATIVE') then Result := tkKey else + if KeyComp('I-O-CONTROL') then Result := tkKey else + if KeyComp('NUMERIC') then Result := tkKey else + if KeyComp('ZEROS') then Result := tkString else + if KeyComp('AUTHOR') then Result := tkKey else + if KeyComp('CONSOLE') then Result := tkKey else + if KeyComp('SEGMENT') then Result := tkKey else + if KeyComp('EXECUTE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func84: TtkTokenKind; +begin + if KeyComp('COMMAND-LINE') then Result := tkKey else + if KeyComp('DESCENDING') then Result := tkKey else + if KeyComp('ZERO-FILL') then Result := tkKey else + if KeyComp('CRT-UNDER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func85: TtkTokenKind; +begin + if KeyComp('SENTENCE') then Result := tkKey else + if KeyComp('CONTAINED') then Result := tkKey else + if KeyComp('REDEFINES') then Result := tkKey else + if KeyComp('BOTTOM') then Result := tkKey else + if KeyComp('REPLACING') then Result := tkKey else + if KeyComp('SECTION') then Result := tkKey else + if KeyComp('INSERT') then Result := tkPreprocessor else + if KeyComp('SEPARATE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func86: TtkTokenKind; +begin + if KeyComp('PARAGRAPH') then Result := tkKey else + if KeyComp('FOOTING') then Result := tkKey else + if KeyComp('INSPECT') then Result := tkKey else + if KeyComp('REMOVAL') then Result := tkKey else + if KeyComp('DISPLAY') then Result := tkKey else + if KeyComp('OMITTED') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func87: TtkTokenKind; +begin + if KeyComp('DB-STATUS') then Result := tkKey else + if KeyComp('ROLLING') then Result := tkKey else + if KeyComp('INITIATE') then Result := tkKey else + if KeyComp('EVALUATE') then Result := tkKey else + if KeyComp('STRING') then Result := tkKey else + if KeyComp('REMAINDER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func88: TtkTokenKind; +begin + if KeyComp('PROGRAM') then Result := tkKey else + if KeyComp('DATE-COMPILED') then Result := tkKey else + if KeyComp('HIGHLIGHT') then Result := tkKey else + if KeyComp('ZEROES') then Result := tkString else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func89: TtkTokenKind; +begin + if KeyComp('MODULES') then Result := tkKey else + if KeyComp('MEMORY') then Result := tkKey else + if KeyComp('SEQUENCE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func90: TtkTokenKind; +begin + if KeyComp('TRAILING') then Result := tkKey else + if KeyComp('EMPTY-CHECK') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func91: TtkTokenKind; +begin + if KeyComp('CONTENT') then Result := tkKey else + if KeyComp('END-EVALUATE') then Result := tkKey else + if KeyComp('UNEQUAL') then Result := tkKey else + if KeyComp('END-STRING') then Result := tkKey else + if KeyComp('PERFORM') then Result := tkKey else + if KeyComp('DUPLICATE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func92: TtkTokenKind; +begin + if KeyComp('PICTURE') then Result := tkKey else + if KeyComp('RELATIVE') then Result := tkKey else + if KeyComp('TERMINAL') then Result := tkKey else + if KeyComp('REPORT') then Result := tkKey else + if KeyComp('LOW-VALUE') then Result := tkString else + if KeyComp('RESERVE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func93: TtkTokenKind; +begin + if KeyComp('ALLOWING') then Result := tkKey else + if KeyComp('HIGH-VALUES') then Result := tkString else + if KeyComp('INDICATOR') then Result := tkKey else + if KeyComp('AUTO-SKIP') then Result := tkKey else + if KeyComp('COLLATING') then Result := tkKey else + if KeyComp('COMPUTE') then Result := tkKey else + if KeyComp('RECORDING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func94: TtkTokenKind; +begin + if KeyComp('RELATION') then Result := tkKey else + if KeyComp('SESSION-ID') then Result := tkKey else + if KeyComp('CURSOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func95: TtkTokenKind; +begin + if KeyComp('CONTAINS') then Result := tkKey else + if KeyComp('END-PERFORM') then Result := tkKey else + if KeyComp('DELIMITER') then Result := tkKey else + if KeyComp('PROCESS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func96: TtkTokenKind; +begin + if KeyComp('CHARACTERS') then Result := tkKey else + if KeyComp('VARYING') then Result := tkKey else + if KeyComp('RETURN') then Result := tkKey else + if KeyComp('ALTERNATE') then Result := tkKey else + if KeyComp('REVERSED') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func97: TtkTokenKind; +begin + if KeyComp('THROUGH') then Result := tkKey else + if KeyComp('REQUIRED') then Result := tkKey else + if KeyComp('CONTROL') then Result := tkPreprocessor else + if KeyComp('RETAINING') then Result := tkKey else + if KeyComp('POINTER') then Result := tkKey else + if KeyComp('PRESENT') then Result := tkKey else + if KeyComp('QUOTES') then Result := tkString else + if KeyComp('RECONNECT') then Result := tkKey else + if KeyComp('END-COMPUTE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func98: TtkTokenKind; +begin + if KeyComp('DB-EXCEPTION') then Result := tkKey else + if KeyComp('REFERENCES') then Result := tkKey else + if KeyComp('REWRITE') then Result := tkKey else + if KeyComp('SPECIAL-NAMES') then Result := tkKey else + if KeyComp('SYMBOLIC') then Result := tkKey else + if KeyComp('PROMPT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func99: TtkTokenKind; +begin + if KeyComp('CURRENT') then Result := tkKey else + if KeyComp('SHIFT-OUT') then Result := tkKey else + if KeyComp('EXTERNAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func100: TtkTokenKind; +begin + if KeyComp('TALLYING') then Result := tkKey else + if KeyComp('STATUS') then Result := tkKey else + if KeyComp('PRINTER') then Result := tkKey else + if KeyComp('END-RETURN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func101: TtkTokenKind; +begin + if KeyComp('DIVISION') then Result := tkKey else + if KeyComp('CONTINUE') then Result := tkKey else + if KeyComp('SORT-MERGE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func102: TtkTokenKind; +begin + if KeyComp('END-REWRITE') then Result := tkKey else + if KeyComp('FUNCTION') then Result := tkKey else + if KeyComp('OPTIONAL') then Result := tkKey else + if KeyComp('DECIMAL-POINT') then Result := tkKey else + if KeyComp('UNDERLINE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func103: TtkTokenKind; +begin + if KeyComp('CONTROL-AREA') then Result := tkKey else + if KeyComp('JUSTIFIED') then Result := tkKey else + if KeyComp('TIMEOUT') then Result := tkKey else + if KeyComp('AUTOMATIC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func104: TtkTokenKind; +begin + if KeyComp('SUBTRACT') then Result := tkKey else + if KeyComp('RETURN-CODE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func105: TtkTokenKind; +begin + if KeyComp('TERMINATE') then Result := tkKey else + if KeyComp('PROCEDURE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func106: TtkTokenKind; +begin + if KeyComp('PAGE-COUNTER') then Result := tkKey else + if KeyComp('ARITHMETIC') then Result := tkKey else + if KeyComp('DISCONNECT') then Result := tkKey else + if KeyComp('PROTECTED') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func107: TtkTokenKind; +begin + if KeyComp('PRINTING') then Result := tkKey else + if KeyComp('CURRENCY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func108: TtkTokenKind; +begin + if KeyComp('END-SUBTRACT') then Result := tkKey else + if KeyComp('CLOCK-UNITS') then Result := tkKey else + if KeyComp('STARTING') then Result := tkKey else + if KeyComp('MULTIPLE') then Result := tkKey else + if KeyComp('WHEN-COMPILED') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func110: TtkTokenKind; +begin + if KeyComp('DUPLICATES') then Result := tkKey else + if KeyComp('RETRIEVAL') then Result := tkKey else + if KeyComp('FILE-CONTROL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func111: TtkTokenKind; +begin + if KeyComp('LOW-VALUES') then Result := tkString else + if KeyComp('EXCEPTION') then Result := tkKey else + if KeyComp('REPORTS') then Result := tkKey else + if KeyComp('NUMERIC-EDITED') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func112: TtkTokenKind; +begin + if KeyComp('INDICATORS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func113: TtkTokenKind; +begin + if KeyComp('OUTPUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func114: TtkTokenKind; +begin + if KeyComp('INITIALIZE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func115: TtkTokenKind; +begin + if KeyComp('PASSWORD') then Result := tkKey else + if KeyComp('POSITIVE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func116: TtkTokenKind; +begin + if KeyComp('CONTROLS') then Result := tkKey else + if KeyComp('TRANSCEIVE') then Result := tkKey else + if KeyComp('OVERFLOW') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func117: TtkTokenKind; +begin + if KeyComp('POSITION') then Result := tkKey else + if KeyComp('LINE-COUNTER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func119: TtkTokenKind; +begin + if KeyComp('DECLARATIVES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func120: TtkTokenKind; +begin + if KeyComp('DATE-WRITTEN') then Result := tkKey else + if KeyComp('SECURITY') then Result := tkKey else + if KeyComp('END-TRANSCEIVE') then Result := tkKey else + if KeyComp('TRAILING-SIGN') then Result := tkKey else + if KeyComp('EXCLUSIVE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func121: TtkTokenKind; +begin + if KeyComp('ALPHANUMERIC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func122: TtkTokenKind; +begin + if KeyComp('WRITE-ONLY') then Result := tkKey else + if KeyComp('REPORTING') then Result := tkKey else + if KeyComp('SORT-MESSAGE') then Result := tkKey else + if KeyComp('UNSTRING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func123: TtkTokenKind; +begin + if KeyComp('SEQUENTIAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func124: TtkTokenKind; +begin + if KeyComp('PROCEDURES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func125: TtkTokenKind; +begin + if KeyComp('PREVIOUS') then Result := tkKey else + if KeyComp('PROCESSING') then Result := tkKey else + if KeyComp('LINAGE-COUNTER') then Result := tkKey else + if KeyComp('COMMITMENT') then Result := tkKey else + if KeyComp('SORT-FILE-SIZE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func126: TtkTokenKind; +begin + if KeyComp('END-UNSTRING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func127: TtkTokenKind; +begin + if KeyComp('SEGMENT-LIMIT') then Result := tkKey else + if KeyComp('CONVERTING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func128: TtkTokenKind; +begin + if KeyComp('REVERSE-VIDEO') then Result := tkKey else + if KeyComp('MULTIPLY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func130: TtkTokenKind; +begin + if KeyComp('SUBPROGRAM') then Result := tkKey else + if KeyComp('SORT-MODE-SIZE') then Result := tkKey else + if KeyComp('DEBUG-CONTENTS') then Result := tkKey else + if KeyComp('DESTINATION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func131: TtkTokenKind; +begin + if KeyComp('ALPHABETIC-LOWER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func132: TtkTokenKind; +begin + if KeyComp('END-MULTIPLY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func133: TtkTokenKind; +begin + if KeyComp('SUPPRESS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func134: TtkTokenKind; +begin + if KeyComp('TRANSACTION') then Result := tkKey else + if KeyComp('SORT-CORE-SIZE') then Result := tkKey else + if KeyComp('LEFT-JUSTIFY') then Result := tkKey else + if KeyComp('ALPHABETIC-UPPER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func137: TtkTokenKind; +begin + if KeyComp('DB-ACCESS-CONTROL-KEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func138: TtkTokenKind; +begin + if KeyComp('IDENTIFICATION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func140: TtkTokenKind; +begin + if KeyComp('PRINT-SWITCH') then Result := tkKey else + if KeyComp('BACKGROUND-COLOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func141: TtkTokenKind; +begin + if KeyComp('COMPUTATIONAL-5') then Result := tkKey else + if KeyComp('COMPUTATIONAL-8') then Result := tkKey else + if KeyComp('COMPUTATIONAL-0') then Result := tkKey else + if KeyComp('COMPUTATIONAL-2') then Result := tkKey else + if KeyComp('COMPUTATIONAL-3') then Result := tkKey else + if KeyComp('COMPUTATIONAL-6') then Result := tkKey else + if KeyComp('COMPUTATIONAL-7') then Result := tkKey else + if KeyComp('COMPUTATIONAL-9') then Result := tkKey else + if KeyComp('COMPUTATIONAL-4') then Result := tkKey else + if KeyComp('COMPUTATIONAL-1') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func146: TtkTokenKind; +begin + if KeyComp('INSTALLATION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func147: TtkTokenKind; +begin + if KeyComp('OBJECT-COMPUTER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func149: TtkTokenKind; +begin + if KeyComp('ALPHANUMERIC-EDITED') then Result := tkKey else + if KeyComp('ENVIRONMENT') then Result := tkKey else + if KeyComp('ORGANIZATION') then Result := tkKey else + if KeyComp('SORT-RETURN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func150: TtkTokenKind; +begin + if KeyComp('COMMUNICATION') then Result := tkKey else + if KeyComp('SORT-CONTROL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func152: TtkTokenKind; +begin + if KeyComp('CONFIGURATION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func153: TtkTokenKind; +begin + if KeyComp('RIGHT-JUSTIFY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func157: TtkTokenKind; +begin + if KeyComp('CORRESPONDING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func160: TtkTokenKind; +begin + if KeyComp('SYNCHRONIZED') then Result := tkKey else + if KeyComp('COMPUTATIONAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func161: TtkTokenKind; +begin + if KeyComp('BACKGROUND-COLOUR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func163: TtkTokenKind; +begin + if KeyComp('WORKING-STORAGE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func165: TtkTokenKind; +begin + if KeyComp('COMPUTATIONAL-X') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func167: TtkTokenKind; +begin + if KeyComp('FOREGROUND-COLOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func173: TtkTokenKind; +begin + if KeyComp('SOURCE-COMPUTER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func174: TtkTokenKind; +begin + if KeyComp('INPUT-OUTPUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func188: TtkTokenKind; +begin + if KeyComp('FOREGROUND-COLOUR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.Func208: TtkTokenKind; +begin + if KeyComp('EXTERNALLY-DESCRIBED-KEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCobolSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynCobolSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if (0 <= HashKey) and (HashKey <= MaxKey) then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynCobolSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0: fProcTable[I] := @NullProc; + #10: fProcTable[I] := @LFProc; + #13: fProcTable[I] := @CRProc; + '"': fProcTable[I] := @StringOpenProc; + '''': fProcTable[I] := @StringOpenProc; + '=': fProcTable[I] := @StringOpenProc; + #1..#9, + #11, + #12, + #14..#32 : fProcTable[I] := @SpaceProc; + '.': fProcTable[I] := @PointProc; + '0'..'9': fProcTable[I] := @NumberProc; + 'A'..'Z', 'a'..'z': fProcTable[I] := @IdentProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +procedure TSynCobolSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + inc(Run); + until not (fLine[Run] in [#1..#32]); +end; + +procedure TSynCobolSyn.FirstCharsProc; +var + I: Integer; +begin + if fLine[Run] in [#0, #10, #13] then + fProcTable[fLine[Run]] + else + if Run < fCodeStartPos - 1 then + begin + fTokenID := tkSequence; + repeat + inc(Run); + until (Run = fCodeStartPos - 1) or (fLine[Run] in [#0, #10, #13]); + end + else + begin + fTokenID := tkIndicator; + case fLine[Run] of + '*', '/', 'D': fIndicator := fLine[Run]; + '-': if fRange in [rsQuoteStringMayBe, rsApostStringMayBe] then + begin + I := Run + 1; + while fLine[I] = ' ' do + Inc(I); + if (StrLIComp( PChar(@fLine[I]), PChar(StringOfChar(StringChars[fRange], 2)), 2) <> 0) + or (I + 1 > fCodeEndPos) then + fRange := rsUnknown; + end; + end; + inc(Run); + end; +end; + +procedure TSynCobolSyn.LastCharsProc; +begin + if fLine[Run] in [#0, #10, #13] then + fProcTable[fLine[Run]] + else + begin + fTokenID := tkTagArea; + repeat + inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynCobolSyn.CommentProc; +begin + fIndicator := #0; + + if fLine[Run] in [#0, #10, #13] then + fProcTable[fLine[Run]] + else + begin + fTokenID := tkComment; + repeat + Inc(Run); + until (fLine[Run] in [#0, #10, #13]) or (Run > fCodeEndPos); + end; +end; + +procedure TSynCobolSyn.DebugProc; +begin + fIndicator := #0; + + if fLine[Run] in [#0, #10, #13] then + fProcTable[fLine[Run]] + else + begin + fTokenID := tkDebugLines; + repeat + Inc(Run); + until (fLine[Run] in [#0, #10, #13]) or (Run > fCodeEndPos); + end; +end; + +procedure TSynCobolSyn.PointProc; +begin + if (Run < fCodeEndPos) and (FLine[Run + 1] in ['0'..'9', 'e', 'E']) then + NumberProc + else + UnknownProc; +end; + +procedure TSynCobolSyn.NumberProc; +var + fFloat: Boolean; +begin + fTokenID := tkNumber; + Inc(Run); + fFloat := False; + + while (FLine[Run] in ['0'..'9', '.', 'e', 'E', '-', '+']) and (Run <= fCodeEndPos) do + begin + case FLine[Run] of + '.': + if not (FLine[Run + 1] in ['0'..'9', 'e', 'E']) then + Break + else + fFloat := True; + 'e', 'E': + if not (FLine[Run - 1] in ['0'..'9', '.']) then + Break + else fFloat := True; + '-', '+': + begin + if (not fFloat) or (not (FLine[Run - 1] in ['e', 'E'])) then + Break; + end; + end; + Inc(Run); + end; +end; + +procedure TSynCobolSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynCobolSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then + inc(Run); +end; + +procedure TSynCobolSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynCobolSyn.StringOpenProc; +begin + case fLine[Run] of + '"': fRange := rsQuoteString; + '''': fRange := rsApostString; + else + if fLine[Run + 1] = '=' then + begin + fRange := rsPseudoText; + Inc(Run); + end + else + begin + UnknownProc; + Exit; + end; + end; + + Inc(Run); + StringProc; + fTokenID := tkString; +end; + +procedure TSynCobolSyn.StringProc; +begin + fTokenID := tkString; + + if Run <= fCodeEndPos then + repeat + if (fLine[Run] = StringChars[fRange]) + and ((fLine[Run] <> '=') or ((Run > 0) and (fLine[Run - 1] = '='))) then + begin + if (Run = fCodeEndPos) and (fRange in [rsQuoteString, rsApostString]) then + Inc(fRange, 3) + else + fRange := rsUnknown; + Inc(Run); + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until (fLine[Run] in [#0, #10, #13]) or (Run > fCodeEndPos); +end; + +procedure TSynCobolSyn.StringEndProc; +begin + if fLine[Run] in [#0, #10, #13] then + fProcTable[fLine[Run]] + else + begin + fTokenID := tkString; + + if (fRange <> rsPseudoText) and (Run <= fCodeEndPos) then + repeat + if (fLine[Run] = StringChars[fRange]) then + begin + if fRange in [rsQuoteString, rsApostString] then + Inc(Run) + else + begin + Inc(Run, 2); + Dec(fRange, 3); + end; + Break; + end; + Inc(Run); + until (fLine[Run] in [#0, #10, #13]) or (Run > fCodeEndPos); + + StringProc; + end; +end; + +constructor TSynCobolSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + fCommentAttri.Foreground := clGray; + AddAttribute(fCommentAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fAIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrAreaAIdentifier); + fAIdentifierAttri.Foreground := clTeal; + fAIdentifierAttri.Style := [fsBold]; + AddAttribute(fAIdentifierAttri); + + fPreprocessorAttri := TSynHighLighterAttributes.Create(SYNS_AttrPreprocessor); + fPreprocessorAttri.Foreground := clMaroon; + AddAttribute(fPreprocessorAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighLighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clGreen; + AddAttribute(fNumberAttri); + + fBooleanAttri := TSynHighLighterAttributes.Create(SYNS_AttrBoolean); + fBooleanAttri.Foreground := clGreen; + AddAttribute(fBooleanAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clBlue; + AddAttribute(fStringAttri); + + fSequenceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSequence); + fSequenceAttri.Foreground := clDkGray; + AddAttribute(fSequenceAttri); + + fIndicatorAttri := TSynHighLighterAttributes.Create(SYNS_AttrIndicator); + fIndicatorAttri.Foreground := clRed; + AddAttribute(fIndicatorAttri); + + fTagAreaAttri := TSynHighLighterAttributes.Create(SYNS_AttrTagArea); + fTagAreaAttri.Foreground := clMaroon; + AddAttribute(fTagAreaAttri); + + fDebugLinesAttri := TSynHighLighterAttributes.Create(SYNS_AttrDebugLines); + fDebugLinesAttri.Foreground := clDkGray; + AddAttribute(fDebugLinesAttri); + + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterCOBOL; + fRange := rsUnknown; + fIndicator := #0; + + fCodeStartPos := 7; + fCodeMediumPos := 11; + fCodeEndPos := 71; +end; + +procedure TSynCobolSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynCobolSyn.IdentProc; +begin + if (UpCase(fLine[Run]) in ['X', 'G']) + and (Run < fCodeEndPos) and (fLine[Run + 1] in ['"', '''']) then + begin + Inc(Run); + StringOpenProc; + end + else + begin + fTokenID := IdentKind((fLine + Run)); + if (fTokenID = tkIdentifier) and (Run < fCodeMediumPos) then + fTokenID := tkAIdentifier; + inc(Run, fStringLen); + + while Identifiers[fLine[Run]] and (Run <= fCodeEndPos) do + Inc(Run); + end; +end; + +procedure TSynCobolSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynCobolSyn.Next; +begin + fTokenPos := Run; + + if fTokenPos < fCodeStartPos then + FirstCharsProc + else + case fIndicator of + '*', '/': CommentProc; + 'D': DebugProc; + else + if fTokenPos > fCodeEndPos then + LastCharsProc + else + case fRange of + rsQuoteString..rsApostStringMayBe: StringEndProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; + end; +end; + +function TSynCobolSyn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_STRING : Result := fStringAttri; + SYN_ATTR_WHITESPACE : Result := fSpaceAttri; + else + Result := nil; + end; +end; + +function TSynCobolSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynCobolSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynCobolSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynCobolSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynCobolSyn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkAIdentifier: Result := fAIdentifierAttri; + tkPreprocessor: Result := fPreprocessorAttri; + tkKey: Result := fKeyAttri; + tkBoolean: Result := fBooleanAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSequence: Result := fSequenceAttri; + tkIndicator: Result := fIndicatorAttri; + tkTagArea: Result := fTagAreaAttri; + tkDebugLines: Result := fDebugLinesAttri; + tkUnknown: Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynCobolSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynCobolSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynCobolSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['-', '0'..'9', 'A'..'Z', 'a'..'z']; +end; + +function TSynCobolSyn.GetSampleSource: string; +begin + Result := '000100* This is a sample file to be used to show all TSynCobolSyn''s'#13#10 + + '000200* features.'#13#10 + + '000300* This isn''t a valid COBOL program.'#13#10 + + '000400'#13#10 + + '000500* 1. Supported COBOL features.'#13#10 + + '000600'#13#10 + + '000700* 1.1 Sequence area.'#13#10 + + '000800* First six columns in COBOL are reserved for enumeration'#13#10 + + '000900* of source lines.'#13#10 + + '001000* 1.2 Indicator area.'#13#10 + + '001100* 7th column in COBOL is reserved for special markers like ''*'''#13#10 + + '001200* or ''D''.'#13#10 + + '001300* 1.3 Comment lines.'#13#10 + + '001400* Any line started from ''*'' in 7th column is a comment.'#13#10 + + '001500* No separate word highlighting will be done by the editor.'#13#10 + + '001600* 1.4 Debug lines.'#13#10 + + '001700D Any line started from ''D'' will be treated as containing debug'#13#10 + + '001800D commands. No separate word highlighting will be done'#13#10 + + '001900D by the editor.'#13#10 + + '002000* 1.5 Tag area.'#13#10 + + '002100* Only columns from 8th till 72th can be used for COBOL TAG_AREA'#13#10 + + '002200* program. Columns beyond the 72th one may be used by some TAG_AREA'#13#10 + + '002300* COBOL compilers to tag the code in some internal way. TAG_AREA'#13#10 + + '002400* 1.6 Area A identifiers.'#13#10 + + '002500* In area A (from 8th column till'#13#10 + + '002600* 11th one) you should type only sections''/paragraphs'' names.'#13#10 + + '002700* For example "SOME" is a section name:'#13#10 + + '002800 SOME SECTION.'#13#10 + + '002900* 1.7 Preprocessor directives.'#13#10 + + '003000* For example "COPY" is a preprocessor directive:'#13#10 + + '003100 COPY "PRD-DATA.SEL".'#13#10 + + '003200* 1.8 Key words.'#13#10 + + '003300* For example "ACCEPT" and "AT" are COBOL key words:'#13#10 + + '003400 ACCEPT WS-ENTRY AT 2030.'#13#10 + + '003500* 1.9 Boolean constants.'#13#10 + + '003600* These are "TRUE" and "FALSE" constants. For example:'#13#10 + + '003700 EVALUATE TRUE.'#13#10 + + '003800* 1.10 Numbers.'#13#10 + + '003900* Here are the examples of numbers:'#13#10 + + '004000 01 WSV-TEST-REC.'#13#10 + + '004100 03 WSV-INT-T PIC 9(5) VALUE 12345.'#13#10 + + '004200 03 WSV-PRICES PIC 9(4)V99 COMP-3 VALUE 0000.33. '#13#10 + + '004300 03 WSV-Z-PRICES PIC Z(5)9.99- VALUE -2.12. '#13#10 + + '004400 03 WSV-STORE-DATE PIC 9(4)V99E99 VALUE 0001.33E02.'#13#10 + + '004500* 1.11 Strings.'#13#10 + + '004600* The following types of strings are supported:'#13#10 + + '004700* 1.11.1 Quoted strings.'#13#10 + + '004800 MOVE "The name of field is ""PRODUCT""" TO WS-ERR-MESS.'#13#10 + + '004900 MOVE ''The name of field is ''''PRODUCT'''''' TO WS-ERR-MESS.'#13#10 + + '005000* 1.11.2 Pseudo-text.'#13#10 + + '005100 COPY'#13#10 + + '005200 REPLACING ==+00001== BY +2'#13#10 + + '005300 == 1 == BY -3.'#13#10 + + '005400* 1.11.3 Figurative constants.'#13#10 + + '005500* For example "SPACES" is figurative constant:'#13#10 + + '005600 DISPLAY SPACES UPON CRT.'#13#10 + + '005700* 1.12 Continued lines.'#13#10 + + '005800* Only continued strings are supported. For example:'#13#10 + + '005900 MOVE "The name of figurative constant field is'#13#10 + + '006000-"SPACES" TO WS-ERR-MESS.'#13#10 + + '006100* Or (a single quotation mark in 72th column):'#13#10 + + '005900 MOVE "The name of figurative constant field is ""SPACES"'#13#10 + + '006000-""" TO WS-ERR-MESS.'#13#10 + + '006100'#13#10 + + '006200* 2. Unsupported COBOL features.'#13#10 + + '006300'#13#10 + + '006400* 2.1 Continued lines.'#13#10 + + '006500* Continuation of key words is not supported. For example,'#13#10 + + '006600* the following COBOL code is valid but TSynCobolSyn won''t'#13#10 + + '006700* highlight "VALUE" keyword properly:'#13#10 + + '006800 03 WSV-STORE-DATE PIC 9(4)V99E99 VAL'#13#10 + + '006900-UE 0001.33E02.'#13#10 + + '007000* 2.2 Identifiers started from digits.'#13#10 + + '007100* They are valid in COBOL but won''t be highlighted properly'#13#10 + + '007200* by TSynCobolSyn. For example, "000-main" is a paragraph'#13#10 + + '007300* name and should be highlighted as Area A identifier:'#13#10 + + '007400 000-main.'#13#10 + + '007500* 2.3 Comment entries in optional paragraphs'#13#10 + + '007600* The so called comment-entries in the optional paragraphs'#13#10 + + '007700* of the Identification Division are not supported and won''t'#13#10 + + '007800* be highlighted properly.'; +end; + +function TSynCobolSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterCOBOL; +end; + +procedure TSynCobolSyn.SetCodeStartPos(Value: LongInt); +begin + if Value < fCodeMediumPos then + fCodeStartPos := Value + else + fCodeStartPos := fCodeMediumPos; +end; + +procedure TSynCobolSyn.SetCodeMediumPos(Value: LongInt); +begin + if (fCodeStartPos <= Value) and (Value <= fCodeEndPos) then + fCodeMediumPos := Value + else + if Value > fCodeEndPos + then fCodeMediumPos := fCodeEndPos + else fCodeMediumPos := fCodeStartPos; +end; + +procedure TSynCobolSyn.SetCodeEndPos(Value: LongInt); +begin + if Value > fCodeMediumPos then + fCodeEndPos := Value + else + fCodeEndPos := fCodeMediumPos; +end; + +class function TSynCobolSyn.GetLanguageName: string; +begin + Result := SYNS_LangCOBOL; +end; + +procedure TSynCobolSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynCobolSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynCobolSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynCobolSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightercs.pas b/components/extrasyn/SyneditHighlighters/synhighlightercs.pas new file mode 100644 index 000000000..69251f860 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightercs.pas @@ -0,0 +1,1588 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterCS.pas, released 2001-10-28. +The Original Code is based on SynHighlighterCpp.pas, released 2000-04-10, +which in turn is based on the dcjCppSyn.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: SynHighlighterCS.pas,v 1.9 2005/01/28 16:53:21 maelh Exp $ + +You may retrieve the latest version of SynEdit from the SynEdit home page, +located at http://SynEdit.SourceForge.net + +You may retrieve the latest version of this file from +http://www.ashleybrown.co.uk/synedit/ + +Known Issues: + - strings on multiple lines are not supported +-------------------------------------------------------------------------------} +{ +@abstract(Provides a C# syntax highlighter for SynEdit) +@author(Ashley Brown) +@created(2001) +@lastmod(2001-10-20) +The SynHighlighterCS unit provides SynEdit with a C# syntax highlighter. +Based on SynHighlighterCpp.pas +} +unit SynHighlighterCS; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkAsm, tkComment, tkDirective, tkIdentifier, tkKey, tkNull, + tkNumber, tkSpace, tkString, tkSymbol, tkUnknown); + + TxtkTokenKind = ( + xtkAdd, xtkAddAssign, xtkAnd, xtkAndAssign, xtkArrow, xtkAssign, + xtkBitComplement, xtkBraceClose, xtkBraceOpen, xtkColon, xtkComma, + xtkDecrement, xtkDivide, xtkDivideAssign, xtkEllipse, xtkGreaterThan, + xtkGreaterThanEqual, xtkIncOr, xtkIncOrAssign, xtkIncrement, xtkLessThan, + xtkLessThanEqual, xtkLogAnd, xtkLogComplement, xtkLogEqual, xtkLogOr, + xtkMod, xtkModAssign, xtkMultiplyAssign, xtkNotEqual, xtkPoint, xtkQuestion, + xtkRoundClose, xtkRoundOpen, xtkScopeResolution, xtkSemiColon, xtkShiftLeft, + xtkShiftLeftAssign, xtkShiftRight, xtkShiftRightAssign, xtkSquareClose, + xtkSquareOpen, xtkStar, xtkSubtract, xtkSubtractAssign, xtkXor, + xtkXorAssign); + + TRangeState = (rsUnknown, rsAnsiC, rsAnsiCAsm, rsAnsiCAsmBlock, rsAsm, + rsAsmBlock, rsDirective, rsDirectiveComment, rsString34, rsString39, + rsMultiLineString); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TSynCSSyn = class(TSynCustomHighlighter) + private + fAsmStart: Boolean; + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + FExtTokenID: TxtkTokenKind; + fLineNumber: Integer; + fIdentFuncTable: array[0..206] of TIdentFuncTableFunc; + fAsmAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fDirecAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fInvalidAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func17: TtkTokenKind; + function Func21: TtkTokenKind; + function Func22: TtkTokenKind; + function Func25: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func34: TtkTokenKind; + function Func40: TtkTokenKind; + function Func42: TtkTokenKind; + function Func45: TtkTokenKind; + function Func46: TtkTokenKind; + function Func48: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func78: TtkTokenKind; + function Func83: TtkTokenKind; + function Func86: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func98: TtkTokenKind; + function Func99: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func104: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func109: TtkTokenKind; + function Func110: TtkTokenKind; + function Func115: TtkTokenKind; + function Func116: TtkTokenKind; + + procedure AnsiCProc; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure AtSymbolProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure CRProc; + procedure ColonProc; + procedure CommaProc; + procedure DirectiveProc; + procedure EqualProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NotSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure QuestionProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure StarProc; + procedure StringProc; + procedure TildeProc; + procedure XOrSymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure StringEndProc; + protected + function GetIdentChars: TSynIdentChars; override; + function GetExtTokenID: TxtkTokenKind; + function IsFilterStored: boolean; override; + function GetSampleSource: string; override; + public + class function GetCapabilities: TSynHighlighterCapabilities; override; + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + property ExtTokenID: TxtkTokenKind read GetExtTokenID; + published + property AsmAttri: TSynHighlighterAttributes read fAsmAttri write fAsmAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property DirecAttri: TSynHighlighterAttributes read fDirecAttri + write fDirecAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property InvalidAttri: TSynHighlighterAttributes read fInvalidAttri + write fInvalidAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + Case I in['_', 'a'..'z', 'A'..'Z'] of + True: + begin + if (I > #64) and (I < #91) then mHashTable[I] := Ord(I) - 64 else + if (I > #96) then mHashTable[I] := Ord(I) - 95; + end; + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynCSSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[34] := @Func34; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[46] := @Func46; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[61] := @Func61; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[90] := @Func90; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[104] := @Func104; + fIdentFuncTable[106] := @Func106; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[109] := @Func109; + fIdentFuncTable[110] := @Func110; + fIdentFuncTable[115] := @Func115; + fIdentFuncTable[116] := @Func116; +end; + +function TSynCSSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; { KeyHash } + +function TSynCSSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; { KeyComp } + +function TSynCSSyn.Func17: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func21: TtkTokenKind; +begin + if KeyComp('do') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func22: TtkTokenKind; +begin + if KeyComp('as') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func25: TtkTokenKind; +begin + if KeyComp('in') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func30: TtkTokenKind; +begin + if KeyComp('is') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynCSSyn.Func32: TtkTokenKind; +begin + if KeyComp('ref') then Result := tkKey else + if KeyComp('case') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func31: TtkTokenKind; +begin + if KeyComp('base') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func34: TtkTokenKind; +begin + if KeyComp('char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func40: TtkTokenKind; +begin + if KeyComp('catch') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func42: TtkTokenKind; +begin + if KeyComp('for') then Result := tkKey else + if KeyComp('break') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func45: TtkTokenKind; +begin + if KeyComp('lock') then Result := tkKey else + if KeyComp('else') then Result := tkKey else + if KeyComp('new') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func46: TtkTokenKind; +begin + if KeyComp('int') then Result := tkKey + else if KeyComp('checked') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func48: TtkTokenKind; +begin + if KeyComp('false') then Result := tkKey else + if KeyComp('bool') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func52: TtkTokenKind; +begin + if KeyComp('sealed') then Result := tkKey else + if KeyComp('long') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func53: TtkTokenKind; +begin + if KeyComp('fixed') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func54: TtkTokenKind; +begin + if KeyComp('decimal') then Result := tkKey else + if KeyComp('void') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func56: TtkTokenKind; +begin + if KeyComp('byte') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynCSSyn.Func57: TtkTokenKind; +begin + if KeyComp('enum') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func59: TtkTokenKind; +begin + if KeyComp('out') then Result := tkKey else + if KeyComp('class') then Result := tkKey else + if KeyComp('float') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func60: TtkTokenKind; +begin + if KeyComp('this') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func61: TtkTokenKind; +begin + if KeyComp('object') then Result := tkKey else + if KeyComp('goto') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func62: TtkTokenKind; +begin + + if KeyComp('while') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func63: TtkTokenKind; +begin + if KeyComp('foreach') then Result := tkKey else + if KeyComp('null') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func65: TtkTokenKind; +begin + if KeyComp('double') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func66: TtkTokenKind; +begin + if KeyComp('try') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func67: TtkTokenKind; +begin + if KeyComp('delegate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func68: TtkTokenKind; +begin + if KeyComp('uint') then Result := tkKey else + if KeyComp('true') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func69: TtkTokenKind; +begin + + if KeyComp('public') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func71: TtkTokenKind; +begin + if KeyComp('event') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func72: TtkTokenKind; +begin + if KeyComp('unsafe') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func74: TtkTokenKind; +begin + if KeyComp('ulong') then Result := tkKey else + if KeyComp('params') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func75: TtkTokenKind; +begin + if KeyComp('using') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func76: TtkTokenKind; +begin + if KeyComp('sbyte') then Result := tkKey else + if KeyComp('const') then Result := tkKey else + if KeyComp('default') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func78: TtkTokenKind; +begin + if KeyComp('static') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func83: TtkTokenKind; +begin + if KeyComp('unchecked') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func86: TtkTokenKind; +begin + if KeyComp('sizeof') then Result := tkKey else + if KeyComp('finally') then Result := tkKey else + if KeyComp('namespace') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func88: TtkTokenKind; +begin + + if KeyComp('switch') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func89: TtkTokenKind; +begin + if KeyComp('throw') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func90: TtkTokenKind; +begin + if KeyComp('interface') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynCSSyn.Func92: TtkTokenKind; +begin + if KeyComp('abstract') then Result := tkKey else + if KeyComp('extern') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func93: TtkTokenKind; +begin + if KeyComp('typeof') then Result := tkKey else + if KeyComp('string') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func98: TtkTokenKind; +begin + if KeyComp('private') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynCSSyn.Func99: TtkTokenKind; +begin + if KeyComp('implicit') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynCSSyn.Func101: TtkTokenKind; +begin + if KeyComp('internal') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func102: TtkTokenKind; +begin + if KeyComp('readonly') then Result := tkKey else + if KeyComp('return') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func104: TtkTokenKind; +begin + if KeyComp('override') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynCSSyn.Func106: TtkTokenKind; +begin + if KeyComp('explicit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func107: TtkTokenKind; +begin + if KeyComp('ushort') then Result := tkKey else + if KeyComp('stackalloc') then Result := tkKey else + if KeyComp('struct') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func109: TtkTokenKind; +begin + + if KeyComp('continue') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func110: TtkTokenKind; +begin + if KeyComp('virtual') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func115: TtkTokenKind; +begin + if KeyComp('protected') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynCSSyn.Func116: TtkTokenKind; +begin + if KeyComp('operator') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynCSSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynCSSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 207 then Result := fIdentFuncTable[HashKey]() else Result := tkIdentifier; +end; + +procedure TSynCSSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := @AndSymbolProc; + #39: fProcTable[I] := @AsciiCharProc; + '@': fProcTable[I] := @AtSymbolProc; + '}': fProcTable[I] := @BraceCloseProc; + '{': fProcTable[I] := @BraceOpenProc; + #13: fProcTable[I] := @CRProc; + ':': fProcTable[I] := @ColonProc; + ',': fProcTable[I] := @CommaProc; + '#': fProcTable[I] := @DirectiveProc; + '=': fProcTable[I] := @EqualProc; + '>': fProcTable[I] := @GreaterProc; + '?': fProcTable[I] := @QuestionProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @LowerProc; + '-': fProcTable[I] := @MinusProc; + '%': fProcTable[I] := @ModSymbolProc; + '!': fProcTable[I] := @NotSymbolProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + '|': fProcTable[I] := @OrSymbolProc; + '+': fProcTable[I] := @PlusProc; + '.': fProcTable[I] := @PointProc; + ')': fProcTable[I] := @RoundCloseProc; + '(': fProcTable[I] := @RoundOpenProc; + ';': fProcTable[I] := @SemiColonProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + ']': fProcTable[I] := @SquareCloseProc; + '[': fProcTable[I] := @SquareOpenProc; + '*': fProcTable[I] := @StarProc; + #34: fProcTable[I] := @StringProc; + '~': fProcTable[I] := @TildeProc; + '^': fProcTable[I] := @XOrSymbolProc; + else fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynCSSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fAsmAttri := TSynHighlighterAttributes.Create(SYNS_AttrAssembler); + AddAttribute(fAsmAttri); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style:= [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fInvalidAttri := TSynHighlighterAttributes.Create(SYNS_AttrIllegalChar); + AddAttribute(fInvalidAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + fSpaceAttri.Foreground := clWindow; + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fDirecAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor); + AddAttribute(fDirecAttri); + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + fAsmStart := False; + fDefaultFilter := SYNS_FilterCS; +end; { Create } + +procedure TSynCSSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynCSSyn.AnsiCProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + #13: + begin + CRProc; + exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + inc(Run, 2); + if fRange = rsAnsiCAsm then + fRange := rsAsm + else if fRange = rsAnsiCAsmBlock then + fRange := rsAsmBlock + else if fRange = rsDirectiveComment then + fRange := rsDirective + else + fRange := rsUnKnown; + break; + end else + inc(Run); + #10: break; + #13: break; + else inc(Run); + end; +end; + +procedure TSynCSSyn.AndSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {and assign} + begin + inc(Run, 2); + FExtTokenID := xtkAndAssign; + end; + '&': {logical and} + begin + inc(Run, 2); + FExtTokenID := xtkLogAnd; + end; + else {and} + begin + inc(Run); + FExtTokenID := xtkAnd; + end; + end; +end; + +procedure TSynCSSyn.AsciiCharProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then begin + if fLine[Run + 1] in [#39, '\'] then + inc(Run); + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, #39]; + if fLine[Run] = #39 then + inc(Run); +end; + +procedure TSynCSSyn.AtSymbolProc; +begin + fTokenID := tkUnknown; + inc(Run); +end; + +procedure TSynCSSyn.BraceCloseProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceClose; + if fRange = rsAsmBlock then fRange := rsUnknown; +end; + +procedure TSynCSSyn.BraceOpenProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceOpen; + if fRange = rsAsm then + begin + fRange := rsAsmBlock; + fAsmStart := True; + end; +end; + +procedure TSynCSSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run + 1] = #10 then Inc(Run); +end; + +procedure TSynCSSyn.ColonProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + ':': {scope resolution operator} + begin + inc(Run, 2); + FExtTokenID := xtkScopeResolution; + end; + else {colon} + begin + inc(Run); + FExtTokenID := xtkColon; + end; + end; +end; + +procedure TSynCSSyn.CommaProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkComma; +end; + +procedure TSynCSSyn.DirectiveProc; +begin + if fLine[Run] in [#0, #10, #13] then begin + if (Run <= 0) or (fLine[Run - 1] <> '\') then + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end else begin + fTokenID := tkDirective; + while TRUE do + case fLine[Run] of + '/': // comment? + begin + if fLine[Run + 1] = '/' then begin // is end of directive as well + fRange := rsUnknown; + break; + end else if fLine[Run + 1] = '*' then begin // might be embedded only + fRange := rsDirectiveComment; + break; + end else + Inc(Run); + end; + '\': // directive continued on next line? + begin + Inc(Run); + if fLine[Run] in [#0, #10, #13] then begin + fRange := rsDirective; + break; + end; + end; + #0, #10, #13: + begin + fRange := rsUnknown; + break; + end; + else Inc(Run); + end; + end; +end; + +procedure TSynCSSyn.EqualProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {logical equal} + begin + inc(Run, 2); + FExtTokenID := xtkLogEqual; + end; + else {assign} + begin + inc(Run); + FExtTokenID := xtkAssign; + end; + end; +end; + +procedure TSynCSSyn.GreaterProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {greater than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkGreaterThanEqual; + end; + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftRightAssign; + end + else {shift right} + begin + inc(Run, 2); + FExtTokenID := xtkShiftRight; + end; + end; + else {greater than} + begin + inc(Run); + FExtTokenID := xtkGreaterThan; + end; + end; +end; + +procedure TSynCSSyn.QuestionProc; +begin + fTokenID := tkSymbol; {conditional} + FExtTokenID := xtkQuestion; + inc(Run); +end; + +procedure TSynCSSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynCSSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynCSSyn.LowerProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {less than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkLessThanEqual; + end; + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftLeftAssign; + end + else {shift left} + begin + inc(Run, 2); + FExtTokenID := xtkShiftLeft; + end; + end; + else {less than} + begin + inc(Run); + FExtTokenID := xtkLessThan; + end; + end; +end; + +procedure TSynCSSyn.MinusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {subtract assign} + begin + inc(Run, 2); + FExtTokenID := xtkSubtractAssign; + end; + '-': {decrement} + begin + inc(Run, 2); + FExtTokenID := xtkDecrement; + end; + '>': {arrow} + begin + inc(Run, 2); + FExtTokenID := xtkArrow; + end; + else {subtract} + begin + inc(Run); + FExtTokenID := xtkSubtract; + end; + end; +end; + +procedure TSynCSSyn.ModSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {mod assign} + begin + inc(Run, 2); + FExtTokenID := xtkModAssign; + end; + else {mod} + begin + inc(Run); + FExtTokenID := xtkMod; + end; + end; +end; + +procedure TSynCSSyn.NotSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {not equal} + begin + inc(Run, 2); + FExtTokenID := xtkNotEqual; + end; + else {not} + begin + inc(Run); + FExtTokenID := xtkLogComplement; + end; + end; +end; + +procedure TSynCSSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynCSSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', 'A'..'F', 'a'..'f', '.', 'u', 'U', 'l', 'L', 'x', 'X'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynCSSyn.OrSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {or assign} + begin + inc(Run, 2); + FExtTokenID := xtkIncOrAssign; + end; + '|': {logical or} + begin + inc(Run, 2); + FExtTokenID := xtkLogOr; + end; + else {or} + begin + inc(Run); + FExtTokenID := xtkIncOr; + end; + end; +end; + +procedure TSynCSSyn.PlusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {add assign} + begin + inc(Run, 2); + FExtTokenID := xtkAddAssign; + end; + '+': {increment} + begin + inc(Run, 2); + FExtTokenID := xtkIncrement; + end; + else {add} + begin + inc(Run); + FExtTokenID := xtkAdd; + end; + end; +end; + +procedure TSynCSSyn.PointProc; +begin + fTokenID := tkSymbol; + if (FLine[Run + 1] = '.') and (FLine[Run + 2] = '.') then + begin {ellipse} + inc(Run, 3); + FExtTokenID := xtkEllipse; + end + else {point} + begin + inc(Run); + FExtTokenID := xtkPoint; + end; +end; + +procedure TSynCSSyn.RoundCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkRoundClose; +end; + +procedure TSynCSSyn.RoundOpenProc; +begin + inc(Run); + FTokenID := tkSymbol; + FExtTokenID := xtkRoundOpen; +end; + +procedure TSynCSSyn.SemiColonProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSemiColon; + if fRange = rsAsm then fRange := rsUnknown; +end; + +procedure TSynCSSyn.SlashProc; +begin + case FLine[Run + 1] of + '/': {c++ style comments} + begin + fTokenID := tkComment; + inc(Run, 2); + while not (fLine[Run] in [#0, #10, #13]) do Inc(Run); + end; + '*': {c style comments} + begin + fTokenID := tkComment; + if fRange = rsAsm then + fRange := rsAnsiCAsm + else if fRange = rsAsmBlock then + fRange := rsAnsiCAsmBlock + else if fRange <> rsDirectiveComment then + fRange := rsAnsiC; + inc(Run, 2); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + inc(Run, 2); + if fRange = rsDirectiveComment then + fRange := rsDirective + else if fRange = rsAnsiCAsm then + fRange := rsAsm + else + begin + if fRange = rsAnsiCAsmBlock then + fRange := rsAsmBlock + else + fRange := rsUnKnown; + end; + break; + end else inc(Run); + #10, #13: + begin + if fRange = rsDirectiveComment then + fRange := rsAnsiC; + break; + end; + else inc(Run); + end; + end; + '=': {divide assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + FExtTokenID := xtkDivideAssign; + end; + else {divide} + begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkDivide; + end; + end; +end; + +procedure TSynCSSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynCSSyn.SquareCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareClose; +end; + +procedure TSynCSSyn.SquareOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareOpen; +end; + +procedure TSynCSSyn.StarProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {multiply assign} + begin + inc(Run, 2); + FExtTokenID := xtkMultiplyAssign; + end; + else {star} + begin + inc(Run); + FExtTokenID := xtkStar; + end; + end; +end; + +procedure TSynCSSyn.StringProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then begin + case fLine[Run + 1] of + #34, '\': + Inc(Run); + #00: + begin + Inc(Run); + fRange := rsMultilineString; + Exit; + end; + end; + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, #34]; + if FLine[Run] = #34 then + inc(Run); +end; + +procedure TSynCSSyn.StringEndProc; +begin + fTokenID := tkString; + + case FLine[Run] of + #0: + begin + NullProc; + Exit; + end; + #10: + begin + LFProc; + Exit; + end; + #13: + begin + CRProc; + Exit; + end; + end; + + fRange := rsUnknown; + + repeat + case FLine[Run] of + #0, #10, #13: Break; + '\': + begin + case fLine[Run + 1] of + #34, '\': + Inc(Run); + #00: + begin + Inc(Run); + fRange := rsMultilineString; + Exit; + end; + end; + end; + #34: Break; + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, #34]; + if FLine[Run] = #34 then + inc(Run); +end; + +procedure TSynCSSyn.TildeProc; +begin + inc(Run); {bitwise complement} + fTokenId := tkSymbol; + FExtTokenID := xtkBitComplement; +end; + +procedure TSynCSSyn.XOrSymbolProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {xor assign} + begin + inc(Run, 2); + FExtTokenID := xtkXorAssign; + end; + else {xor} + begin + inc(Run); + FExtTokenID := xtkXor; + end; + end; +end; + +procedure TSynCSSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynCSSyn.Next; +begin + fAsmStart := False; + fTokenPos := Run; + case fRange of + rsAnsiC, rsAnsiCAsm, + rsAnsiCAsmBlock, rsDirectiveComment: AnsiCProc; + rsDirective: DirectiveProc; + rsMultilineString: StringEndProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynCSSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + else Result := nil; + end; +end; + +function TSynCSSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynCSSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynCSSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynCSSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynCSSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; + if ((fRange = rsAsm) or (fRange = rsAsmBlock)) and not fAsmStart + and not (fTokenId in [tkComment, tkSpace, tkNull]) + then + Result := tkAsm; +end; + +function TSynCSSyn.GetExtTokenID: TxtkTokenKind; +begin + Result := FExtTokenID; +end; + +function TSynCSSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkAsm: Result := fAsmAttri; + tkComment: Result := fCommentAttri; + tkDirective: Result := fDirecAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fInvalidAttri; + else Result := nil; + end; +end; + +function TSynCSSyn.GetTokenKind: integer; +begin + Result := Ord(GetTokenID); +end; + +function TSynCSSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynCSSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +procedure TSynCSSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynCSSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; +end; + +function TSynCSSyn.GetSampleSource: string; +begin + Result := '// Hello3.cs'+LineEnding+ + '// arguments: A B C D'+LineEnding+ + 'using System;'+LineEnding+ + ''+LineEnding+ + 'public class Hello3'+LineEnding+ + '{'+LineEnding+ + ' public static void Main(string[] args)'+LineEnding+ + ' {'+LineEnding+ + ' Console.WriteLine("Hello, World!");'+LineEnding+ + ' Console.WriteLine("You entered the following {0} command line arguments:",'+LineEnding+ + ' args.Length );'+LineEnding+ + ' for (int i=0; i < args.Length; i++)'+LineEnding+ + ' {'+LineEnding+ + ' Console.WriteLine("{0}", args[i]);'+LineEnding+ + ' }'+LineEnding+ + ' }'+LineEnding+ + '}'+LineEnding+ + ''+LineEnding+ + '//Catching an exception'+LineEnding+ + 'int top = 0, bottom = 0, result = 0;'+LineEnding+ + 'try'+LineEnding+ + '{'+LineEnding+ + ' result = top / bottom;'+LineEnding+ + '}'+LineEnding+ + 'catch (System.DivideByZeroException ex)'+LineEnding+ + '{'+LineEnding+ + ' Console.WriteLine("{0} Exception caught.", ex);'+LineEnding+ + '}'+LineEnding+ + ''+LineEnding+ + '//DECLARE A PROPERTY'+LineEnding+ + 'private string name;'+LineEnding+ + '// A read-write instance property:'+LineEnding+ + 'public string NameProperty'+LineEnding+ + '{'+LineEnding+ + ' get'+LineEnding+ + ' {'+LineEnding+ + ' return name;'+LineEnding+ + ' }'+LineEnding+ + ' set'+LineEnding+ + ' {'+LineEnding+ + ' name = value;'+LineEnding+ + ' }'+LineEnding+ + '}'+LineEnding + + ; +end; { GetSampleSource } + +class function TSynCSSyn.GetLanguageName: string; +begin + Result := SYNS_LangCS; +end; + +function TSynCSSyn.IsFilterStored: boolean; +begin + Result := fDefaultFilter <> SYNS_FilterCS; +end; + +class function TSynCSSyn.GetCapabilities: TSynHighlighterCapabilities; +begin + Result := inherited GetCapabilities + [hcUserSettings]; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynCSSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterdml.pas b/components/extrasyn/SyneditHighlighters/synhighlighterdml.pas new file mode 100644 index 000000000..6d47a806c --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterdml.pas @@ -0,0 +1,1859 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterDml.pas, released 2000-04-17. +The Original Code is based on the mwDmlSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Peter Adam. +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: SynHighlighterDml.pas,v 1.12 2005/01/28 16:53:22 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +Known Issues: + - There are no metadata qualifiers. +-------------------------------------------------------------------------------} +{ +@abstract(Provides a Dml highlighter for SynEdit) +@author(Peter Adam) +@created(1999) +@lastmod(2000-06-23) +The SynHighlighterDml unit provides SynEdit with a Dml highlighter. +} +unit SynHighlighterDml; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkBlock, tkComment, tkForm, tkFunction, tkIdentifier, tkKey, + tkNull, tkNumber, tkQualifier, tkSpace, tkSpecial, tkString, tkSymbol, + tkUnknown, tkVariable); + + TRangeState = (rsANil, rsAdd, rsFind, rsUnKnown); + + TProcTableProc = procedure of object; + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TSynDmlSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + Temp: PChar; + fStringLen: Integer; + fToIdent: PChar; + fIdentFuncTable: array[0..327] of TIdentFuncTableFunc; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fFormAttri: TSynHighlighterAttributes; + fBlockAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fQualiAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fFunctionAttri: TSynHighlighterAttributes; + fVariableAttri: TSynHighlighterAttributes; + fSpecialAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func9: TtkTokenKind; + function Func15: TtkTokenKind; + function Func17: TtkTokenKind; + function Func19: TtkTokenKind; + function Func22: TtkTokenKind; + function Func23: TtkTokenKind; + function Func24: TtkTokenKind; + function Func26: TtkTokenKind; + function Func27: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func34: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func45: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func60: TtkTokenKind; + function Func62: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func89: TtkTokenKind; + function Func91: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func94: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func98: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func103: TtkTokenKind; + function Func104: TtkTokenKind; + function Func106: TtkTokenKind; + function Func108: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func113: TtkTokenKind; + function Func116: TtkTokenKind; + function Func117: TtkTokenKind; + function Func120: TtkTokenKind; + function Func121: TtkTokenKind; + function Func122: TtkTokenKind; + function Func123: TtkTokenKind; + function Func124: TtkTokenKind; + function Func125: TtkTokenKind; + function Func126: TtkTokenKind; + function Func127: TtkTokenKind; + function Func128: TtkTokenKind; + function Func129: TtkTokenKind; + function Func131: TtkTokenKind; + function Func132: TtkTokenKind; + function Func134: TtkTokenKind; + function Func135: TtkTokenKind; + function Func136: TtkTokenKind; + function Func137: TtkTokenKind; + function Func138: TtkTokenKind; + function Func139: TtkTokenKind; + function Func140: TtkTokenKind; + function Func141: TtkTokenKind; + function Func142: TtkTokenKind; + function Func144: TtkTokenKind; + function Func146: TtkTokenKind; + function Func148: TtkTokenKind; + function Func150: TtkTokenKind; + function Func152: TtkTokenKind; + function Func153: TtkTokenKind; + function Func154: TtkTokenKind; + function Func155: TtkTokenKind; + function Func156: TtkTokenKind; + function Func157: TtkTokenKind; + function Func163: TtkTokenKind; + function Func164: TtkTokenKind; + function Func166: TtkTokenKind; + function Func169: TtkTokenKind; + function Func173: TtkTokenKind; + function Func174: TtkTokenKind; + function Func175: TtkTokenKind; + function Func176: TtkTokenKind; + function Func178: TtkTokenKind; + function Func179: TtkTokenKind; + function Func182: TtkTokenKind; + function Func183: TtkTokenKind; + function Func184: TtkTokenKind; + function Func185: TtkTokenKind; + function Func187: TtkTokenKind; + function Func188: TtkTokenKind; + function Func203: TtkTokenKind; + function Func206: TtkTokenKind; + function Func216: TtkTokenKind; + function Func219: TtkTokenKind; + function Func221: TtkTokenKind; + function Func232: TtkTokenKind; + function Func234: TtkTokenKind; + function Func235: TtkTokenKind; + function Func243: TtkTokenKind; + function Func244: TtkTokenKind; + function Func255: TtkTokenKind; + function Func313: TtkTokenKind; + function Func327: TtkTokenKind; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure SymbolProc; + procedure AddressOpProc; + procedure AsciiCharProc; + procedure CRProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure NullProc; + procedure NumberProc; + procedure PointProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + procedure RemProc; + function IsQuali: boolean; + function IsSpecial: Boolean; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + published + property BlockAttri: TSynHighlighterAttributes read fBlockAttri + write fBlockAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property FormAttri: TSynHighlighterAttributes read fFormAttri + write fFormAttri; + property FunctionAttri: TSynHighlighterAttributes read fFunctionAttri + write fFunctionAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property QualiAttri: TSynHighlighterAttributes read fQualiAttri + write fQualiAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property SpecialAttri: TSynHighlighterAttributes read fSpecialAttri + write fSpecialAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property VariableAttri: TSynHighlighterAttributes read fVariableAttri + write fVariableAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I of + 'a'..'z', 'A'..'Z', '_': mHashTable[I] := Ord(J) - 64; + else mHashTable[Char(I)] := 0; + end; + end; +end; + +procedure TSynDmlSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[9] := @Func9; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[24] := @Func24; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[27] := @Func27; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[34] := @Func34; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[91] := @Func91; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[94] := @Func94; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[100] := @Func100; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[103] := @Func103; + fIdentFuncTable[104] := @Func104; + fIdentFuncTable[106] := @Func106; + fIdentFuncTable[108] := @Func108; + fIdentFuncTable[110] := @Func110; + fIdentFuncTable[111] := @Func111; + fIdentFuncTable[113] := @Func113; + fIdentFuncTable[116] := @Func116; + fIdentFuncTable[117] := @Func117; + fIdentFuncTable[120] := @Func120; + fIdentFuncTable[121] := @Func121; + fIdentFuncTable[122] := @Func122; + fIdentFuncTable[123] := @Func123; + fIdentFuncTable[124] := @Func124; + fIdentFuncTable[125] := @Func125; + fIdentFuncTable[126] := @Func126; + fIdentFuncTable[127] := @Func127; + fIdentFuncTable[128] := @Func128; + fIdentFuncTable[129] := @Func129; + fIdentFuncTable[131] := @Func131; + fIdentFuncTable[132] := @Func132; + fIdentFuncTable[134] := @Func134; + fIdentFuncTable[135] := @Func135; + fIdentFuncTable[136] := @Func136; + fIdentFuncTable[137] := @Func137; + fIdentFuncTable[138] := @Func138; + fIdentFuncTable[139] := @Func139; + fIdentFuncTable[140] := @Func140; + fIdentFuncTable[141] := @Func141; + fIdentFuncTable[142] := @Func142; + fIdentFuncTable[144] := @Func144; + fIdentFuncTable[146] := @Func146; + fIdentFuncTable[148] := @Func148; + fIdentFuncTable[150] := @Func150; + fIdentFuncTable[152] := @Func152; + fIdentFuncTable[153] := @Func153; + fIdentFuncTable[154] := @Func154; + fIdentFuncTable[155] := @Func155; + fIdentFuncTable[156] := @Func156; + fIdentFuncTable[157] := @Func157; + fIdentFuncTable[163] := @Func163; + fIdentFuncTable[164] := @Func164; + fIdentFuncTable[166] := @Func166; + fIdentFuncTable[169] := @Func169; + fIdentFuncTable[173] := @Func173; + fIdentFuncTable[174] := @Func174; + fIdentFuncTable[175] := @Func175; + fIdentFuncTable[176] := @Func176; + fIdentFuncTable[178] := @Func178; + fIdentFuncTable[179] := @Func179; + fIdentFuncTable[182] := @Func182; + fIdentFuncTable[183] := @Func183; + fIdentFuncTable[184] := @Func184; + fIdentFuncTable[185] := @Func185; + fIdentFuncTable[187] := @Func187; + fIdentFuncTable[188] := @Func188; + fIdentFuncTable[203] := @Func203; + fIdentFuncTable[206] := @Func206; + fIdentFuncTable[216] := @Func216; + fIdentFuncTable[219] := @Func219; + fIdentFuncTable[221] := @Func221; + fIdentFuncTable[232] := @Func232; + fIdentFuncTable[234] := @Func234; + fIdentFuncTable[235] := @Func235; + fIdentFuncTable[243] := @Func243; + fIdentFuncTable[244] := @Func244; + fIdentFuncTable[255] := @Func255; + fIdentFuncTable[313] := @Func313; + fIdentFuncTable[327] := @Func327; +end; + +function TSynDmlSyn.IsQuali: boolean; +begin + Result:= False; + if Run > 0 then + if fLine[Run-1]= '/' then Result:= True; +end; + +function TSynDmlSyn.IsSpecial :Boolean; +begin + Result:= False; + if Run > 0 then + if fLine[Run-1]= '%' then Result:= True; +end; + +function TSynDmlSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['a'..'z', 'A'..'Z', '_'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + if ToHash^ in ['_', '0'..'9'] then inc(ToHash); + fStringLen := ToHash - fToIdent; +end; { KeyHash } + +function TSynDmlSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; { KeyComp } + +function TSynDmlSyn.Func9: TtkTokenKind; +begin + if KeyComp('Add') then + begin + if IsSpecial then Result := tkSpecial + else begin + Result := tkKey; + fRange := rsAdd; + end; + end else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func15: TtkTokenKind; +begin + if KeyComp('If') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func17: TtkTokenKind; +begin + if KeyComp('Back') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func19: TtkTokenKind; +begin + if KeyComp('Dcl') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func22: TtkTokenKind; +begin + if KeyComp('Abs') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func23: TtkTokenKind; +begin + if KeyComp('In') and (fRange = rsFind) then + begin + Result := tkKey; + fRange:= rsUnKnown; + end else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func24: TtkTokenKind; +begin + if KeyComp('Cli') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func26: TtkTokenKind; +begin + if KeyComp('Mid') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func27: TtkTokenKind; +begin + if KeyComp('Base') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func28: TtkTokenKind; +begin + if KeyComp('Tag') and IsQuali then Result := tkQualifier else + if KeyComp('Case') then Result := tkKey else + if KeyComp('Call') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func29: TtkTokenKind; +begin + if KeyComp('Chr') then Result := tkFunction else + if KeyComp('Ceil') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func30: TtkTokenKind; +begin + if KeyComp('Check') and IsQuali then Result := tkQualifier else + if KeyComp('Col') then begin + if IsQuali then Result := tkQualifier else + if IsSpecial then Result := tkSpecial else Result := tkIdentifier; + end else + if KeyComp('Date') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func31: TtkTokenKind; +begin + if KeyComp('Len') then begin + if IsQuali then Result := tkQualifier else Result := tkFunction; + end else + if KeyComp('Dir') then Result := tkKey else + if KeyComp('Bell') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func32: TtkTokenKind; +begin + if KeyComp('Mod') then Result := tkFunction else + if KeyComp('Load') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func33: TtkTokenKind; +begin + if KeyComp('Find') then + begin + Result := tkKey; + fRange := rsFind; + end else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func34: TtkTokenKind; +begin + if KeyComp('Log') then begin + if IsQuali then Result := tkQualifier else Result := tkFunction; + end else if KeyComp('Batch') and IsQuali then Result := tkQualifier else + if KeyComp('Log10') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func35: TtkTokenKind; +begin + if KeyComp('Tan') then Result := tkFunction else + if KeyComp('To') and (fRange=rsAdd) then + begin + Result := tkKey; + fRange := rsUnKnown; + end else + if KeyComp('Mail') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func36: TtkTokenKind; +begin + if KeyComp('Atan2') then Result := tkFunction else + if KeyComp('Atan') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func37: TtkTokenKind; +begin + if KeyComp('Break') and IsQuali then Result := tkQualifier else + if KeyComp('Break0') and IsQuali then Result := tkQualifier else + if KeyComp('Cos') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func38: TtkTokenKind; +begin + if KeyComp('Acos') then Result := tkFunction else + if KeyComp('Edit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func40: TtkTokenKind; +begin + if KeyComp('Line') then Result := tkKey else + if KeyComp('Table') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func41: TtkTokenKind; +begin + if KeyComp('Else') then Result := tkKey else + if KeyComp('Lock') and IsQuali then Result := tkQualifier else + if KeyComp('Ascii') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func42: TtkTokenKind; +begin + if KeyComp('Send') then Result := tkKey else + if KeyComp('Sin') then Result := tkFunction else + if KeyComp('New') and IsQuali then Result := tkQualifier else + if KeyComp('Fetch') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func43: TtkTokenKind; +begin + if KeyComp('Asin') then Result := tkFunction else + if KeyComp('Int') then Result := tkFunction else + if KeyComp('Left') then Result := tkFunction else + if KeyComp('Tanh') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func45: TtkTokenKind; +begin + if KeyComp('Cosh') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func47: TtkTokenKind; +begin + if KeyComp('Item') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func48: TtkTokenKind; +begin + if KeyComp('Heading') and IsQuali then Result := tkQualifier else + if KeyComp('Erase') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func49: TtkTokenKind; +begin + if KeyComp('Days') then Result := tkFunction else + if KeyComp('Lov') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func50: TtkTokenKind; +begin + if KeyComp('Pos') and IsQuali then Result := tkQualifier else + if KeyComp('Sinh') then Result := tkFunction else + if KeyComp('Open') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func51: TtkTokenKind; +begin + if KeyComp('Files') then Result := tkKey else + if KeyComp('Opt') and IsQuali then Result := tkQualifier else + if KeyComp('Delete') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func52: TtkTokenKind; +begin + if KeyComp('Form') then begin + if IsSpecial then Result := tkSpecial else Result := tkForm; + end else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func53: TtkTokenKind; +begin + if KeyComp('Wait') and IsQuali then Result := tkQualifier else + if KeyComp('Menu') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func54: TtkTokenKind; +begin + if KeyComp('Close') then Result := tkKey else + if KeyComp('Search') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func56: TtkTokenKind; +begin + if KeyComp('Domain') and IsQuali then Result := tkQualifier else + if KeyComp('Row') and IsQuali then Result := tkQualifier else + if KeyComp('Row') and IsSpecial then Result := tkSpecial else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func57: TtkTokenKind; +begin + if KeyComp('While') then Result := tkKey else + if KeyComp('Height') and IsQuali then Result := tkQualifier else + if KeyComp('Goto') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func58: TtkTokenKind; +begin + if KeyComp('Exit') and IsQuali then Result := tkQualifier else + if KeyComp('Exit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func60: TtkTokenKind; +begin + if KeyComp('List') then Result := tkKey else + if KeyComp('With') and IsQuali then Result := tkQualifier else + if KeyComp('Trim') then Result := tkFunction else + if KeyComp('Nobell') and IsQuali then Result := tkFunction else + if KeyComp('Lheading') and IsQuali then Result := tkQualifier else + if KeyComp('Remain') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func62: TtkTokenKind; +begin + if KeyComp('Right') then Result := tkFunction else + if KeyComp('Pause') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func64: TtkTokenKind; +begin + if KeyComp('Width') and IsQuali then Result := tkQualifier else + if KeyComp('Expand') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func65: TtkTokenKind; +begin + if KeyComp('Finish') then Result := tkKey else + if KeyComp('Release') then Result := tkKey else + if KeyComp('Random') then Result := tkKey else + if KeyComp('Repeat') then begin + if IsQuali then Result := tkQualifier else Result := tkKey; + end else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func66: TtkTokenKind; +begin + if KeyComp('Rheading') and IsQuali then Result := tkQualifier else + if KeyComp('Floor') then Result := tkKey else + if KeyComp('Title') then begin + if IsQuali then Result := tkQualifier else Result := tkKey; + end else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func67: TtkTokenKind; +begin + if KeyComp('Unload') then Result := tkKey else + if KeyComp('Receive') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func68: TtkTokenKind; +begin + if KeyComp('Total') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func69: TtkTokenKind; +begin + if KeyComp('Message') then Result := tkKey else + if KeyComp('End_if') then Result := tkKey else + if KeyComp('Text') then begin + if IsSpecial then Result := tkSpecial else Result := tkKey; + end else if KeyComp('End_if') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func70: TtkTokenKind; +begin + if KeyComp('Using') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func71: TtkTokenKind; +begin + if KeyComp('Target') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func72: TtkTokenKind; +begin + if KeyComp('First') and IsQuali then Result := tkQualifier else + if KeyComp('Failure') then begin + if IsQuali then Result := tkQualifier else + if IsSpecial then Result := tkSpecial else Result := tkIdentifier; + end else + if KeyComp('Ltrim') then Result := tkFunction else + if KeyComp('Round') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func73: TtkTokenKind; +begin + if KeyComp('Commit') then Result := tkKey else + if KeyComp('Compile') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func74: TtkTokenKind; +begin + if KeyComp('Sqrt') then Result := tkFunction else + if KeyComp('Error') then begin + if IsQuali then Result := tkQualifier else Result := tkKey; + end else + if KeyComp('Rollback') then Result := tkKey else + if KeyComp('Connect') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func75: TtkTokenKind; +begin + if KeyComp('Generate') then Result := tkKey else + if KeyComp('Write') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func76: TtkTokenKind; +begin + if KeyComp('Invoke') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func77: TtkTokenKind; +begin + if KeyComp('Noerase') and IsQuali then Result := tkQualifier else + if KeyComp('Noheading') and IsQuali then Result := tkQualifier else + if KeyComp('Account') and IsSpecial then Result := tkSpecial else + if KeyComp('Print') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func78: TtkTokenKind; +begin + if KeyComp('Confirm') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func79: TtkTokenKind; +begin + if KeyComp('Seconds') then Result := tkFunction else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func81: TtkTokenKind; +begin + if KeyComp('Source') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func82: TtkTokenKind; +begin + if KeyComp('End_case') then Result := tkKey else + if KeyComp('Switch') and IsQuali then Result := tkQualifier else + if KeyComp('Nowait') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func83: TtkTokenKind; +begin + if KeyComp('Execute') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func84: TtkTokenKind; +begin + if KeyComp('Trigger') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func85: TtkTokenKind; +begin + if KeyComp('Facility') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func86: TtkTokenKind; +begin + if KeyComp('Footing') and IsQuali then Result := tkQualifier else + if KeyComp('Query') then Result := tkKey else + if KeyComp('Display') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func87: TtkTokenKind; +begin + if KeyComp('String') then Result := tkFunction else + if KeyComp('Else_if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func89: TtkTokenKind; +begin + if KeyComp('Sequence') and IsQuali then Result := tkQualifier else + if KeyComp('Success') then begin + if IsQuali then Result := tkQualifier else + if IsSpecial then Result := tkSpecial else Result := tkIdentifier; + end else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func91: TtkTokenKind; +begin + if KeyComp('Perform') then Result := tkKey else + if KeyComp('Use_if') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func92: TtkTokenKind; +begin + if KeyComp('Report') then Result := tkKey else + if KeyComp('Add_form') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func93: TtkTokenKind; +begin + if KeyComp('Item_if') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func94: TtkTokenKind; +begin + if KeyComp('Norepeat') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func96: TtkTokenKind; +begin + if KeyComp('Begin_case') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func97: TtkTokenKind; +begin + if KeyComp('Protect') and IsQuali then Result := tkQualifier else + if KeyComp('End_block') then Result := tkBlock else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func98: TtkTokenKind; +begin + if KeyComp('Lfooting') and IsQuali then Result := tkQualifier else + if KeyComp('Prompt') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func99: TtkTokenKind; +begin + if KeyComp('Identifier') and IsQuali then Result := tkQualifier else + if KeyComp('Send_data') then Result := tkKey else + if KeyComp('Read_line') then Result := tkKey else + if KeyComp('External') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func100: TtkTokenKind; +begin + if KeyComp('Status') then begin + if IsQuali then Result := tkQualifier else + if IsSpecial then Result := tkSpecial else Result := tkIdentifier; + end else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func101: TtkTokenKind; +begin + if KeyComp('Continue') and IsQuali then Result := tkQualifier else + if KeyComp('System') and IsQuali then Result := tkQualifier else + if KeyComp('Transfer') then Result := tkKey else + if KeyComp('Lowercase') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func102: TtkTokenKind; +begin + if KeyComp('Selection') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func103: TtkTokenKind; +begin + if KeyComp('Noerror') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func104: TtkTokenKind; +begin + if KeyComp('Secondary') and IsQuali then Result := tkQualifier else + if KeyComp('Uppercase') then Result := tkFunction else + if KeyComp('Rfooting') then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func106: TtkTokenKind; +begin + if KeyComp('End_form') then Result := tkForm else + if KeyComp('Lov_data') and IsQuali then Result := tkQualifier else + if KeyComp('Disconnect') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func108: TtkTokenKind; +begin + if KeyComp('Options') and IsQuali then Result := tkQualifier else + if KeyComp('Compress') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func110: TtkTokenKind; +begin + if KeyComp('End_row') and IsQuali then Result := tkQualifier else + if KeyComp('Lov_col') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func111: TtkTokenKind; +begin + if KeyComp('End_while') then Result := tkKey else + if KeyComp('Begin_block') then Result := tkBlock else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func113: TtkTokenKind; +begin + if KeyComp('Send_table') then Result := tkKey else + if KeyComp('Output') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func116: TtkTokenKind; +begin + if KeyComp('Find_form') and IsQuali then Result := tkQualifier else + if KeyComp('Nototals') and IsSpecial then Result := tkSpecial else + if KeyComp('No_domain') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func117: TtkTokenKind; +begin + if KeyComp('Check_domain') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func120: TtkTokenKind; +begin + if KeyComp('Statistic') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func121: TtkTokenKind; +begin + if KeyComp('Item_block') then Result := tkBlock else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func122: TtkTokenKind; +begin + if KeyComp('Top_line') and IsSpecial then Result := tkSpecial else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func123: TtkTokenKind; +begin + if KeyComp('Severity') and IsQuali then Result := tkQualifier else + if KeyComp('Joined_to') and IsQuali then Result := tkQualifier else + if KeyComp('Table_form') then Result := tkForm else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func124: TtkTokenKind; +begin + if KeyComp('Begin_row') and IsQuali then Result := tkQualifier else + if KeyComp('Utilities') then Result := tkKey else + if KeyComp('Receive_data') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func125: TtkTokenKind; +begin + if KeyComp('Read_only') and IsQuali then Result := tkQualifier else + if KeyComp('Table_search') then Result := tkKey else + if KeyComp('Tag_length') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func126: TtkTokenKind; +begin + if KeyComp('Reduced_to') and IsQuali then Result := tkQualifier else + if KeyComp('Actual_break') and IsSpecial then Result := tkSpecial else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func127: TtkTokenKind; +begin + if KeyComp('Source_if') and IsQuali then Result := tkQualifier else + if KeyComp('Menu_block') then Result := tkBlock else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func128: TtkTokenKind; +begin + if KeyComp('Clear_buffer') then Result := tkKey else + if KeyComp('Default_tag') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func129: TtkTokenKind; +begin + if KeyComp('Nostatus') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func131: TtkTokenKind; +begin + if KeyComp('Heading_form') then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func132: TtkTokenKind; +begin + if KeyComp('Description') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func134: TtkTokenKind; +begin + if KeyComp('Delete_form') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func135: TtkTokenKind; +begin + if KeyComp('Nolov_data') and IsQuali then Result := tkQualifier else + if KeyComp('Attributes') and IsQuali then Result := tkQualifier else + if KeyComp('User_key') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func136: TtkTokenKind; +begin + if KeyComp('Menu_form') then Result := tkForm else + if KeyComp('Pause_block') then Result := tkBlock else + if KeyComp('Lov_row') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func137: TtkTokenKind; +begin + if KeyComp('Lov_height') and IsQuali then Result := tkQualifier else + if KeyComp('End_execute') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func138: TtkTokenKind; +begin + if KeyComp('Receive_table') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func139: TtkTokenKind; +begin + if KeyComp('Sorted_by') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func140: TtkTokenKind; +begin + if KeyComp('Date_seconds') then Result := tkFunction else + if KeyComp('Reposition') then Result := tkKey else + if KeyComp('Switch_base') and IsQuali then Result := tkQualifier else + if KeyComp('Lines_after') and IsQuali then Result := tkQualifier else + if KeyComp('Lov_with') and IsQuali then Result := tkQualifier else + if KeyComp('Lines_after') and IsSpecial then Result := tkSpecial + else if KeyComp('Stream_name') and IsQuali then + Result := tkQualifier + else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func141: TtkTokenKind; +begin + if KeyComp('Lines_before') and IsQuali then Result := tkQualifier else + if KeyComp('Lines_after') and IsSpecial then Result := tkSpecial else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func142: TtkTokenKind; +begin + if KeyComp('Send_message') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func144: TtkTokenKind; +begin + if KeyComp('Grouped_by') and IsQuali then Result := tkQualifier else + if KeyComp('Lov_width') and IsQuali then Result := tkQualifier else + if KeyComp('Row_height') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func146: TtkTokenKind; +begin + if KeyComp('Write_line') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func148: TtkTokenKind; +begin + if KeyComp('Commit_rate') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func150: TtkTokenKind; +begin + if KeyComp('Open_text') then Result := tkKey else + if KeyComp('Nounderlines') then begin + if IsQuali then Result := tkQualifier else + if IsSpecial then Result := tkSpecial else Result := tkIdentifier; + end else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func152: TtkTokenKind; +begin + if KeyComp('Lov_first') and IsQuali then Result := tkQualifier else + if KeyComp('Yesno_block') then Result := tkBlock else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func153: TtkTokenKind; +begin + if KeyComp('Tsuppress') and IsSpecial then Result := tkSpecial else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func154: TtkTokenKind; +begin + if KeyComp('Documentation') then Result := tkKey else + if KeyComp('Input_block') then Result := tkBlock else + if KeyComp('Close_text') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func155: TtkTokenKind; +begin + if KeyComp('Modify_form') and IsQuali then Result := tkQualifier else + if KeyComp('Input_mask') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func156: TtkTokenKind; +begin + if KeyComp('Bottom_line') and IsSpecial then Result := tkSpecial else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func157: TtkTokenKind; +begin + if KeyComp('Lov_noheading') and IsQuali then Result := tkQualifier else + if KeyComp('Noclear_buffer') and IsQuali then Result := tkQualifier else + if KeyComp('Day_of_week') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func163: TtkTokenKind; +begin + if KeyComp('Lov_nosearch') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func164: TtkTokenKind; +begin + if KeyComp('Compress_all') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func166: TtkTokenKind; +begin + if KeyComp('Text_only') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func169: TtkTokenKind; +begin + if KeyComp('Query_form') then Result := tkForm else + if KeyComp('Footing_form') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func173: TtkTokenKind; +begin + if KeyComp('Nodeadlock_exit') and IsQuali then Result := tkQualifier else + if KeyComp('Rewind_text') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func174: TtkTokenKind; +begin + if KeyComp('Exit_forward') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func175: TtkTokenKind; +begin + if KeyComp('Report_form') then Result := tkForm else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func176: TtkTokenKind; +begin + if KeyComp('Column_headings') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func178: TtkTokenKind; +begin + if KeyComp('Column_spacing') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func179: TtkTokenKind; +begin + if KeyComp('Alternate_form') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func182: TtkTokenKind; +begin + if KeyComp('Lov_selection') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func183: TtkTokenKind; +begin + if KeyComp('Display_length') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func184: TtkTokenKind; +begin + if KeyComp('Lov_secondary') and IsQuali then Result := tkQualifier else + if KeyComp('Cross_reference') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func185: TtkTokenKind; +begin + if KeyComp('Start_stream') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func187: TtkTokenKind; +begin + if KeyComp('Output_block') then Result := tkBlock else Result := tkIdentifier; +end; + +function TSynDmlSyn.Func188: TtkTokenKind; +begin + if KeyComp('Output_mask') and IsQuali then Result := tkQualifier else + if KeyComp('Procedure_form') then Result := tkForm else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func203: TtkTokenKind; +begin + if KeyComp('Noexit_forward') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func206: TtkTokenKind; +begin + if KeyComp('Lov_reduced_to') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func216: TtkTokenKind; +begin + if KeyComp('Receive_arguments') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func219: TtkTokenKind; +begin + if KeyComp('Lov_sorted_by') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func221: TtkTokenKind; +begin + if KeyComp('End_disable_trigger') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func232: TtkTokenKind; +begin + if KeyComp('Lov_auto_select') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func234: TtkTokenKind; +begin + if KeyComp('Binary_to_poly') then Result := tkFunction else + if KeyComp('Poly_to_binary') then Result := tkFunction else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func235: TtkTokenKind; +begin + if KeyComp('Begin_disable_trigger') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func243: TtkTokenKind; +begin + if KeyComp('Start_transaction') then Result := tkKey else + if KeyComp('Absolute_position') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func244: TtkTokenKind; +begin + if KeyComp('Column_heading_row') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func255: TtkTokenKind; +begin + if KeyComp('Input_row_height') and IsQuali then Result := tkQualifier else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func313: TtkTokenKind; +begin + if KeyComp('End_signal_to_status') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.Func327: TtkTokenKind; +begin + if KeyComp('Begin_signal_to_status') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynDmlSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynDmlSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 328 then Result := fIdentFuncTable[HashKey]() else + Result := tkIdentifier; +end; + +procedure TSynDmlSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0: fProcTable[I] := @NullProc; + #10: fProcTable[I] := @LFProc; + #13: fProcTable[I] := @CRProc; + #1..#9, #11, #12, #14..#32: + fProcTable[I] := @SpaceProc; + '#': fProcTable[I] := @AsciiCharProc; + '"': fProcTable[I] := @StringProc; + '0'..'9': fProcTable[I] := @NumberProc; + 'A'..'Z', 'a'..'z', '_': + fProcTable[I] := @IdentProc; + '{': fProcTable[I] := @SymbolProc; + '}': fProcTable[I] := @SymbolProc; + '!': fProcTable[I] := @RemProc; + '.': fProcTable[I] := @PointProc; + '<': fProcTable[I] := @LowerProc; + '>': fProcTable[I] := @GreaterProc; + '@': fProcTable[I] := @AddressOpProc; + #39, '&', '('..'-', '/', ':', ';', '=', '?', '['..'^', '`', '~': + fProcTable[I] := @SymbolProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynDmlSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + fFormAttri:= TSynHighlighterAttributes.Create(SYNS_AttrForm); + fFormAttri.Style:= [fsBold]; + fFormAttri.Foreground:= clBlue; + AddAttribute(fFormAttri); + fBlockAttri:= TSynHighlighterAttributes.Create(SYNS_AttrBlock); + fBlockAttri.Style:= [fsBold]; + fBlockAttri.Foreground:= clGreen; + AddAttribute(fBlockAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrKey); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style:= [fsBold]; + fCommentAttri.Foreground:= clRed; + AddAttribute(fCommentAttri); + fQualiAttri:= TSynHighlighterAttributes.Create(SYNS_AttrQualifier); + fQualiAttri.Style:= [fsItalic]; + fQualiAttri.Foreground:= clGreen; + AddAttribute(fQualiAttri); + fFunctionAttri:= TSynHighlighterAttributes.Create(SYNS_AttrFunction); + fFunctionAttri.Style:= [fsItalic]; + fFunctionAttri.Foreground:= clBlack; + AddAttribute(fFunctionAttri); + fVariableAttri:= TSynHighlighterAttributes.Create(SYNS_AttrVariable); + fVariableAttri.Style:= [fsBold, fsItalic]; + fVariableAttri.Foreground:= clBlack; + AddAttribute(fVariableAttri); + fSpecialAttri:= TSynHighlighterAttributes.Create(SYNS_AttrSpecialVariable); + fSpecialAttri.Style:= [fsItalic]; + fSpecialAttri.Foreground:= clBlack; + AddAttribute(fSpecialAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange(@DefHighlightChange); + + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + + fDefaultFilter := SYNS_FilterGembase; +end; + +procedure TSynDmlSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynDmlSyn.AddressOpProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if fLine[Run] = '@' then Inc(Run); +end; + +procedure TSynDmlSyn.AsciiCharProc; +begin + // variables... + fTokenID := tkVariable; + repeat + inc(Run); + until not (FLine[Run] in ['_', '0'..'9', 'a'..'z', 'A'..'Z']); +end; + +procedure TSynDmlSyn.SymbolProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynDmlSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if FLine[Run] = #10 then inc(Run); +end; + +procedure TSynDmlSyn.GreaterProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if FLine[Run] = '=' then Inc(Run); +end; + +procedure TSynDmlSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynDmlSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynDmlSyn.LowerProc; +begin + fTokenID := tkSymbol; + inc(Run); + if (fLine[Run]= '=') or (fLine[Run]= '>') then Inc(Run); +end; + +procedure TSynDmlSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynDmlSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynDmlSyn.PointProc; +begin + fTokenID := tkSymbol; + inc(Run); + if (fLine[Run]='.') or (fLine[Run]=')') then inc(Run); +end; + +procedure TSynDmlSyn.RemProc; +var + p: PChar; +begin + p := PChar(@fLine[Run - 1]); + while p >= fLine do begin + if not (p^ in [#9, #32]) then begin + inc(Run); + fTokenID := tkSymbol; + exit; + end; + Dec(p); + end; + // it is a comment... + fTokenID := tkComment; + p := PChar(@fLine[Run]); + repeat + Inc(p); + until p^ in [#0, #10, #13]; + Run := p - fLine; +end; + +procedure TSynDmlSyn.SpaceProc; +var p: PChar; +begin + fTokenID := tkSpace; + p := PChar(@fLine[Run]); + repeat + Inc(p); + until (p^ > #32) or (p^ in [#0, #10, #13]); + Run := p - fLine; +end; + +procedure TSynDmlSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = '"') and (FLine[Run + 2] = '"') then inc(Run, 2); + repeat + inc(Run); + until (FLine[Run] in ['"', #0, #10, #13]); + + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynDmlSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynDmlSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynDmlSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynDmlSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynDmlSyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynDmlSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynDmlSyn.GetTokenID: TtkTokenKind; +begin + Result:= fTokenId; +end; + +function TSynDmlSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkForm: Result := fFormAttri; + tkBlock: Result := fBlockAttri; + tkKey: Result := fKeyAttri; + tkComment: Result := fCommentAttri; + tkQualifier: Result := fQualiAttri; + tkFunction: Result := fFunctionAttri; + tkIdentifier: Result := fIdentifierAttri; + tkNumber: Result := fNumberAttri; + tkSpecial: Result := fSpecialAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkVariable: Result := fVariableAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fSymbolAttri; + else Result := nil; + end; +end; + +function TSynDmlSyn.GetTokenKind: integer; +begin + Result := Ord(GetTokenID); +end; + +function TSynDmlSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynDmlSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +procedure TSynDmlSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynDmlSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +function TSynDmlSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterGembase; +end; + +class function TSynDmlSyn.GetLanguageName: string; +begin + Result := SYNS_LangGembase; +end; + +function TSynDmlSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynDmlSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterdot.pas b/components/extrasyn/SyneditHighlighters/synhighlighterdot.pas new file mode 100644 index 000000000..b1357c3c4 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterdot.pas @@ -0,0 +1,1378 @@ +{------------------------------------------------------------------------------- +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. + +Code template generated with SynGen. +The original code is: SynHighlighterDOT.pas, released 2002-11-30. +Description: DOT Syntax Parser/Highlighter +The initial author of this file is nissl (nissl@tiscali.it, nissl@mammuth.it) +Copyright (c) 2002, 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: SynHighlighterDOT.pas,v 1.4 2005/01/28 16:53:21 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} +{ +@abstract(Provides a ATT DOT highlighter for SynEdit) +@author(Massimo Maria Ghisalberti (nissl@mammuth.it)) +@created(november 2002) +@lastmod(2002-11-30) +The SynHighlighterDOT unit provides SynEdit with a DOT Graph Drawing (.dot) highlighter. +The highlighter formats DOT source code ref.: http://www.research.att.com/sw/tools/graphviz/. +} +unit SynHighlighterDOT; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = ( + tkArrowHead, + tkAttribute, + tkComment, + tkDirections, + tkIdentifier, + tkKey, + tkNull, + tkShape, + tkSpace, + tkString, + tkUnknown, + tkValue, + tkSymbol); + + TRangeState = (rsUnKnown, rsCStyleComment, rsString); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +const + MaxKey = 174; + +type + TSynDOTSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + fRange: TRangeState; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0 .. MaxKey] of TIdentFuncTableFunc; + fArrowHeadAttri: TSynHighlighterAttributes; + fAttributeAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fDirectionsAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fShapeAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fValueAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func5: TtkTokenKind; + function Func13: TtkTokenKind; + function Func14: TtkTokenKind; + function Func17: TtkTokenKind; + function Func19: TtkTokenKind; + function Func21: TtkTokenKind; + function Func23: TtkTokenKind; + function Func24: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func94: TtkTokenKind; + function Func96: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func104: TtkTokenKind; + function Func107: TtkTokenKind; + function Func109: TtkTokenKind; + function Func111: TtkTokenKind; + function Func113: TtkTokenKind; + function Func114: TtkTokenKind; + function Func117: TtkTokenKind; + function Func118: TtkTokenKind; + function Func120: TtkTokenKind; + function Func121: TtkTokenKind; + function Func127: TtkTokenKind; + function Func128: TtkTokenKind; + function Func129: TtkTokenKind; + function Func131: TtkTokenKind; + function Func133: TtkTokenKind; + function Func134: TtkTokenKind; + function Func140: TtkTokenKind; + function Func142: TtkTokenKind; + function Func143: TtkTokenKind; + function Func146: TtkTokenKind; + function Func150: TtkTokenKind; + function Func155: TtkTokenKind; + function Func159: TtkTokenKind; + function Func174: TtkTokenKind; + procedure IdentProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure NullProc; + procedure SpaceProc; + procedure CRProc; + procedure LFProc; + procedure CStyleCommentOpenProc; + procedure CStyleCommentProc; + procedure StringOpenProc; + procedure StringProc; + procedure SymbolProc; + procedure DirectionsProc; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + constructor Create(AOwner: TComponent); override; + class function GetLanguageName: string; override; + function GetRange: Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override; + function GetEol: Boolean; override; + function GetKeyWords: string; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property ArrowHeadAttri: TSynHighlighterAttributes read fArrowHeadAttri write fArrowHeadAttri; + property AttributeAttri: TSynHighlighterAttributes read fAttributeAttri write fAttributeAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property DirectionsAttri: TSynHighlighterAttributes read fDirectionsAttri write fDirectionsAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property ShapeAttri: TSynHighlighterAttributes read fShapeAttri write fShapeAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property ValueAttri: TSynHighlighterAttributes read fValueAttri write fValueAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable : array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynDOTSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[5] := @Func5; + fIdentFuncTable[13] := @Func13; + fIdentFuncTable[14] := @Func14; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[24] := @Func24; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[44] := @Func44; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[61] := @Func61; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[90] := @Func90; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[94] := @Func94; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[100] := @Func100; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[104] := @Func104; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[109] := @Func109; + fIdentFuncTable[111] := @Func111; + fIdentFuncTable[113] := @Func113; + fIdentFuncTable[114] := @Func114; + fIdentFuncTable[117] := @Func117; + fIdentFuncTable[118] := @Func118; + fIdentFuncTable[120] := @Func120; + fIdentFuncTable[121] := @Func121; + fIdentFuncTable[127] := @Func127; + fIdentFuncTable[128] := @Func128; + fIdentFuncTable[129] := @Func129; + fIdentFuncTable[131] := @Func131; + fIdentFuncTable[133] := @Func133; + fIdentFuncTable[134] := @Func134; + fIdentFuncTable[140] := @Func140; + fIdentFuncTable[142] := @Func142; + fIdentFuncTable[143] := @Func143; + fIdentFuncTable[146] := @Func146; + fIdentFuncTable[150] := @Func150; + fIdentFuncTable[155] := @Func155; + fIdentFuncTable[159] := @Func159; + fIdentFuncTable[174] := @Func174; +end; + +function TSynDOTSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynDOTSyn.KeyComp(const aKey :string) :Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else + Result := False; +end; + +function TSynDOTSyn.Func5: TtkTokenKind; +begin + if KeyComp('e') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func13: TtkTokenKind; +begin + if KeyComp('id') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func14: TtkTokenKind; +begin + if KeyComp('n') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func17: TtkTokenKind; +begin + if KeyComp('back') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func19: TtkTokenKind; +begin + if KeyComp('egg') then Result := tkShape else + if KeyComp('s') then Result := tkValue else + if KeyComp('ne') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func21: TtkTokenKind; +begin + if KeyComp('edge') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func23: TtkTokenKind; +begin + if KeyComp('w') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func24: TtkTokenKind; +begin + if KeyComp('se') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func25: TtkTokenKind; +begin + if KeyComp('all') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func26: TtkTokenKind; +begin + if KeyComp('z') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func29: TtkTokenKind; +begin + if KeyComp('page') then Result := tkAttribute else + if KeyComp('page') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func30: TtkTokenKind; +begin + if KeyComp('lhead') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func31: TtkTokenKind; +begin + if KeyComp('dir') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func32: TtkTokenKind; +begin + if KeyComp('label') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func33: TtkTokenKind; +begin + if KeyComp('bold') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func36: TtkTokenKind; +begin + if KeyComp('min') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func37: TtkTokenKind; +begin + if KeyComp('nw') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func38: TtkTokenKind; +begin + if KeyComp('max') then Result := tkValue else + if KeyComp('same') then Result := tkValue else + if KeyComp('node') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func39: TtkTokenKind; +begin + if KeyComp('dot') then Result := tkArrowHead else + if KeyComp('fill') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func41: TtkTokenKind; +begin + if KeyComp('box') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func42: TtkTokenKind; +begin + if KeyComp('sw') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func43: TtkTokenKind; +begin + if KeyComp('false') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func44: TtkTokenKind; +begin + if KeyComp('rank') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func45: TtkTokenKind; +begin + if KeyComp('both') then Result := tkValue else + if KeyComp('inv') then Result := tkArrowHead else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func48: TtkTokenKind; +begin + if KeyComp('none') then Result := tkValue else + if KeyComp('filled') then Result := tkValue else + if KeyComp('filled') then Result := tkAttribute else + if KeyComp('none') then Result := tkArrowHead else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func49: TtkTokenKind; +begin + if KeyComp('shape') then Result := tkAttribute else + if KeyComp('global') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func50: TtkTokenKind; +begin + if KeyComp('when') then Result := tkAttribute else + if KeyComp('when') then Result := tkAttribute else + if KeyComp('graph') then Result := tkKey else + if KeyComp('headlabel') then Result := tkAttribute else + if KeyComp('circle') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func51: TtkTokenKind; +begin + if KeyComp('url') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func52: TtkTokenKind; +begin + if KeyComp('merged') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func53: TtkTokenKind; +begin + if KeyComp('sink') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func54: TtkTokenKind; +begin + if KeyComp('ltail') then Result := tkAttribute else + if KeyComp('odot') then Result := tkArrowHead else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func56: TtkTokenKind; +begin + if KeyComp('samehead') then Result := tkAttribute else + if KeyComp('sides') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func57: TtkTokenKind; +begin + if KeyComp('height') then Result := tkAttribute else + if KeyComp('auto') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func58: TtkTokenKind; +begin + if KeyComp('skew') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func59: TtkTokenKind; +begin + if KeyComp('size') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func60: TtkTokenKind; +begin + if KeyComp('pagedir') then Result := tkAttribute else + if KeyComp('diamond') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func61: TtkTokenKind; +begin + if KeyComp('layer') then Result := tkAttribute else + if KeyComp('layer') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func62: TtkTokenKind; +begin + if KeyComp('labelloc') then Result := tkAttribute else + if KeyComp('margin') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func63: TtkTokenKind; +begin + if KeyComp('color') then Result := tkAttribute else + if KeyComp('ratio') then Result := tkAttribute else + if KeyComp('record') then Result := tkShape else + if KeyComp('mcircle') then Result := tkShape else + if KeyComp('digraph') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func64: TtkTokenKind; +begin + if KeyComp('width') then Result := tkAttribute else + if KeyComp('onto') then Result := tkAttribute else + if KeyComp('true') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func65: TtkTokenKind; +begin + if KeyComp('center') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func67: TtkTokenKind; +begin + if KeyComp('minlen') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func68: TtkTokenKind; +begin + if KeyComp('house') then Result := tkShape else + if KeyComp('dotted') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func69: TtkTokenKind; +begin + if KeyComp('headURL') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func71: TtkTokenKind; +begin + if KeyComp('labelangle') then Result := tkAttribute else + if KeyComp('decorate') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func72: TtkTokenKind; +begin + if KeyComp('weight') then Result := tkAttribute else + if KeyComp('bgcolor') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func73: TtkTokenKind; +begin + if KeyComp('mdiamond') then Result := tkShape else + if KeyComp('normal') then Result := tkArrowHead else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func74: TtkTokenKind; +begin + if KeyComp('point') then Result := tkShape else + if KeyComp('taillabel') then Result := tkAttribute else + if KeyComp('hexagon') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func75: TtkTokenKind; +begin + if KeyComp('octagon') then Result := tkShape else + if KeyComp('rankdir') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func76: TtkTokenKind; +begin + if KeyComp('mrecord') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func77: TtkTokenKind; +begin + if KeyComp('group') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func78: TtkTokenKind; +begin + if KeyComp('ellipse') then Result := tkShape else + if KeyComp('nodesep') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func79: TtkTokenKind; +begin + if KeyComp('mclimit') then Result := tkAttribute else + if KeyComp('rotate') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func80: TtkTokenKind; +begin + if KeyComp('layers') then Result := tkAttribute else + if KeyComp('layers') then Result := tkKey else + if KeyComp('sametail') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func81: TtkTokenKind; +begin + if KeyComp('shapefile') then Result := tkAttribute else + if KeyComp('style') then Result := tkAttribute else + if KeyComp('source') then Result := tkValue else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func82: TtkTokenKind; +begin + if KeyComp('regular') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func83: TtkTokenKind; +begin + if KeyComp('comment') then Result := tkAttribute else + if KeyComp('toplabel') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func84: TtkTokenKind; +begin + if KeyComp('ranksep') then Result := tkAttribute else + if KeyComp('invdot') then Result := tkArrowHead else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func85: TtkTokenKind; +begin + if KeyComp('forward') then Result := tkValue else + if KeyComp('section') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func86: TtkTokenKind; +begin + if KeyComp('triangle') then Result := tkShape else + if KeyComp('labelfloat') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func87: TtkTokenKind; +begin + if KeyComp('headport') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func88: TtkTokenKind; +begin + if KeyComp('fontname') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func89: TtkTokenKind; +begin + if KeyComp('strict') then Result := tkKey else + if KeyComp('appendix') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func90: TtkTokenKind; +begin + if KeyComp('ordering') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func92: TtkTokenKind; +begin + if KeyComp('minimum') then Result := tkAttribute else + if KeyComp('subgraph') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func93: TtkTokenKind; +begin + if KeyComp('tailURL') then Result := tkAttribute else + if KeyComp('arrowhead') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func94: TtkTokenKind; +begin + if KeyComp('msquare') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func96: TtkTokenKind; +begin + if KeyComp('nslimit') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func99: TtkTokenKind; +begin + if KeyComp('invodot') then Result := tkArrowHead else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func100: TtkTokenKind; +begin + if KeyComp('fontpath') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func101: TtkTokenKind; +begin + if KeyComp('compound') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func102: TtkTokenKind; +begin + if KeyComp('fillcolor') then Result := tkAttribute else + if KeyComp('labeljust') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func104: TtkTokenKind; +begin + if KeyComp('polygon') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func107: TtkTokenKind; +begin + if KeyComp('quantum') then Result := tkAttribute else + if KeyComp('fixedsize') then Result := tkAttribute else + if KeyComp('labeldistance') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func109: TtkTokenKind; +begin + if KeyComp('doublecircle') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func111: TtkTokenKind; +begin + if KeyComp('tailport') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func113: TtkTokenKind; +begin + if KeyComp('searchsize') then Result := tkAttribute else + if KeyComp('invhouse') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func114: TtkTokenKind; +begin + if KeyComp('fontsize') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func117: TtkTokenKind; +begin + if KeyComp('arrowtail') then Result := tkAttribute else + if KeyComp('bottomlabel') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func118: TtkTokenKind; +begin + if KeyComp('concentrate') then Result := tkAttribute else + if KeyComp('fontcolor') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func120: TtkTokenKind; +begin + if KeyComp('labelfontname') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func121: TtkTokenKind; +begin + if KeyComp('plaintext') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func127: TtkTokenKind; +begin + if KeyComp('multiples') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func128: TtkTokenKind; +begin + if KeyComp('peripheries') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func129: TtkTokenKind; +begin + if KeyComp('trapezium') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func131: TtkTokenKind; +begin + if KeyComp('invtriangle') then Result := tkShape else + if KeyComp('parallelogram') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func133: TtkTokenKind; +begin + if KeyComp('constraint') then Result := tkAttribute else + if KeyComp('remincross') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func134: TtkTokenKind; +begin + if KeyComp('arrowsize') then Result := tkAttribute else + if KeyComp('doubleoctagon') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func140: TtkTokenKind; +begin + if KeyComp('orientation') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func142: TtkTokenKind; +begin + if KeyComp('clusterrank') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func143: TtkTokenKind; +begin + if KeyComp('distortion') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func146: TtkTokenKind; +begin + if KeyComp('labelfontsize') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func150: TtkTokenKind; +begin + if KeyComp('labelfontcolor') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func155: TtkTokenKind; +begin + if KeyComp('tripleoctagon') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func159: TtkTokenKind; +begin + if KeyComp('samplepoints') then Result := tkAttribute else Result := tkIdentifier; +end; + +function TSynDOTSyn.Func174: TtkTokenKind; +begin + if KeyComp('invtrapezium') then Result := tkShape else Result := tkIdentifier; +end; + +function TSynDOTSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynDOTSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey <= MaxKey then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynDOTSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0: fProcTable[I] := @NullProc; + #10: fProcTable[I] := @LFProc; + #13: fProcTable[I] := @CRProc; + '/': fProcTable[I] := @CStyleCommentOpenProc; + '-': fProcTable[I] := @DirectionsProc; + '''': fProcTable[I] := @StringOpenProc; + #1..#9, + #11, + #12, + #14..#32 : fProcTable[I] := @SpaceProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + '~', '{', '}', ',', '(', ')', '[', ']', '<', '>', ':', '?', ';', '!', '=': fProcTable[I] := @SymbolProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +procedure TSynDOTSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + inc(Run); + until not (fLine[Run] in [#1..#32]); +end; + +procedure TSynDOTSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynDOTSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then + inc(Run); +end; + +procedure TSynDOTSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynDOTSyn.DirectionsProc; +begin + Inc(Run); + if (fLine[Run] = '>') or (fLine[Run] = '-') then + begin + fTokenID := tkDirections; + inc(Run); + end + else + fTokenID := tkSymbol; +end; + +procedure TSynDOTSyn.CStyleCommentOpenProc; +begin + Inc(Run); + if (fLine[Run] = '/') then + begin + fTokenID := tkComment; + inc(Run, 2); + while not (fLine[Run] in [#0, #10, #13]) do Inc(Run); + Exit; + end; + if (fLine[Run] = '*') then + begin + fRange := rsCStyleComment; + CStyleCommentProc; + fTokenID := tkComment; + end + else + fTokenID := tkIdentifier; +end; + +procedure TSynDOTSyn.CStyleCommentProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + begin + fTokenID := tkComment; + repeat + if (fLine[Run] = '*') and + (fLine[Run + 1] = '/') then + begin + Inc(Run, 2); + fRange := rsUnKnown; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + end; +end; + +procedure TSynDOTSyn.StringOpenProc; +begin + Inc(Run); + fRange := rsString; + StringProc; + fTokenID := tkString; +end; + +procedure TSynDOTSyn.StringProc; +begin + fTokenID := tkString; + repeat + if (fLine[Run] = '''') then + begin + Inc(Run, 1); + fRange := rsUnKnown; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +constructor TSynDOTSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fArrowHeadAttri := TSynHighLighterAttributes.Create(SYNS_AttrArrowHead); + fArrowHeadAttri.Foreground := clRed; + AddAttribute(fArrowHeadAttri); + + fAttributeAttri := TSynHighLighterAttributes.Create(SYNS_AttrAttribute); + AddAttribute(fAttributeAttri); + + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + fCommentAttri.Foreground := clNavy; + AddAttribute(fCommentAttri); + + fDirectionsAttri := TSynHighLighterAttributes.Create(SYNS_AttrDirections); + fDirectionsAttri.Style := [fsBold]; + fDirectionsAttri.Foreground := clYellow; + AddAttribute(fDirectionsAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + + fShapeAttri := TSynHighLighterAttributes.Create(SYNS_AttrShape); + fShapeAttri.Style := [fsBold]; + fShapeAttri.Foreground := clRed; + AddAttribute(fShapeAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + + fValueAttri := TSynHighLighterAttributes.Create(SYNS_AttrValue); + fValueAttri.Style := [fsItalic]; + fValueAttri.Foreground := clRed; + AddAttribute(fValueAttri); + + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + fSymbolAttri.Style := [fsBold]; + fSymbolAttri.Foreground := clGreen; + AddAttribute(fSymbolAttri); + + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterDOT; + fRange := rsUnknown; +end; + +procedure TSynDOTSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynDOTSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + Inc(Run); +end; + +procedure TSynDOTSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynDOTSyn.SymbolProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynDOTSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsCStyleComment: CStyleCommentProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynDOTSyn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_STRING : Result := fStringAttri; + SYN_ATTR_WHITESPACE : Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynDOTSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynDOTSyn.GetKeyWords: string; +begin + Result := + '--,->,all,appendix,arrowhead,arrowsize,arrowtail,auto,back,bgcolor,bo' + + 'ld,both,bottomlabel,box,center,circle,clusterrank,color,comment,compou' + + 'nd,concentrate,constraint,decorate,diamond,digraph,dir,distortion,dot,' + + 'dotted,doublecircle,doubleoctagon,e,edge,egg,ellipse,false,fill,fillco' + + 'lor,filled,fixedsize,fontcolor,fontname,fontpath,fontsize,forward,glob' + + 'al,graph,group,headlabel,headport,headURL,height,hexagon,house,id,inv,' + + 'invdot,invhouse,invodot,invtrapezium,invtriangle,label,labelangle,labe' + + 'ldistance,labelfloat,labelfontcolor,labelfontname,labelfontsize,labelj' + + 'ust,labelloc,layer,layers,lhead,ltail,margin,max,mcircle,mclimit,mdiam' + + 'ond,merged,min,minimum,minlen,mrecord,msquare,multiples,n,ne,node,node' + + 'sep,none,normal,nslimit,nw,octagon,odot,onto,ordering,orientation,page' + + ',pagedir,parallelogram,peripheries,plaintext,point,polygon,quantum,ran' + + 'k,rankdir,ranksep,ratio,record,regular,remincross,rotate,s,same,samehe' + + 'ad,sametail,samplepoints,se,searchsize,section,shape,shapefile,sides,s' + + 'ink,size,skew,source,strict,style,subgraph,sw,taillabel,tailport,tailU' + + 'RL,toplabel,trapezium,triangle,tripleoctagon,true,url,w,weight,when,wi' + + 'dth,z'; +end; + +function TSynDOTSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynDOTSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynDOTSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynDOTSyn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkArrowHead: Result := fArrowHeadAttri; + tkAttribute: Result := fAttributeAttri; + tkComment: Result := fCommentAttri; + tkDirections: Result := fDirectionsAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkShape: Result := fShapeAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkValue: Result := fValueAttri; + tkUnknown: Result := fIdentifierAttri; + tkSymbol: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynDOTSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynDOTSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynDOTSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', 'a'..'z', 'A'..'Z']; +end; + +function TSynDOTSyn.GetSampleSource: string; +begin + Result := + '// ATT DOT Graphic description language'#13#10 + + 'digraph asde91 {'#13#10 + + ' ranksep=.75; size = "7.5,7.5";'#13#10 + + ' {'#13#10 + + ' node [shape=plaintext, fontsize=16];'#13#10 + + ' /* the time-line graph */'#13#10 + + ' past -> 1978 -> 1980 -> 1982 -> 1983 -> 1985 -> 1986 ->'#13#10 + + ' 1987 -> 1988 -> 1989 -> 1990 -> "future";'#13#10 + + ' /* ancestor programs */'#13#10 + + ' "Bourne sh"; "make"; "SCCS"; "yacc"; "cron"; "Reiser cpp";'#13#10 + + ' "Cshell"; "emacs"; "build"; "vi"; ""; "RCS"; "C*";'#13#10 + + ' }'#13#10 + + ' { rank = same;'#13#10 + + ' "Software IS"; "Configuration Mgt"; "Architecture & Libraries";'#13#10 + + ' "Process";'#13#10 + + ' };'#13#10 + + ' node [shape=box];'#13#10 + + ' { rank = same; "past"; "SCCS"; "make"; "Bourne sh"; "yacc"; "cron"; }'#13#10 + + ' { rank = same; 1978; "Reiser cpp"; "Cshell"; }'#13#10 + + ' { rank = same; 1980; "build"; "emacs"; "vi"; }'#13#10 + + ' { rank = same; 1982; "RCS"; ""; "IMX"; "SYNED"; }'#13#10 + + ' { rank = same; 1983; "ksh"; "IFS"; "TTU"; }'#13#10 + + ' { rank = same; 1985; "nmake"; "Peggy"; }'#13#10 + + ' { rank = same; 1986; "C*"; "ncpp"; "ksh-i"; ""; "PG2"; }'#13#10 + + ' { rank = same; 1987; "Ansi cpp"; "nmake 2.0"; "3D File System"; "fdelta";'#13#10 + + ' "DAG"; "CSAS";}'#13#10 + + ' { rank = same; 1988; "CIA"; "SBCS"; "ksh-88"; "PEGASUS/PML"; "PAX";'#13#10 + + ' "backtalk"; }'#13#10 + + ' { rank = same; 1989; "CIA++"; "APP"; "SHIP"; "DataShare"; "ryacc";'#13#10 + + ' "Mosaic"; }'#13#10 + + ' { rank = same; 1990; "libft"; "CoShell"; "DIA"; "IFS-i"; "kyacc"; "sfio";'#13#10 + + ' "yeast"; "ML-X"; "DOT"; }'#13#10 + + ' { rank = same; "future"; "Adv. Software Technology"; }'#13#10 + + ' "PEGASUS/PML" -> "ML-X";'#13#10 + + ' "SCCS" -> "nmake";'#13#10 + + ' "SCCS" -> "3D File System";'#13#10 + + ' "SCCS" -> "RCS";'#13#10 + + ' "make" -> "nmake";'#13#10 + + ' "make" -> "build";'#13#10 + + '}'; +end; + +function TSynDOTSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterDOT; +end; + +class function TSynDOTSyn.GetLanguageName: string; +begin + Result := SYNS_LangDOT; +end; + +procedure TSynDOTSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynDOTSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynDOTSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynDOTSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightereiffel.pas b/components/extrasyn/SyneditHighlighters/synhighlightereiffel.pas new file mode 100644 index 000000000..aed61a280 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightereiffel.pas @@ -0,0 +1,1423 @@ +{------------------------------------------------------------------------------- +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. + +Code template generated with SynGen. +The original code is: SynHighlighterEiffel.pas, released 2004-03-08. +Description: Eiffel Syntax Parser/Highlighter +The initial author of this file is Massimo Maria Ghisalberti (nissl). +Copyright (c) 2004, 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: SynHighlighterEiffel.pas,v 1.3 2004/07/31 16:20:08 markonjezic Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} +{ +@abstract(Provides an Eiffel highlighter for SynEdit) +@author(Massimo Maria Ghisalberti (nissl@mammuth.it, nissl@linee.it - www.linee.it) +@created(03-08-2004) +@lastmod(03-08-2004) +The SynHighlighterEiffel unit provides SynEdit with an Eiffel highlighter. +} +unit SynHighlighterEiffel; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = ( + tkBasicTypes, + tkComment, + tkIdentifier, + tkKey, + tkLace, + tkNull, + tkOperatorAndSymbols, + tkPredefined, + tkResultValue, + tkSpace, + tkString, + tkUnknown); + + TRangeState = (rsUnKnown, rsEiffelComment, rsString, rsOperatorAndSymbolProc); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function :TtkTokenKind of object; + +const + MaxKey = 144; + +type + TSynEiffelSyn = class(TSynCustomHighlighter) + private + fLineRef :string; + fLine :PChar; + fLineNumber :Integer; + fProcTable :array[#0..#255] of TProcTableProc; + fRange :TRangeState; + Run :LongInt; + fStringLen :Integer; + fToIdent :PChar; + fTokenPos :Integer; + fTokenID :TtkTokenKind; + fIdentFuncTable :array[0..MaxKey] of TIdentFuncTableFunc; + fBasicTypesAttri :TSynHighlighterAttributes; + fCommentAttri :TSynHighlighterAttributes; + fIdentifierAttri :TSynHighlighterAttributes; + fKeyAttri :TSynHighlighterAttributes; + fLaceAttri :TSynHighlighterAttributes; + fOperatorAndSymbolsAttri :TSynHighlighterAttributes; + fPredefinedAttri :TSynHighlighterAttributes; + fResultValueAttri :TSynHighlighterAttributes; + fSpaceAttri :TSynHighlighterAttributes; + fStringAttri :TSynHighlighterAttributes; + function KeyHash(ToHash :PChar) :Integer; + function KeyComp(const aKey :string) :Boolean; + function Func0 :TtkTokenKind; + function Func15 :TtkTokenKind; + function Func19 :TtkTokenKind; + function Func20 :TtkTokenKind; + function Func21 :TtkTokenKind; + function Func23 :TtkTokenKind; + function Func25 :TtkTokenKind; + function Func28 :TtkTokenKind; + function Func29 :TtkTokenKind; + function Func30 :TtkTokenKind; + function Func31 :TtkTokenKind; + function Func33 :TtkTokenKind; + function Func36 :TtkTokenKind; + function Func37 :TtkTokenKind; + function Func39 :TtkTokenKind; + function Func41 :TtkTokenKind; + function Func42 :TtkTokenKind; + function Func43 :TtkTokenKind; + function Func45 :TtkTokenKind; + function Func47 :TtkTokenKind; + function Func49 :TtkTokenKind; + function Func50 :TtkTokenKind; + function Func52 :TtkTokenKind; + function Func54 :TtkTokenKind; + function Func55 :TtkTokenKind; + function Func56 :TtkTokenKind; + function Func57 :TtkTokenKind; + function Func58 :TtkTokenKind; + function Func59 :TtkTokenKind; + function Func62 :TtkTokenKind; + function Func63 :TtkTokenKind; + function Func64 :TtkTokenKind; + function Func65 :TtkTokenKind; + function Func66 :TtkTokenKind; + function Func68 :TtkTokenKind; + function Func69 :TtkTokenKind; + function Func71 :TtkTokenKind; + function Func73 :TtkTokenKind; + function Func74 :TtkTokenKind; + function Func75 :TtkTokenKind; + function Func76 :TtkTokenKind; + function Func77 :TtkTokenKind; + function Func78 :TtkTokenKind; + function Func82 :TtkTokenKind; + function Func83 :TtkTokenKind; + function Func84 :TtkTokenKind; + function Func85 :TtkTokenKind; + function Func86 :TtkTokenKind; + function Func87 :TtkTokenKind; + function Func89 :TtkTokenKind; + function Func93 :TtkTokenKind; + function Func95 :TtkTokenKind; + function Func97 :TtkTokenKind; + function Func98 :TtkTokenKind; + function Func99 :TtkTokenKind; + function Func101 :TtkTokenKind; + function Func108 :TtkTokenKind; + function Func113 :TtkTokenKind; + function Func116 :TtkTokenKind; + function Func120 :TtkTokenKind; + function Func133 :TtkTokenKind; + function Func144 :TtkTokenKind; + procedure IdentProc; + procedure OperatorAndSymbolProc; + procedure UnknownProc; + function AltFunc :TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe :PChar) :TtkTokenKind; + procedure MakeMethodTables; + procedure NullProc; + procedure SpaceProc; + procedure CRProc; + procedure LFProc; + procedure EiffelCommentOpenProc; + procedure EiffelCommentProc; + procedure StringOpenProc; + procedure StringProc; + protected + function GetIdentChars :TSynIdentChars; override; + function GetSampleSource :string; override; + function IsFilterStored :Boolean; override; + public + constructor Create(AOwner :TComponent); override; + class function GetLanguageName :string; override; + function GetRange :Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value :Pointer); override; + function GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; override; + function GetEol :Boolean; override; + function GetKeyWords :string; + function GetTokenID :TtkTokenKind; + procedure SetLine(const NewValue :string; LineNumber :Integer); override; + function GetToken :string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute :TSynHighlighterAttributes; override; + function GetTokenKind :integer; override; + function GetTokenPos :Integer; override; + procedure Next; override; + published + property BasicTypesAttri :TSynHighlighterAttributes read fBasicTypesAttri write fBasicTypesAttri; + property CommentAttri :TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property IdentifierAttri :TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri :TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property LaceAttri :TSynHighlighterAttributes read fLaceAttri write fLaceAttri; + property OperatorAndSymbolsAttri :TSynHighlighterAttributes read fOperatorAndSymbolsAttri write fOperatorAndSymbolsAttri; + property PredefinedAttri :TSynHighlighterAttributes read fPredefinedAttri write fPredefinedAttri; + property ResultValueAttri :TSynHighlighterAttributes read fResultValueAttri write fResultValueAttri; + property SpaceAttri :TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri :TSynHighlighterAttributes read fStringAttri write fStringAttri; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +var + Identifiers :array[#0..#255] of ByteBool; + mHashTable :array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J :Char; +begin + for I := #0 to #255 do + begin + case I of + '_', 'a'..'z', 'A'..'Z' :Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'A'..'Z', 'a'..'z'] of + True :mHashTable[I] := Ord(J) - 64 + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynEiffelSyn.InitIdent; +var + I :Integer; + pF :PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[0] := @Func0; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[20] := @Func20; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[55] := @Func55; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[95] := @Func95; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[108] := @Func108; + fIdentFuncTable[113] := @Func113; + fIdentFuncTable[116] := @Func116; + fIdentFuncTable[120] := @Func120; + fIdentFuncTable[133] := @Func133; + fIdentFuncTable[144] := @Func144; +end; + +function TSynEiffelSyn.KeyHash(ToHash :PChar) :Integer; +begin + Result := 0; + while ToHash^ in ['_', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynEiffelSyn.KeyComp(const aKey :string) :Boolean; +var + I :Integer; + Temp :PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else + Result := False; +end; + +function TSynEiffelSyn.Func0 :TtkTokenKind; +begin + if KeyComp('@') then + Result := tkOperatorAndSymbols + else + if KeyComp(']') then + Result := tkOperatorAndSymbols + else + if KeyComp('*') then + Result := tkOperatorAndSymbols + else + if KeyComp('&') then + Result := tkOperatorAndSymbols + else + if KeyComp('|') then + Result := tkOperatorAndSymbols + else + if KeyComp('#') then + Result := tkOperatorAndSymbols + else + if KeyComp('.') then + Result := tkOperatorAndSymbols + else + if KeyComp('=') then + Result := tkOperatorAndSymbols + else + if KeyComp('(') then + Result := tkOperatorAndSymbols + else + if KeyComp('/') then + Result := tkOperatorAndSymbols + else + if KeyComp('[') then + Result := tkOperatorAndSymbols + else + if KeyComp('\\') then + Result := tkOperatorAndSymbols + else + if KeyComp('$') then + Result := tkOperatorAndSymbols + else + if KeyComp('<') then + Result := tkOperatorAndSymbols + else + if KeyComp(':=') then + Result := tkOperatorAndSymbols + else + if KeyComp('^') then + Result := tkOperatorAndSymbols + else + if KeyComp('!') then + Result := tkOperatorAndSymbols + else + if KeyComp('<>') then + Result := tkOperatorAndSymbols + else + if KeyComp('>') then + Result := tkOperatorAndSymbols + else + if KeyComp('+') then + Result := tkOperatorAndSymbols + else + if KeyComp('/=') then + Result := tkOperatorAndSymbols + else + if KeyComp('//') then + Result := tkOperatorAndSymbols + else + if KeyComp(':') then + Result := tkOperatorAndSymbols + else + if KeyComp(';') then + Result := tkOperatorAndSymbols + else + if KeyComp('-') then + Result := tkOperatorAndSymbols + else + if KeyComp(')') then + Result := tkOperatorAndSymbols + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func15 :TtkTokenKind; +begin + if KeyComp('if') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func19 :TtkTokenKind; +begin + if KeyComp('do') then + Result := tkKey + else + if KeyComp('and') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func20 :TtkTokenKind; +begin + if KeyComp('as') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func21 :TtkTokenKind; +begin + if KeyComp('%U') then + Result := tkPredefined + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func23 :TtkTokenKind; +begin + if KeyComp('end') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func25 :TtkTokenKind; +begin + if KeyComp('all') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func28 :TtkTokenKind; +begin + if KeyComp('is') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func29 :TtkTokenKind; +begin + if KeyComp('no') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func30 :TtkTokenKind; +begin + if KeyComp('check') then + Result := tkKey + else + if KeyComp('make') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func31 :TtkTokenKind; +begin + if KeyComp('old') then + Result := tkKey + else + if KeyComp('BIT') then + Result := tkPredefined + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func33 :TtkTokenKind; +begin + if KeyComp('or') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func36 :TtkTokenKind; +begin + if KeyComp('real') then + Result := tkBasicTypes + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func37 :TtkTokenKind; +begin + if KeyComp('like') then + Result := tkKey + else + if KeyComp('once') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func39 :TtkTokenKind; +begin + if KeyComp('debug') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func41 :TtkTokenKind; +begin + if KeyComp('else') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func42 :TtkTokenKind; +begin + if KeyComp('alias') then + Result := tkKey + else + if KeyComp('adapt') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func43 :TtkTokenKind; +begin + if KeyComp('local') then + Result := tkKey + else + if KeyComp('false') then + Result := tkPredefined + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func45 :TtkTokenKind; +begin + if KeyComp('comma') then + Result := tkLace + else + if KeyComp('use') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func47 :TtkTokenKind; +begin + if KeyComp('trace') then + Result := tkLace + else + if KeyComp('then') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func49 :TtkTokenKind; +begin + if KeyComp('yes') then + Result := tkLace + else + if KeyComp('not') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func50 :TtkTokenKind; +begin + if KeyComp('void') then + Result := tkPredefined + else + if KeyComp('when') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func52 :TtkTokenKind; +begin + if KeyComp('from') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func54 :TtkTokenKind; +begin + if KeyComp('class') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func55 :TtkTokenKind; +begin + if KeyComp('object') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func56 :TtkTokenKind; +begin + if KeyComp('rename') then + Result := tkKey + else + if KeyComp('elseif') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func57 :TtkTokenKind; +begin + if KeyComp('xor') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func58 :TtkTokenKind; +begin + if KeyComp('loop') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func59 :TtkTokenKind; +begin + if KeyComp('double') then + Result := tkBasicTypes + else + if KeyComp('colon') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func62 :TtkTokenKind; +begin + if KeyComp('infix') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func63 :TtkTokenKind; +begin + if KeyComp('Array') then + Result := tkBasicTypes + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func64 :TtkTokenKind; +begin + if KeyComp('boolean') then + Result := tkBasicTypes + else + if KeyComp('true') then + Result := tkPredefined + else + if KeyComp('select') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func65 :TtkTokenKind; +begin + if KeyComp('deferred') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func66 :TtkTokenKind; +begin + if KeyComp('redefine') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func68 :TtkTokenKind; +begin + if KeyComp('include') then + Result := tkLace + else + if KeyComp('root') then + Result := tkLace + else + if KeyComp('ignore') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func69 :TtkTokenKind; +begin + if KeyComp('default') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func71 :TtkTokenKind; +begin + if KeyComp('rescue') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func73 :TtkTokenKind; +begin + if KeyComp('expanded') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func74 :TtkTokenKind; +begin + if KeyComp('exclude') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func75 :TtkTokenKind; +begin + if KeyComp('generate') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func76 :TtkTokenKind; +begin + if KeyComp('until') then + Result := tkKey + else + if KeyComp('feature') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func77 :TtkTokenKind; +begin + if KeyComp('character') then + Result := tkBasicTypes + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func78 :TtkTokenKind; +begin + if KeyComp('undefine') then + Result := tkKey + else + if KeyComp('prefix') then + Result := tkKey + else + if KeyComp('integer') then + Result := tkBasicTypes + else + if KeyComp('visible') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func82 :TtkTokenKind; +begin + if KeyComp('ensure') then + Result := tkKey + else + if KeyComp('strip') then + Result := tkPredefined + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func83 :TtkTokenKind; +begin + if KeyComp('inherit') then + Result := tkKey + else + if KeyComp('implies') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func84 :TtkTokenKind; +begin + if KeyComp('frozen') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func85 :TtkTokenKind; +begin + if KeyComp('variant') then + Result := tkKey + else + if KeyComp('creation') then + Result := tkKey + else + if KeyComp('separate') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func86 :TtkTokenKind; +begin + if KeyComp('retry') then + Result := tkKey + else + if KeyComp('inspect') then + Result := tkKey + else + if KeyComp('indexing') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func87 :TtkTokenKind; +begin + if KeyComp('string') then + Result := tkBasicTypes + else + if KeyComp('unique') then + Result := tkPredefined + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func89 :TtkTokenKind; +begin + if KeyComp('option') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func93 :TtkTokenKind; +begin + if KeyComp('require') then + Result := tkKey + else + if KeyComp('obsolete') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func95 :TtkTokenKind; +begin + if KeyComp('result') then + Result := tkResultValue + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func97 :TtkTokenKind; +begin + if KeyComp('pointer') then + Result := tkBasicTypes + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func98 :TtkTokenKind; +begin + if KeyComp('cluster') then + Result := tkLace + else + if KeyComp('executable') then + Result := tkLace + else + if KeyComp('export') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func99 :TtkTokenKind; +begin + if KeyComp('external') then + Result := tkKey + else + if KeyComp('current') then + Result := tkPredefined + else + if KeyComp('identifier') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func101 :TtkTokenKind; +begin + if KeyComp('system') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func108 :TtkTokenKind; +begin + if KeyComp('invariant') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func113 :TtkTokenKind; +begin + if KeyComp('optimize') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func116 :TtkTokenKind; +begin + if KeyComp('precompiled') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func120 :TtkTokenKind; +begin + if KeyComp('assertion') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func133 :TtkTokenKind; +begin + if KeyComp('precursor') then + Result := tkPredefined + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.Func144 :TtkTokenKind; +begin + if KeyComp('include_path') then + Result := tkLace + else + Result := tkIdentifier; +end; + +function TSynEiffelSyn.AltFunc :TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynEiffelSyn.IdentKind(MayBe :PChar) :TtkTokenKind; +var + HashKey :Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey <= MaxKey then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynEiffelSyn.MakeMethodTables; +var + I :Char; +begin + for I := #0 to #255 do + case I of + #33, #35..#44, #46..#47, #58..#64, #91..#96, #123..#127: + fProcTable[I] := @OperatorAndSymbolProc; + #0: fProcTable[I] := @NullProc; + #10: fProcTable[I] := @LFProc; + #13: fProcTable[I] := @CRProc; + '-': fProcTable[I] := @EiffelCommentOpenProc; + '"': fProcTable[I] := @StringOpenProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + 'A'..'Z', 'a'..'z': fProcTable[I] := @IdentProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +procedure TSynEiffelSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + inc(Run); + until not (fLine[Run] in [#1..#32]); +end; + +procedure TSynEiffelSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynEiffelSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then + inc(Run); +end; + +procedure TSynEiffelSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynEiffelSyn.OperatorAndSymbolProc; +begin + fTokenID := tkIdentifier; + if fLine[Run] = #33 then + begin + fRange := rsOperatorAndSymbolProc; + fTokenID := tkOperatorAndSymbols; + Inc(Run); + Exit; + end; + if fLine[Run] in [#35..#44] then + begin + fRange := rsOperatorAndSymbolProc; + fTokenID := tkOperatorAndSymbols; + Inc(Run); + Exit; + end; + if fLine[Run] in [#46..#47] then + begin + fRange := rsOperatorAndSymbolProc; + fTokenID := tkOperatorAndSymbols; + Inc(Run); + Exit; + end; + if fLine[Run] in [#58..#64] then + begin + fRange := rsOperatorAndSymbolProc; + fTokenID := tkOperatorAndSymbols; + Inc(Run); + Exit; + end; + if fLine[Run] in [#91..#96] then + begin + fRange := rsOperatorAndSymbolProc; + fTokenID := tkOperatorAndSymbols; + Inc(Run); + Exit; + end; + if fLine[Run] in [#123..#127] then + begin + fRange := rsOperatorAndSymbolProc; + fTokenID := tkOperatorAndSymbols; + Inc(Run); + Exit; + end; +end; + +procedure TSynEiffelSyn.EiffelCommentOpenProc; +begin + Inc(Run); + if (fLine[Run - 1] = '-') and (fLine[Run] = '-') then + begin + fRange := rsEiffelComment; + EiffelCommentProc; + fTokenID := tkComment; + end + else + fTokenID := tkOperatorAndSymbols; +end; + +procedure TSynEiffelSyn.EiffelCommentProc; +begin + fTokenID := tkComment; + repeat + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynEiffelSyn.StringOpenProc; +begin + Inc(Run); + fRange := rsString; + StringProc; + fTokenID := tkString; +end; + +procedure TSynEiffelSyn.StringProc; +begin + fTokenID := tkString; + repeat + if (fLine[Run] = '"') then + begin + Inc(Run, 1); + fRange := rsUnKnown; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +constructor TSynEiffelSyn.Create(AOwner :TComponent); +begin + inherited Create(AOwner); + fBasicTypesAttri := TSynHighLighterAttributes.Create(SYNS_AttrBasicTypes); + fBasicTypesAttri.Style := [fsBold]; + fBasicTypesAttri.Foreground := clBlue; + AddAttribute(fBasicTypesAttri); + + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + fCommentAttri.Foreground := clTeal; + AddAttribute(fCommentAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + fIdentifierAttri.Foreground := clMaroon; + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + fKeyAttri.Foreground := clNavy; + AddAttribute(fKeyAttri); + + fLaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrLace); + fLaceAttri.Style := [fsBold]; + fLaceAttri.Foreground := clNavy; + AddAttribute(fLaceAttri); + + fOperatorAndSymbolsAttri := TSynHighLighterAttributes.Create(SYNS_AttrOperatorAndSymbols); + fOperatorAndSymbolsAttri.Style := [fsBold]; + fOperatorAndSymbolsAttri.Foreground := clOlive; + AddAttribute(fOperatorAndSymbolsAttri); + + fPredefinedAttri := TSynHighLighterAttributes.Create(SYNS_AttrPredefined); + fPredefinedAttri.Style := [fsBold]; + fPredefinedAttri.Foreground := clRed; + AddAttribute(fPredefinedAttri); + + fResultValueAttri := TSynHighLighterAttributes.Create(SYNS_AttrResultValue); + fResultValueAttri.Style := [fsBold]; + fResultValueAttri.Foreground := clPurple; + AddAttribute(fResultValueAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString); + fStringAttri.Style := [fsItalic]; + fStringAttri.Foreground := clGray; + AddAttribute(fStringAttri); + + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterEiffel; + fRange := rsUnknown; +end; + +procedure TSynEiffelSyn.SetLine(const NewValue :string; LineNumber :Integer); +begin + fLineRef := NewValue; + fLine := PChar(fLineRef); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynEiffelSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + Inc(Run); +end; + +procedure TSynEiffelSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynEiffelSyn.Next; +begin + fTokenPos := Run; + fRange := rsUnknown; + fProcTable[fLine[Run]]; +end; + +function TSynEiffelSyn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT :Result := fCommentAttri; + SYN_ATTR_IDENTIFIER :Result := fIdentifierAttri; + SYN_ATTR_KEYWORD :Result := fKeyAttri; + SYN_ATTR_STRING :Result := fStringAttri; + SYN_ATTR_WHITESPACE :Result := fSpaceAttri; + else + Result := nil; + end; +end; + +function TSynEiffelSyn.GetEol :Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynEiffelSyn.GetKeyWords :string; +begin + Result := + '-,!,#,$,%U,&,(,),*,.,/,//,/=,:,:=,;,@,[,\\,],^,|,+,<,<>,=,>,adapt,ali' + + 'as,all,and,Array,as,assertion,BIT,boolean,character,check,class,cluste' + + 'r,colon,comma,creation,current,debug,default,deferred,do,double,else,e' + + 'lseif,end,ensure,exclude,executable,expanded,export,external,false,fea' + + 'ture,from,frozen,generate,identifier,if,ignore,implies,include,include' + + '_path,indexing,infix,inherit,inspect,integer,invariant,is,like,local,l' + + 'oop,make,no,not,object,obsolete,old,once,optimize,option,or,pointer,pr' + + 'ecompiled,precursor,prefix,real,redefine,rename,require,rescue,result,' + + 'retry,root,select,separate,string,strip,system,then,trace,true,undefin' + + 'e,unique,until,use,variant,visible,void,when,xor,yes'; +end; + +function TSynEiffelSyn.GetToken :string; +var + Len :LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynEiffelSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynEiffelSyn.GetTokenID :TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynEiffelSyn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkBasicTypes :Result := fBasicTypesAttri; + tkComment :Result := fCommentAttri; + tkIdentifier :Result := fIdentifierAttri; + tkKey :Result := fKeyAttri; + tkLace :Result := fLaceAttri; + tkOperatorAndSymbols :Result := fOperatorAndSymbolsAttri; + tkPredefined :Result := fPredefinedAttri; + tkResultValue :Result := fResultValueAttri; + tkSpace :Result := fSpaceAttri; + tkString :Result := fStringAttri; + tkUnknown :Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynEiffelSyn.GetTokenKind :integer; +begin + Result := Ord(fTokenId); +end; + +function TSynEiffelSyn.GetTokenPos :Integer; +begin + Result := fTokenPos; +end; + +function TSynEiffelSyn.GetIdentChars :TSynIdentChars; +begin + Result := ['_', 'a'..'z', 'A'..'Z']; +end; + +function TSynEiffelSyn.GetSampleSource :string; +begin + Result := '-- Eiffel sample source from SmartEiffel'#13#10 + + 'class FIBONACCI'#13#10 + + '-- Eiffel comment'#13#10 + + 'creation make'#13#10 + + #13#10 + + 'feature'#13#10 + + #13#10 + + ' make is'#13#10 + + ' do'#13#10 + + ' if argument_count /= 1 or else'#13#10 + + ' not argument(1).is_integer'#13#10 + + ' then'#13#10 + + ' io.put_string("Usage: ");'#13#10 + + ' io.put_string(argument(0));'#13#10 + + ' io.put_string(" %N");'#13#10 + + ' die_with_code(exit_failure_code);'#13#10 + + ' end;'#13#10 + + ' io.put_integer(fibonacci(argument(1).to_integer));'#13#10 + + ' io.put_new_line;'#13#10 + + ' end;'#13#10 + + ' -- Eiffel comment'#13#10 + + ' fibonacci(i: INTEGER): INTEGER is'#13#10 + + ' require -- Eiffel comment'#13#10 + + ' i >= 0'#13#10 + + ' do'#13#10 + + ' if i = 0 then'#13#10 + + ' Result := 1;'#13#10 + + ' elseif i = 1 then'#13#10 + + ' Result := 1;'#13#10 + + ' else'#13#10 + + ' Result := fibonacci(i - 1) + fibonacci(i - 2) ;'#13#10 + + ' end;'#13#10 + + ' end;'#13#10 + + #13#10 + + 'end'; +end; + +function TSynEiffelSyn.IsFilterStored :Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterEiffel; +end; + +class function TSynEiffelSyn.GetLanguageName :string; +begin + Result := SYNS_LangEiffel; +end; + +procedure TSynEiffelSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynEiffelSyn.SetRange(Value :Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynEiffelSyn.GetRange :Pointer; +begin + Result := Pointer(fRange); +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynEiffelSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterfortran.pas b/components/extrasyn/SyneditHighlighters/synhighlighterfortran.pas new file mode 100644 index 000000000..03cdce0cc --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterfortran.pas @@ -0,0 +1,979 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterFortran.pas, released 2000-04-21. +The Original Code is based on the mwFortranSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is "riceball". +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: SynHighlighterFortran.pas,v 1.16 2005/01/28 16:53:22 maelh Exp $ + +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 Fortran syntax highlighter for SynEdit) +@author(riceball , converted to SynEdit by Bruno Mikkelsen ) +@created(2000, converted to SynEdit 2000-04-21) +@lastmod(2000-06-23) +The SynHighlighterFortran unit provides SynEdit with a Fortran syntax highlighter. +Thanks to Martin Waldenburg. +} +unit SynHighlighterFortran; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, + tkString, tkSymbol, tkUnknown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynFortranSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fIdentFuncTable: array[0..145] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func15: TtkTokenKind; + function Func19: TtkTokenKind; + function Func23: TtkTokenKind; + function Func26: TtkTokenKind; + function Func28: TtkTokenKind; + function Func30: TtkTokenKind; + function Func36: TtkTokenKind; + function Func38: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func50: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func61: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func66: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func73: TtkTokenKind; + function Func75: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func84: TtkTokenKind; + function Func88: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func99: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func114: TtkTokenKind; + function Func127: TtkTokenKind; + function Func144: TtkTokenKind; + function Func145: TtkTokenKind; + procedure AsciiCharProc; + procedure CRProc; + procedure CommaProc; + procedure EqualProc; + procedure ExclamationProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure PlusProc; + procedure PointProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure StarProc; + procedure StringProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure CommentProc; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I in ['_', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynFortranSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[61] := @Func61; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[114] := @Func114; + fIdentFuncTable[127] := @Func127; + fIdentFuncTable[144] := @Func144; + fIdentFuncTable[145] := @Func145; +end; + +function TSynFortranSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynFortranSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynFortranSyn.Func15: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func19: TtkTokenKind; +begin + if KeyComp('do') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func23: TtkTokenKind; +begin + if KeyComp('end') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func26: TtkTokenKind; +begin + if KeyComp('data') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func28: TtkTokenKind; +begin + if KeyComp('call') then Result := tkKey else + if KeyComp('case') then Result := tkKey else + if KeyComp('read') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func30: TtkTokenKind; +begin + if KeyComp('map') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func36: TtkTokenKind; +begin + if KeyComp('real') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func38: TtkTokenKind; +begin + if KeyComp('endif') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func41: TtkTokenKind; +begin + if KeyComp('else') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func42: TtkTokenKind; +begin + if KeyComp('enddo') then Result := tkKey else + if KeyComp('enddo') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func47: TtkTokenKind; +begin + if KeyComp('then') then Result := tkKey else + if KeyComp('save') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func48: TtkTokenKind; +begin + if KeyComp('cycle') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func50: TtkTokenKind; +begin + if KeyComp('open') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func56: TtkTokenKind; +begin + if KeyComp('elseif') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func57: TtkTokenKind; +begin + if KeyComp('while') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func58: TtkTokenKind; +begin + if KeyComp('exit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func59: TtkTokenKind; +begin + if KeyComp('logical') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func61: TtkTokenKind; +begin + if KeyComp('value') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func63: TtkTokenKind; +begin + if KeyComp('record') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func64: TtkTokenKind; +begin + if KeyComp('select') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func66: TtkTokenKind; +begin + if KeyComp('type') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func68: TtkTokenKind; +begin + if KeyComp('include') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func69: TtkTokenKind; +begin + if KeyComp('allocate') then Result := tkKey else + if KeyComp('default') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func70: TtkTokenKind; +begin + if KeyComp('stop') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func73: TtkTokenKind; +begin + if KeyComp('union') then Result := tkKey else + if KeyComp('common') then Result := tkKey else + if KeyComp('format') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func75: TtkTokenKind; +begin + if KeyComp('write') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func77: TtkTokenKind; +begin + if KeyComp('character') then Result := tkKey else + if KeyComp('print') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func78: TtkTokenKind; +begin + if KeyComp('integer') then Result := tkKey else + if KeyComp('deallocate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func81: TtkTokenKind; +begin + if KeyComp('interface') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func82: TtkTokenKind; +begin + if KeyComp('entry') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func84: TtkTokenKind; +begin + if KeyComp('allocatable') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func88: TtkTokenKind; +begin + if KeyComp('program') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func96: TtkTokenKind; +begin + if KeyComp('return') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func97: TtkTokenKind; +begin + if KeyComp('parameter') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func99: TtkTokenKind; +begin + if KeyComp('external') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func101: TtkTokenKind; +begin + if KeyComp('continue') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func102: TtkTokenKind; +begin + if KeyComp('function') then Result := tkKey else + if KeyComp('dimension') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func114: TtkTokenKind; +begin + if KeyComp('equivalence') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func127: TtkTokenKind; +begin + if KeyComp('stucture') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func144: TtkTokenKind; +begin + if KeyComp('subroutine') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.Func145: TtkTokenKind; +begin + if KeyComp('structure') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFortranSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynFortranSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 146 then Result := fIdentFuncTable[HashKey]() else Result := tkIdentifier; +end; + +procedure TSynFortranSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #39: fProcTable[I] := @AsciiCharProc; + #13: fProcTable[I] := @CRProc; + ',': fProcTable[I] := @CommaProc; + '=': fProcTable[I] := @EqualProc; + '!': fProcTable[I] := @ExclamationProc; + '>': fProcTable[I] := @GreaterProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @LowerProc; + '-': fProcTable[I] := @MinusProc; + '%': fProcTable[I] := @ModSymbolProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + '+': fProcTable[I] := @PlusProc; + '.': fProcTable[I] := @PointProc; + ')': fProcTable[I] := @RoundCloseProc; + '(': fProcTable[I] := @RoundOpenProc; + ';': fProcTable[I] := @SemiColonProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + '*': fProcTable[I] := @StarProc; + #34: fProcTable[I] := @StringProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynFortranSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterFortran; +end; + +procedure TSynFortranSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynFortranSyn.AsciiCharProc; +begin + fTokenID := tkString; + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynFortranSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then Inc(Run); +end; + +procedure TSynFortranSyn.CommaProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.EqualProc; +begin + case FLine[Run + 1] of + '=': {logical equal} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {assign} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynFortranSyn.ExclamationProc; +begin + inc(Run, 1); {Fortran Comments} + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; +end; + +procedure TSynFortranSyn.GreaterProc; +begin + Case FLine[Run + 1] of + '=': {greater than or equal to} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + inc(Run, 3) + else {shift right} + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {greater than} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynFortranSyn.IdentProc; +begin + if (FLine[Run] in ['C', 'c']) and (Run = 0) then + begin //Fortran comments + inc(Run, 1); + CommentProc; + end + else begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); + end; +end; + +procedure TSynFortranSyn.LFProc; +begin + inc(Run); + fTokenID := tkSpace; +end; + +procedure TSynFortranSyn.LowerProc; +begin + case FLine[Run + 1] of + '=': {less than or equal to} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + inc(Run, 3) + else {shift left} + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {less than} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynFortranSyn.MinusProc; +begin + {subtract} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.ModSymbolProc; +begin + {mod} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynFortranSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', '.', 'x', 'X', 'e', 'E', 'f', 'F'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynFortranSyn.PlusProc; +begin + {subtract} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.PointProc; +begin + if (((UpCase(FLine[Run + 1]) = 'G') and (UpCase(FLine[Run + 2]) in ['E','T'])) {.ge. .gt.} + or ((UpCase(FLine[Run + 1]) = 'L') and (UpCase(FLine[Run + 2]) in ['E','T'])) {.le. .lt.} + or ((UpCase(FLine[Run + 1]) = 'N') and (UpCase(FLine[Run + 2]) = 'E')) {.ne.} + or ((UpCase(FLine[Run + 1]) = 'E') and (UpCase(FLine[Run + 2]) = 'Q')) {.eq.} + or ((UpCase(FLine[Run + 1]) = 'O') and (UpCase(FLine[Run + 2]) = 'R'))){.or.} + and (FLine[Run + 3] = '.') then + begin + inc(Run, 4); + fTokenID := tkSymbol; + end + else if (((UpCase(FLine[Run + 1]) = 'A') + and (UpCase(FLine[Run + 2]) = 'N') + and (UpCase(FLine[Run + 3]) = 'D')) {.and.} + or ((UpCase(FLine[Run + 1]) = 'N') + and (UpCase(FLine[Run + 2]) = 'O') + and (UpCase(FLine[Run + 3]) = 'T'))) {.not.} + and (FLine[Run + 4] = '.') then + begin + inc(Run, 5); + fTokenID := tkSymbol; + end + else if (UpCase(FLine[Run + 1]) = 'T') + and (UpCase(FLine[Run + 2]) = 'R') + and (UpCase(FLine[Run + 3]) = 'U') + and (UpCase(FLine[Run + 4]) = 'E') + and (FLine[Run + 5] = '.') then {.true.} + begin + inc(Run, 6); + fTokenID := tkSymbol; + end + else if (UpCase(FLine[Run + 1]) = 'F') + and (UpCase(FLine[Run + 2]) = 'A') + and (UpCase(FLine[Run + 3]) = 'L') + and (UpCase(FLine[Run + 4]) = 'S') + and (UpCase(FLine[Run + 5]) = 'E') + and (FLine[Run + 6] = '.') then {.false.} + begin + inc(Run, 7); + fTokenID := tkSymbol; + end + else {point} + begin + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynFortranSyn.RoundCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.RoundOpenProc; +begin + inc(Run); + FTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.SemiColonProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.SlashProc; +begin + {division} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFortranSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynFortranSyn.StarProc; +begin + if (Run = 0) then begin //Fortran comments + inc(Run); + CommentProc; + end + else begin + {star} + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynFortranSyn.CommentProc; +begin + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; //case + inc(Run); + end; //while +end; + +procedure TSynFortranSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + #92: + if FLine[Run + 1] = #10 then inc(Run); + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynFortranSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynFortranSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynFortranSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynFortranSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynFortranSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynFortranSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength:=Run-fTokenPos; + TokenStart:=FLine + fTokenPos; +end; +{$ENDIF} + +function TSynFortranSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynFortranSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynFortranSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynFortranSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynFortranSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynFortranSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterFortran; +end; + +class function TSynFortranSyn.GetLanguageName: string; +begin + Result := SYNS_LangFortran; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynFortranSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterfoxpro.pas b/components/extrasyn/SyneditHighlighters/synhighlighterfoxpro.pas new file mode 100644 index 000000000..e84f673ab --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterfoxpro.pas @@ -0,0 +1,1587 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterFoxpro.pas, released 2000-04-21. +The Original Code is based on the mwFoxproSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is "riceball". +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: SynHighlighterFoxpro.pas,v 1.13 2005/01/28 16:53:22 maelh Exp $ + +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 Foxpro Syntax highlighter for SynEdit) +@author(riceball , converted to SynEdit by Bruno Mikkelsen ) +@created(2000, converted to SynEdit 2000-04-21) +@lastmod(2000-06-23) +The SynHighlighterFoxpro unit provides SynEdit with a Foxpro syntax highlighter. +Thanks to Martin Waldenburg. +} +unit SynHighlighterFoxpro; + +{$I synedit.inc} + +interface + +uses + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, + tkString, tkSymbol, tkUnknown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynFoxproSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fIdentFuncTable: array[0..160] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func15: TtkTokenKind; + function Func19: TtkTokenKind; + function Func21: TtkTokenKind; + function Func22: TtkTokenKind; + function Func23: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func27: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func46: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func85: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func91: TtkTokenKind; + function Func94: TtkTokenKind; + function Func95: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func98: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func104: TtkTokenKind; + function Func105: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func112: TtkTokenKind; + function Func113: TtkTokenKind; + function Func114: TtkTokenKind; + function Func116: TtkTokenKind; + function Func117: TtkTokenKind; + function Func118: TtkTokenKind; + function Func119: TtkTokenKind; + function Func120: TtkTokenKind; + function Func122: TtkTokenKind; + function Func127: TtkTokenKind; + function Func131: TtkTokenKind; + function Func133: TtkTokenKind; + function Func135: TtkTokenKind; + function Func160: TtkTokenKind; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure AtSymbolProc; + procedure BraceOpenProc; + procedure CRProc; + procedure ColonProc; + procedure CommaProc; + procedure EqualProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NotSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure QuestionProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure StarProc; + procedure StringProc; + procedure TildeProc; + procedure XOrSymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I in ['_', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynFoxproSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[27] := @Func27; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[44] := @Func44; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[46] := @Func46; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[55] := @Func55; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[61] := @Func61; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[66] := @Func66; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[75] := @Func75; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[90] := @Func90; + fIdentFuncTable[91] := @Func91; + fIdentFuncTable[94] := @Func94; + fIdentFuncTable[95] := @Func95; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[100] := @Func100; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[104] := @Func104; + fIdentFuncTable[105] := @Func105; + fIdentFuncTable[106] := @Func106; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[108] := @Func108; + fIdentFuncTable[110] := @Func110; + fIdentFuncTable[111] := @Func111; + fIdentFuncTable[112] := @Func112; + fIdentFuncTable[113] := @Func113; + fIdentFuncTable[114] := @Func114; + fIdentFuncTable[116] := @Func116; + fIdentFuncTable[117] := @Func117; + fIdentFuncTable[118] := @Func118; + fIdentFuncTable[119] := @Func119; + fIdentFuncTable[120] := @Func120; + fIdentFuncTable[122] := @Func122; + fIdentFuncTable[127] := @Func127; + fIdentFuncTable[131] := @Func131; + fIdentFuncTable[133] := @Func133; + fIdentFuncTable[135] := @Func135; + fIdentFuncTable[160] := @Func160; +end; + +function TSynFoxproSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynFoxproSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynFoxproSyn.Func15: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func19: TtkTokenKind; +begin + if KeyComp('do') then Result := tkKey else + if KeyComp('and') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func21: TtkTokenKind; +begin + if KeyComp('at') then Result := tkKey else + if KeyComp('bar') then Result := tkKey else + if KeyComp('of') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func22: TtkTokenKind; +begin + if KeyComp('go') then Result := tkKey else + if KeyComp('abs') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func23: TtkTokenKind; +begin + if KeyComp('bof') then Result := tkKey else + if KeyComp('asc') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func25: TtkTokenKind; +begin + if KeyComp('all') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func26: TtkTokenKind; +begin + if KeyComp('dele') then Result := tkKey else + if KeyComp('eof') then Result := tkKey else + if KeyComp('dim') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func27: TtkTokenKind; +begin + if KeyComp('rgb') then Result := tkKey else + if KeyComp('off') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func28: TtkTokenKind; +begin + if KeyComp('tag') then Result := tkKey else + if KeyComp('read') then Result := tkKey else + if KeyComp('call') then Result := tkKey else + if KeyComp('case') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func29: TtkTokenKind; +begin + if KeyComp('on') then Result := tkKey else + if KeyComp('blan') then Result := tkKey else + if KeyComp('chr') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func30: TtkTokenKind; +begin + if KeyComp('date') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func31: TtkTokenKind; +begin + if KeyComp('echo') then Result := tkKey else + if KeyComp('bell') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func32: TtkTokenKind; +begin + if KeyComp('get') then Result := tkKey else + if KeyComp('again') then Result := tkKey else + if KeyComp('file') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func33: TtkTokenKind; +begin + if KeyComp('acti') then Result := tkKey else + if KeyComp('or') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func35: TtkTokenKind; +begin + if KeyComp('val') then Result := tkKey else + if KeyComp('to') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func36: TtkTokenKind; +begin + if KeyComp('para') then Result := tkKey else + if KeyComp('gath') then Result := tkKey else + if KeyComp('rela') then Result := tkKey else + if KeyComp('field') then Result := tkKey else + if KeyComp('atan') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func37: TtkTokenKind; +begin + if KeyComp('begin') then Result := tkKey else + if KeyComp('scan') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func38: TtkTokenKind; +begin + if KeyComp('appe') then Result := tkKey else + if KeyComp('endif') then Result := tkKey else + if KeyComp('cancel') then Result := tkKey else + if KeyComp('near') then Result := tkKey else + if KeyComp('edit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func39: TtkTokenKind; +begin + if KeyComp('fill') then Result := tkKey else + if KeyComp('for') then Result := tkKey else + if KeyComp('clear') then Result := tkKey else + if KeyComp('debug') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func40: TtkTokenKind; +begin + if KeyComp('table') then Result := tkKey else + if KeyComp('blank') then Result := tkKey else + if KeyComp('seek') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func41: TtkTokenKind; +begin + if KeyComp('else') then Result := tkKey else + if KeyComp('help') then Result := tkKey else + if KeyComp('modi') then Result := tkKey else + if KeyComp('box') then Result := tkKey else + if KeyComp('lock') then Result := tkKey else + if KeyComp('key') then Result := tkKey else + if KeyComp('sele') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func42: TtkTokenKind; +begin + if KeyComp('enddo') then Result := tkKey else + if KeyComp('alias') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func43: TtkTokenKind; +begin + if KeyComp('define') then Result := tkKey else + if KeyComp('scat') then Result := tkKey else + if KeyComp('local') then Result := tkKey else + if KeyComp('mark') then Result := tkKey else + if KeyComp('ansi') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func44: TtkTokenKind; +begin + if KeyComp('set') then Result := tkKey else + if KeyComp('clock') then Result := tkKey else + if KeyComp('func') then Result := tkKey else + if KeyComp('comm') then Result := tkKey else + if KeyComp('talk') then Result := tkKey else + if KeyComp('space') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func45: TtkTokenKind; +begin + if KeyComp('modal') then Result := tkKey else + if KeyComp('use') then Result := tkKey else + if KeyComp('say') then Result := tkKey else + if KeyComp('path') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func46: TtkTokenKind; +begin + if KeyComp('memo') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func48: TtkTokenKind; +begin + if KeyComp('blink') then Result := tkKey else + if KeyComp('accept') then Result := tkKey else + if KeyComp('build') then Result := tkKey else + if KeyComp('device') then Result := tkKey else + if KeyComp('fixed') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func49: TtkTokenKind; +begin + if KeyComp('escape') then Result := tkKey else + if KeyComp('not') then Result := tkKey else + if KeyComp('year') then Result := tkKey else + if KeyComp('clos') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func51: TtkTokenKind; +begin + if KeyComp('top') then Result := tkKey else + if KeyComp('repl') then Result := tkKey else + if KeyComp('delete') then Result := tkKey else + if KeyComp('files') then Result := tkKey else + if KeyComp('endcase') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func52: TtkTokenKind; +begin + if KeyComp('create') then Result := tkKey else + if KeyComp('from') then Result := tkKey else + if KeyComp('repla') then Result := tkKey else + if KeyComp('proc') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func53: TtkTokenKind; +begin + if KeyComp('wait') then Result := tkKey else + if KeyComp('exact') then Result := tkKey else + if KeyComp('menu') then Result := tkKey else + if KeyComp('scheme') then Result := tkKey else + if KeyComp('database') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func54: TtkTokenKind; +begin + if KeyComp('class') then Result := tkKey else + if KeyComp('close') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func55: TtkTokenKind; +begin + if KeyComp('recno') then Result := tkKey else + if KeyComp('deleted') then Result := tkKey else + if KeyComp('skip') then Result := tkKey else + if KeyComp('fields') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func56: TtkTokenKind; +begin + if KeyComp('index') then Result := tkKey else + if KeyComp('append') then Result := tkKey else + if KeyComp('fopen') then Result := tkKey else + if KeyComp('this') then Result := tkKey else + if KeyComp('locate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func57: TtkTokenKind; +begin + if KeyComp('while') then Result := tkKey else + if KeyComp('bott') then Result := tkKey else + if KeyComp('str') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func58: TtkTokenKind; +begin + if KeyComp('machelp') then Result := tkKey else + if KeyComp('mackey') then Result := tkKey else + if KeyComp('brow') then Result := tkKey else + if KeyComp('into') then Result := tkKey else + if KeyComp('fcreate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func59: TtkTokenKind; +begin + if KeyComp('view') then Result := tkKey else + if KeyComp('copy') then Result := tkKey else + if KeyComp('gather') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func60: TtkTokenKind; +begin + if KeyComp('with') then Result := tkKey else + if KeyComp('endscan') then Result := tkKey else + if KeyComp('order') then Result := tkKey else + if KeyComp('fclose') then Result := tkKey else + if KeyComp('replace') then Result := tkKey else + if KeyComp('step') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func61: TtkTokenKind; +begin + if KeyComp('proced') then Result := tkKey else + if KeyComp('atline') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func62: TtkTokenKind; +begin + if KeyComp('endfor') then Result := tkKey else + if KeyComp('border') then Result := tkKey else + if KeyComp('margin') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func63: TtkTokenKind; +begin + if KeyComp('color') then Result := tkKey else + if KeyComp('array') then Result := tkKey else + if KeyComp('command') then Result := tkKey else + if KeyComp('topic') then Result := tkKey else + if KeyComp('next') then Result := tkKey else + if KeyComp('scatt') then Result := tkKey else + if KeyComp('public') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func64: TtkTokenKind; +begin + if KeyComp('retu') then Result := tkKey else + if KeyComp('select') then Result := tkKey else + if KeyComp('screen') then Result := tkKey else + if KeyComp('push') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func65: TtkTokenKind; +begin + if KeyComp('carry') then Result := tkKey else + if KeyComp('release') then Result := tkKey else + if KeyComp('relati') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func66: TtkTokenKind; +begin + if KeyComp('decimals') then Result := tkKey else + if KeyComp('event') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func67: TtkTokenKind; +begin + if KeyComp('quit') then Result := tkKey else + if KeyComp('headings') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func68: TtkTokenKind; +begin + if KeyComp('collate') then Result := tkKey else + if KeyComp('region') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func69: TtkTokenKind; +begin + if KeyComp('message') then Result := tkKey else + if KeyComp('default') then Result := tkKey else + if KeyComp('text') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func70: TtkTokenKind; +begin + if KeyComp('filter') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func72: TtkTokenKind; +begin + if KeyComp('modify') then Result := tkKey else + if KeyComp('schemes') then Result := tkKey else + if KeyComp('memvar') then Result := tkKey else + if KeyComp('databases') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func73: TtkTokenKind; +begin + if KeyComp('functi') then Result := tkKey else + if KeyComp('curdir') then Result := tkKey else + if KeyComp('mouse') then Result := tkKey else + if KeyComp('format') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func74: TtkTokenKind; +begin + if KeyComp('between') then Result := tkKey else + if KeyComp('point') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func75: TtkTokenKind; +begin + if KeyComp('endproc') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func76: TtkTokenKind; +begin + if KeyComp('safety') then Result := tkKey else + if KeyComp('xcmdfile') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func77: TtkTokenKind; +begin + if KeyComp('classlib') then Result := tkKey else + if KeyComp('store') then Result := tkKey else + if KeyComp('delimite') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func78: TtkTokenKind; +begin + if KeyComp('confirm') then Result := tkKey else + if KeyComp('caption') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func79: TtkTokenKind; +begin + if KeyComp('empty') then Result := tkKey else + if KeyComp('refresh') then Result := tkKey else + if KeyComp('fcount') then Result := tkKey else + if KeyComp('palette') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func80: TtkTokenKind; +begin + if KeyComp('capslock') then Result := tkKey else + if KeyComp('backcolor') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func81: TtkTokenKind; +begin + if KeyComp('hours') then Result := tkKey else + if KeyComp('fwrite') then Result := tkKey else + if KeyComp('activate') then Result := tkKey else + if KeyComp('regional') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func82: TtkTokenKind; +begin + if KeyComp('commands') then Result := tkKey else + if KeyComp('fputs') then Result := tkKey else + if KeyComp('nowait') then Result := tkKey else + if KeyComp('browse') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func83: TtkTokenKind; +begin + if KeyComp('console') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func85: TtkTokenKind; +begin + if KeyComp('library') then Result := tkKey else + if KeyComp('bottom') then Result := tkKey else + if KeyComp('events') then Result := tkKey else + if KeyComp('typeahead') then Result := tkKey else + if KeyComp('insert') then Result := tkKey else + if KeyComp('alltrim') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func86: TtkTokenKind; +begin + if KeyComp('display') then Result := tkKey else + if KeyComp('scatter') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func87: TtkTokenKind; +begin + if KeyComp('unique') then Result := tkKey else + if KeyComp('sticky') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func88: TtkTokenKind; +begin + if KeyComp('aplabout') then Result := tkKey else + if KeyComp('keycomp') then Result := tkKey else + if KeyComp('volume') then Result := tkKey else + if KeyComp('window') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func89: TtkTokenKind; +begin + if KeyComp('notify') then Result := tkKey else + if KeyComp('shadows') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func90: TtkTokenKind; +begin + if KeyComp('readborder') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func91: TtkTokenKind; +begin + if KeyComp('private') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func94: TtkTokenKind; +begin + if KeyComp('barcount') then Result := tkKey else + if KeyComp('cursor') then Result := tkKey else + if KeyComp('relation') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func95: TtkTokenKind; +begin + if KeyComp('odometer') then Result := tkKey else + if KeyComp('_screen') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func96: TtkTokenKind; +begin + if KeyComp('compatible') then Result := tkKey else + if KeyComp('alternate') then Result := tkKey else + if KeyComp('fullpath') then Result := tkKey else + if KeyComp('return') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func97: TtkTokenKind; +begin + if KeyComp('parameter') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func98: TtkTokenKind; +begin + if KeyComp('udfparms') then Result := tkKey else + if KeyComp('prompt') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func100: TtkTokenKind; +begin + if KeyComp('scoreboard') then Result := tkKey else + if KeyComp('status') then Result := tkKey else + if KeyComp('printer') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func101: TtkTokenKind; +begin + if KeyComp('pdsetup') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func102: TtkTokenKind; +begin + if KeyComp('dimension') then Result := tkKey else + if KeyComp('function') then Result := tkKey else + if KeyComp('blocksize') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func104: TtkTokenKind; +begin + if KeyComp('autosave') then Result := tkKey else + if KeyComp('resource') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func105: TtkTokenKind; +begin + if KeyComp('procedure') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func106: TtkTokenKind; +begin + if KeyComp('century') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func107: TtkTokenKind; +begin + if KeyComp('macdesktop') then Result := tkKey else + if KeyComp('currency') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func108: TtkTokenKind; +begin + if KeyComp('thisform') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func110: TtkTokenKind; +begin + if KeyComp('memowidth') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func111: TtkTokenKind; +begin + if KeyComp('helpfilter') then Result := tkKey else + if KeyComp('ansitooem') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func112: TtkTokenKind; +begin + if KeyComp('trbetween') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func113: TtkTokenKind; +begin + if KeyComp('separator') then Result := tkKey else + if KeyComp('optimize') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func114: TtkTokenKind; +begin + if KeyComp('delimiters') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func116: TtkTokenKind; +begin + if KeyComp('sysmenu') then Result := tkKey else + if KeyComp('parameters') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func117: TtkTokenKind; +begin + if KeyComp('textmerge') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func118: TtkTokenKind; +begin + if KeyComp('reprocess') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func119: TtkTokenKind; +begin + if KeyComp('barprompt') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func120: TtkTokenKind; +begin + if KeyComp('brstatus') then Result := tkKey else + if KeyComp('nocptrans') then Result := tkKey else + if KeyComp('exclusive') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func122: TtkTokenKind; +begin + if KeyComp('otherwise') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func127: TtkTokenKind; +begin + if KeyComp('logerrors') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func131: TtkTokenKind; +begin + if KeyComp('development') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func133: TtkTokenKind; +begin + if KeyComp('dohistory') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func135: TtkTokenKind; +begin + if KeyComp('intensity') then Result := tkKey else + if KeyComp('multilocks') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.Func160: TtkTokenKind; +begin + if KeyComp('_msysmenu') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynFoxproSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynFoxproSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 161 then Result := fIdentFuncTable[HashKey]() else Result := tkIdentifier; +end; + +procedure TSynFoxproSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := @AndSymbolProc; + #39: fProcTable[I] := @AsciiCharProc; + '@': fProcTable[I] := @AtSymbolProc; + '{': fProcTable[I] := @BraceOpenProc; + #13: fProcTable[I] := @CRProc; + ':': fProcTable[I] := @ColonProc; + ',': fProcTable[I] := @CommaProc; + '=': fProcTable[I] := @EqualProc; + '>': fProcTable[I] := @GreaterProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @LowerProc; + '-': fProcTable[I] := @MinusProc; + '%': fProcTable[I] := @ModSymbolProc; + '!': fProcTable[I] := @NotSymbolProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + '|': fProcTable[I] := @OrSymbolProc; + '+': fProcTable[I] := @PlusProc; + '.': fProcTable[I] := @PointProc; + '?': fProcTable[I] := @QuestionProc; + ')': fProcTable[I] := @RoundCloseProc; + '(': fProcTable[I] := @RoundOpenProc; + ';': fProcTable[I] := @SemiColonProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + ']': fProcTable[I] := @SquareCloseProc; + '[': fProcTable[I] := @SquareOpenProc; + '*': fProcTable[I] := @StarProc; + #34: fProcTable[I] := @StringProc; + '~': fProcTable[I] := @TildeProc; + '^': fProcTable[I] := @XOrSymbolProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynFoxproSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterFoxpro; +end; + +procedure TSynFoxproSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynFoxproSyn.AndSymbolProc; +begin + case FLine[Run + 1] of + '&': {Comments} + begin + inc(Run, 2); + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; //case + inc(Run); + end; + end; + else {and} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynFoxproSyn.AsciiCharProc; +begin + fTokenID := tkString; + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynFoxproSyn.AtSymbolProc; +begin + fTokenID := tkKey; + inc(Run); +end; + +procedure TSynFoxproSyn.BraceOpenProc; +begin + fTokenID := tkString; + repeat + case FLine[Run] of + #0, #10, #13: break; + #92: + if FLine[Run + 1] = #10 then inc(Run); + end; + inc(Run); + until FLine[Run] = '}'; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynFoxproSyn.CRProc; +begin + fTokenID := tkSpace; + Case FLine[Run + 1] of + #10: inc(Run, 2); + else inc(Run); + end; +end; + +procedure TSynFoxproSyn.ColonProc; +begin + {colon} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.CommaProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.EqualProc; +begin + case FLine[Run + 1] of + '=': {logical equal} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {assign} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynFoxproSyn.GreaterProc; +begin + Case FLine[Run + 1] of + '=': {greater than or equal to} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + inc(Run, 3) + else {shift right} + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {greater than} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynFoxproSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynFoxproSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynFoxproSyn.LowerProc; +begin + case FLine[Run + 1] of + '=': {less than or equal to} + begin + inc(Run, 2); + fTokenID := tkSymbol; + end; + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + inc(Run, 3) + else {shift left} + inc(Run, 2); + fTokenID := tkSymbol; + end; + else {less than} + begin + inc(Run); + fTokenID := tkSymbol; + end; + end; +end; + +procedure TSynFoxproSyn.MinusProc; +begin + {subtract} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.ModSymbolProc; +begin + {mod} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.NotSymbolProc; +begin + {not} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynFoxproSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', '.', 'x', 'X', 'e', 'E', 'f', 'F'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynFoxproSyn.OrSymbolProc; +begin + {or} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.PlusProc; +begin + {subtract} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.PointProc; +begin + if ((UpCase(FLine[Run + 1]) = 'T') {.t.} + or (UpCase(FLine[Run + 1]) = 'F')) {.f.} + and (FLine[Run + 2] = '.') then + begin + inc(Run, 3); + fTokenID := tkSymbol; + end + else if (((UpCase(FLine[Run + 1]) = 'A') + and (UpCase(FLine[Run + 2]) = 'N') + and (UpCase(FLine[Run + 3]) = 'D')) {.and.} + or ((UpCase(FLine[Run + 1]) = 'N') + and (UpCase(FLine[Run + 2]) = 'O') + and (UpCase(FLine[Run + 3]) = 'T'))) {.not.} + and (FLine[Run + 4] = '.') then + begin + inc(Run, 5); + fTokenID := tkSymbol; + end + else if (UpCase(FLine[Run + 1]) = 'O') + and (UpCase(FLine[Run + 2]) = 'R') + and (FLine[Run + 3] = '.') then {.or.} + begin + inc(Run, 4); + fTokenID := tkSymbol; + end + else {point} + begin + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynFoxproSyn.QuestionProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.RoundCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.RoundOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.SemiColonProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.SlashProc; +begin + {division} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynFoxproSyn.SquareCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.SquareOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.StarProc; +begin + if Run = 0 then + begin {Foxpro Comments} + inc(Run); + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; + end else begin + {star} + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynFoxproSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + #92: + if FLine[Run + 1] = #10 then inc(Run); + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynFoxproSyn.TildeProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynFoxproSyn.XOrSymbolProc; +begin + {xor} + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynFoxproSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynFoxproSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynFoxproSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynFoxproSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynFoxproSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynFoxproSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength:=Run-fTokenPos; + TokenStart:=FLine + fTokenPos; +end; +{$ENDIF} + +function TSynFoxproSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynFoxproSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynFoxproSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynFoxproSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynFoxproSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynFoxproSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterFoxpro; +end; + +class function TSynFoxproSyn.GetLanguageName: string; +begin + Result := SYNS_LangFoxpro; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynFoxproSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightergalaxy.pas b/components/extrasyn/SyneditHighlighters/synhighlightergalaxy.pas new file mode 100644 index 000000000..0b1c6a5ce --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightergalaxy.pas @@ -0,0 +1,451 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterGalaxy.pas, released 2000-04-07. +The Original Code is based on the mkGalaxySyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Martijn van der Kooij. +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: SynHighlighterGalaxy.pas,v 1.13 2005/01/28 16:53:22 maelh Exp $ + +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 Galaxy highlighter for SynEdit) +@author(Martijn van der Kooij, converted to SynEdit by David Muir ) +@created(May 1999, converted to SynEdit June 19, 2000) +@lastmod(2000-06-23) +The SynHighlighterGalaxy unit provides SynEdit with a Galaxy highlighter. +Galaxy is a PBEM game for 10 to 500+ players, to see it wokring goto: http://members.tripod.com/~erisande/kooij.html . +The keywords in the string list KeyWords have to be in UPPERCASE and sorted. +} +unit SynHighlighterGalaxy; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditHighlighter, + SysUtils, Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkSpace, tkMessage, + tkUnknown); + + TRangeState = (rsUnKnown, rsMessageStyle); + + TProcTableProc = procedure of object; + +type + TSynGalaxySyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fLineNumber : Integer; + fMessageAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyWords: TStrings; + procedure PointCommaProc; + procedure CRProc; + procedure IdentProc; + procedure LFProc; + procedure NullProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + procedure MakeMethodTables; + procedure MessageStyleProc; + procedure SetKeyWords(const Value: TStrings); + protected + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + function IsKeyword(const AKeyword: string): boolean; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property KeyWords: TStrings read fKeyWords write SetKeyWords; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property MessageAttri: TSynHighlighterAttributes read fMessageAttri + write fMessageAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z', '#': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpperCase(I)[1]; + Case I in ['_', 'a'..'z', 'A'..'Z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +function TSynGalaxySyn.IsKeyword(const AKeyword: string): boolean; +var + First, Last, I, Compare: Integer; + Token: String; +begin + First := 0; + Last := fKeywords.Count - 1; + Result := False; + Token := UpperCase(AKeyword); + while First <= Last do + begin + I := (First + Last) shr 1; + Compare := CompareStr(fKeywords[i], Token); + if Compare = 0 then + begin + Result := True; + break; + end else + if Compare < 0 then First := I + 1 else Last := I - 1; + end; +end; { IsKeyWord } + +procedure TSynGalaxySyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + ';': fProcTable[I] := @PointCommaProc; + #13: fProcTable[I] := @CRProc; + '#','A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + #0: fProcTable[I] := @NullProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + '@': fProcTable[I] := @StringProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynGalaxySyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fKeyWords := TStringList.Create; + TStringList(fKeyWords).Sorted := True; + TStringList(fKeyWords).Duplicates := dupIgnore; + TStringList(fKeyWords).CommaText := + '#END,#GALAXY,A,ANONYMOUS,AUTOUNLOAD,B,BATTLEPROTOCOL,C,CAP,CARGO,COL,' + + 'COMPRESS,D,DRIVE,E,EMP,F,FLEET,FLEETTABLES,G,GALAXYTV,GPLUS,GROUPFORECAST,' + + 'H,I,J,L,M,MACHINEREPORT,MAT,N,NAMECASE,NO,O,OPTIONS,P,PLANETFORECAST,' + + 'PRODTABLE,PRODUCE,Q,R,ROUTESFORECAST,S,SEND,SHIELDS,SHIPTYPEFORECAST,' + + 'SORTGROUPS,T,TWOCOL,U,UNDERSCORES,V,W,WAR,WEAPONS,X,Y,Z'; + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fMessageAttri := TSynHighlighterAttributes.Create(SYNS_AttrMessage); + AddAttribute(fMessageAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange(@DefHighlightChange); + + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterGalaxy; +end; { Create } + +destructor TSynGalaxySyn.Destroy; +begin + fKeyWords.Free; + inherited Destroy; +end; { Destroy } + +procedure TSynGalaxySyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynGalaxySyn.MessageStyleProc; +begin + fTokenID := tkMessage; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + + #13: + begin + CRProc; + exit; + end; + end; + + if (Run = 0) and (FLine[Run] = '@') then begin + fRange := rsUnKnown; + inc(Run); + end else + while FLine[Run] <> #0 do + inc(Run); +end; + +procedure TSynGalaxySyn.PointCommaProc; +begin + fTokenID := tkComment; + fRange := rsUnknown; + repeat + inc(Run); + until fLine[Run] = #0; +end; + +procedure TSynGalaxySyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then + Inc(Run); +end; + +procedure TSynGalaxySyn.IdentProc; +begin + while Identifiers[fLine[Run]] do + Inc(Run); + if IsKeyWord(GetToken) then + fTokenId := tkKey + else + fTokenId := tkIdentifier; +end; + +procedure TSynGalaxySyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynGalaxySyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynGalaxySyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynGalaxySyn.StringProc; +begin + if (Run = 0) and (fTokenID <> tkMessage) then + begin + fTokenID := tkMessage; + fRange := rsMessageStyle; + end; + inc(Run); +end; + +procedure TSynGalaxySyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnKnown; +end; + +procedure TSynGalaxySyn.Next; +begin + fTokenPos := Run; + if fRange = rsMessageStyle then + MessageStyleProc + else + fProcTable[fLine[Run]]; +end; + +function TSynGalaxySyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynGalaxySyn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSynGalaxySyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynGalaxySyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynGalaxySyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength:=Run-fTokenPos; + TokenStart:=FLine + fTokenPos; +end; +{$ENDIF} + +function TSynGalaxySyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynGalaxySyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkMessage: Result := fMessageAttri; + tkSpace: Result := fSpaceAttri; + tkUnknown: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynGalaxySyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynGalaxySyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynGalaxySyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynGalaxySyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynGalaxySyn.SetKeyWords(const Value: TStrings); +var + i: Integer; +begin + if Value <> nil then + begin + Value.BeginUpdate; + for i := 0 to Value.Count - 1 do + Value[i] := UpperCase(Value[i]); + Value.EndUpdate; + end; + fKeyWords.Assign(Value); + DefHighLightChange(nil); +end; + +function TSynGalaxySyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterGalaxy; +end; + +class function TSynGalaxySyn.GetLanguageName: string; +begin + Result := SYNS_LangGalaxy; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynGalaxySyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightergeneral.pas b/components/extrasyn/SyneditHighlighters/synhighlightergeneral.pas new file mode 100644 index 000000000..496d8f02e --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightergeneral.pas @@ -0,0 +1,806 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterGeneral.pas, released 2000-04-07. +The Original Code is based on the mwGeneralSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Martin Waldenburg. +Portions written by Martin Waldenburg are copyright 1999 Martin Waldenburg. +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: SynHighlighterGeneral.pas,v 1.16 2005/01/28 16:53:22 maelh Exp $ + +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 customizable highlighter for SynEdit) +@author(Martin Waldenburg, converted to SynEdit by Michael Hieke) +@created(1999) +@lastmod(2000-06-23) +The SynHighlighterGeneral unit provides a customizable highlighter for SynEdit. +} + +{$IFNDEF QSYNHIGHLIGHTERGENERAL} +unit SynHighlighterGeneral; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + SysUtils, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, + tkPreprocessor, tkSpace, tkString, tkSymbol, tkUnknown); + + TCommentStyle = (csAnsiStyle, csPasStyle, csCStyle, csAsmStyle, csBasStyle, + csCPPStyle); + TCommentStyles = set of TCommentStyle; + + TRangeState = (rsANil, rsAnsi, rsPasStyle, rsCStyle, rsUnKnown); + + TStringDelim = (sdSingleQuote, sdDoubleQuote); + + TProcTableProc = procedure of object; + +type + TSynGeneralSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fLineNumber : Integer; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fPreprocessorAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fKeyWords: TStrings; + fComments: TCommentStyles; + fStringDelimCh: char; + fIdentChars: TSynIdentChars; + fDetectPreprocessor: boolean; + procedure AsciiCharProc; + procedure BraceOpenProc; + procedure PointCommaProc; + procedure CRProc; + procedure IdentProc; + procedure IntegerProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure RoundOpenProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + procedure MakeMethodTables; + procedure AnsiProc; + procedure PasStyleProc; + procedure CStyleProc; + procedure SetKeyWords(const Value: TStrings); + procedure SetComments(Value: TCommentStyles); + function GetStringDelim: TStringDelim; + procedure SetStringDelim(const Value: TStringDelim); + function GetIdentifierChars: string; + procedure SetIdentifierChars(const Value: string); + procedure SetDetectPreprocessor(Value: boolean); + protected + function GetIdentChars: TSynIdentChars; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + function GetToken: String; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + function IsKeyword(const AKeyword: string): boolean; override; + procedure Next; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + // procedure SetLine(NewValue: String; LineNumber: Integer); override; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + {$IFNDEF SYN_LAZARUS} + function SaveToRegistry(RootKey: HKEY; Key: string): boolean; override; + function LoadFromRegistry(RootKey: HKEY; Key: string): boolean; override; + {$ENDIF} + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property Comments: TCommentStyles read fComments write SetComments; + property DetectPreprocessor: boolean read fDetectPreprocessor + write SetDetectPreprocessor; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property IdentifierChars: string read GetIdentifierChars + write SetIdentifierChars; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property KeyWords: TStrings read fKeyWords write SetKeyWords; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property PreprocessorAttri: TSynHighlighterAttributes + read fPreprocessorAttri write fPreprocessorAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property StringDelim: TStringDelim read GetStringDelim write SetStringDelim + default sdSingleQuote; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst; +{$ENDIF} + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I in ['_', 'a'..'z', 'A'..'Z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +function TSynGeneralSyn.IsKeyword(const AKeyword: string): boolean; +var + First, Last, I, Compare: Integer; + Token: String; +begin + First := 0; + Last := fKeywords.Count - 1; + Result := False; + Token := UpperCase(AKeyword); + while First <= Last do + begin + I := (First + Last) shr 1; + Compare := AnsiCompareText(fKeywords[i], Token); + if Compare = 0 then + begin + Result := True; + break; + end else + if Compare < 0 then First := I + 1 else Last := I - 1; + end; +end; { IsKeyWord } + +procedure TSynGeneralSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '#': fProcTable[I] := {$ifdef FPC} @ {$endif}AsciiCharProc; + '{': fProcTable[I] := {$ifdef FPC} @ {$endif}BraceOpenProc; + ';': fProcTable[I] := {$ifdef FPC} @ {$endif}PointCommaProc; + #13: fProcTable[I] := {$ifdef FPC} @ {$endif}CRProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$ifdef FPC} @ {$endif}IdentProc; + '$': fProcTable[I] := {$ifdef FPC} @ {$endif}IntegerProc; + #10: fProcTable[I] := {$ifdef FPC} @ {$endif}LFProc; + #0: fProcTable[I] := {$ifdef FPC} @ {$endif}NullProc; + '0'..'9': fProcTable[I] := {$ifdef FPC} @ {$endif}NumberProc; + '(': fProcTable[I] := {$ifdef FPC} @ {$endif}RoundOpenProc; + '/': fProcTable[I] := {$ifdef FPC} @ {$endif}SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$ifdef FPC} @ {$endif}SpaceProc; + else fProcTable[I] := {$ifdef FPC} @ {$endif}UnknownProc; + end; + fProcTable[fStringDelimCh] := {$ifdef FPC} @ {$endif}StringProc; +end; + +constructor TSynGeneralSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fKeyWords := TStringList.Create; + TStringList(fKeyWords).Sorted := True; + TStringList(fKeyWords).Duplicates := dupIgnore; + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fPreprocessorAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor); + AddAttribute(fPreprocessorAttri); + SetAttributesOnChange({$ifdef FPC} @ {$endif}DefHighlightChange); + + fStringDelimCh := ''''; + fIdentChars := inherited GetIdentChars; + MakeMethodTables; + fRange := rsUnknown; +end; { Create } + +destructor TSynGeneralSyn.Destroy; +begin + fKeyWords.Free; + inherited Destroy; +end; { Destroy } + +{$IFDEF SYN_LAZARUS} +procedure TSynGeneralSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynGeneralSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynGeneralSyn.AnsiProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + fTokenID := tkComment; + repeat + if (fLine[Run] = '*') and (fLine[Run + 1] = ')') then begin + fRange := rsUnKnown; + Inc(Run, 2); + break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynGeneralSyn.PasStyleProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + fTokenID := tkComment; + repeat + if fLine[Run] = '}' then begin + fRange := rsUnKnown; + Inc(Run); + break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynGeneralSyn.CStyleProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + fTokenID := tkComment; + repeat + if (fLine[Run] = '*') and (fLine[Run + 1] = '/') then begin + fRange := rsUnKnown; + Inc(Run, 2); + break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynGeneralSyn.AsciiCharProc; +begin + if fDetectPreprocessor then begin + fTokenID := tkPreprocessor; + repeat + inc(Run); + until fLine[Run] in [#0, #10, #13]; + end else begin + fTokenID := tkString; + repeat + inc(Run); + until not (fLine[Run] in ['0'..'9']); + end; +end; + +procedure TSynGeneralSyn.BraceOpenProc; +begin + if csPasStyle in fComments then + begin + fTokenID := tkComment; + fRange := rsPasStyle; + inc(Run); + while FLine[Run] <> #0 do + case FLine[Run] of + '}': + begin + fRange := rsUnKnown; + inc(Run); + break; + end; + #10: break; + + #13: break; + else inc(Run); + end; + end else + begin + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynGeneralSyn.PointCommaProc; +begin + if (csASmStyle in fComments) or (csBasStyle in fComments) then + begin + fTokenID := tkComment; + fRange := rsUnknown; + inc(Run); + while FLine[Run] <> #0 do + begin + fTokenID := tkComment; + inc(Run); + end; + end else + begin + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynGeneralSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then Inc(Run); +end; + +procedure TSynGeneralSyn.IdentProc; +begin + while Identifiers[fLine[Run]] do inc(Run); + if IsKeyWord(GetToken) then fTokenId := tkKey else fTokenId := tkIdentifier; +end; + +procedure TSynGeneralSyn.IntegerProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f'] do inc(Run); +end; + +procedure TSynGeneralSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynGeneralSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynGeneralSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E', 'x'] do + begin + case FLine[Run] of + 'x': begin // handle C style hex numbers + IntegerProc; + break; + end; + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynGeneralSyn.RoundOpenProc; +begin + inc(Run); + if csAnsiStyle in fComments then + begin + case fLine[Run] of + '*': + begin + fTokenID := tkComment; + fRange := rsAnsi; + inc(Run); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = ')' then + begin + fRange := rsUnKnown; + inc(Run, 2); + break; + end else inc(Run); + #10: break; + #13: break; + else inc(Run); + end; + end; + '.': + begin + inc(Run); + fTokenID := tkSymbol; + end; + else + begin + FTokenID := tkSymbol; + end; + end; + end else fTokenId := tkSymbol; +end; + +procedure TSynGeneralSyn.SlashProc; +begin + Inc(Run); + case FLine[Run] of + '/': + begin + if csCPPStyle in fComments then + begin + fTokenID := tkComment; + Inc(Run); + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; + end + else + fTokenId := tkSymbol; + end; + '*': + begin + if csCStyle in fComments then + begin + fTokenID := tkComment; + fRange := rsCStyle; + Inc(Run); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + fRange := rsUnKnown; + inc(Run, 2); + break; + end else inc(Run); + #10, #13: + break; + else + Inc(Run); + end; + end + else + fTokenId := tkSymbol; + end; + else + fTokenID := tkSymbol; + end; +end; + +procedure TSynGeneralSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynGeneralSyn.StringProc; +begin + fTokenID := tkString; + if (fLine[Run + 1] = fStringDelimCh) and (fLine[Run + 2] = fStringDelimCh) then + Inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = fStringDelimCh; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynGeneralSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynGeneralSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsAnsi: AnsiProc; + rsPasStyle: PasStyleProc; + rsCStyle: CStyleProc; + else + fProcTable[fLine[Run]]; + end; +end; + +function TSynGeneralSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynGeneralSyn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSynGeneralSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynGeneralSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynGeneralSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynGeneralSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkPreprocessor: Result := fPreprocessorAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynGeneralSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynGeneralSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynGeneralSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynGeneralSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynGeneralSyn.SetKeyWords(const Value: TStrings); +var + i: Integer; +begin + if Value <> nil then + begin + Value.BeginUpdate; + for i := 0 to Value.Count - 1 do + Value[i] := UpperCase(Value[i]); + Value.EndUpdate; + end; + fKeyWords.Assign(Value); + DefHighLightChange(nil); +end; + +procedure TSynGeneralSyn.SetComments(Value: TCommentStyles); +begin + if fComments <> Value then + begin + fComments := Value; + DefHighLightChange(Self); + end; +end; + +class function TSynGeneralSyn.GetLanguageName: string; +begin + Result := SYNS_LangGeneral; +end; + +{$IFNDEF SYN_LAZARUS} +function TSynGeneralSyn.LoadFromRegistry(RootKey: HKEY; Key: string): boolean; +var + r: TBetterRegistry; +begin + r:= TBetterRegistry.Create; + try + r.RootKey := RootKey; + if r.OpenKeyReadOnly(Key) then begin + if r.ValueExists('KeyWords') then KeyWords.Text:= r.ReadString('KeyWords'); + Result := inherited LoadFromRegistry(RootKey, Key); + end + else Result := false; + finally r.Free; end; +end; + +function TSynGeneralSyn.SaveToRegistry(RootKey: HKEY; Key: string): boolean; +var + r: TBetterRegistry; +begin + r:= TBetterRegistry.Create; + try + r.RootKey := RootKey; + if r.OpenKey(Key,true) then begin + Result := true; + r.WriteString('KeyWords', KeyWords.Text); + Result := inherited SaveToRegistry(RootKey, Key); + end + else Result := false; + finally r.Free; end; +end; +{$ENDIF} + +function TSynGeneralSyn.GetStringDelim: TStringDelim; +begin + if fStringDelimCh = '''' then + Result := sdSingleQuote + else + Result := sdDoubleQuote; +end; + +procedure TSynGeneralSyn.SetStringDelim(const Value: TStringDelim); +var + newCh: char; +begin + case Value of + sdSingleQuote: newCh := ''''; + else newCh := '"'; + end; //case + if newCh <> fStringDelimCh then begin + fStringDelimCh := newCh; + MakeMethodTables; + end; +end; + +function TSynGeneralSyn.GetIdentifierChars: string; +var + ch: char; + s: shortstring; +begin + s := ''; + for ch := #0 to #255 do + if ch in fIdentChars then s := s + ch; + Result := s; +end; + +procedure TSynGeneralSyn.SetIdentifierChars(const Value: string); +var + i: integer; +begin + fIdentChars := []; + for i := 1 to Length(Value) do begin + fIdentChars := fIdentChars + [Value[i]]; + end; //for + WordBreakChars := WordBreakChars - fIdentChars; +end; + +function TSynGeneralSyn.GetIdentChars: TSynIdentChars; +begin + Result := fIdentChars; +end; + +procedure TSynGeneralSyn.SetDetectPreprocessor(Value: boolean); +begin + if Value <> fDetectPreprocessor then begin + fDetectPreprocessor := Value; + DefHighlightChange(Self); + end; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynGeneralSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightergws.pas b/components/extrasyn/SyneditHighlighters/synhighlightergws.pas new file mode 100644 index 000000000..18ed11812 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightergws.pas @@ -0,0 +1,1065 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterCpp.pas, released 2000-04-10. +The Original Code is based on the dcjCppSyn.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: SynHighlighterGWS.pas,v 1.14 2005/01/28 16:53:22 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} +unit SynHighlighterGWS; + +{ This unit provides a syntax highlighter for GW-TEL Scripts } + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +Type + TtkTokenKind = ( + tkComment, + tkIdentifier, + tkKey, + tkNull, + tkNumber, + tkSpace, + tkString, + tkSymbol, + tkUnknown); + + TxtkTokenKind = ( + xtkAdd, xtkAddAssign, xtkAnd, xtkAndAssign, xtkArrow, xtkAssign, + xtkBitComplement, xtkBraceClose, xtkBraceOpen, xtkColon, xtkComma, + xtkDecrement, xtkDivide, xtkDivideAssign, xtkEllipse, xtkGreaterThan, + xtkGreaterThanEqual, xtkIncOr, xtkIncOrAssign, xtkIncrement, xtkLessThan, + xtkLessThanEqual, xtkLogAnd, xtkLogComplement, xtkLogEqual, xtkLogOr, + xtkMod, xtkModAssign, xtkMultiplyAssign, xtkNotEqual, xtkPoint, xtkQuestion, + xtkRoundClose, xtkRoundOpen, xtkScopeResolution, xtkSemiColon, xtkShiftLeft, + xtkShiftLeftAssign, xtkShiftRight, xtkShiftRightAssign, xtkSquareClose, + xtkSquareOpen, xtkStar, xtkSubtract, xtkSubtractAssign, xtkXor, + xtkXorAssign); + + TRangeState = (rsAnsiC, rsUnKnown); + + TProcTableProc = procedure of Object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of Object; + + TSynGWScriptSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + FExtTokenID: TxtkTokenKind; + fLineNumber: Integer; + fIdentFuncTable: array[0..206] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fInvalidAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func17: TtkTokenKind; + function Func21: TtkTokenKind; + function Func34: TtkTokenKind; + function Func42: TtkTokenKind; + function Func45: TtkTokenKind; + function Func46: TtkTokenKind; + function Func48: TtkTokenKind; + function Func62: TtkTokenKind; + function Func68: TtkTokenKind; + function Func93: TtkTokenKind; + function Func102: TtkTokenKind; + + procedure AnsiCProc; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure AtSymbolProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure CRProc; + procedure ColonProc; + procedure CommaProc; + procedure EqualProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NotSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure QuestionProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure StarProc; + procedure StringProc; + procedure TildeProc; + procedure XOrSymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + + protected + function GetIdentChars: TSynIdentChars; override; + function GetExtTokenID: TxtkTokenKind; + function IsFilterStored: Boolean; override; + + public + constructor Create(AOwner: TComponent); override; + + class function GetLanguageName: string; override; + function GetDefaultAttribute (Index: integer): TSynHighlighterAttributes; override; + + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + + property ExtTokenID: TxtkTokenKind read GetExtTokenID; + + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property InvalidAttri: TSynHighlighterAttributes read fInvalidAttri write fInvalidAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + Case I in['_', 'a'..'z', 'A'..'Z'] of + True: + begin + if (I > #64) and (I < #91) then mHashTable[I] := Ord(I) - 64 else + if (I > #96) then mHashTable[I] := Ord(I) - 95; + end; + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynGWScriptSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[34] := @Func34; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[46] := @Func46; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[102] := @Func102; +end; + +function TSynGWScriptSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; { KeyHash } + +function TSynGWScriptSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; { KeyComp } + +function TSynGWScriptSyn.Func17: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func21: TtkTokenKind; +begin + if KeyComp('do') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func34: TtkTokenKind; +begin + if KeyComp('char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func42: TtkTokenKind; +begin + if KeyComp('for') then Result := tkKey else + if KeyComp('break') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func45: TtkTokenKind; +begin + if KeyComp('else') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func46: TtkTokenKind; +begin + if KeyComp('int') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func48: TtkTokenKind; +begin + if KeyComp('false') then Result := tkKey else + if KeyComp('bool') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func62: TtkTokenKind; +begin + if KeyComp('while') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func68: TtkTokenKind; +begin + if KeyComp('true') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func93: TtkTokenKind; +begin + if KeyComp('string') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.Func102: TtkTokenKind; +begin + if KeyComp('return') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynGWScriptSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynGWScriptSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 207 then Result := fIdentFuncTable[HashKey]() else Result := tkIdentifier; +end; + +procedure TSynGWScriptSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := @AndSymbolProc; + #39: fProcTable[I] := @AsciiCharProc; + '@': fProcTable[I] := @AtSymbolProc; + '}': fProcTable[I] := @BraceCloseProc; + '{': fProcTable[I] := @BraceOpenProc; + #13: fProcTable[I] := @CRProc; + ':': fProcTable[I] := @ColonProc; + ',': fProcTable[I] := @CommaProc; + '=': fProcTable[I] := @EqualProc; + '>': fProcTable[I] := @GreaterProc; + '?': fProcTable[I] := @QuestionProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @LowerProc; + '-': fProcTable[I] := @MinusProc; + '%': fProcTable[I] := @ModSymbolProc; + '!': fProcTable[I] := @NotSymbolProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + '|': fProcTable[I] := @OrSymbolProc; + '+': fProcTable[I] := @PlusProc; + '.': fProcTable[I] := @PointProc; + ')': fProcTable[I] := @RoundCloseProc; + '(': fProcTable[I] := @RoundOpenProc; + ';': fProcTable[I] := @SemiColonProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + ']': fProcTable[I] := @SquareCloseProc; + '[': fProcTable[I] := @SquareOpenProc; + '*': fProcTable[I] := @StarProc; + #34: fProcTable[I] := @StringProc; + '~': fProcTable[I] := @TildeProc; + '^': fProcTable[I] := @XOrSymbolProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynGWScriptSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style:= [fsItalic]; + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + fInvalidAttri := TSynHighlighterAttributes.Create(SYNS_AttrIllegalChar); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style:= [fsBold]; + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + fSpaceAttri.Foreground := clWindow; + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + + AddAttribute(fCommentAttri); + AddAttribute(fIdentifierAttri); + AddAttribute(fInvalidAttri); + AddAttribute(fKeyAttri); + AddAttribute(fNumberAttri); + AddAttribute(fSpaceAttri); + AddAttribute(fStringAttri); + AddAttribute(fSymbolAttri); + + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterGWS; +end; { Create } + +procedure TSynGWScriptSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynGWScriptSyn.AnsiCProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + #13: + begin + CRProc; + exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '*': + if fLine[Run + 1] = '/' then begin + inc(Run, 2); + fRange := rsUnKnown; + break; + end else + inc(Run); + #10: break; + #13: break; + else inc(Run); + end; +end; + +procedure TSynGWScriptSyn.AndSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {and assign} + begin + inc(Run, 2); + FExtTokenID := xtkAndAssign; + end; + '&': {logical and} + begin + inc(Run, 2); + FExtTokenID := xtkLogAnd; + end; + else {and} + begin + inc(Run); + FExtTokenID := xtkAnd; + end; + end; +end; + +procedure TSynGWScriptSyn.AsciiCharProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then begin + if fLine[Run + 1] in [#39, '\'] then + inc(Run); + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, #39]; + if fLine[Run] = #39 then + inc(Run); +end; + +procedure TSynGWScriptSyn.AtSymbolProc; +begin + fTokenID := tkUnknown; + inc(Run); +end; + +procedure TSynGWScriptSyn.BraceCloseProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceClose; + fRange := rsUnknown; +end; + +procedure TSynGWScriptSyn.BraceOpenProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceOpen; +end; + +procedure TSynGWScriptSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run + 1] = #10 then Inc(Run); +end; + +procedure TSynGWScriptSyn.ColonProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + ':': {scope resolution operator} + begin + inc(Run, 2); + FExtTokenID := xtkScopeResolution; + end; + else {colon} + begin + inc(Run); + FExtTokenID := xtkColon; + end; + end; +end; + +procedure TSynGWScriptSyn.CommaProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkComma; +end; + +procedure TSynGWScriptSyn.EqualProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {logical equal} + begin + inc(Run, 2); + FExtTokenID := xtkLogEqual; + end; + else {assign} + begin + inc(Run); + FExtTokenID := xtkAssign; + end; + end; +end; + +procedure TSynGWScriptSyn.GreaterProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {greater than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkGreaterThanEqual; + end; + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftRightAssign; + end + else {shift right} + begin + inc(Run, 2); + FExtTokenID := xtkShiftRight; + end; + end; + else {greater than} + begin + inc(Run); + FExtTokenID := xtkGreaterThan; + end; + end; +end; + +procedure TSynGWScriptSyn.QuestionProc; +begin + fTokenID := tkSymbol; {conditional} + FExtTokenID := xtkQuestion; + inc(Run); +end; + +procedure TSynGWScriptSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynGWScriptSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynGWScriptSyn.LowerProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {less than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkLessThanEqual; + end; + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftLeftAssign; + end + else {shift left} + begin + inc(Run, 2); + FExtTokenID := xtkShiftLeft; + end; + end; + else {less than} + begin + inc(Run); + FExtTokenID := xtkLessThan; + end; + end; +end; + +procedure TSynGWScriptSyn.MinusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {subtract assign} + begin + inc(Run, 2); + FExtTokenID := xtkSubtractAssign; + end; + '-': {decrement} + begin + inc(Run, 2); + FExtTokenID := xtkDecrement; + end; + '>': {arrow} + begin + inc(Run, 2); + FExtTokenID := xtkArrow; + end; + else {subtract} + begin + inc(Run); + FExtTokenID := xtkSubtract; + end; + end; +end; + +procedure TSynGWScriptSyn.ModSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {mod assign} + begin + inc(Run, 2); + FExtTokenID := xtkModAssign; + end; + else {mod} + begin + inc(Run); + FExtTokenID := xtkMod; + end; + end; +end; + +procedure TSynGWScriptSyn.NotSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {not equal} + begin + inc(Run, 2); + FExtTokenID := xtkNotEqual; + end; + else {not} + begin + inc(Run); + FExtTokenID := xtkLogComplement; + end; + end; +end; + +procedure TSynGWScriptSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynGWScriptSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', 'A'..'F', 'a'..'f', '.', 'u', 'U', 'l', 'L', 'x', 'X'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynGWScriptSyn.OrSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {or assign} + begin + inc(Run, 2); + FExtTokenID := xtkIncOrAssign; + end; + '|': {logical or} + begin + inc(Run, 2); + FExtTokenID := xtkLogOr; + end; + else {or} + begin + inc(Run); + FExtTokenID := xtkIncOr; + end; + end; +end; + +procedure TSynGWScriptSyn.PlusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {add assign} + begin + inc(Run, 2); + FExtTokenID := xtkAddAssign; + end; + '+': {increment} + begin + inc(Run, 2); + FExtTokenID := xtkIncrement; + end; + else {add} + begin + inc(Run); + FExtTokenID := xtkAdd; + end; + end; +end; + +procedure TSynGWScriptSyn.PointProc; +begin + fTokenID := tkSymbol; + if (FLine[Run + 1] = '.') and (FLine[Run + 2] = '.') then + begin {ellipse} + inc(Run, 3); + FExtTokenID := xtkEllipse; + end + else {point} + begin + inc(Run); + FExtTokenID := xtkPoint; + end; +end; + +procedure TSynGWScriptSyn.RoundCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkRoundClose; +end; + +procedure TSynGWScriptSyn.RoundOpenProc; +begin + inc(Run); + FTokenID := tkSymbol; + FExtTokenID := xtkRoundOpen; +end; + +procedure TSynGWScriptSyn.SemiColonProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSemiColon; + fRange := rsUnknown; +end; + +procedure TSynGWScriptSyn.SlashProc; +begin + case FLine[Run + 1] of + '/': {c++ style comments} + begin + fTokenID := tkComment; + inc(Run, 2); + while not (fLine[Run] in [#0, #10, #13]) do Inc(Run); + end; + '*': {c style comments} + begin + fTokenID := tkComment; + fRange := rsAnsiC; + inc(Run, 2); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + inc(Run, 2); + fRange := rsUnKnown; + break; + end else inc(Run); + #10: break; + #13: break; + else inc(Run); + end; + end; + '=': {divide assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + FExtTokenID := xtkDivideAssign; + end; + else {divide} + begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkDivide; + end; + end; +end; + +procedure TSynGWScriptSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynGWScriptSyn.SquareCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareClose; +end; + +procedure TSynGWScriptSyn.SquareOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareOpen; +end; + +procedure TSynGWScriptSyn.StarProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {multiply assign} + begin + inc(Run, 2); + FExtTokenID := xtkMultiplyAssign; + end; + else {star} + begin + inc(Run); + FExtTokenID := xtkStar; + end; + end; +end; + +procedure TSynGWScriptSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + #92: {backslash} + case FLine[Run + 1] of + #34: inc(Run); {escaped quote doesn't count} + #92: inc(Run); {escaped backslash doesn't count} + end; + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynGWScriptSyn.TildeProc; +begin + inc(Run); {bitwise complement} + fTokenId := tkSymbol; + FExtTokenID := xtkBitComplement; +end; + +procedure TSynGWScriptSyn.XOrSymbolProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {xor assign} + begin + inc(Run, 2); + FExtTokenID := xtkXorAssign; + end; + else {xor} + begin + inc(Run); + FExtTokenID := xtkXor; + end; + end; +end; + +procedure TSynGWScriptSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynGWScriptSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsAnsiC : AnsiCProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynGWScriptSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynGWScriptSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynGWScriptSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynGWScriptSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynGWScriptSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynGWScriptSyn.GetExtTokenID: TxtkTokenKind; +begin + Result := FExtTokenID; +end; + +function TSynGWScriptSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fInvalidAttri; + else Result := nil; + end; +end; + +function TSynGWScriptSyn.GetTokenKind: integer; +begin + Result := Ord(GetTokenID); +end; + +function TSynGWScriptSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynGWScriptSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +procedure TSynGWScriptSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynGWScriptSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynGWScriptSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterGWS; +end; + +class function TSynGWScriptSyn.GetLanguageName: string; +begin + Result := SYNS_LangGWS; +end; + +function TSynGWScriptSyn.GetDefaultAttribute (Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_STRING : Result := fStringAttri; + SYN_ATTR_WHITESPACE : Result := fSpaceAttri; + SYN_ATTR_SYMBOL : Result := fSymbolAttri; + else + Result := nil; + end; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter (TSynGWScriptSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterhaskell.pas b/components/extrasyn/SyneditHighlighters/synhighlighterhaskell.pas new file mode 100644 index 000000000..f9e92ca62 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterhaskell.pas @@ -0,0 +1,1147 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterHaskell.pas, released 2001-10-28 +The Original Code is based on the SynHighlighterCpp.pas, released 2000-04-10 +which in turn was based on the dcjCppSyn.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. + +You may retrieve the latest version of SynEdit from the SynEdit home page, +located at http://SynEdit.SourceForge.net + +You may retrieve the latest version of this file from +http://www.ashleybrown.co.uk/synedit/ + +-------------------------------------------------------------------------------} +{ +@abstract(Provides a Haskell syntax highlighter for SynEdit) +@author(Ashley Brown) +@created(2001) +@lastmod(2000-10-26) +The SynHighlighterHaskell unit provides SynEdit with a Haskell syntax highlighter. +Based on SynHighlighterCpp. + +http://haskell.org/ +http://www.ashleybrown.co.uk/ +ashley@ashleybrown.co.uk +} +unit SynHighlighterHaskell; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, + tkNumber, tkSpace, tkString, tkSymbol, tkUnknown); + + TxtkTokenKind = ( + xtkAdd, xtkAddAssign, xtkAnd, xtkAndAssign, xtkArrow, xtkAssign, + xtkBitComplement, xtkBraceClose, xtkBraceOpen, xtkColon, xtkComma, + xtkDecrement, xtkDivide, xtkDivideAssign, xtkEllipse, xtkGreaterThan, + xtkGreaterThanEqual, xtkIncOr, xtkIncOrAssign, xtkIncrement, xtkLessThan, + xtkLessThanEqual, xtkLogAnd, xtkLogComplement, xtkLogEqual, xtkLogOr, + xtkMod, xtkModAssign, xtkMultiplyAssign, xtkNotEqual, xtkPoint, xtkQuestion, + xtkRoundClose, xtkRoundOpen, xtkScopeResolution, xtkSemiColon, xtkShiftLeft, + xtkShiftLeftAssign, xtkShiftRight, xtkShiftRightAssign, xtkSquareClose, + xtkSquareOpen, xtkStar, xtkSubtract, xtkSubtractAssign, xtkXor, + xtkXorAssign); + + TRangeState = (rsUnknown, rsAnsiC, rsAnsiCAsm, rsAnsiCAsmBlock, rsAsm, + rsAsmBlock, rsDirective, rsDirectiveComment, rsString34, rsString39); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TSynHaskellSyn = class(TSynCustomHighlighter) + private + fAsmStart: Boolean; + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + FExtTokenID: TxtkTokenKind; + fLineNumber: Integer; + fIdentFuncTable: array[0..206] of TIdentFuncTableFunc; + + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + + function Func17: TtkTokenKind; + function Func24: TtkTokenKind; + function Func25: TtkTokenKind; + function Func30: TtkTokenKind; + function Func33: TtkTokenKind; + function Func40: TtkTokenKind; + function Func45: TtkTokenKind; + function Func47: TtkTokenKind; + function Func51: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func64: TtkTokenKind; + function Func67: TtkTokenKind; + function Func70: TtkTokenKind; + function Func76: TtkTokenKind; + function Func84: TtkTokenKind; + function Func92: TtkTokenKind; + function Func93: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func131: TtkTokenKind; + + procedure AnsiCProc; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure AtSymbolProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure CRProc; + procedure ColonProc; + procedure CommaProc; + procedure EqualProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NotSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure QuestionProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure StarProc; + procedure StringProc; + procedure TildeProc; + procedure XOrSymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetSampleSource: string; override; + function GetIdentChars: TSynIdentChars; override; + function GetExtTokenID: TxtkTokenKind; + function IsFilterStored: Boolean; override; + public + class function GetCapabilities: TSynHighlighterCapabilities; override; + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + property ExtTokenID: TxtkTokenKind read GetExtTokenID; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z', #39: + Identifiers[I] := True; + else + Identifiers[I] := False; + end; + Case I in['_', 'a'..'z', 'A'..'Z'] of + True: + begin + if (I > #64) and (I < #91) then + mHashTable[I] := Ord(I) - 64 + else if (I > #96) then + mHashTable[I] := Ord(I) - 95; + end; + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynHaskellSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[24] := @Func24; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[33] := @Func33; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[131] := @Func131; +end; + +function TSynHaskellSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; { KeyHash } + +function TSynHaskellSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else + Result := False; +end; { KeyComp } + +function TSynHaskellSyn.Func17: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func24: TtkTokenKind; +begin + if KeyComp('IO') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func25: TtkTokenKind; +begin + if KeyComp('in') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func30: TtkTokenKind; +begin + if KeyComp('data') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func33: TtkTokenKind; +begin + if KeyComp('Char') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func40: TtkTokenKind; +begin + if KeyComp('let') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func45: TtkTokenKind; +begin + if KeyComp('Int') then Result := tkKey else + if KeyComp('else') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func47: TtkTokenKind; +begin + if KeyComp('False') then Result := tkKey else + if KeyComp('Bool') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func51: TtkTokenKind; +begin + if KeyComp('then') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func58: TtkTokenKind; +begin + if KeyComp('Float') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func59: TtkTokenKind; +begin + if KeyComp('class') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func64: TtkTokenKind; +begin + if KeyComp('where') then Result := tkKey else + if KeyComp('Double') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func67: TtkTokenKind; +begin + if KeyComp('True') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func70: TtkTokenKind; +begin + if KeyComp('type') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func76: TtkTokenKind; +begin + if KeyComp('module') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynHaskellSyn.Func84: TtkTokenKind; +begin + if KeyComp('Integer') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func92: TtkTokenKind; +begin + if KeyComp('String') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func93: TtkTokenKind; +begin + if KeyComp('instance') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func96: TtkTokenKind; +begin + if KeyComp('deriving') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func97: TtkTokenKind; +begin + if KeyComp('import') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynHaskellSyn.Func131: TtkTokenKind; +begin + if KeyComp('otherwise') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynHaskellSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynHaskellSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 207 then Result := fIdentFuncTable[HashKey]() else Result := tkIdentifier; +end; + +procedure TSynHaskellSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := @AndSymbolProc; + #39: fProcTable[I] := @AsciiCharProc; + '@': fProcTable[I] := @AtSymbolProc; + '}': fProcTable[I] := @BraceCloseProc; + '{': fProcTable[I] := @BraceOpenProc; + #13: fProcTable[I] := @CRProc; + ':': fProcTable[I] := @ColonProc; + ',': fProcTable[I] := @CommaProc; + '=': fProcTable[I] := @EqualProc; + '>': fProcTable[I] := @GreaterProc; + '?': fProcTable[I] := @QuestionProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @LowerProc; + '-': fProcTable[I] := @MinusProc; + '%': fProcTable[I] := @ModSymbolProc; + '!': fProcTable[I] := @NotSymbolProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + '|': fProcTable[I] := @OrSymbolProc; + '+': fProcTable[I] := @PlusProc; + '.': fProcTable[I] := @PointProc; + ')': fProcTable[I] := @RoundCloseProc; + '(': fProcTable[I] := @RoundOpenProc; + ';': fProcTable[I] := @SemiColonProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + ']': fProcTable[I] := @SquareCloseProc; + '[': fProcTable[I] := @SquareOpenProc; + '*': fProcTable[I] := @StarProc; + #34: fProcTable[I] := @StringProc; + '~': fProcTable[I] := @TildeProc; + '^': fProcTable[I] := @XOrSymbolProc; + else fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynHaskellSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style:= [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + fSpaceAttri.Foreground := clWindow; + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + fAsmStart := False; + fDefaultFilter := SYNS_FilterHaskell; +end; { Create } + +procedure TSynHaskellSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynHaskellSyn.AnsiCProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + #13: + begin + CRProc; + exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + inc(Run, 2); + if fRange = rsAnsiCAsm then + fRange := rsAsm + else if fRange = rsAnsiCAsmBlock then + fRange := rsAsmBlock + else if fRange = rsDirectiveComment then + fRange := rsDirective + else + fRange := rsUnKnown; + break; + end else + inc(Run); + #10: break; + #13: break; + else inc(Run); + end; +end; + +procedure TSynHaskellSyn.AndSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {and assign} + begin + inc(Run, 2); + FExtTokenID := xtkAndAssign; + end; + '&': {logical and} + begin + inc(Run, 2); + FExtTokenID := xtkLogAnd; + end; + else {and} + begin + inc(Run); + FExtTokenID := xtkAnd; + end; + end; +end; + +procedure TSynHaskellSyn.AsciiCharProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then begin + if fLine[Run + 1] in [#39, '\'] then + inc(Run); + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, #39]; + if fLine[Run] = #39 then + inc(Run); +end; + +procedure TSynHaskellSyn.AtSymbolProc; +begin + fTokenID := tkUnknown; + inc(Run); +end; + +procedure TSynHaskellSyn.BraceCloseProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceClose; + if fRange = rsAsmBlock then fRange := rsUnknown; +end; + +procedure TSynHaskellSyn.BraceOpenProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceOpen; + if fRange = rsAsm then + begin + fRange := rsAsmBlock; + fAsmStart := True; + end; +end; + +procedure TSynHaskellSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run + 1] = #10 then Inc(Run); +end; + +procedure TSynHaskellSyn.ColonProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + ':': {scope resolution operator} + begin + inc(Run, 2); + FExtTokenID := xtkScopeResolution; + end; + else {colon} + begin + inc(Run); + FExtTokenID := xtkColon; + end; + end; +end; + +procedure TSynHaskellSyn.CommaProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkComma; +end; + +procedure TSynHaskellSyn.EqualProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {logical equal} + begin + inc(Run, 2); + FExtTokenID := xtkLogEqual; + end; + else {assign} + begin + inc(Run); + FExtTokenID := xtkAssign; + end; + end; +end; + +procedure TSynHaskellSyn.GreaterProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {greater than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkGreaterThanEqual; + end; + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftRightAssign; + end + else {shift right} + begin + inc(Run, 2); + FExtTokenID := xtkShiftRight; + end; + end; + else {greater than} + begin + inc(Run); + FExtTokenID := xtkGreaterThan; + end; + end; +end; + +procedure TSynHaskellSyn.QuestionProc; +begin + fTokenID := tkSymbol; {conditional} + FExtTokenID := xtkQuestion; + inc(Run); +end; + +procedure TSynHaskellSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynHaskellSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynHaskellSyn.LowerProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {less than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkLessThanEqual; + end; + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftLeftAssign; + end + else {shift left} + begin + inc(Run, 2); + FExtTokenID := xtkShiftLeft; + end; + end; + else {less than} + begin + inc(Run); + FExtTokenID := xtkLessThan; + end; + end; +end; + +procedure TSynHaskellSyn.MinusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {subtract assign} + begin + inc(Run, 2); + FExtTokenID := xtkSubtractAssign; + end; + '-': {decrement} + begin + fTokenID := tkComment; + inc(Run, 2); + while not (fLine[Run] in [#0, #10, #13]) do Inc(Run); + end; + '>': {arrow} + begin + inc(Run, 2); + FExtTokenID := xtkArrow; + end; + else {subtract} + begin + inc(Run); + FExtTokenID := xtkSubtract; + end; + end; +end; + +procedure TSynHaskellSyn.ModSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {mod assign} + begin + inc(Run, 2); + FExtTokenID := xtkModAssign; + end; + else {mod} + begin + inc(Run); + FExtTokenID := xtkMod; + end; + end; +end; + +procedure TSynHaskellSyn.NotSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {not equal} + begin + inc(Run, 2); + FExtTokenID := xtkNotEqual; + end; + else {not} + begin + inc(Run); + FExtTokenID := xtkLogComplement; + end; + end; +end; + +procedure TSynHaskellSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynHaskellSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', 'A'..'F', 'a'..'f', '.', 'u', 'U', 'l', 'L', 'x', 'X'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynHaskellSyn.OrSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {or assign} + begin + inc(Run, 2); + FExtTokenID := xtkIncOrAssign; + end; + '|': {logical or} + begin + inc(Run, 2); + FExtTokenID := xtkLogOr; + end; + else {or} + begin + inc(Run); + FExtTokenID := xtkIncOr; + end; + end; +end; + +procedure TSynHaskellSyn.PlusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {add assign} + begin + inc(Run, 2); + FExtTokenID := xtkAddAssign; + end; + '+': {increment} + begin + inc(Run, 2); + FExtTokenID := xtkIncrement; + end; + else {add} + begin + inc(Run); + FExtTokenID := xtkAdd; + end; + end; +end; + +procedure TSynHaskellSyn.PointProc; +begin + fTokenID := tkSymbol; + if (FLine[Run + 1] = '.') and (FLine[Run + 2] = '.') then + begin {ellipse} + inc(Run, 3); + FExtTokenID := xtkEllipse; + end + else {point} + begin + inc(Run); + FExtTokenID := xtkPoint; + end; +end; + +procedure TSynHaskellSyn.RoundCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkRoundClose; +end; + +procedure TSynHaskellSyn.RoundOpenProc; +begin + inc(Run); + FTokenID := tkSymbol; + FExtTokenID := xtkRoundOpen; +end; + +procedure TSynHaskellSyn.SemiColonProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSemiColon; + if fRange = rsAsm then fRange := rsUnknown; +end; + +procedure TSynHaskellSyn.SlashProc; +begin + case FLine[Run + 1] of + '=': {divide assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + FExtTokenID := xtkDivideAssign; + end; + else {divide} + begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkDivide; + end; + end; +end; + +procedure TSynHaskellSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynHaskellSyn.SquareCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareClose; +end; + +procedure TSynHaskellSyn.SquareOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareOpen; +end; + +procedure TSynHaskellSyn.StarProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {multiply assign} + begin + inc(Run, 2); + FExtTokenID := xtkMultiplyAssign; + end; + else {star} + begin + inc(Run); + FExtTokenID := xtkStar; + end; + end; +end; + +procedure TSynHaskellSyn.StringProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then begin + if fLine[Run + 1] in [#34, '\'] then + Inc(Run); + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, #34]; + if FLine[Run] = #34 then + inc(Run); +end; + +procedure TSynHaskellSyn.TildeProc; +begin + inc(Run); {bitwise complement} + fTokenId := tkSymbol; + FExtTokenID := xtkBitComplement; +end; + +procedure TSynHaskellSyn.XOrSymbolProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {xor assign} + begin + inc(Run, 2); + FExtTokenID := xtkXorAssign; + end; + else {xor} + begin + inc(Run); + FExtTokenID := xtkXor; + end; + end; +end; + +procedure TSynHaskellSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynHaskellSyn.Next; +begin + fAsmStart := False; + fTokenPos := Run; + case fRange of + rsAnsiC, rsAnsiCAsm, + rsAnsiCAsmBlock: AnsiCProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynHaskellSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + else Result := nil; + end; +end; + +function TSynHaskellSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynHaskellSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynHaskellSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynHaskellSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynHaskellSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynHaskellSyn.GetExtTokenID: TxtkTokenKind; +begin + Result := FExtTokenID; +end; + +function TSynHaskellSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + else Result := nil; + end; +end; + +function TSynHaskellSyn.GetTokenKind: integer; +begin + Result := Ord(GetTokenID); +end; + +function TSynHaskellSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynHaskellSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +procedure TSynHaskellSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynHaskellSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; +end; + +function TSynHaskellSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterHaskell; +end; + +class function TSynHaskellSyn.GetLanguageName: string; +begin + Result := SYNS_LangHaskell; +end; + +class function TSynHaskellSyn.GetCapabilities: TSynHighlighterCapabilities; +begin + Result := inherited GetCapabilities + [hcUserSettings]; +end; + +function TSynHaskellSyn.GetSampleSource: string; +begin + Result := '-- Haskell Sample Source'#13#10 + + 'tail :: [a] -> [a]'#13#10 + + 'tail (x:xs) = xs'#13#10 + + ''; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynHaskellSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterhp48.pas b/components/extrasyn/SyneditHighlighters/synhighlighterhp48.pas new file mode 100644 index 000000000..b8f4cdbaf --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterhp48.pas @@ -0,0 +1,975 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterHP48.pas, released 2000-06-23. +The Original Code is based on the cbHPSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Cyrille de Brebisson. +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: SynHighlighterHP48.pas,v 1.11 2005/12/31 07:34:36 skyweb Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +Known Issues: + - small memory leak in TSpeedStringList has to be fixed +-------------------------------------------------------------------------------} +{ +@abstract(Provides SynEdit with a HP48 assembler syntax highlighter.) +@author(Cyrille de Brebisson , converted to SynEdit by David Muir ) +@created(1998-12, converted to SynEdit 2000-06-23) +@lastmod(2000-06-23) +The unit SynHighlighterHP48 provides SynEdit with a HP48 assembler highlighter. +} +unit SynHighlighterHP48; + +{$I synedit.inc} + +interface + +uses + SynEditHighlighter, + SysUtils, + Classes; + +const + NbSubList = 128; + +type + TSpeedStringList = class; + + TSpeedListObject = class + protected + FName: string; + FSpeedList: TSpeedStringList; + fobject: tobject; + procedure SetName(const Value: string); virtual; + public + property Name: string read FName write SetName; + constructor Create(Aname: string); + destructor Destroy; override; + property SpeedList: TSpeedStringList read FSpeedList write FSpeedList; + property pointer: tobject read fobject write fobject; + end; + + PSpeedListObjects = ^TSpeedListObjects; + TSpeedListObjects = array[0..0] of TSpeedListObject; + + TSpeedStringList = class + private + function GetText: string; + procedure SetText(const Value: string); + function GetInObject(Index: Integer): TObject; + procedure SetInObject(Index: Integer; const Value: TObject); + protected + FOnChange: TNotifyEvent; + SumOfUsed: array[0..NbSubList - 1] of integer; + datasUsed: array[0..NbSubList - 1] of integer; + datas: array[0..NbSubList - 1] of PSpeedListObjects; + lengthDatas: array[0..NbSubList - 1] of integer; + procedure Changed; virtual; + function Get(Index: Integer): string; virtual; + function GetObject(Index: Integer): TSpeedListObject; + function GetCount: integer; + function GetStringList: TStrings; + procedure SetStringList(const value: TStrings); + public + procedure NameChange(const obj: TSpeedListObject; const NewName: string); + procedure ObjectDeleted(const obj: TSpeedListObject); + + destructor Destroy; override; + constructor create; + function AddObj(const Value: TSpeedListObject): Integer; + function Add(const Value: string): TSpeedListObject; + procedure Clear; + function Find(const name: string): TSpeedListObject; + property OnChange: TNotifyEvent read FOnChange write FOnChange; + property Objects[Index: Integer]: TSpeedListObject read GetObject; + property inobject[Index: Integer]: TObject read GetInObject write SetInObject; + property Strings[Index: Integer]: string read Get; default; + property count: integer read GetCount; + property StringList: TStrings read GetStringList write SetStringList; + property text: string read GetText write SetText; + end; + + TtkTokenKind = (tkNull, tkAsmKey, tkAsm, tkAsmComment, tksAsmKey, tksAsm, + tksAsmComment, tkRplKey, tkRpl, tkRplComment); + + TRangeState = (rsRpl, rsComRpl, rssasm1, rssasm2, rssasm3, rsAsm, rsComAsm2, + rsComAsm1); + + TSynHP48Syn = class(TSynCustomHighLighter) + private + fTockenKind: TtkTokenKind; + fRange: TRangeState; + fLine: string; + Run: LongInt; + fTokenPos: Integer; + fEol: Boolean; + Attribs: array[TtkTokenKind] of TSynHighlighterAttributes; + FRplKeyWords: TSpeedStringList; + FAsmKeyWords: TSpeedStringList; + FSAsmNoField: TSpeedStringList; + FBaseRange: TRangeState; + function GetAttrib(Index: integer): TSynHighlighterAttributes; + procedure SetAttrib(Index: integer; Value: TSynHighlighterAttributes); + + function NullProc: TtkTokenKind; + function SpaceProc: TtkTokenKind; + function ParOpenProc: TtkTokenKind; + function RplComProc: TtkTokenKind; + function AsmComProc(c: char): TtkTokenKind; + function PersentProc: TtkTokenKind; + function IdentProc: TtkTokenKind; + function SlashProc: TtkTokenKind; + function SasmProc1: TtkTokenKind; + function SasmProc2: TtkTokenKind; + function SasmProc3: TtkTokenKind; + procedure EndOfToken; + procedure SetHighLightChange; + function Next1: TtkTokenKind; + procedure Next2(tkk: TtkTokenKind); + function GetTokenFromRange: TtkTokenKind; + function StarProc: TtkTokenKind; + protected + function GetAttribCount: integer; override; + function GetAttribute(idx: integer): TSynHighlighterAttributes; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + procedure SetLine(const NewValue: string; LineNumber: Integer); override; + function GetToken: string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenPos: Integer; override; + procedure Next; override; + + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + + function GetRange: Pointer; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + procedure Assign(Source: TPersistent); override; + property AsmKeyWords: TSpeedStringList read FAsmKeyWords; + property SAsmFoField: TSpeedStringList read FSAsmNoField; + property RplKeyWords: TSpeedStringList read FRplKeyWords; + published + property AsmKey: TSynHighlighterAttributes index Ord(tkAsmKey) + read GetAttrib write SetAttrib; + property AsmTxt: TSynHighlighterAttributes index Ord(tkAsm) + read GetAttrib write SetAttrib; + property AsmComment: TSynHighlighterAttributes index Ord(tkAsmComment) + read GetAttrib write SetAttrib; + property sAsmKey: TSynHighlighterAttributes index Ord(tksAsmKey) + read GetAttrib write SetAttrib; + property sAsmTxt: TSynHighlighterAttributes index Ord(tksAsm) + read GetAttrib write SetAttrib; + property sAsmComment: TSynHighlighterAttributes index Ord(tksAsmComment) + read GetAttrib write SetAttrib; + property RplKey: TSynHighlighterAttributes index Ord(tkRplKey) + read GetAttrib write SetAttrib; + property RplTxt: TSynHighlighterAttributes index Ord(tkRpl) + read GetAttrib write SetAttrib; + property RplComment: TSynHighlighterAttributes index Ord(tkRplComment) + read GetAttrib write SetAttrib; + property BaseRange: TRangeState read FBaseRange write FBaseRange; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +const + tkTokenName: array[TtkTokenKind] of string = (SYNS_AttrNull, + SYNS_AttrAsmKey, SYNS_AttrAsm, SYNS_AttrAsmComment, + SYNS_AttrSASMKey, SYNS_AttrSASM, SYNS_AttrSASMComment, + SYNS_AttrRplKey, SYNS_AttrRpl, SYNS_AttrRplComment); + + DefaultAsmKeyWords: string = '!RPL'#13#10'ENDCODE'#13#10'{'#13#10'}'#13#10 + + 'GOTO'#13#10'GOSUB'#13#10'GOSBVL'#13#10'GOVLNG'#13#10'GOLONG'#13#10'SKIP' + + #13#10'SKIPYES' + #13#10'->'#13#10'SKUB'#13#10'SKUBL'#13#10'SKC'#13#10'SKNC'#13#10'SKELSE' + + #13#10'SKEC'#13#10'SKENC'#13#10'SKLSE'#13#10 + 'GOTOL'#13#10'GOSUBL'#13#10 + + 'RTN'#13#10'RTNC'#13#10'RTNNC'#13#10'RTNSC'#13#10'RTNCC'#13#10'RTNSXM'#13#10'RTI'; + OtherAsmKeyWords: array[0..5] of string = ('UP', 'EXIT', 'UPC', 'EXITC', 'UPNC', 'EXITNC'); + DefaultRplKeyWords: string = + 'CODEM'#13#10'ASSEMBLEM'#13#10'CODE'#13#10'ASSEMBLE'#13#10'IT'#13#10'ITE'#13#10'case'#13#10'::'#13#10';'#13#10'?SEMI'#13#10''''#13#10'#=case'#13#10'{'#13#10'}'#13#10'NAMELESS'#13#10'LOCAL'#13#10'LOCALNAME'#13#10'LABEL'#13#10 + + 'LOCALLABEL'#13#10'xNAME'#13#10'tNAME' + 'COLA'#13#10'NULLNAME'#13#10'xROMID'#13#10'#0=ITE'#13#10'#ITE'#13#10'2''RCOLARPITE'#13#10'ANDITE'#13#10'COLAITE'#13#10'COLARPITE'#13#10'DUP#0=ITE'#13#10 + + 'EQITE'#13#10'ITE'#13#10'RPITE'#13#10'SysITE'#13#10'UNxSYMRPITE'#13#10'UserITE'#13#10'snnSYMRPITE'#13#10'snsSYMRPITE'#13#10'ssnSYMRPITE'#13#10'sssSYMRPITE'#13#10'$_EXIT'#13#10'DA1OK?NOTIT'#13#10'DA2aOK?NOTIT'#13#10 + + 'DA2bOK?NOTIT'#13#10'DA3OK?NOTIT'#13#10'DO#EXIT'#13#10'DO$EXIT'#13#10'DO%EXIT'#13#10'DOHXSEXIT'#13#10'DUP#0=IT'#13#10'EQIT'#13#10'GCDHEULPEXIT'#13#10'GSPLIT'#13#10'NOT_IT'#13#10'POINTEXIT'#13#10'POLYARIT'#13#10'RPIT'#13#10 + + 'parleftIT'#13#10'parrightIT'#13#10''''#13#10'IT'#13#10'ITE'#13#10'SEMI'#13#10'UNTIL'#13#10'LOOP'#13#10'?SEMI'#13#10'NOT?SEMI'#13#10'#0=case'#13#10'#1=case'#13#10'#<>case'#13#10'#2case'#13#10'#>33case'#13#10'#>case'#13#10'%-1=case'#13#10'%0=case'#13#10'%1=case'#13#10'%2=case'#13#10'AEQ1stcase'#13#10'AEQopscase'#13#10'ANDNOTcase'#13#10'ANDcase'#13#10'C%-1=case'#13#10 + + 'C%0=case'#13#10'C%1=case'#13#10'C%2=case'#13#10'COLANOTcase'#13#10'COLAcase'#13#10'DUP#0=case'#13#10'EQUALNOTcase'#13#10'EQUALcase'#13#10'EQUALcasedrop'#13#10'EQUALcasedrp'#13#10'EQcase'#13#10'EQcaseDROP'#13#10 + + 'EQcasedrop'#13#10'EnvNGcase'#13#10'M-1stcasechs'#13#10'MEQ*case'#13#10'MEQ+case'#13#10'MEQ-case'#13#10'MEQ/case'#13#10'MEQ1stcase'#13#10'MEQCHScase'#13#10'MEQFCNcase'#13#10'MEQINVcase'#13#10'MEQSQcase'#13#10'MEQ^case'#13#10 + + 'MEQopscase'#13#10'Mid1stcase'#13#10'NOTBAKcase'#13#10'NOTLIBcase'#13#10'NOTLISTcase'#13#10'NOTMATRIXcase'#13#10'NOTROMPcase'#13#10'NOTSECOcase'#13#10'NOTTYPEcase'#13#10'NOTcase'#13#10'NOTcase2DROP'#13#10'NOTcase2drop'#13#10 + + 'NOTcaseDROP'#13#10'NOTcaseFALSE'#13#10'NOTcaseTRUE'#13#10'NOTcasedrop'#13#10'NULLargcase'#13#10'NcaseSIZEERR'#13#10'NcaseTYPEERR'#13#10'NoEdit?case'#13#10'ORcase'#13#10'OVER#=case'#13#10'REALcase'#13#10'REQcase'#13#10 + + 'REQcasedrop'#13#10'Z-1=case'#13#10'Z0=case'#13#10'Z1=case'#13#10'accNBAKcase'#13#10'accNLIBcase'#13#10'case'#13#10'case2DROP'#13#10'case2drop'#13#10'case2drpfls'#13#10'caseDEADKEY'#13#10'caseDROP'#13#10'caseDoBadKey'#13#10 + + 'caseDrpBadKy'#13#10'caseERRJMP'#13#10'caseFALSE'#13#10'caseSIZEERR'#13#10'caseTRUE'#13#10'casedrop'#13#10'casedrpfls'#13#10'casedrptru'#13#10'caseout'#13#10'cxcasecheck'#13#10'dARRYcase'#13#10'dIDNTNcase'#13#10'dLISTcase'#13#10 + + 'dMATRIXcase'#13#10'dREALNcase'#13#10'dREALcase'#13#10'dZINTNcase'#13#10'delimcase'#13#10'estcase'#13#10'idntcase'#13#10'idntlamcase'#13#10'j#-1=case'#13#10'j#0=case'#13#10'j#1=case'#13#10'j%-1=case'#13#10'j%0=case'#13#10 + + 'j%1=case'#13#10'jEQcase'#13#10'jZ-1=case'#13#10'jZ0=case'#13#10'jZ1=case'#13#10'namelscase'#13#10'need''case'#13#10'negrealcase'#13#10'ngsizecase'#13#10'nonopcase'#13#10'nonrmcase'#13#10'num#-1=case'#13#10'num#0=case'#13#10 + + 'num#1=case'#13#10'num-1=case'#13#10'num0=case'#13#10'num0case'#13#10'num1=case'#13#10'num2=case'#13#10'numb1stcase'#13#10'rebuildcase'#13#10'tok=casedrop'#13#10'wildcase'#13#10'zerdercase'#13#10; + SasmNoField: string = 'LOOP'#13#10'RTNSXM'#13#10'RTN'#13#10'RTNSC'#13#10'RTNCC'#13#10'SETDEC'#13#10'SETHEX'#13#10'RSTK=C'#13#10'C=RSTK'#13#10'CLRST'#13#10'C=ST'#13#10'ST=C'#13#10'CSTEX'#13#10 + + 'RTI'#13#10'R0=A'#13#10'R1=A'#13#10'R2=A'#13#10'R3=A'#13#10'R4=A'#13#10'R0=C'#13#10'R1=C'#13#10'R2=C'#13#10'R3=C'#13#10'R4=C'#13#10'A=R0'#13#10'A=R1'#13#10'A=R2'#13#10'A=R3'#13#10'A=R4'#13#10 + + 'C=R0'#13#10'C=R1'#13#10'C=R2'#13#10'C=R3'#13#10'C=R4'#13#10'AR0EX'#13#10'AR1EX'#13#10'AR2EX'#13#10'AR3EX'#13#10'AR4EX'#13#10'CR0EX'#13#10'CR1EX'#13#10'CR2EX'#13#10'CR3EX'#13#10'CR4EX'#13#10 + + 'D0=A'#13#10'D0=C'#13#10'D1=A'#13#10'D1=C'#13#10'AD0EX'#13#10'AD1EX'#13#10'CD0EX'#13#10'CD1EX'#13#10'D0=AS'#13#10'D1=AS'#13#10'D0=CS'#13#10'D1=CD'#13#10'CD1XS'#13#10'CD0XS'#13#10'AD1XS'#13#10'AD0XS'#13#10 + + 'RTNC'#13#10'RTNNC'#13#10'OUT=CS'#13#10'OUT=C'#13#10'A=IN'#13#10'C=IN'#13#10'SHUTDN'#13#10'INTON'#13#10'C=ID'#13#10'CONFIG'#13#10'UNCNFG'#13#10'RSI'#13#10'PC=(A)'#13#10'PC=(C)'#13#10'INTOFF'#13#10 + + 'C+P+1'#13#10'RESET'#13#10'SREQ?'#13#10'ASLC'#13#10'BSLC'#13#10'CSLC'#13#10'DSLC'#13#10'ASRC'#13#10'BSRC'#13#10'CSRC'#13#10'DSRC'#13#10'ASRB'#13#10'BSRB'#13#10'CSRB'#13#10'DSRB'#13#10'PC=A'#13#10'PC=C'#13#10 + + 'A=PC'#13#10'C=PC'#13#10'APCEX'#13#10'CPCEX'#13#10'XM=0'#13#10'SB=0'#13#10'SR=0'#13#10'MP=0'#13#10'CLRHST'#13#10'?XM=0'#13#10'?SR=0'#13#10'?MP=0'#13#10'?SB=0'#13#10'RTNYES'#13#10'SKIPYES{'#13#10'{'#13#10'}'#13#10'UP'#13#10'EXIT'#13#10'EXITNC'#13#10'EXITC'#13#10'UPC'#13#10'UPNC' + + '}SKELSE{'#13#10'SKC{'#13#10'SKNC{'#13#10'SKUB{'#13#10'SKUBL{'#13#10'SKIPC{'#13#10'SKIPNC{'#13#10'EXIT2'#13#10'EXIT3'#13#10'UP2'#13#10'UP3'#13#10'}SKLSE{'#13#10'}SKEC{'#13#10'}SKENC{'#13#10; + +function StringCrc(S: string): integer; +var + i: integer; +begin + result := 0; + for i := 1 to length(s) do begin + result := (result shr 4) xor (((result xor ord(s[i])) and $F) * $1081); + result := (result shr 4) xor (((result xor (ord(s[i]) shr 4)) and $F) * $1081); + end; +end; + +{ TSpeedListObject } + +constructor TSpeedListObject.create(Aname: string); +begin + inherited create; + FName := Aname; +end; + +destructor TSpeedListObject.destroy; +begin + if FSpeedList <> nil then + FSpeedList.ObjectDeleted(Self); + inherited destroy; +end; + +procedure TSpeedListObject.SetName(const Value: string); +begin + FName := Value; + if FSpeedList <> nil then + FSpeedList.NameChange(Self, Value); +end; + +{ TSpeedStringList } + +function TSpeedStringList.AddObj(const Value: TSpeedListObject): Integer; +var + crc: integer; + i: integer; +begin + crc := StringCrc(Value.Name) mod High(Datas) + 1; + if DatasUsed[crc] = lengthDatas[crc] then begin + ReallocMem(datas[crc], (lengthDatas[crc] * 2 + 1) * SizeOf(datas[1][0])); + lengthDatas[crc] := lengthDatas[crc] * 2 + 1; + end; + Datas[crc]^[DatasUsed[crc]] := Value; + result := SumOfUsed[crc] + DatasUsed[crc]; + inc(DatasUsed[crc]); + for i := crc + 1 to High(SumOfUsed) do + inc(SumOfUsed[i]); + Value.SpeedList := Self; +end; + +function TSpeedStringList.Add(const Value: string): TSpeedListObject; +begin + result := TSpeedListObject.Create(value); + AddObj(Result); +end; + +procedure TSpeedStringList.Changed; +begin + if Assigned(FOnChange) then + FOnChange(Self); +end; + +procedure TSpeedStringList.Clear; +var + i, j: integer; +begin + for i := low(datas) to high(datas) do begin + for j := 0 to DatasUsed[i] - 1 do + datas[i]^[j].free; + datasUsed[i] := 0; + ReallocMem(datas[i], 0); + lengthDatas[i] := 0; + SumOfUsed[i] := 0; + end; + Changed; +end; + +constructor TSpeedStringList.create; +var + i: integer; +begin + inherited Create; + for i := Low(Datas) to high(datas) do begin + SumOfUsed[i] := 0; + DatasUsed[i] := 0; + lengthDatas[i] := 0; + datas[i] := nil; + end; +end; + +destructor TSpeedStringList.Destroy; +begin + Clear; + inherited destroy; +end; + +function TSpeedStringList.Find(const name: string): TSpeedListObject; +var + crc: integer; + i: integer; +begin + crc := StringCrc(name) mod High(Datas) + 1; + for i := 0 to DatasUsed[crc] - 1 do + if Datas[crc]^[i].name = name then begin + result := Datas[crc]^[i]; + exit; + end; + result := nil; +end; + +function TSpeedStringList.Get(Index: Integer): string; +var + i: integer; +begin + for i := low(SumOfUsed) + 1 to High(SumOfUsed) do + if Index > SumOfUsed[i] then begin + result := Datas[i - 1]^[Index - SumOfUsed[i - 1]].name; + exit; + end; + result := ''; +end; + +function TSpeedStringList.GetCount: integer; +begin + result := SumOfUsed[High(datas)] + DatasUsed[High(Datas)]; +end; + +function TSpeedStringList.GetInObject(Index: Integer): TObject; +var + i: integer; +begin + for i := low(SumOfUsed) + 1 to High(SumOfUsed) do + if Index > SumOfUSed[i] then begin + result := Datas[i - 1]^[Index - SumOfUsed[i - 1]].pointer; + exit; + end; + result := nil; +end; + +function TSpeedStringList.GetObject(Index: Integer): TSpeedListObject; +var + i: integer; +begin + for i := low(SumOfUsed) + 1 to High(SumOfUsed) do + if Index > SumOfUSed[i] then begin + result := Datas[i - 1]^[Index - SumOfUsed[i - 1]]; + exit; + end; + result := nil; +end; + +function TSpeedStringList.GetStringList: TStrings; +var + i, j: integer; +begin + result := TStringList.Create; + for i := Low(Datas) to High(Datas) do + for j := 0 to DatasUsed[i] - 1 do + result.add(datas[i]^[j].name); +end; + +function TSpeedStringList.GetText: string; +begin + with StringList do begin + result := Text; + free; + end; +end; + +procedure TSpeedStringList.NameChange(const Obj: TSpeedListObject; const NewName: string); +var + crc: integer; + i: integer; + j: integer; +begin + crc := StringCrc(obj.Name) mod High(Datas) + 1; + for i := 0 to DatasUsed[crc] - 1 do + if Datas[crc]^[i] = Obj then begin + for j := i + 1 to DatasUsed[crc] - 1 do + Datas[i - 1] := Datas[i]; + for j := crc + 1 to High(Datas) do + dec(SumOfUsed[j]); + if DatasUsed[crc] < lengthDatas[crc] div 2 then begin + ReallocMem(Datas[crc], DatasUsed[crc] * SizeOf(Datas[crc][0])); + lengthDatas[crc] := DatasUsed[crc]; + end; + AddObj(Obj); + exit; + end; +end; + +procedure TSpeedStringList.ObjectDeleted(const obj: TSpeedListObject); +var + crc: integer; + i: integer; + j: integer; +begin + crc := StringCrc(obj.Name) mod High(Datas) + 1; + for i := 0 to DatasUsed[crc] - 1 do + if Datas[crc]^[i] = Obj then begin + for j := i + 1 to DatasUsed[crc] - 1 do + Datas[i - 1] := Datas[i]; + for j := crc + 1 to High(Datas) do + dec(SumOfUsed[j]); + Obj.FSpeedList := nil; + exit; + end; +end; + +procedure TSpeedStringList.SetInObject(Index: Integer; + const Value: TObject); +var + i: integer; +begin + for i := low(SumOfUsed) + 1 to High(SumOfUsed) do + if Index > SumOfUSed[i] then begin + Datas[i - 1]^[Index - SumOfUsed[i - 1]].pointer := value; + exit; + end; +end; + +procedure TSpeedStringList.SetStringList(const value: TStrings); +var + i: integer; +begin + clear; + for i := 0 to Value.Count - 1 do + AddObj(TSpeedListObject.Create(value[i])); +end; + +procedure TSpeedStringList.SetText(const Value: string); +var + s: TStrings; +begin + s := TStringList.Create; + try + s.Text := Value; + StringList := s; + finally + s.Free; + end; +end; + +{ TSynHP48Syn } + +constructor TSynHP48Syn.Create(AOwner: TComponent); +var + i: TtkTokenKind; + j, k: integer; +begin + for i := low(TtkTokenKind) to High(TtkTokenKind) do + Attribs[i] := TSynHighlighterAttributes.Create(tkTokenName[i]); + inherited Create(AOwner); + SetHighlightChange; + FAsmKeyWords := TSpeedStringList.Create; + FAsmKeyWords.Text := DefaultAsmKeyWords; + for j := low(OtherAsmKeyWords) to High(OtherAsmKeyWords) do begin + FAsmKeyWords.AddObj(TSpeedListObject.Create(OtherAsmKeyWords[j])); + for k := 1 to 8 do + FAsmKeyWords.AddObj(TSpeedListObject.Create(OtherAsmKeyWords[j] + IntToStr(k))); + end; + FRplKeyWords := TSpeedStringList.Create; + FRplKeyWords.Text := DefaultRplKeyWords; + FSAsmNoField := TSpeedStringList.Create; + FSAsmNoField.Text := SAsmNoField; + BaseRange := rsRpl; + fRange := rsRpl; + fDefaultFilter := SYNS_FilterHP48; +end; { Create } + +destructor TSynHP48Syn.Destroy; +var + i: TtkTokenKind; +begin + for i := low(TtkTokenKind) to High(TtkTokenKind) do + Attribs[i].Free; + FAsmKeyWords.Free; + FRplKeyWords.Free; + FSAsmNoField.free; + inherited Destroy; +end; { Destroy } + +procedure TSynHP48Syn.SetLine(const NewValue: string; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 1; + fEol := False; + Next; +end; { SetLine } + +function TSynHP48Syn.AsmComProc(c: char): TtkTokenKind; +begin + Result := tkAsmComment; + if (Run > Length(fLine)) then + Result := NullProc + else + while Run <= Length(FLine) do + if ((run = 1) or (fLine[run - 1] <= ' ')) and + (fLine[Run] = '*') and + ((run < Length(fLine)) and (fLine[run + 1] = c)) and + ((run + 1 = Length(fLine)) or (fLine[run + 2] <= ' ')) then begin + inc(run, 2); + fRange := rsAsm; + break; + end + else + inc(Run); +end; + +function TSynHP48Syn.RplComProc: TtkTokenKind; +begin + Result := tkRplComment; + if (Run > Length(fLine)) then + Result := NullProc + else + while Run <= Length(FLine) do + if fLine[Run] = ')' then begin + inc(run); + fRange := rsRpl; + break; + end + else + inc(Run); +end; + +function TSynHP48Syn.SlashProc: TtkTokenKind; +begin + if fRange = rsRpl then + Result := IdentProc + else if ((Run = 1) or (fLine[Run - 1] <= ' ')) and + (fLine[Run] = '/') and + (run < Length(fLine)) and + (fLine[run + 1] = '*') and + ((run + 1 = Length(fLine)) or (fLine[Run + 2] <= ' ')) then begin + inc(Run, 2); + Result := tkAsmComment; + fRange := rsComAsm2; + end + else if (run < Length(fLine)) and (fLine[Run + 1] = '/') then begin + inc(Run, 2); + Result := tkAsmComment; + while (run <= Length(fLine)) do + if FLine[Run] in [#10, #13] then begin + inc(Run); + break; + end + else + inc(Run); + end + else + Result := IdentProc +end; + +function TSynHP48Syn.ParOpenProc: TtkTokenKind; +begin + if fRange = rsRpl then + if ((Run = 1) and ((Length(fLine) = 1) or (fLine[Run + 1] <= ' '))) or + ((fLine[Run - 1] <= ' ') and ((Length(fLine) = Run) or (fLine[Run + 1] <= ' '))) then begin + inc(Run); + Result := tkRplComment; + fRange := rsComRpl; + end + else + Result := IdentProc + else if ((run = 1) or (fLine[run - 1] <= ' ')) and + (fline[Run] = '(') and + (run < Length(fLine)) and + (fLine[run + 1] = '*') and + ((run + 2 > Length(fLine)) or (fLine[run + 2] <= ' ')) then begin + inc(Run, 2); + Result := tkAsmComment; + fRange := rsComAsm1; + end + else + Result := IdentProc +end; + +function TSynHP48Syn.PersentProc: TtkTokenKind; +begin + if fRange = rsAsm then begin + inc(Run); + Result := tkAsmComment; + while (run <= Length(fLine)) do + case FLine[Run] of + #10, #13: begin + inc(Run); + break; + end; + else + inc(Run); + end; + end + else + Result := IdentProc; +end; + +function TSynHP48Syn.StarProc: TtkTokenKind; +begin + if fRange = rsRpl then begin + inc(Run); + Result := tkRplComment; + while (run <= Length(fLine)) do + case FLine[Run] of + #10, #13: begin + inc(Run); + break; + end; + else + inc(Run); + end; + end + else + Result := IdentProc; +end; + +function TSynHP48Syn.IdentProc: TtkTokenKind; +var + i: integer; + s: string; +begin + i := Run; + EndOfToken; + s := Copy(fLine, i, run - i); + if fRange = rsAsm then + if FAsmKeyWords.Find(s) <> nil then + if (s = '!RPL') or (s = 'ENDCODE') then begin + fRange := rsRpl; + result := tkAsmKey; + end + else + result := tkAsmKey + else if fLine[i] <> '*' then + result := tkAsm + else + result := tkAsmKey + else if FRplKeyWords.Find(s) <> nil then + if (s = 'CODEM') or (s = 'ASSEMBLEM') then begin + fRange := rsAsm; + result := tkAsmKey; + end + else if (s = 'CODE') or (s = 'ASSEMBLE') then begin + fRange := rssAsm1; + result := tksAsmKey; + end + else + result := tkRplKey + else + result := tkRpl; +end; + +function TSynHP48Syn.GetTokenFromRange: TtkTokenKind; +begin + case frange of + rsAsm: result := tkAsm; + rssAsm1: result := tksAsmKey; + rssAsm2: result := tksAsm; + rssAsm3: result := tksAsmComment; + rsRpl: result := tkRpl; + rsComRpl: result := tkRplComment; + rsComAsm1, rsComAsm2: result := tkAsmComment; + else + result := tkNull; + end; +end; + +function TSynHP48Syn.NullProc: TtkTokenKind; +begin + Result := tkNull; + fEol := True; +end; + +function TSynHP48Syn.SpaceProc: TtkTokenKind; +begin + inc(Run); + while (Run <= Length(FLine)) and (FLine[Run] in [#1..#32]) do + inc(Run); + result := GetTokenFromRange; +end; + +function TSynHP48Syn.Next1: TtkTokenKind; +begin + fTokenPos := Run; + if Run > Length(fLine) then + result := NullProc + else if fRange = rsComRpl then + result := RplComProc + else if fRange = rsComAsm1 then + result := AsmComProc(')') + else if fRange = rsComAsm2 then + result := AsmComProc('/') + else if frange = rssasm1 then + result := SasmProc1 + else if frange = rssasm2 then + result := sasmproc2 + else if frange = rssasm3 then + result := sasmproc3 + else if fLine[Run] in [#1..#32] then + result := SpaceProc + else if fLine[Run] = '(' then + result := ParOpenProc + else if fLine[Run] = '%' then + result := PersentProc + else if fLine[Run] = '/' then + result := SlashProc + else if (run = 1) and (fRange = rsRpl) and (fLine[1] = '*') then + result := StarProc + else + result := IdentProc; +end; + +procedure TSynHP48Syn.Next2(tkk: TtkTokenKind); +begin + fTockenKind := tkk; +end; + +procedure TSynHP48Syn.Next; +begin + Next2(Next1); +end; + +function TSynHP48Syn.GetEol: Boolean; +begin + Result := fEol; +end; + +function TSynHP48Syn.GetToken: string; +var + Len: LongInt; + a: PChar; +begin + a := @(fLine[fTokenPos]); + Len := Run - fTokenPos; + SetString(Result, a, Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynHP48Syn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := @FLine[fTokenPos]; +end; +{$ENDIF} + +function TSynHP48Syn.GetTokenPos: Integer; +begin + Result := fTokenPos - 1; +end; + +function TSynHP48Syn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +procedure TSynHP48Syn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynHP48Syn.ResetRange; +begin + fRange := BaseRange; +end; + +function TSynHP48Syn.GetAttrib(Index: integer): TSynHighlighterAttributes; +begin + Result := Attribs[TtkTokenKind(Index)]; +end; + +procedure TSynHP48Syn.SetAttrib(Index: integer; Value: TSynHighlighterAttributes); +begin + Attribs[TtkTokenKind(Index)].Assign(Value); +end; + +procedure TSynHP48Syn.EndOfToken; +begin + while (Run <= Length(fLine)) and (FLine[Run] > ' ') do + Inc(Run); +end; + +procedure TSynHP48Syn.Assign(Source: TPersistent); +var + i: TtkTokenKind; +begin + if Source is TSynHP48Syn then begin + for i := Low(Attribs) to High(Attribs) do begin + Attribs[i].Background := TSynHP48Syn(source).Attribs[i].Background; + Attribs[i].Foreground := TSynHP48Syn(source).Attribs[i].Foreground; + Attribs[i].Style := TSynHP48Syn(source).Attribs[i].Style; + end; + AsmKeyWords.Text := TSynHP48Syn(source).AsmKeyWords.Text; + RplKeyWords.Text := TSynHP48Syn(source).RplKeyWords.Text; + end + else + inherited Assign(Source); +end; + +function TSynHP48Syn.GetAttribCount: integer; +begin + Result := Ord(High(Attribs)) - Ord(Low(Attribs)) + 1; +end; + +function TSynHP48Syn.GetAttribute(idx: integer): TSynHighlighterAttributes; +begin // sorted by name + if (idx <= Ord(High(TtkTokenKind))) then + Result := Attribs[TtkTokenKind(idx)] + else + Result := nil; +end; + +function TSynHP48Syn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterHP48; +end; + +class function TSynHP48Syn.GetLanguageName: string; +begin + Result := SYNS_LangHP48; +end; + +procedure TSynHP48Syn.SetHighLightChange; +var + i: TtkTokenKind; +begin + for i := Low(Attribs) to High(Attribs) do begin + Attribs[i].OnChange := @DefHighLightChange; + Attribs[i].InternalSaveDefaultValues; + end; +end; + +function TSynHP48Syn.SasmProc1: TtkTokenKind; +var + i: integer; + s: string; +begin + Result := tksAsmKey; + if run > Length(fLine) then + exit; + if FLine[Run] = '*' then begin + frange := rssasm3; + result := tksAsmComment; + exit; + end; + if FLine[Run] >= ' ' then begin + i := run; + while (run <= Length(fLine)) and (FLine[run] > ' ') do + inc(run); + s := Copy(fLine, i, run - i); + if (s = 'RPL') or (s = 'ENDCODE') then begin + frange := rsRpl; + exit; + end; + end; + while (run <= Length(fLine)) and (FLine[run] <= ' ') and (FLine[run] <> #10) do + inc(run); + if run <= Length(fLine) then + frange := rssasm2 + else + frange := rssasm1; +end; + +function TSynHP48Syn.SasmProc2: TtkTokenKind; +var + i: integer; + s: string; +begin + Result := tksAsm; + while (run <= Length(fLine)) and (FLine[run] <= ' ') and (fline[run] <> #10) do + inc(run); + if run > 30 then begin + frange := rssasm3; + exit; + end; + i := run; + while (run <= Length(fLine)) and (FLine[run] > ' ') do + inc(run); + s := Copy(fLine, i, run - i); + if (s = 'ENDCODE') or (s = 'RPL') then begin + frange := rsRpl; + result := tksAsmKey; + end + else begin + if FSAsmNoField.Find(s) = nil then begin + while (run <= Length(fLine)) and (FLine[run] <= ' ') and (FLine[run] <> #10) do + inc(run); + while (run <= Length(fLine)) and (FLine[run] > ' ') do + inc(run); + while (run <= Length(fLine)) and (FLine[run] <= ' ') and (FLine[run] <> #10) do + inc(run); + end; + if run <= Length(fLine) then + frange := rssasm3 + else + frange := rssasm1; + end; +end; + +function TSynHP48Syn.SasmProc3: TtkTokenKind; +begin + Result := tksAsmComment; + while (run <= Length(fLine)) and (FLine[run] <> #10) do + inc(run); + if run <= Length(fLine) then inc(run); + frange := rssasm1; +end; + +function TSynHP48Syn.GetTokenAttribute: TSynHighlighterAttributes; +begin + Result := GetAttrib(Ord(fTockenKind)); +end; + +function TSynHP48Syn.GetTokenKind: integer; +begin + Result := Ord(fTockenKind); +end; + +function TSynHP48Syn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + Result := nil; +end; + +initialization + RegisterPlaceableHighlighter(TSynHP48Syn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighteridl.pas b/components/extrasyn/SyneditHighlighters/synhighlighteridl.pas new file mode 100644 index 000000000..f752ab422 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighteridl.pas @@ -0,0 +1,924 @@ +{------------------------------------------------------------------------------- +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. + +Code template generated with SynGen. +The original code is: SynHighlighterIDL.pas, released 2001-10-15. +Description: CORBA IDL Parser/Highlighter +The initial author of this file is P.L. Polak. +Copyright (c) 2001, 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: SynHighlighterIDL.pas,v 1.9 2005/01/28 16:53:23 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} +unit SynHighlighterIDL; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + SysUtils, + Classes; + +Type + TtkTokenKind = ( + tkComment, + tkDatatype, + tkIdentifier, + tkKey, + tkNull, + tkNumber, + tkPreprocessor, + tkSpace, + tkString, + tkSymbol, + tkUnknown); + + TRangeState = (rsUnKnown, rsComment, rsString, rsChar); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +const + MaxKey = 152; + +type + TSynIdlSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + fRange: TRangeState; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0 .. MaxKey] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fDatatypeAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fPreprocessorAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func25: TtkTokenKind; + function Func32: TtkTokenKind; + function Func34: TtkTokenKind; + function Func43: TtkTokenKind; + function Func48: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func71: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: 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 Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func117: TtkTokenKind; + function Func120: TtkTokenKind; + function Func125: TtkTokenKind; + function Func128: TtkTokenKind; + function Func136: TtkTokenKind; + function Func152: TtkTokenKind; + procedure IdentProc; + procedure SymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure NullProc; + procedure NumberProc; + procedure SpaceProc; + procedure CRProc; + procedure LFProc; + procedure CommentOpenProc; + procedure CommentProc; + procedure StringOpenProc; + procedure StringProc; + procedure CharOpenProc; + procedure CharProc; + procedure PreProcessorProc; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + constructor Create(AOwner: TComponent); override; + class function GetLanguageName: string; override; + function GetRange: Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property DatatypeAttri: TSynHighlighterAttributes read fDatatypeAttri write fDatatypeAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property PreprocessorAttri: TSynHighlighterAttributes read fPreprocessorAttri write fPreprocessorAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable : array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else + Identifiers[I] := False; + end; + case I in ['_', 'A'..'Z', 'a'..'z'] of + True: + begin + if (I > #64) and (I < #91) then + mHashTable[I] := Ord(I) - 64 + else if (I > #96) then + mHashTable[I] := Ord(I) - 95; + end; + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynIdlSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[34] := @Func34; + fIdentFuncTable[43] := @Func43; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[71] := @Func71; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[90] := @Func90; + fIdentFuncTable[92] := @Func92; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[95] := @Func95; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[101] := @Func101; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[108] := @Func108; + fIdentFuncTable[117] := @Func117; + fIdentFuncTable[120] := @Func120; + fIdentFuncTable[125] := @Func125; + fIdentFuncTable[128] := @Func128; + fIdentFuncTable[136] := @Func136; + fIdentFuncTable[152] := @Func152; +end; + +function TSynIdlSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynIdlSyn.KeyComp(const aKey :string) :Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynIdlSyn.Func25: TtkTokenKind; +begin + if KeyComp('in') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func32: TtkTokenKind; +begin + if KeyComp('case') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func34: TtkTokenKind; +begin + if KeyComp('char') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func43: TtkTokenKind; +begin + if KeyComp('FALSE') then Result := tkKey else + if KeyComp('any') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func48: TtkTokenKind; +begin + if KeyComp('local') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func52: TtkTokenKind; +begin + if KeyComp('long') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func53: TtkTokenKind; +begin + if KeyComp('fixed') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func54: TtkTokenKind; +begin + if KeyComp('void') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func57: TtkTokenKind; +begin + if KeyComp('enum') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func58: TtkTokenKind; +begin + if KeyComp('wchar') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func59: TtkTokenKind; +begin + if KeyComp('out') then Result := tkKey else + if KeyComp('float') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func60: TtkTokenKind; +begin + if KeyComp('Object') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func64: TtkTokenKind; +begin + if KeyComp('TRUE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func65: TtkTokenKind; +begin + if KeyComp('double') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func68: TtkTokenKind; +begin + if KeyComp('octet') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func69: TtkTokenKind; +begin + if KeyComp('public') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func71: TtkTokenKind; +begin + if KeyComp('boolean') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func76: TtkTokenKind; +begin + if KeyComp('default') then Result := tkKey else + if KeyComp('const') then Result := tkKey else + if KeyComp('module') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func77: TtkTokenKind; +begin + if KeyComp('raises') then Result := tkKey else + if KeyComp('native') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func78: TtkTokenKind; +begin + if KeyComp('union') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func84: TtkTokenKind; +begin + if KeyComp('inout') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func85: TtkTokenKind; +begin + if KeyComp('short') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func88: TtkTokenKind; +begin + if KeyComp('switch') then Result := tkKey else + if KeyComp('typedef') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func89: TtkTokenKind; +begin + if KeyComp('oneway') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func90: TtkTokenKind; +begin + if KeyComp('interface') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func92: TtkTokenKind; +begin + if KeyComp('abstract') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func93: TtkTokenKind; +begin + if KeyComp('string') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func95: TtkTokenKind; +begin + if KeyComp('factory') then Result := tkKey else + if KeyComp('ValueBase') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func97: TtkTokenKind; +begin + if KeyComp('custom') then Result := tkKey else + if KeyComp('sequence') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func98: TtkTokenKind; +begin + if KeyComp('private') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func101: TtkTokenKind; +begin + if KeyComp('unsigned') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func102: TtkTokenKind; +begin + if KeyComp('readonly') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func107: TtkTokenKind; +begin + if KeyComp('struct') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func108: TtkTokenKind; +begin + if KeyComp('context') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func117: TtkTokenKind; +begin + if KeyComp('wstring') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func120: TtkTokenKind; +begin + if KeyComp('exception') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func125: TtkTokenKind; +begin + if KeyComp('attribute') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func128: TtkTokenKind; +begin + if KeyComp('truncatable') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func136: TtkTokenKind; +begin + if KeyComp('valuetype') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.Func152: TtkTokenKind; +begin + if KeyComp('supports') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynIdlSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynIdlSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey <= MaxKey then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynIdlSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0 : fProcTable[I] := @NullProc; + #10 : fProcTable[I] := @LFProc; + #13 : fProcTable[I] := @CRProc; + '/' : fProcTable[I] := @CommentOpenProc; + '"' : fProcTable[I] := @StringOpenProc; + '''' : fProcTable[I] := @CharOpenProc; + '#' : fProcTable[I] := @PreProcessorProc; + #1..#9, + #11, + #12, + #14..#32 : fProcTable[I] := @SpaceProc; + 'A'..'Z', + 'a'..'z', + '_' : fProcTable[I] := @IdentProc; + '0'..'9' : fProcTable[I] := @NumberProc; + '-', '+', + '*', '\', + ',', '.', + '[', ']', + '{', '}', + '<', '>', + '(', ')', + '=', '?', + ':', ';' : fProcTable[I] := @SymbolProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +procedure TSynIdlSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + inc(Run); + until not (fLine[Run] in [#1..#32]); +end; + +procedure TSynIdlSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynIdlSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do + begin + case FLine[Run] of + '.': if FLine[Run + 1] = '.' then + Break; + end; + inc(Run); + end; +end; { NumberProc } + + +procedure TSynIdlSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then + inc(Run); +end; + +procedure TSynIdlSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynIdlSyn.CommentOpenProc; +begin + Inc(Run); + if (fLine[Run] = '*') then + begin + fRange := rsComment; + CommentProc; + fTokenID := tkComment; + end + else if (fLine[Run] = '/') then + begin + while not (fLine[Run] in [#0, #10, #13]) do + Inc(Run); + fTokenID := tkComment; + end + else + fTokenID := tkSymbol; +end; + +procedure TSynIdlSyn.CommentProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + begin + fTokenID := tkComment; + repeat + if (fLine[Run] = '*') and + (fLine[Run + 1] = '/') then + begin + Inc(Run, 2); + fRange := rsUnKnown; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + end; +end; + +procedure TSynIdlSyn.StringOpenProc; +begin + Inc(Run); + fRange := rsString; + StringProc; + fTokenID := tkString; +end; + +procedure TSynIdlSyn.StringProc; +begin + fTokenID := tkString; + repeat + if (fLine[Run] = '"') then + begin + Inc(Run); + fRange := rsUnKnown; + Break; + end + else if (fLine[Run] = '\') then + Inc(Run); + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynIdlSyn.CharOpenProc; +begin + Inc(Run); + fRange := rsChar; + CharProc; + fTokenID := tkString; +end; + +procedure TSynIdlSyn.CharProc; +begin + fTokenID := tkString; + repeat + if (fLine[Run] = '''') then + begin + Inc(Run); + fRange := rsUnKnown; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynIdlSyn.PreProcessorProc; +var + Directive: String; +begin + Directive := ''; + while not (fLine[Run] in [#0, #9, #10, #13, #32]) do + begin + Directive := Directive + fLine[Run]; + Inc(Run); + end; + if (AnsiCompareStr(Directive, '#include') = 0) then + fTokenID := tkPreprocessor + else if (AnsiCompareStr(Directive, '#pragma') = 0) then + fTokenID := tkPreprocessor + else + fTokenID := tkIdentifier; +end; { PreProcessorProc } + + +constructor TSynIdlSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + fCommentAttri.Foreground := clNavy; + AddAttribute(fCommentAttri); + + fDatatypeAttri := TSynHighLighterAttributes.Create(SYNS_AttrDatatype); + fDatatypeAttri.Style := [fsBold]; + fDatatypeAttri.Foreground := clTeal; + AddAttribute(fDatatypeAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighLighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clBlue; + AddAttribute(fNumberAttri); + + fPreprocessorAttri := TSynHighLighterAttributes.Create(SYNS_AttrPreprocessor); + fPreprocessorAttri.Foreground := clRed; + AddAttribute(fPreprocessorAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clBlue; + AddAttribute(fStringAttri); + + fSymbolAttri := TSynHighLighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterCORBAIDL; + fRange := rsUnknown; +end; + +procedure TSynIdlSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynIdlSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + Inc(Run); +end; + +procedure TSynIdlSyn.SymbolProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynIdlSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynIdlSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsComment: CommentProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynIdlSyn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_STRING : Result := fStringAttri; + SYN_ATTR_WHITESPACE : Result := fSpaceAttri; + SYN_ATTR_SYMBOL : Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynIdlSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynIdlSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynIdlSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynIdlSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynIdlSyn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkDatatype: Result := fDatatypeAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkPreprocessor: Result := fPreprocessorAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynIdlSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynIdlSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynIdlSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', 'a'..'z', 'A'..'Z'] + TSynSpecialChars; +end; + +function TSynIdlSyn.GetSampleSource: string; +begin + Result := '/* CORBA IDL sample source */'#13#10 + + '#include '#13#10 + + #13#10 + + 'const string TestString = "Hello World";'#13#10 + + 'const long TestLong = 10;'#13#10 + + #13#10 + + 'module TestModule {'#13#10 + + ' interface DemoInterface {'#13#10 + + ' boolean HelloWorld(in string Message);'#13#10 + + ' }'#13#10 + + '}'; +end; + +function TSynIdlSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterCORBAIDL; +end; + +class function TSynIdlSyn.GetLanguageName: string; +begin + Result := SYNS_LangCORBAIDL; +end; + +procedure TSynIdlSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynIdlSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynIdlSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynIdlSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterinno.pas b/components/extrasyn/SyneditHighlighters/synhighlighterinno.pas new file mode 100644 index 000000000..5d73febd6 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterinno.pas @@ -0,0 +1,967 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterInno.pas, released 2000-05-01. +The Initial Author of this file is Satya. +Portions created by Satya are Copyright 2000 Satya. +All Rights Reserved. + +Contributors to the SynEdit project 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: SynHighlighterInno.pas,v 1.23 2005/01/28 16:53:23 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +Known Issues: +-------------------------------------------------------------------------------} +{ +@abstract(Provides an Inno script file highlighter for SynEdit) +@author(Satya) +@created(2000-05-01) +@lastmod(2001-01-23) +The SynHighlighterInno unit provides an Inno script file highlighter for SynEdit. +Check out http://www.jrsoftware.org for the free Inno Setup program, +and http://www.wintax.nl/isx/ for My Inno Setup Extensions. +} +unit SynHighlighterInno; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + SynHighlighterHashEntries, + Classes; + +type + TtkTokenKind = (tkComment, tkConstant, tkIdentifier, tkKey, tkKeyOrParameter, + tkNull, tkNumber, tkParameter, tkSection, tkSpace, tkString, tkSymbol, + tkUnknown); + + TProcTableProc = procedure of object; + + TSynInnoSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fConstantAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fSectionAttri: TSynHighlighterAttributes; + fParamAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fInvalidAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fKeywords: TSynHashEntryList; + function KeyHash(ToHash: PChar): integer; + function KeyComp(const aKey: string): Boolean; + procedure SymbolProc; + procedure CRProc; + procedure IdentProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure SectionProc; + procedure SpaceProc; + procedure EqualProc; + procedure ConstantProc; + procedure SemiColonProc; + procedure StringProc; + procedure UnknownProc; + + procedure DoAddKeyword(AKeyword: string; AKind: integer); + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetToken: string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenID: TtkTokenKind; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetLine(const NewValue: string; LineNumber:Integer); override; + function GetSampleSource :string; override; + published + property ConstantAttri: TSynHighlighterAttributes read fConstantAttri + write fConstantAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property InvalidAttri: TSynHighlighterAttributes read fInvalidAttri + write fInvalidAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property ParameterAttri: TSynHighlighterAttributes read fParamAttri + write fParamAttri; + property SectionAttri: TSynHighlighterAttributes read fSectionAttri + write fSectionAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst,SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +const + {Note: new 'Section names' and the new 'Constants' need not be added + as they are highlighted automatically} + + {Ref: Keywords and Parameters are updated as they last appeared in + Inno Setup / ISX version 1.3.26} + + Keywords: string = + 'AdminPrivilegesRequired,AllowNoIcons,AllowRootDirectory,AllowUNCPath,' + + 'AlwaysCreateUninstallIcon,AlwaysRestart,AlwaysShowComponentsList,' + + 'AlwaysShowDirOnReadyPage,AlwaysShowGroupOnReadyPage,' + + 'AlwaysUsePersonalGroup,AppCopyright,AppId,AppMutex,AppName,AppPublisher,' + + 'AppPublisherURL,AppSupportURL,AppUpdatesURL,AppVerName,AppVersion,' + + 'Attribs,BackColor,BackColor2,BackColorDirection,BackSolid,Bits,' + + 'ChangesAssociations,Check,CodeFile,Comment,Components,Compression,CompressLevel,CopyMode,'+ + 'CreateAppDir,CreateUninstallRegKey,DefaultDirName,DefaultGroupName,' + + 'Description,DestDir,DestName,DirExistsWarning,DisableAppendDir,' + + 'DisableDirExistsWarning,DisableDirPage,DisableFinishedPage,' + + 'DisableProgramGroupPage,DisableReadyMemo,DisableReadyPage,' + + 'DisableStartupPrompt,DiskClusterSize,DiskSize,DiskSpaceMBLabel,' + + 'DiskSpanning,DontMergeDuplicateFiles,EnableDirDoesntExistWarning,' + + 'ExtraDiskSpaceRequired,Filename,Flags,FlatComponentsList,FontInstall,' + + 'GroupDescription,HotKey,IconFilename,IconIndex,InfoAfterFile,InfoBeforeFile,' + + 'InstallMode,InternalCompressLevel,Key,LicenseFile,MessagesFile,MinVersion,Name,' + + 'OnlyBelowVersion,OutputBaseFilename,OutputDir,OverwriteUninstRegEntries,' + + 'Parameters,Password,ReserveBytes,Root,RunOnceId,Section,' + + 'ShowComponentSizes,Source,SourceDir,StatusMsg,Subkey,Tasks,Type,Types,' + + 'UninstallDisplayIcon,UninstallDisplayName,UninstallFilesDir,' + + 'UninstallIconName,UninstallLogMode,UninstallStyle,Uninstallable,' + + 'UpdateUninstallLogAppName,UsePreviousAppDir,UsePreviousGroup,' + + 'UsePreviousTasks,UsePreviousSetupType,UseSetupLdr,ValueData,ValueName,' + + 'ValueType,WindowResizable,WindowShowCaption,WindowStartMaximized,' + + 'WindowVisible,WizardImageBackColor,WizardImageFile,WizardSmallImageFile,' + + 'WizardStyle,WorkingDir'; + + Parameters: string = + 'HKCC,HKCR,HKCU,HKLM,HKU,alwaysoverwrite,alwaysskipifsameorolder,append,' + + 'binary,classic,closeonexit,comparetimestampalso,confirmoverwrite,' + + 'createkeyifdoesntexist,createonlyiffileexists,createvalueifdoesntexist,' + + 'deleteafterinstall,deletekey,deletevalue,dirifempty,dontcloseonexit,' + + 'dontcreatekey,disablenouninstallwarning,dword,exclusive,expandsz,' + + 'external,files,filesandordirs,fixed,fontisnttruetype,iscustom,isreadme,' + + 'modern,multisz,new,noerror,none,normal,nowait,onlyifdestfileexists,' + + 'onlyifdoesntexist,overwrite,overwritereadonly,postinstall,' + + 'preservestringtype,regserver,regtypelib,restart,restartreplace,' + + 'runmaximized,runminimized,sharedfile,shellexec,showcheckbox,' + + 'skipifnotsilent,skipifsilent,silent,skipifdoesntexist,' + + 'skipifsourcedoesntexist,unchecked,uninsalwaysuninstall,' + + 'uninsclearvalue,uninsdeleteentry,uninsdeletekey,uninsdeletekeyifempty,' + + 'uninsdeletesection,uninsdeletesectionifempty,uninsdeletevalue,' + + 'uninsneveruninstall,useapppaths,verysilent,waituntilidle'; + + KeyOrParameter: string = 'string'; + +procedure MakeIdentTable; +var + c: char; +begin + FillChar(Identifiers, SizeOf(Identifiers), 0); + for c := 'a' to 'z' do + Identifiers[c] := TRUE; + for c := 'A' to 'Z' do + Identifiers[c] := TRUE; + for c := '0' to '9' do + Identifiers[c] := TRUE; + Identifiers['_'] := TRUE; + + FillChar(mHashTable, SizeOf(mHashTable), 0); + mHashTable['_'] := 1; + for c := 'a' to 'z' do + mHashTable[c] := 2 + Ord(c) - Ord('a'); + for c := 'A' to 'Z' do + mHashTable[c] := 2 + Ord(c) - Ord('A'); +end; + +function TSynInnoSyn.KeyHash(ToHash: PChar): integer; +begin + Result := 0; + while Identifiers[ToHash^] do begin +{$IFOPT Q-} + Result := 7 * Result + mHashTable[ToHash^]; +{$ELSE} + Result := (7 * Result + mHashTable[ToHash^]) and $FFFFFF; +{$ENDIF} + inc(ToHash); + end; + Result := Result and $1FF; // 511 + fStringLen := ToHash - fToIdent; +end; + +function TSynInnoSyn.KeyComp(const aKey: string): Boolean; +var + i: integer; + pKey1, pKey2: PChar; +begin + pKey1 := fToIdent; + // Note: fStringLen is always > 0 ! + pKey2 := pointer(aKey); + for i := 1 to fStringLen do + begin + if mHashTable[pKey1^] <> mHashTable[pKey2^] then + begin + Result := FALSE; + exit; + end; + Inc(pKey1); + Inc(pKey2); + end; + Result := TRUE; +end; + +function TSynInnoSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + Entry: TSynHashEntry; +begin + fToIdent := MayBe; + Entry := fKeywords[KeyHash(MayBe)]; + while Assigned(Entry) do begin + if Entry.KeywordLen > fStringLen then + break + else if Entry.KeywordLen = fStringLen then + if KeyComp(Entry.Keyword) then begin + Result := TtkTokenKind(Entry.Kind); + exit; + end; + Entry := Entry.Next; + end; + Result := tkIdentifier; +end; + +procedure TSynInnoSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #13: fProcTable[I] := @CRProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + #59 {';'}: fProcTable[I] := @SemiColonProc; + #61 {=} : fProcTable[I] := @EqualProc; + #34: fProcTable[I] := @StringProc; + '#', ':', ',', '(', ')': fProcTable[I] := @SymbolProc; + '{': fProcTable[I] := @ConstantProc; + #91 {[} : fProcTable[i] := @SectionProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynInnoSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fKeywords := TSynHashEntryList.Create; + + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + fCommentAttri.Foreground := clGray; + AddAttribute(fCommentAttri); + + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fInvalidAttri := TSynHighlighterAttributes.Create(SYNS_AttrIllegalChar); + AddAttribute(fInvalidAttri); + + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + fKeyAttri.Foreground := clNavy; + AddAttribute(fKeyAttri); + + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clMaroon; + AddAttribute(fNumberAttri); + + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clBlue; + AddAttribute(fStringAttri); + + fConstantAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective); + fConstantAttri.Style := [fsBold, fsItalic]; + fConstantAttri.Foreground := clTeal; + AddAttribute(fConstantAttri); + + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + + //Parameters + fParamAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor); + fParamAttri.Style := [fsBold]; + fParamAttri.Foreground := clOlive; + AddAttribute(fParamAttri); + + fSectionAttri := TSynHighlighterAttributes.Create(SYNS_AttrSection); + fSectionAttri.Style := [fsBold]; + fSectionAttri.Foreground := clRed; + AddAttribute(fSectionAttri); + + SetAttributesOnChange(@DefHighlightChange); + EnumerateKeywords(Ord(tkKey), Keywords, IdentChars, @DoAddKeyword); + EnumerateKeywords(Ord(tkParameter), Parameters, IdentChars, @DoAddKeyword); + EnumerateKeywords(Ord(tkKeyOrParameter), KeyOrParameter, IdentChars, + @DoAddKeyword); + MakeMethodTables; + fDefaultFilter := SYNS_FilterInno; +end; + +destructor TSynInnoSyn.Destroy; +begin + fKeywords.Free; + inherited Destroy; +end; + +procedure TSynInnoSyn.SetLine(const NewValue: string; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +function TSynInnoSyn.GetSampleSource :string; +begin + Result:='; Inno Setup '+LineEnding+ + '; Copyright (C) 1997-2012 Jordan Russell. All rights reserved.'+LineEnding+ + '; Portions by Martijn Laan'+LineEnding+ + '; For conditions of distribution and use, see LICENSE.TXT.'+LineEnding+ + ';'+LineEnding+ + '; Setup script'+LineEnding+LineEnding+ + '[Setup]'+LineEnding+ + 'AppName=Inno Setup'+LineEnding+ + 'AppId=Inno Setup 5'+LineEnding+ + 'AppVersion=5.5.5'+LineEnding+ + 'AppPublisher=jrsoftware.org'+LineEnding+ + 'AppPublisherURL=http://www.innosetup.com/'+LineEnding+ + 'AppSupportURL=http://www.innosetup.com/'+LineEnding+ + 'AppUpdatesURL=http://www.innosetup.com/'+LineEnding+ + 'VersionInfoCopyright=Copyright (C) 1997-2012 Jordan Russell. Portions Copyright (C) 2000-2012 Martijn Laan.'+LineEnding+ + 'AppMutex=InnoSetupCompilerAppMutex,Global\InnoSetupCompilerAppMutex'+LineEnding+ + 'MinVersion=0,5.0'+LineEnding+ + 'DefaultDirName={pf}\Inno Setup 5'+LineEnding+ + 'DefaultGroupName=Inno Setup 5'+LineEnding+ + 'AllowNoIcons=yes'+LineEnding+ + 'Compression=lzma2/max'+LineEnding+ + 'SolidCompression=yes'+LineEnding+ + 'Uninstallable=not PortableCheck'+LineEnding+ + 'UninstallDisplayIcon={app}\Compil32.exe'+LineEnding+ + 'LicenseFile=license.txt'+LineEnding+ + 'TimeStampsInUTC=yes'+LineEnding+ + 'TouchDate=none'+LineEnding+ + 'TouchTime=00:00'+LineEnding+ + 'WizardImageFile=compiler:WizModernImage-IS.bmp'+LineEnding+ + 'WizardSmallImageFile=compiler:WizModernSmallImage-IS.bmp'+LineEnding+ + '#ifndef NOSIGNTOOL'+LineEnding+ + 'SignTool=issigntool'+LineEnding+ + 'SignedUninstaller=yes'+LineEnding+ + '#endif'+LineEnding+LineEnding+ + '[Languages]'+LineEnding+ + 'Name: en; MessagesFile: "files\Default.isl"'+LineEnding+ + 'Name: br; MessagesFile: "files\Languages\BrazilianPortuguese.isl"'+LineEnding+ + 'Name: ca; MessagesFile: "files\Languages\Catalan.isl"'+LineEnding+ + 'Name: co; MessagesFile: "files\Languages\Corsican.isl"'+LineEnding+ + 'Name: cz; MessagesFile: "files\Languages\Czech.isl"'+LineEnding+ + 'Name: da; MessagesFile: "files\Languages\Danish.isl"'+LineEnding+ + 'Name: nl; MessagesFile: "files\Languages\Dutch.isl"'+LineEnding+ + 'Name: fi; MessagesFile: "files\Languages\Finnish.isl"'+LineEnding+ + 'Name: fr; MessagesFile: "files\Languages\French.isl"'+LineEnding+ + 'Name: de; MessagesFile: "files\Languages\German.isl"'+LineEnding+ + 'Name: gr; MessagesFile: "files\Languages\Greek.isl"'+LineEnding+ + 'Name: he; MessagesFile: "files\Languages\Hebrew.isl"'+LineEnding+ + 'Name: hu; MessagesFile: "files\Languages\Hungarian.isl"'+LineEnding+ + 'Name: it; MessagesFile: "files\Languages\Italian.isl"'+LineEnding+ + 'Name: ja; MessagesFile: "files\Languages\Japanese.isl"'+LineEnding+ + '#ifdef UNICODE'+LineEnding+ + 'Name: nep; MessagesFile: "files\Languages\Nepali.islu"'+LineEnding+ + '#endif'+LineEnding+ + 'Name: no; MessagesFile: "files\Languages\Norwegian.isl"'+LineEnding+ + 'Name: pl; MessagesFile: "files\Languages\Polish.isl"'+LineEnding+ + 'Name: pt; MessagesFile: "files\Languages\Portuguese.isl"'+LineEnding+ + 'Name: ru; MessagesFile: "files\Languages\Russian.isl"'+LineEnding+ + 'Name: sg; MessagesFile: "files\Languages\ScottishGaelic.isl"'+LineEnding+ + 'Name: se; MessagesFile: "files\Languages\SerbianLatin.isl"'+LineEnding+ + 'Name: se2; MessagesFile: "files\Languages\SerbianCyrillic.isl"'+LineEnding+ + 'Name: sl2; MessagesFile: "files\Languages\Slovenian.isl"'+LineEnding+ + 'Name: sp; MessagesFile: "files\Languages\Spanish.isl"'+LineEnding+ + 'Name: tu; MessagesFile: "files\Languages\Turkish.isl"'+LineEnding+ + 'Name: uk; MessagesFile: "files\Languages\Ukrainian.isl"'+LineEnding+LineEnding+ + '[Messages]'+LineEnding+ + '; two "Setup" on the same line looks weird, so put a line break in between'+LineEnding+ + 'en.WelcomeLabel1=Welcome to the Inno Setup%nSetup Wizard'+LineEnding+LineEnding+ + '[Tasks]'+LineEnding+ + 'Name: desktopicon; Description: "{cm:CreateDesktopIcon}"; Flags: unchecked'+LineEnding+ + 'Name: fileassoc; Description: "{cm:AssocFileExtension,Inno Setup,.iss}"'+LineEnding+LineEnding+ + '[InstallDelete]'+LineEnding+ + '; Remove Unicode-only files if needed'+LineEnding+ + '#ifndef UNICODE'+LineEnding+ + 'Type: files; Name: "{app}\Languages\Nepali.islu"'+LineEnding+ + '#endif'+LineEnding+ + '; Remove ISPP files if needed'+LineEnding+ + 'Type: files; Name: "{app}\ISPP.dll"; Check: not ISPPCheck'+LineEnding+ + 'Type: files; Name: "{app}\ISPPBuiltins.iss"; Check: not ISPPCheck'+LineEnding+ + '; Remove old ISPP files'+LineEnding+ + 'Type: files; Name: "{app}\ISCmplr.dls"'+LineEnding+ + 'Type: files; Name: "{app}\Builtins.iss"'+LineEnding+ + '; Older versions created the desktop icon under {userdesktop}'+LineEnding+ + 'Type: files; Name: "{userdesktop}\Inno Setup Compiler.lnk"'+LineEnding+LineEnding+ + '[Files]'+LineEnding+ + '; Files used by [Code] first so these can be quickly decompressed despite solid compression'+LineEnding+ + 'Source: "files\ISPP.ico"; Flags: dontcopy'+LineEnding+ + '; Other files'+LineEnding+ + 'Source: "license.txt"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "ishelp\Staging\ISetup.chm"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Compil32.exe"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\isscint.dll"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\ISCC.exe"; DestDir: "{app}"; Flags: ignoreversion touch; Check: not ISPPCheck'+LineEnding+ + 'Source: "files\ISCmplr.dll"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Setup.e32"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\SetupLdr.e32"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Default.isl"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\BrazilianPortuguese.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Catalan.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Corsican.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Czech.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Danish.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Dutch.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\French.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Finnish.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\German.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Greek.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Hebrew.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Hungarian.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Italian.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Japanese.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + '#ifdef UNICODE'+LineEnding+ + 'Source: "files\Languages\Nepali.islu"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + '#endif'+LineEnding+ + 'Source: "files\Languages\Norwegian.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Polish.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Portuguese.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Russian.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\ScottishGaelic.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\SerbianCyrillic.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\SerbianLatin.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Slovenian.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Spanish.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Turkish.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\Languages\Ukrainian.isl"; DestDir: "{app}\Languages"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\WizModernImage.bmp"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\WizModernImage-IS.bmp"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\WizModernSmallImage.bmp"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\WizModernSmallImage-IS.bmp"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\iszlib.dll"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\isunzlib.dll"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\isbzip.dll"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\isbunzip.dll"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\islzma.dll"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\islzma32.exe"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\islzma64.exe"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "whatsnew.htm"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "ishelp\isfaq.htm"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Example1.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Example2.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Example3.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\64Bit.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\64BitThreeArch.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\64BitTwoArch.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Components.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Languages.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyProg.exe"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyProg-x64.exe"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyProg-IA64.exe"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyProg.chm"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Readme.txt"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Readme-Dutch.txt"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\Readme-German.txt"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\CodeExample1.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\CodeDlg.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\CodeClasses.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\CodeDll.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\CodeAutomation.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\CodeAutomation2.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\CodePrepareToInstall.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\UninstallCodeExample1.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyDll.dll"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyDll\C\MyDll.c"; DestDir: "{app}\Examples\MyDll\C"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyDll\C\MyDll.def"; DestDir: "{app}\Examples\MyDll\C"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyDll\C\MyDll.dsp"; DestDir: "{app}\Examples\MyDll\C"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\MyDll\Delphi\MyDll.dpr"; DestDir: "{app}\Examples\MyDll\Delphi"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\ISPPExample1.iss"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "Examples\ISPPExample1License.txt"; DestDir: "{app}\Examples"; Flags: ignoreversion touch'+LineEnding+ + '; ISPP files'+LineEnding+ + 'Source: "Projects\ISPP\Help\Staging\ISPP.chm"; DestDir: "{app}"; Flags: ignoreversion touch'+LineEnding+ + 'Source: "files\ISPPCC.exe"; DestDir: "{app}"; DestName: "ISCC.exe"; Flags: ignoreversion touch; Check: ISPPCheck'+LineEnding+ + 'Source: "files\ISPP.dll"; DestDir: "{app}"; Flags: ignoreversion touch; Check: ISPPCheck'+LineEnding+ + 'Source: "files\ISPPBuiltins.iss"; DestDir: "{app}"; Flags: ignoreversion touch; Check: ISPPCheck'+LineEnding+LineEnding+ + '[Icons]'+LineEnding+ + 'Name: "{group}\Inno Setup Compiler"; Filename: "{app}\Compil32.exe"; WorkingDir: "{app}"; AppUserModelID: "JR'+ + '.InnoSetup.IDE.5"'+LineEnding+ + 'Name: "{group}\Inno Setup Documentation"; Filename: "{app}\ISetup.chm"'+LineEnding+ + 'Name: "{group}\Inno Setup Example Scripts"; Filename: "{app}\Examples\"'+LineEnding+ + 'Name: "{group}\Inno Setup FAQ"; Filename: "{app}\isfaq.htm"'+LineEnding+ + 'Name: "{group}\Inno Setup Revision History"; Filename: "{app}\whatsnew.htm"'+LineEnding+ + 'Name: "{commondesktop}\Inno Setup Compiler"; Filename: "{app}\Compil32.exe"; WorkingDir: "{app}"; AppUserMode'+ + 'lID: "JR.InnoSetup.IDE.5"; Tasks: desktopicon'+LineEnding+LineEnding+ + '[Run]'+LineEnding+ + 'Filename: "{app}\Compil32.exe"; Parameters: "/ASSOC"; StatusMsg: "{cm:AssocingFileExtension,Inno Setup,.iss}"'+ + '; Tasks: fileassoc'+LineEnding+ + 'Filename: "{app}\Compil32.exe"; WorkingDir: "{app}"; Description: "{cm:LaunchProgram,Inno Setup}"; Flags: now'+ + 'ait postinstall skipifsilent'+LineEnding+LineEnding+ + '[UninstallRun]'+LineEnding+ + 'Filename: "{app}\Compil32.exe"; Parameters: "/UNASSOC"; RunOnceId: "RemoveISSAssoc"'+LineEnding+LineEnding+ + '[CustomMessages]'+LineEnding+ + 'ISPPTitle=Inno Setup Preprocessor'+LineEnding+ + 'ISPPSubtitle=Would you like to install Inno Setup Preprocessor?'+LineEnding+ + 'ISPPText=Inno Setup Preprocessor (ISPP) is an official add-on for Inno Setup. ISPP allows you to conditionall'+ + 'y compile parts of scripts, to use compile time variables in your scripts and to use built-in functions which'+ + 'for example can read from the registry or INI files at compile time.%n%nISPP also contains a special version '+ + 'of the ISCC command line compiler which can take variable definitions as command line parameters and use them'+ + 'during compilation.'+LineEnding+ + 'ISPPText2=Select whether you would like to install ISPP, then click Next.'+LineEnding+ + 'ISPPCheck=&Install Inno Setup Preprocessor'+LineEnding+LineEnding+ + '[Code]'+LineEnding+ + 'var'+LineEnding+ + ' ISPPPage: TWizardPage;'+LineEnding+ + ' ISPPCheckBox: TCheckBox;'+LineEnding+LineEnding+ + 'function GetModuleHandle(lpModuleName: LongInt): LongInt;'+LineEnding+ + 'external ''GetModuleHandleA@kernel32.dll stdcall'';'+LineEnding+ + 'function ExtractIcon(hInst: LongInt; lpszExeFileName: AnsiString; nIconIndex: LongInt): LongInt;'+LineEnding+ + 'external ''ExtractIconA@shell32.dll stdcall'';'+LineEnding+ + 'function DrawIconEx(hdc: LongInt; xLeft, yTop: Integer; hIcon: LongInt; cxWidth, cyWidth: Integer; istepIfAni'+ + 'Cur: LongInt; hbrFlickerFreeDraw, diFlags: LongInt): LongInt;'+LineEnding+ + 'external ''DrawIconEx@user32.dll stdcall'';'+LineEnding+ + 'function DestroyIcon(hIcon: LongInt): LongInt;'+LineEnding+ + 'external ''DestroyIcon@user32.dll stdcall'';'+LineEnding+LineEnding+ + 'const'+LineEnding+ + ' DI_NORMAL = 3;'+LineEnding+LineEnding+ + 'function CreateCustomOptionPage(AAfterId: Integer; ACaption, ASubCaption, AIconFileName, ALabel1Caption, ALab'+ + 'el2Caption,'+LineEnding+ + ' ACheckCaption: String; var CheckBox: TCheckBox): TWizardPage;'+LineEnding+ + 'var'+LineEnding+ + ' Page: TWizardPage;'+LineEnding+ + ' Rect: TRect;'+LineEnding+ + ' hIcon: LongInt;'+LineEnding+ + ' Label1, Label2: TNewStaticText;'+LineEnding+ + 'begin'+LineEnding+ + ' Page := CreateCustomPage(AAfterID, ACaption, ASubCaption);'+LineEnding+LineEnding+ + ' try'+LineEnding+ + ' AIconFileName := ExpandConstant(''{tmp}\'' + AIconFileName);'+LineEnding+ + ' if not FileExists(AIconFileName) then'+LineEnding+ + ' ExtractTemporaryFile(ExtractFileName(AIconFileName));'+LineEnding+LineEnding+ + ' Rect.Left := 0;'+LineEnding+ + ' Rect.Top := 0;'+LineEnding+ + ' Rect.Right := 32;'+LineEnding+ + ' Rect.Bottom := 32;'+LineEnding+LineEnding+ + ' hIcon := ExtractIcon(GetModuleHandle(0), AIconFileName, 0);'+LineEnding+ + ' try'+LineEnding+ + ' with TBitmapImage.Create(Page) do begin'+LineEnding+ + ' with Bitmap do begin'+LineEnding+ + ' Width := 32;'+LineEnding+ + ' Height := 32;'+LineEnding+ + ' Canvas.Brush.Color := WizardForm.Color;'+LineEnding+ + ' Canvas.FillRect(Rect);'+LineEnding+ + ' DrawIconEx(Canvas.Handle, 0, 0, hIcon, 32, 32, 0, 0, DI_NORMAL);'+LineEnding+ + ' end;'+LineEnding+ + ' Parent := Page.Surface;'+LineEnding+ + ' end;'+LineEnding+ + ' finally'+LineEnding+ + ' DestroyIcon(hIcon);'+LineEnding+ + ' end;'+LineEnding+ + ' except'+LineEnding+ + ' end;'+LineEnding+LineEnding+ + ' Label1 := TNewStaticText.Create(Page);'+LineEnding+ + ' with Label1 do begin'+LineEnding+ + ' AutoSize := False;'+LineEnding+ + ' Left := WizardForm.SelectDirLabel.Left;'+LineEnding+ + ' Width := Page.SurfaceWidth - Left;'+LineEnding+ + ' WordWrap := True;'+LineEnding+ + ' Caption := ALabel1Caption;'+LineEnding+ + ' Parent := Page.Surface;'+LineEnding+ + ' end;'+LineEnding+ + ' WizardForm.AdjustLabelHeight(Label1);'+LineEnding+LineEnding+ + ' Label2 := TNewStaticText.Create(Page);'+LineEnding+ + ' with Label2 do begin'+LineEnding+ + ' Top := Label1.Top + Label1.Height + ScaleY(12);'+LineEnding+ + ' Caption := ALabel2Caption;'+LineEnding+ + ' Parent := Page.Surface;'+LineEnding+ + ' end;'+LineEnding+ + ' WizardForm.AdjustLabelHeight(Label2);'+LineEnding+LineEnding+ + ' CheckBox := TCheckBox.Create(Page);'+LineEnding+ + ' with CheckBox do begin'+LineEnding+ + ' Top := Label2.Top + Label2.Height + ScaleY(12);'+LineEnding+ + ' Width := Page.SurfaceWidth;'+LineEnding+ + ' Caption := ACheckCaption;'+LineEnding+ + ' Parent := Page.Surface;'+LineEnding+ + ' end;'+LineEnding+LineEnding+ + ' Result := Page;'+LineEnding+ + 'end;'+LineEnding+LineEnding+ + 'procedure CreateCustomPages;'+LineEnding+ + 'var'+LineEnding+ + ' Caption, SubCaption1, IconFileName, Label1Caption, Label2Caption, CheckCaption: String;'+LineEnding+ + 'begin'+LineEnding+ + ' Caption := CustomMessage(''ISPPTitle'');'+LineEnding+ + ' SubCaption1 := CustomMessage(''ISPPSubtitle'');'+LineEnding+ + ' IconFileName := ''ISPP.ico'';'+LineEnding+ + ' Label1Caption := CustomMessage(''ISPPText'');'+LineEnding+ + ' Label2Caption := CustomMessage(''ISPPText2'');'+LineEnding+ + ' CheckCaption := CustomMessage(''ISPPCheck'');'+LineEnding+LineEnding+ + ' ISPPPage := CreateCustomOptionPage(wpSelectProgramGroup, Caption, SubCaption1, IconFileName, Label1Caption,'+ + ' Label2Caption, CheckCaption, ISPPCheckBox);'+LineEnding+ + 'end;'+LineEnding+LineEnding+ + 'procedure InitializeWizard;'+LineEnding+ + 'begin'+LineEnding+ + ' CreateCustomPages;'+LineEnding+LineEnding+ + ' ISPPCheckBox.Checked := (GetPreviousData(''ISPP'', ''1'') = ''1'') or (ExpandConstant(''{param:ispp|0}'') ='+ + ' ''1'');'+LineEnding+ + 'end;'+LineEnding+LineEnding+ + 'procedure RegisterPreviousData(PreviousDataKey: Integer);'+LineEnding+ + 'begin'+LineEnding+ + ' SetPreviousData(PreviousDataKey, ''ISPP'', IntToStr(Ord(ISPPCheckBox.Checked)));'+LineEnding+ + 'end;'+LineEnding+LineEnding+ + 'function ISPPCheck: Boolean;'+LineEnding+ + 'begin'+LineEnding+ + ' Result := ISPPCheckBox.Checked;'+LineEnding+ + 'end;'+LineEnding+LineEnding+ + 'function PortableCheck: Boolean;'+LineEnding+ + 'begin'+LineEnding+ + ' Result := ExpandConstant(''{param:portable|0}'') = ''1'';'+LineEnding+ + 'end;'+LineEnding+LineEnding +; +end; + +procedure TSynInnoSyn.SymbolProc; +begin + fTokenID := tkSymbol; + inc(Run); +end; + +procedure TSynInnoSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then inc(Run); +end; + +procedure TSynInnoSyn.EqualProc; +begin +// If any word has equal (=) symbol, +// then the immediately followed text is treated as string +// (though it does not have quotes) + fTokenID := tkString; + repeat + Inc(Run); + if fLine[Run] = ';' then begin + Inc(Run); + break; + end; + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynInnoSyn.IdentProc; +var + LookAhead: integer; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + if fTokenID = tkKeyOrParameter then begin + LookAhead := Run; + while fLine[LookAhead] in [#9, ' '] do + Inc(LookAhead); + if fLine[LookAhead] = ':' then + fTokenID := tkKey + else + fTokenID := tkParameter; + end; +end; + +procedure TSynInnoSyn.SectionProc; +begin + // if it is not column 0 mark as tkParameter and get out of here + if Run > 0 then + begin + fTokenID := tkUnknown; + inc(Run); + Exit; + end; + + // this is column 0 ok it is a Section + fTokenID := tkSection; + repeat + Inc(Run); + if fLine[Run] = ']' then + begin + Inc(Run); + break; + end; + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynInnoSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynInnoSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynInnoSyn.NumberProc; +begin + fTokenID := tkNumber; + repeat + Inc(Run); + until not (fLine[Run] in ['0'..'9']); +end; + +procedure TSynInnoSyn.ConstantProc; +var + BraceLevel, LastOpenBrace: Integer; +begin + { Much of this is based on code from the SkipPastConst function in IS's + CmnFunc2 unit. [jr] } + if fLine[Run + 1] = '{' then begin + fTokenID := tkUnknown; + Inc(Run, 2); + Exit; + end; + fTokenID := tkConstant; + BraceLevel := 1; + LastOpenBrace := Low(Integer); + repeat + Inc(Run); + case fLine[Run] of + '{': begin + if LastOpenBrace <> Run-1 then begin + Inc(BraceLevel); + LastOpenBrace := Run; + end + else + Dec(BraceLevel); + end; + '}': begin + Dec (BraceLevel); + if BraceLevel = 0 then begin + Inc(Run); + Break; + end; + end; + end; + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynInnoSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + Inc(Run); + until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]); +end; + +procedure TSynInnoSyn.SemiColonProc; +var + I: Integer; +begin + for I := Run-1 downto 0 do + if fLine[I] > ' ' then begin + // If the semicolon is not the first non-whitespace character on the + // line, then it isn't the start of a comment. + fTokenID := tkUnknown; + inc(Run); + Exit; + end; + fTokenID := tkComment; + repeat + Inc(Run); + until (fLine[Run] in [#0, #10, #13]); +end; + +procedure TSynInnoSyn.StringProc; +begin + fTokenID := tkString; + repeat + Inc(Run); + if fLine[Run] = '"' then begin + Inc(Run); + if fLine[Run] <> '"' then // embedded "" does not end the string + break; + end; + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynInnoSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynInnoSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynInnoSyn.GetDefaultAttribute(Index: integer): + TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynInnoSyn.GetEol: Boolean; +begin + Result := (fTokenId = tkNull); +end; + +function TSynInnoSyn.GetToken :string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynInnoSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynInnoSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkParameter: Result := fParamAttri; + tkSection: Result := fSectionAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkConstant: Result := fConstantAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynInnoSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynInnoSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynInnoSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynInnoSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynInnoSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterInno; +end; + +class function TSynInnoSyn.GetLanguageName: string; +begin + Result := SYNS_LangInno; +end; + +procedure TSynInnoSyn.DoAddKeyword(AKeyword: string; AKind: integer); +var + HashValue: integer; +begin + HashValue := KeyHash(PChar(AKeyword)); + fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind); +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynInnoSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterkix.pas b/components/extrasyn/SyneditHighlighters/synhighlighterkix.pas new file mode 100644 index 000000000..f2bcef63e --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterkix.pas @@ -0,0 +1,1354 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterKix.pas, released 2000-05-05. +The Original Code is based on the jsKixSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Jeff D. Smith. +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: SynHighlighterKix.pas,v 1.13 2005/01/28 16:53:24 maelh Exp $ + +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 Kix syntax highlighter for SynEdit) +@author(Jeff D. Smith) +@created(1999, converted to SynEdit 2000-05-05) +@lastmod(2000-06-23) +The SynHighlighterKix unit provides SynEdit with a Kix script file syntax highlighter. +} +unit SynHighlighterKix; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkMiscellaneous, tkNull, + tkNumber, tkSpace, tkString, tkSymbol, tkVariable, tkUnknown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynKixSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0..273] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fMiscellaneousAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fVariableAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func7: TtkTokenKind; + function Func15: TtkTokenKind; + function Func17: TtkTokenKind; + function Func18: TtkTokenKind; + function Func19: TtkTokenKind; + function Func21: TtkTokenKind; + function Func22: TtkTokenKind; + function Func23: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func30: TtkTokenKind; + function Func31: TtkTokenKind; + function Func32: TtkTokenKind; + function Func34: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func47: TtkTokenKind; + function Func49: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func76: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: TtkTokenKind; + function Func86: TtkTokenKind; + function Func87: TtkTokenKind; + function Func88: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func91: TtkTokenKind; + function Func93: TtkTokenKind; + function Func94: TtkTokenKind; + function Func95: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func102: TtkTokenKind; + function Func104: TtkTokenKind; + function Func105: TtkTokenKind; + function Func108: TtkTokenKind; + function Func109: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func112: TtkTokenKind; + function Func114: TtkTokenKind; + function Func115: TtkTokenKind; + function Func116: TtkTokenKind; + function Func118: TtkTokenKind; + function Func119: TtkTokenKind; + function Func120: TtkTokenKind; + function Func123: TtkTokenKind; + function Func124: TtkTokenKind; + function Func127: TtkTokenKind; + function Func130: TtkTokenKind; + function Func135: TtkTokenKind; + function Func136: TtkTokenKind; + function Func139: TtkTokenKind; + function Func140: TtkTokenKind; + function Func144: TtkTokenKind; + function Func148: TtkTokenKind; + function Func152: TtkTokenKind; + function Func154: TtkTokenKind; + function Func156: TtkTokenKind; + function Func161: TtkTokenKind; + function Func166: TtkTokenKind; + function Func169: TtkTokenKind; + function Func173: TtkTokenKind; + function Func174: TtkTokenKind; + function Func177: TtkTokenKind; + function Func186: TtkTokenKind; + function Func195: TtkTokenKind; + function Func196: TtkTokenKind; + function Func197: TtkTokenKind; + function Func213: TtkTokenKind; + function Func221: TtkTokenKind; + function Func222: TtkTokenKind; + function Func230: TtkTokenKind; + function Func233: TtkTokenKind; + function Func243: TtkTokenKind; + function Func273: TtkTokenKind; + procedure AsciiCharProc; + procedure VariableProc; + procedure CRProc; + procedure IdentProc; + procedure MacroProc; + procedure PrintProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure CommentProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property MiscellaneousAttri: TSynHighlighterAttributes + read fMiscellaneousAttri write fMiscellaneousAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property VariableAttri: TSynHighlighterAttributes read fVariableAttri + write fVariableAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': + Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynKixSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[7] := @Func7; + fIdentFuncTable[15] := @Func15; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[18] := @Func18; + fIdentFuncTable[19] := @Func19; + fIdentFuncTable[21] := @Func21; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[23] := @Func23; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[28] := @Func28; + fIdentFuncTable[29] := @Func29; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[31] := @Func31; + fIdentFuncTable[32] := @Func32; + fIdentFuncTable[34] := @Func34; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[36] := @Func36; + fIdentFuncTable[37] := @Func37; + fIdentFuncTable[38] := @Func38; + fIdentFuncTable[40] := @Func40; + fIdentFuncTable[41] := @Func41; + fIdentFuncTable[44] := @Func44; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[49] := @Func49; + fIdentFuncTable[50] := @Func50; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[53] := @Func53; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[55] := @Func55; + fIdentFuncTable[56] := @Func56; + fIdentFuncTable[57] := @Func57; + fIdentFuncTable[58] := @Func58; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[61] := @Func61; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[63] := @Func63; + fIdentFuncTable[64] := @Func64; + fIdentFuncTable[65] := @Func65; + fIdentFuncTable[67] := @Func67; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[72] := @Func72; + fIdentFuncTable[73] := @Func73; + fIdentFuncTable[74] := @Func74; + fIdentFuncTable[76] := @Func76; + fIdentFuncTable[77] := @Func77; + fIdentFuncTable[78] := @Func78; + fIdentFuncTable[79] := @Func79; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[82] := @Func82; + fIdentFuncTable[83] := @Func83; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[86] := @Func86; + fIdentFuncTable[87] := @Func87; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[89] := @Func89; + fIdentFuncTable[90] := @Func90; + fIdentFuncTable[91] := @Func91; + fIdentFuncTable[93] := @Func93; + fIdentFuncTable[94] := @Func94; + fIdentFuncTable[95] := @Func95; + fIdentFuncTable[96] := @Func96; + fIdentFuncTable[97] := @Func97; + fIdentFuncTable[99] := @Func99; + fIdentFuncTable[100] := @Func100; + fIdentFuncTable[102] := @Func102; + fIdentFuncTable[104] := @Func104; + fIdentFuncTable[105] := @Func105; + fIdentFuncTable[108] := @Func108; + fIdentFuncTable[109] := @Func109; + fIdentFuncTable[110] := @Func110; + fIdentFuncTable[111] := @Func111; + fIdentFuncTable[112] := @Func112; + fIdentFuncTable[114] := @Func114; + fIdentFuncTable[115] := @Func115; + fIdentFuncTable[116] := @Func116; + fIdentFuncTable[118] := @Func118; + fIdentFuncTable[119] := @Func119; + fIdentFuncTable[120] := @Func120; + fIdentFuncTable[123] := @Func123; + fIdentFuncTable[124] := @Func124; + fIdentFuncTable[127] := @Func127; + fIdentFuncTable[130] := @Func130; + fIdentFuncTable[135] := @Func135; + fIdentFuncTable[136] := @Func136; + fIdentFuncTable[139] := @Func139; + fIdentFuncTable[140] := @Func140; + fIdentFuncTable[144] := @Func144; + fIdentFuncTable[148] := @Func148; + fIdentFuncTable[152] := @Func152; + fIdentFuncTable[154] := @Func154; + fIdentFuncTable[156] := @Func156; + fIdentFuncTable[161] := @Func161; + fIdentFuncTable[166] := @Func166; + fIdentFuncTable[169] := @Func169; + fIdentFuncTable[173] := @Func173; + fIdentFuncTable[174] := @Func174; + fIdentFuncTable[177] := @Func177; + fIdentFuncTable[186] := @Func186; + fIdentFuncTable[195] := @Func195; + fIdentFuncTable[196] := @Func196; + fIdentFuncTable[197] := @Func197; + fIdentFuncTable[213] := @Func213; + fIdentFuncTable[221] := @Func221; + fIdentFuncTable[222] := @Func222; + fIdentFuncTable[230] := @Func230; + fIdentFuncTable[233] := @Func233; + fIdentFuncTable[243] := @Func243; + fIdentFuncTable[273] := @Func273; +end; + +function TSynKixSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while Identifiers[ToHash^] do begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynKixSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynKixSyn.Func7: TtkTokenKind; +begin + if KeyComp('CD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func15: TtkTokenKind; +begin + if KeyComp('IF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func17: TtkTokenKind; +begin + if KeyComp('MD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func18: TtkTokenKind; +begin + if KeyComp('BIG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func19: TtkTokenKind; +begin + if KeyComp('DO') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func21: TtkTokenKind; +begin + if KeyComp('DEL') then Result := tkKey else + if KeyComp('AT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func22: TtkTokenKind; +begin + if KeyComp('GO') then Result := tkKey else + if KeyComp('RD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func23: TtkTokenKind; +begin + if KeyComp('ASC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func25: TtkTokenKind; +begin + if KeyComp('LM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func26: TtkTokenKind; +begin + if KeyComp('DIM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func28: TtkTokenKind; +begin + if KeyComp('BEEP') then Result := tkKey else + if KeyComp('CASE') then Result := tkKey else + if KeyComp('CALL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func29: TtkTokenKind; +begin + if KeyComp('CHR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func30: TtkTokenKind; +begin + if KeyComp('DAY') then Result := tkKey else + if KeyComp('DATE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func31: TtkTokenKind; +begin + if KeyComp('DIR') then Result := tkKey else + if KeyComp('LEN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func32: TtkTokenKind; +begin + if KeyComp('SID') then Result := tkKey else + if KeyComp('GET') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func34: TtkTokenKind; +begin + if KeyComp('CLS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func35: TtkTokenKind; +begin + if KeyComp('VAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func36: TtkTokenKind; +begin + if KeyComp('RND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func37: TtkTokenKind; +begin + if KeyComp('BREAK') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func38: TtkTokenKind; +begin + if KeyComp('DOS') then Result := tkKey else + if KeyComp('RAS') then Result := tkKey else + if KeyComp('ENDIF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func40: TtkTokenKind; +begin + if KeyComp('LCASE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func41: TtkTokenKind; +begin + if KeyComp('ELSE') then Result := tkKey else + if KeyComp('BOX') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func44: TtkTokenKind; +begin + if KeyComp('KIX') then Result := tkKey else + if KeyComp('SET') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func45: TtkTokenKind; +begin + if KeyComp('USE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func47: TtkTokenKind; +begin + if KeyComp('TIME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func49: TtkTokenKind; +begin + if KeyComp('YEAR') then Result := tkKey else + if KeyComp('UCASE') then Result := tkKey else + if KeyComp('GLOBAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func50: TtkTokenKind; +begin + if KeyComp('ADDKEY') then Result := tkKey else + if KeyComp('OPEN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func51: TtkTokenKind; +begin + if KeyComp('GETS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func52: TtkTokenKind; +begin + if KeyComp('PWAGE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func53: TtkTokenKind; +begin + if KeyComp('RUN') then Result := tkKey else + if KeyComp('SITE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func54: TtkTokenKind; +begin + if KeyComp('PLAY') then Result := tkKey else + if KeyComp('CLOSE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func55: TtkTokenKind; +begin + if KeyComp('SRND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func56: TtkTokenKind; +begin + if KeyComp('DOMAIN') then Result := tkKey else + if KeyComp('SETL') then Result := tkKey else + if KeyComp('SHELL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func57: TtkTokenKind; +begin + if KeyComp('WHILE') then Result := tkKey else + if KeyComp('SMALL') then Result := tkKey else + if KeyComp('SETM') then Result := tkKey else + if KeyComp('GOTO') then Result := tkKey else + if KeyComp('SLEEP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func58: TtkTokenKind; +begin + if KeyComp('COOKIE1') then Result := tkKey else + if KeyComp('LOOP') then Result := tkKey else + if KeyComp('EXIT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func59: TtkTokenKind; +begin + if KeyComp('COPY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func61: TtkTokenKind; +begin + if KeyComp('LOGOFF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func62: TtkTokenKind; +begin + if KeyComp('DELKEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func63: TtkTokenKind; +begin + if KeyComp('COLOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func64: TtkTokenKind; +begin + if KeyComp('GOSUB') then Result := tkKey else + if KeyComp('SELECT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func65: TtkTokenKind; +begin + if KeyComp('PRIV') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func67: TtkTokenKind; +begin + if KeyComp('QUIT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func68: TtkTokenKind; +begin + if KeyComp('LDOMAIN') then Result := tkKey else + if KeyComp('READLINE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func69: TtkTokenKind; +begin + if KeyComp('DELTREE') then Result := tkKey else + if KeyComp('INWIN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func70: TtkTokenKind; +begin + if KeyComp('LDRIVE') then Result := tkKey else + if KeyComp('MONTH') then Result := tkKey else + if KeyComp('ADDRESS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func72: TtkTokenKind; +begin + if KeyComp('MDAYNO') then Result := tkKey else + if KeyComp('HOMEDIR') then Result := tkKey else + if KeyComp('LTRIM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func73: TtkTokenKind; +begin + if KeyComp('CURDIR') then Result := tkKey else + if KeyComp('LOADKEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func74: TtkTokenKind; +begin + if KeyComp('WKSTA') then Result := tkKey else + if KeyComp('ERROR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func76: TtkTokenKind; +begin + if KeyComp('LOADHIVE') then Result := tkKey else + if KeyComp('USERID') then Result := tkKey else + if KeyComp('UNTIL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func77: TtkTokenKind; +begin + if KeyComp('EXIST') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func78: TtkTokenKind; +begin + if KeyComp('RTRIM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func79: TtkTokenKind; +begin + if KeyComp('FLUSHKB') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func80: TtkTokenKind; +begin + if KeyComp('INSTR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func82: TtkTokenKind; +begin + if KeyComp('WDAYNO') then Result := tkKey else + if KeyComp('DELVALUE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func83: TtkTokenKind; +begin + if KeyComp('COMMENT') then Result := tkKey else + if KeyComp('EXECUTE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func84: TtkTokenKind; +begin + if KeyComp('DECTOHEX') then Result := tkKey else + if KeyComp('YDAYNO') then Result := tkKey else + if KeyComp('FULLNAME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func85: TtkTokenKind; +begin + if KeyComp('SETASCII') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func86: TtkTokenKind; +begin + if KeyComp('DISPLAY') then Result := tkKey else + if KeyComp('HOMESHR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func87: TtkTokenKind; +begin + if KeyComp('ENDSELECT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func88: TtkTokenKind; +begin + if KeyComp('SAVEKEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func89: TtkTokenKind; +begin + if KeyComp('READVALUE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func90: TtkTokenKind; +begin + if KeyComp('MAXPWAGE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func91: TtkTokenKind; +begin + if KeyComp('SETTIME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func93: TtkTokenKind; +begin + if KeyComp('SERROR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func94: TtkTokenKind; +begin + if KeyComp('READTYPE') then Result := tkKey else + if KeyComp('ENUMKEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func95: TtkTokenKind; +begin + if KeyComp('LANROOT') then Result := tkKey else + if KeyComp('IPADDRESS') then Result := tkKey else + if KeyComp('HOSTNAME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func96: TtkTokenKind; +begin + if KeyComp('RETURN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func97: TtkTokenKind; +begin + if KeyComp('SYSLANG') then Result := tkKey else + if KeyComp('USERLANG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func99: TtkTokenKind; +begin + if KeyComp('HOMEDRIVE') then Result := tkKey else + if KeyComp('WUSERID') then Result := tkKey else + if KeyComp('MONTHNO') then Result := tkKey else + if KeyComp('LSERVER') then Result := tkKey else + if KeyComp('SUBSTR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func100: TtkTokenKind; +begin + if KeyComp('LOGEVENT') then Result := tkKey else + if KeyComp('INGROUP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func102: TtkTokenKind; +begin + if KeyComp('SENDKEYS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func104: TtkTokenKind; +begin + if KeyComp('OLECALLFUNC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func105: TtkTokenKind; +begin + if KeyComp('RSERVER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func108: TtkTokenKind; +begin + if KeyComp('SETFOCUS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func109: TtkTokenKind; +begin + if KeyComp('STARTDIR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func110: TtkTokenKind; +begin + if KeyComp('MESSAGEBOX') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func111: TtkTokenKind; +begin + if KeyComp('SENDMESSAGE') then Result := tkKey else + if KeyComp('UNLOADHIVE') then Result := tkKey else + if KeyComp('GETFILETIME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func112: TtkTokenKind; +begin + if KeyComp('OLECALLPROC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func114: TtkTokenKind; +begin + if KeyComp('ENUMVALUE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func115: TtkTokenKind; +begin + if KeyComp('WRITELINE') then Result := tkKey else + if KeyComp('PASSWORD') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func116: TtkTokenKind; +begin + if KeyComp('SCRIPTDIR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func118: TtkTokenKind; +begin + if KeyComp('EXISTKEY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func119: TtkTokenKind; +begin + if KeyComp('GETDISKSPACE') then Result := tkKey else + if KeyComp('OLEGETOBJECT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func120: TtkTokenKind; +begin + if KeyComp('LONGHOMEDIR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func123: TtkTokenKind; +begin + if KeyComp('GETFILESIZE') then Result := tkKey else + if KeyComp('GETFILEATTR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func124: TtkTokenKind; +begin + if KeyComp('SHUTDOWN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func127: TtkTokenKind; +begin + if KeyComp('SETCONSOLE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func130: TtkTokenKind; +begin + if KeyComp('ENUMGROUP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func135: TtkTokenKind; +begin + if KeyComp('SETFILEATTR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func136: TtkTokenKind; +begin + if KeyComp('WRITEVALUE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func139: TtkTokenKind; +begin + if KeyComp('OLECREATEOBJECT') then Result := tkKey else + if KeyComp('CLEAREVENTLOG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func140: TtkTokenKind; +begin + if KeyComp('OLEENUMOBJECT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func144: TtkTokenKind; +begin + if KeyComp('ADDPROGRAMITEM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func148: TtkTokenKind; +begin + if KeyComp('SETWALLPAPER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func152: TtkTokenKind; +begin + if KeyComp('OLERELEASEOBJECT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func154: TtkTokenKind; +begin + if KeyComp('BACKUPEVENTLOG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func156: TtkTokenKind; +begin + if KeyComp('DELPROGRAMITEM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func161: TtkTokenKind; +begin + if KeyComp('OLEGETSUBOBJECT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func166: TtkTokenKind; +begin + if KeyComp('GETFILEVERSION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func169: TtkTokenKind; +begin + if KeyComp('COMPAREFILETIMES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func173: TtkTokenKind; +begin + if KeyComp('ENUMLOCALGROUP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func174: TtkTokenKind; +begin + if KeyComp('ADDPROGRAMGROUP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func177: TtkTokenKind; +begin + if KeyComp('PRIMARYGROUP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func186: TtkTokenKind; +begin + if KeyComp('DELPROGRAMGROUP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func195: TtkTokenKind; +begin + if KeyComp('REDIRECTOUTPUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func196: TtkTokenKind; +begin + if KeyComp('READPROFILESTRING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func197: TtkTokenKind; +begin + if KeyComp('OLEGETPROPERTY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func213: TtkTokenKind; +begin + if KeyComp('SETDEFAULTPRINTER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func221: TtkTokenKind; +begin + if KeyComp('ADDPRINTERCONNECTION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func222: TtkTokenKind; +begin + if KeyComp('OLEPUTPROPERTY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func230: TtkTokenKind; +begin + if KeyComp('SHOWPROGRAMGROUP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func233: TtkTokenKind; +begin + if KeyComp('DELPRINTERCONNECTION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func243: TtkTokenKind; +begin + if KeyComp('WRITEPROFILESTRING') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.Func273: TtkTokenKind; +begin + if KeyComp('EXPANDENVIRONMENTVARS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynKixSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynKixSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 274 then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynKixSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '#': fProcTable[I] := @AsciiCharProc; + #13: fProcTable[I] := @CRProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': fProcTable[I] := @NumberProc; + ';': fProcTable[I] := @CommentProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + '"','''': fProcTable[I] := @StringProc; + '@': fProcTable[I] := @MacroProc; + '?': fProcTable[I] := @PrintProc; + '$': fProcTable[I] := @VariableProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynKixSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrKey); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fMiscellaneousAttri := TSynHighlighterAttributes.Create(SYNS_AttrMiscellaneous); + AddAttribute(fMiscellaneousAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fVariableAttri := TSynHighlighterAttributes.Create(SYNS_AttrVariable); + AddAttribute(fVariableAttri); + + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterKIX; +end; + +procedure TSynKixSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynKixSyn.AsciiCharProc; +begin + fTokenID := tkString; + inc(Run); + while FLine[Run] in ['0'..'9'] do inc(Run); +end; + +procedure TSynKixSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then inc(Run); +end; + +procedure TSynKixSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynKixSyn.MacroProc; +begin + inc(Run); + fTokenID := tkMiscellaneous; + while FLine[Run] in ['0'..'9', 'A'..'Z', 'a'..'z'] do inc(Run); +end; + +procedure TSynKixSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynKixSyn.PrintProc; +begin + fTokenID := tkKey; + inc(Run); +end; + +procedure TSynKixSyn.VariableProc; +begin + fTokenId := tkVariable; + inc(run); + while FLine[Run] in ['_','0'..'9', 'A'..'Z', 'a'..'z'] do inc(run); +end; + +procedure TSynKixSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynKixSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynKixSyn.CommentProc; +begin + fTokenID := tkComment; + repeat + inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynKixSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynKixSyn.StringProc; +var + achr : char; +begin + fTokenID := tkString; + achr := fline[run]; + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = achr; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynKixSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynKixSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynKixSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynKixSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynKixSyn.GetToken :String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynKixSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynKixSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynKixSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkMiscellaneous: Result := fMiscellaneousAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkVariable: Result := fVariableAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynKixSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynKixSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynKixSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +class function TSynKixSyn.GetLanguageName: string; +begin + Result := SYNS_LangKIX; +end; + +function TSynKixSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterKIX; +end; + +function TSynKixSyn.GetSampleSource: string; +begin + Result := '; KiXtart sample source'#13#10 + + 'break on'#13#10 + + 'color b/n'#13#10 + + #13#10 + + 'AT(1, 30) "Hello World!"'#13#10 + + '$USERID = @USERID'#13#10 + + 'AT(1, 30) $USERID'; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynKixSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterldraw.pas b/components/extrasyn/SyneditHighlighters/synhighlighterldraw.pas new file mode 100644 index 000000000..198fadc01 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterldraw.pas @@ -0,0 +1,579 @@ +{------------------------------------------------------------------------------- +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. + +Code template generated with SynGen. +The original code is: SynHighlighterLDraw.pas, released 2003-04-12. +Description: LDraw Parser/Highlighter +The initial author of this file is Orion Pobursky. +Copyright (c) 2003, 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: SynHighlighterLDraw.pas,v 1.8 2005/01/28 16:53:24 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} +{ +@abstract(Provides an LDraw syntax highlighter for SynEdit) +@author(Orion Pobursky) +@created(03/01/2003) +@lastmod(07/05/2003) +The SynHighlighterLDraw unit provides SynEdit with a LEGO LDraw (.ldr / .dat) highlighter. +} +unit SynHighlighterLDraw; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditHighlighter, SynEditTypes, + Classes; + +type + TtkTokenKind = ( + tkColor, + tkComment, + tkFirstTri, + tkFourthTri, + tkIdentifier, + tkKey, + tkLine, + tkNull, + tkOpLine, + tkQuad, + tkSecondTri, + tkThirdTri, + tkTriangle, + tkUnknown); + + TRangeState = (rsUnKnown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +const + MaxKey = 83; + +type + TSynLDRSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + fRange: TRangeState; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0 .. MaxKey] of TIdentFuncTableFunc; + fColorAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fFirstTriAttri: TSynHighlighterAttributes; + fFourthTriAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fLineAttri: TSynHighlighterAttributes; + fOpLineAttri: TSynHighlighterAttributes; + fQuadAttri: TSynHighlighterAttributes; + fSecondTriAttri: TSynHighlighterAttributes; + fThirdTriAttri: TSynHighlighterAttributes; + fTriangleAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func83: TtkTokenKind; + procedure IdentProc; + procedure Number1Proc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure NullProc; + procedure CRProc; + procedure LFProc; + function FirstChar(DatLine: PChar): Char; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + constructor Create(AOwner: TComponent); override; + class function GetLanguageName: string; override; + function GetRange: Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override; + function GetEol: Boolean; override; + function GetKeyWords: string; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property ColorAttri: TSynHighlighterAttributes read fColorAttri write fColorAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property FirstTriAttri: TSynHighlighterAttributes read fFirstTriAttri write fFirstTriAttri; + property FourthTriAttri: TSynHighlighterAttributes read fFourthTriAttri write fFourthTriAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property LineAttri: TSynHighlighterAttributes read fLineAttri write fLineAttri; + property OpLineAttri: TSynHighlighterAttributes read fOpLineAttri write fOpLineAttri; + property QuadAttri: TSynHighlighterAttributes read fQuadAttri write fQuadAttri; + property SecondTriAttri: TSynHighlighterAttributes read fSecondTriAttri write fSecondTriAttri; + property ThirdTriAttri: TSynHighlighterAttributes read fThirdTriAttri write fThirdTriAttri; + property TriangleAttri: TSynHighlighterAttributes read fTriangleAttri write fTriangleAttri; + end; + +implementation + +uses + SynEditStrConst, SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable : array[#0..#255] of Integer; + +function RGB(CONST r, g, b: BYTE): TColor; +begin + RESULT := (r OR (g SHL 8) OR (b SHL 16)) +end; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynLDRSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[83] := @Func83; +end; + +function TSynLDRSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynLDRSyn.KeyComp(const aKey :string) :Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else + Result := False; +end; + +function TSynLDRSyn.Func83: TtkTokenKind; +begin + if KeyComp('Author') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynLDRSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynLDRSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey <= MaxKey then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynLDRSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0: fProcTable[I] := @NullProc; + #10: fProcTable[I] := @LFProc; + #13: fProcTable[I] := @CRProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc; + '0'..'9': fProcTable[I] := @Number1Proc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +procedure TSynLDRSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynLDRSyn.CRProc; +begin + fTokenID := tkUnknown; + inc(Run); + if fLine[Run] = #10 then + inc(Run); +end; + +procedure TSynLDRSyn.LFProc; +begin + fTokenID := tkUnknown; + inc(Run); +end; + +constructor TSynLDRSyn.Create(AOwner: TComponent); + +begin + inherited Create(AOwner); + fColorAttri := TSynHighLighterAttributes.Create(SYNS_AttrColor); + fColorAttri.Foreground := clNavy; + AddAttribute(fColorAttri); + + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Foreground := clBlue; + AddAttribute(fCommentAttri); + + fFirstTriAttri := TSynHighLighterAttributes.Create(SYNS_AttrFirstTri); + fFirstTriAttri.Foreground := RGB(206,111,73); + AddAttribute(fFirstTriAttri); + + fFourthTriAttri := TSynHighLighterAttributes.Create(SYNS_AttrFourthTri); + fFourthTriAttri.Foreground := RGB(54,99,12); + AddAttribute(fFourthTriAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + + fLineAttri := TSynHighLighterAttributes.Create(SYNS_AttrLine); + fLineAttri.Foreground := clBlack; + AddAttribute(fLineAttri); + + fOpLineAttri := TSynHighLighterAttributes.Create(SYNS_AttrOpLine); + fOpLineAttri.Foreground := clBlack; + AddAttribute(fOpLineAttri); + + fQuadAttri := TSynHighLighterAttributes.Create(SYNS_AttrQuad); + fQuadAttri.Foreground := clRed; + AddAttribute(fQuadAttri); + + fSecondTriAttri := TSynHighLighterAttributes.Create(SYNS_AttrSecondTri); + fSecondTriAttri.Foreground := RGB(54,99,12); + AddAttribute(fSecondTriAttri); + + fThirdTriAttri := TSynHighLighterAttributes.Create(SYNS_AttrThirdTri); + fThirdTriAttri.Foreground := RGB(206,111,73); + AddAttribute(fThirdTriAttri); + + fTriangleAttri := TSynHighLighterAttributes.Create(SYNS_AttrTriangle); + fTriangleAttri.Foreground := clBlack; + AddAttribute(fTriangleAttri); + + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterLDraw; + fRange := rsUnknown; +end; + +procedure TSynLDRSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +function TSynLDRSyn.FirstChar(DatLine: PChar): Char; +var + index: Integer; + +begin + index := 0; + while DATLine[index] = ' ' do inc(index); + Result := DATLine[index]; +end; + +procedure TSynLDRSyn.IdentProc; +begin + if FirstChar(fLine) = '0' then + begin + fTokenID := tkComment; + while (fLine[Run] <> #10) and (fLine[Run] <> #13) + and (fLine[Run] <> #0) do inc(Run); + end + else + begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + Inc(Run); + end; +end; + +procedure TSynLDRSyn.Number1Proc; + function ArgNumber(DatLine: PChar): Byte; + + var + index: Integer; + flag: Boolean; + + begin + index := 0; + Result := 0; + flag := false; + while index <= Run do + begin + if DatLine[index] = ' ' then + begin + inc(index); + flag := false; + end + else + begin + if flag = false then inc(Result); + flag := true; + inc(index) + end; + end; + end; + +begin + case ArgNumber(fLine) of + + 1: begin + case fLine[Run] of + '0': fTokenID := tkComment; + '1': fTokenID := tkIdentifier; + '2': fTokenID := tkLine; + '3': fTokenID := tkTriangle; + '4': fTokenID := tkQuad; + '5': fTokenID := tkOpLine; + end; + end; + 2: if FirstChar(fLine) <> '0' then fTokenID := tkColor + else fTokenID := tkComment; + 3..5: if FirstChar(fLine) <> '0' then fTokenID := tkFirstTri + else fTokenID := tkComment; + 6..8: if FirstChar(fLine) <> '0' then fTokenID := tkSecondTri + else fTokenID := tkComment; + 9..11: if FirstChar(fLine) <> '0' then fTokenID := tkThirdTri + else fTokenID := tkComment; + 12..14: if FirstChar(fLine) <> '0' then fTokenID := tkFourthTri + else fTokenID := tkComment; + else + fTokenID := tkIdentifier; + end; + while FLine[Run] in ['0'..'9', '.'] do inc(Run); +end; + +procedure TSynLDRSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynLDRSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynLDRSyn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + else + Result := nil; + end; +end; + +function TSynLDRSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynLDRSyn.GetKeyWords: string; +begin + Result := + 'Author'; +end; + +function TSynLDRSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynLDRSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynLDRSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynLDRSyn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkColor: Result := fColorAttri; + tkComment: Result := fCommentAttri; + tkFirstTri: Result := fFirstTriAttri; + tkFourthTri: Result := fFourthTriAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkLine: Result := fLineAttri; + tkOpLine: Result := fOpLineAttri; + tkQuad: Result := fQuadAttri; + tkSecondTri: Result := fSecondTriAttri; + tkThirdTri: Result := fThirdTriAttri; + tkTriangle: Result := fTriangleAttri; + tkUnknown: Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynLDRSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynLDRSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynLDRSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', 'a'..'z', 'A'..'Z', '0'..'9']; +end; + +function TSynLDRSyn.GetSampleSource: string; +begin + Result := #13#10 + + 'Sample source for: '#13#10 + + 'Ldraw Parser/Highlighter'#13#10 + + '0 Comment'#13#10 + + '1 16 0 0 0 1 0 0 0 1 0 0 0 1 stud.dat'#13#10 + + '2 16 0 0 0 1 1 1'#13#10 + + '3 16 0 0 0 1 1 1 2 2 2'#13#10 + + '4 16 0 0 0 1 1 1 2 2 2 3 3 3'#13#10 + + '5 16 0 0 0 1 1 1 2 2 2 3 3 3'; +end; + +function TSynLDRSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterLDraw; +end; + +class function TSynLDRSyn.GetLanguageName: string; +begin + Result := SYNS_LangLDraw; +end; + +procedure TSynLDRSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynLDRSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynLDRSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynLDRSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterm3.pas b/components/extrasyn/SyneditHighlighters/synhighlighterm3.pas new file mode 100644 index 000000000..3d8d32e52 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterm3.pas @@ -0,0 +1,758 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterM3.pas, released 2000-11-23. + +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: SynHighlighterM3.pas,v 1.12 2005/01/28 16:53:24 maelh Exp $ + +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 Modula-3 syntax highlighter for SynEdit) +@author(Martin Pley ) +@created(January 2000, converted to SynEdit November 23, 2000) +@lastmod(2000-11-23) +The SynHighlighterM3 unit provides SynEdit with a Modula-3 (.m3) highlighter. +} +unit SynHighlighterM3; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + SynHighlighterHashEntries, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkPragma, + tkReserved, tkSpace, tkString, tkSymbol, tkUnknown, tkSyntaxError); + + TTokenRange = (trNone, trComment, trPragma); + + TRangeState = packed record + case boolean of + FALSE: (p: pointer); + TRUE: (TokenRange: word; Level: word); + end; + + TProcTableProc = procedure of object; + + TSynM3Syn = class(TSynCustomHighLighter) + private + fLine: PChar; + fLineNumber: integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fRange: TRangeState; + fStringLen: integer; + fToIdent: PChar; + fTokenPos: integer; + FTokenID: TtkTokenKind; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fPragmaAttri: TSynHighlighterAttributes; + fReservedAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fSyntaxErrorAttri: TSynHighlighterAttributes; + fKeywords: TSynHashEntryList; + procedure DoAddKeyword(AKeyword: string; AKind: integer); + function IdentKind(MayBe: PChar): TtkTokenKind; + function KeyComp(AKey: string): boolean; + function KeyHash(ToHash: PChar): integer; + procedure MakeMethodTables; + procedure SymAsciiCharProc; + procedure SymCommentHelpProc; + procedure SymCRProc; + procedure SymIdentProc; + procedure SymLFProc; + procedure SymNestedHelperProc(AOpenChar, ACloseChar: char); + procedure SymNullProc; + procedure SymNumberProc; + procedure SymPragmaProc; + procedure SymPragmaHelpProc; + procedure SymRoundOpenProc; + procedure SymSpaceProc; + procedure SymStringProc; + procedure SymSymbolProc; + procedure SymUnknownProc; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetToken: String; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure ResetRange; override; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + procedure SetRange(Value: Pointer); override; + function GetSampleSource :string; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property PragmaAttri: TSynHighlighterAttributes read fPragmaAttri + write fPragmaAttri; + property ReservedAttri: TSynHighlighterAttributes read fReservedAttri + write fReservedAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property SyntaxErrorAttri: TSynHighlighterAttributes read fSyntaxErrorAttri + write fSyntaxErrorAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of integer; + +const + Keywords: string = + 'AS,AND,ANY,ARRAY,BEGIN,BITS,BRANDED,BY,CASE,CONST,DIV,DO,ELSE,ELSIF,END,' + + 'EVAL,EXCEPT,EXCEPTION,EXIT,EXPORTS,FINALLY,FOR,FROM,GENERIC,IF,IMPORT,' + + 'IN,INTERFACE,LOCK,LOOP,METHODS,MOD,MODULE,NOT,OBJECT,OF,OR,OVERRIDES,' + + 'PROCEDURE,RAISE,RAISES,READONLY,RECORD,REF,REPEAT,RETURN,REVEAL,ROOT,' + + 'SET,THEN,TO,TRY,TYPE,TYPECASE,UNSAFE,UNTIL,UNTRACED,VALUE,VAR,WHILE,WITH'; + + ReservedWords: string = + 'ABS,ADDRESS,ADR,ADRSIZE,BITSIZE,BOOLEAN,BYTESIZE,CARDINAL,CEILING,CHAR,' + + 'DEC,DISPOSE,FALSE,FIRST,FLOAT,FLOOR,INC,INTEGER,ISTYPE,LAST,LONGFLOAT,' + + 'LONGREAL,LOOPHOLE,MAX,MIN,MUTEX,NARROW,NEW,NIL,NULL,NUMBER,ORD,REAL,' + + 'REFANY,ROUND,SUBARRAY,TEXT,TRUE,TRUNC,TYPECODE,VAL'; + +procedure MakeIdentTable; +var + I: Char; +begin + FillChar(Identifiers, SizeOf(Identifiers), 0); + for I := 'a' to 'z' do + Identifiers[i] := TRUE; + for I := 'A' to 'Z' do + Identifiers[i] := TRUE; + for I := '0' to '9' do + Identifiers[i] := TRUE; + Identifiers['_'] := TRUE; + + FillChar(mHashTable, SizeOf(mHashTable), 0); + for I := 'a' to 'z' do + mHashTable[I] := 1 + Ord(I) - Ord('a'); + for I := 'A' to 'Z' do + mHashTable[I] := 1 + Ord(I) - Ord('A'); + mHashTable['_'] := 27; + for I := '0' to '9' do + mHashTable[I] := 28 + Ord(I) - Ord('0'); +end; + +procedure TSynM3Syn.DoAddKeyword(AKeyword: string; AKind: integer); +var + HashValue: integer; +begin + HashValue := KeyHash(PChar(AKeyword)); + fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind); +end; + +function TSynM3Syn.IdentKind(MayBe: PChar): TtkTokenKind; +var + Entry: TSynHashEntry; +begin + fToIdent := MayBe; + Entry := fKeywords[KeyHash(MayBe)]; + while Assigned(Entry) do begin + if Entry.KeywordLen > fStringLen then + break + else if Entry.KeywordLen = fStringLen then + if KeyComp(Entry.Keyword) then begin + Result := TtkTokenKind(Entry.Kind); + exit; + end; + Entry := Entry.Next; + end; + Result := tkIdentifier; +end; + +function TSynM3Syn.KeyComp(AKey: string): boolean; +var + i: integer; + pKey1, pKey2: PChar; +begin + pKey1 := fToIdent; + // Note: fStringLen is always > 0 ! + pKey2 := pointer(aKey); + for i := 1 to fStringLen do + begin + if pKey1^ <> pKey2^ then begin + Result := FALSE; + exit; + end; + Inc(pKey1); + Inc(pKey2); + end; + Result := TRUE; +end; + +function TSynM3Syn.KeyHash(ToHash: PChar): integer; +begin + Result := 0; + while Identifiers[ToHash^] do begin +{$IFOPT Q-} + Result := 7 * Result + mHashTable[ToHash^]; +{$ELSE} + Result := (7 * Result + mHashTable[ToHash^]) and $FFFFFF; +{$ENDIF} + Inc(ToHash); + end; + Result := Result and $FF; // 255 + fStringLen := ToHash - fToIdent; +end; + +procedure TSynM3Syn.MakeMethodTables; +var + I: char; +begin + for I := #0 to #255 do + case I of + #39: fProcTable[I] := @SymAsciiCharProc; + #13: fProcTable[I] := @SymCRProc; + 'A'..'Z', 'a'..'z', '_': + fProcTable[I] := @SymIdentProc; + #10: fProcTable[I] := @SymLFProc; + #0: fProcTable[I] := @SymNullProc; + '0'..'9': + fProcTable[I] := @SymNumberProc; + '(': fProcTable[I] := @SymRoundOpenProc; + #1..#9, #11, #12, #14..#32: + fProcTable[I] := @SymSpaceProc; + '{','}','|','!', #35..#38, #42..#47, #58, #59, #61..#64, #91..#94, ')': + fProcTable[I] := @SymSymbolProc; + '<' : fProcTable[I]:= @SymPragmaProc; + #34: fProcTable[I] := @SymStringProc; + else + fProcTable[I] := @SymUnknownProc; + end; +end; + +constructor TSynM3Syn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fKeywords := TSynHashEntryList.Create; + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style:= [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrKey); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fPragmaAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor); + fPragmaAttri.Style:= [fsBold]; + AddAttribute(fPragmaAttri); + fReservedAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + AddAttribute(fReservedAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fSyntaxErrorAttri := TSynHighlighterAttributes.Create(SYNS_AttrSyntaxError); + fSyntaxErrorAttri.Foreground := clRed; + AddAttribute(fSyntaxErrorAttri); + SetAttributesOnChange(@DefHighlightChange); + + MakeMethodTables; + EnumerateKeywords(Ord(tkKey), Keywords, IdentChars, @DoAddKeyword); + EnumerateKeywords(Ord(tkReserved), ReservedWords, IdentChars, @DoAddKeyword); + fDefaultFilter := SYNS_FilterModula3; +end; + +destructor TSynM3Syn.Destroy; +begin + fKeywords.Free; + inherited Destroy; +end; + +procedure TSynM3Syn.SymAsciiCharProc; +begin + fTokenID := tkString; + Inc(Run); + while not (fLine[Run] in [#0, #10, #13]) do begin + case fLine[Run] of + '\': if fLine[Run + 1] = #39 then + Inc(Run); + #39: begin + Inc(Run); + if fLine[Run] <> #39 then + break; + end; + end; + Inc(Run); + end; +end; + +procedure TSynM3Syn.SymCommentHelpProc; +begin + fTokenID := tkComment; + SymNestedHelperProc('(', ')'); +end; + +procedure TSynM3Syn.SymCRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then + Inc(Run); +end; + +procedure TSynM3Syn.SymIdentProc; +begin + fTokenID := IdentKind(fLine + Run); + Inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + Inc(Run); +end; + +procedure TSynM3Syn.SymLFProc; +begin + fTokenID := tkSpace; + Inc(Run); +end; + +procedure TSynM3Syn.SymNestedHelperProc(AOpenChar, ACloseChar: char); +begin + case fLine[Run] of + #0: SymNullProc; + #10: SymLFProc; + #13: SymCRProc; + else + repeat + if fLine[Run]= AOpenChar then begin + Inc(Run); + if fLine[Run] = '*' then begin + Inc(Run); + Inc(fRange.Level); + end; + end else if fLine[Run] = '*' then begin + Inc(Run); + if fLine[Run] = ACloseChar then begin + Inc(Run); + if fRange.Level > 0 then + Dec(fRange.Level); + if fRange.Level = 0 then begin + fRange.TokenRange := Ord(trNone); + break + end; + end; + end else + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynM3Syn.SymNullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynM3Syn.SymNumberProc; +const + Digits: array[0..15] of char = '0123456789abcdef'; +var + BasedNumber: boolean; + i, MaxDigit: integer; + ValidDigits: TSynIdentChars; +begin + fTokenID := tkNumber; + BasedNumber := FALSE; + MaxDigit := 9; + // skip leading zeros, but they can be numbers too + while fLine[Run] = '0' do + Inc(Run); + if not Identifiers[fLine[Run]] then + exit; + // check for numbers with a base prefix + if (fLine[Run] in ['2'..'9']) and (fLine[Run + 1] = '_') then begin + BasedNumber := TRUE; + MaxDigit := Ord(fLine[Run]) - Ord('0') - 1; + Inc(Run, 2); + end else if (fLine[Run] ='1') and (fLine[Run + 1] in ['0'..'6']) + and (fLine[Run + 2] = '_') + then begin + BasedNumber := TRUE; + MaxDigit := 10 + Ord(fLine[Run + 1]) - Ord('0') - 1; + Inc(Run, 3); + end; + if BasedNumber then begin + ValidDigits := []; + i := MaxDigit; + while i >= 10 do begin + Include(ValidDigits, Digits[i]); + Include(ValidDigits, UpCase(Digits[i])); + Dec(i); + end; + while i >= 0 do begin + Include(ValidDigits, Digits[i]); + Dec(i); + end; + // advance over all valid digits, but at least one has to be there + if fLine[Run] in ValidDigits then begin + repeat + Inc(Run); + until not (fLine[Run] in ValidDigits); + end else + fTokenID := tkSyntaxError; + end else begin + // "normal" numbers + repeat + Inc(Run); + until not (fLine[Run] in ['0'..'9']); + // can include a decimal point and an exponent + if fLine[Run] = '.' then begin + Inc(Run); + if fLine[Run] in ['0'..'9'] then begin + repeat + Inc(Run); + until not (fLine[Run] in ['0'..'9']); + end else + fTokenID := tkSyntaxError; // must be a number after the '.' + end; + // can include an exponent + if fLine[Run] in ['d', 'D', 'e', 'E', 'x', 'X'] then begin + Inc(Run); + if fLine[Run] in ['+', '-'] then + Inc(Run); + if fLine[Run] in ['0'..'9'] then begin + repeat + Inc(Run); + until not (fLine[Run] in ['0'..'9']); + end else // exponent must include a number + fTokenID := tkSyntaxError; + end; + end; + // it's a syntax error if there are any Identifier chars left + if Identifiers[fLine[Run]] then begin + fTokenID := tkSyntaxError; + repeat + Inc(Run); + until not Identifiers[fLine[Run]]; + end; +end; + +procedure TSynM3Syn.SymPragmaProc; +begin + Inc(Run); + if fLine[Run] = '*' then begin + Inc(Run); + fRange.TokenRange := Ord(trPragma); + Inc(fRange.Level); + if fLine[Run] in [#0, #10, #13] then + fTokenID := tkPragma + else + SymPragmaHelpProc; + end else + fTokenID := tkSymbol; +end; + +procedure TSynM3Syn.SymPragmaHelpProc; +begin + fTokenID := tkPragma; + SymNestedHelperProc('<', '>'); +end; + +procedure TSynM3Syn.SymRoundOpenProc; +begin + Inc(Run); + if fLine[Run] = '*' then begin + Inc(Run); + fRange.TokenRange := Ord(trComment); + Inc(fRange.Level); + if fLine[Run] in [#0, #10, #13] then + fTokenID := tkComment + else + SymCommentHelpProc; + end else begin + fTokenID := tkSymbol; + if fLine[Run] = '.' then + Inc(Run); + end; +end; + +procedure TSynM3Syn.SymSpaceProc; +begin + fTokenID := tkSpace; + repeat + Inc(Run); + until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]); +end; + +procedure TSynM3Syn.SymStringProc; +begin + fTokenID := tkString; + Inc(Run); + while not (fLine[Run] in [#0, #10, #13]) do begin + case fLine[Run] of + #34: begin + Inc(Run); + break; + end; + '\': if fLine[Run + 1] in [#34, '\'] then + Inc(Run); + end; + Inc(Run); + end; +end; + +procedure TSynM3Syn.SymSymbolProc; +begin + Inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynM3Syn.SymUnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynM3Syn.Next; +begin + fTokenPos := Run; + case TTokenRange(fRange.TokenRange) of + trComment: SymCommentHelpProc; + trPragma: SymPragmaHelpProc; + else + fProcTable[fLine[Run]]; + end; +end; + +function TSynM3Syn.GetDefaultAttribute(Index: integer): + TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynM3Syn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSynM3Syn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynM3Syn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterModula3; +end; + +class function TSynM3Syn.GetLanguageName: string; +begin + Result := SYNS_LangModula3; +end; + +function TSynM3Syn.GetRange :Pointer; +begin + result := fRange.p; +end; + +function TSynM3Syn.GetToken :String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, fLine + fTokenPos, Len); +end; + +function TSynM3Syn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkPragma: Result:= fPragmaAttri; + tkReserved: Result := fReservedAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkSyntaxError: Result := fSyntaxErrorAttri; + tkUnknown: Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynM3Syn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +procedure TSynM3Syn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; + +function TSynM3Syn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynM3Syn.GetTokenPos :Integer; +begin + Result := fTokenPos; +end; + +procedure TSynM3Syn.ResetRange; +begin + fRange.p := nil; +end; + +procedure TSynM3Syn.SetLine(const NewValue :String; LineNumber :Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynM3Syn.SetRange(Value :Pointer); +begin + fRange.p := Value; +end; + +function TSynM3Syn.GetSampleSource :string; +begin + + Result:='INTERFACE Shape;'+LineEnding+ + ' TYPE'+LineEnding+ + ' T <: Public;'+LineEnding+ + ' Public = ROOT OBJECT'+LineEnding+ + ' METHODS'+LineEnding+ + ' draw();'+LineEnding+ + ' moveTo(newx: INTEGER; newy: INTEGER);'+LineEnding+ + ' rMoveTo(deltax: INTEGER; deltay: INTEGER);'+LineEnding+ + ' getX(): INTEGER;'+LineEnding+ + ' getY(): INTEGER;'+LineEnding+ + ' END;'+LineEnding+ + 'END Shape.'+LineEnding+LineEnding+ + '-------------------------------------------------------------------------------------------------------------'+LineEnding+ + '-------------------------------------------------------------------------------------------------------------'+LineEnding+ + '-------------------------------------------------------------------------------------------------------------'+LineEnding+LineEnding+ + 'MODULE Shape;'+LineEnding+LineEnding+ + ' REVEAL'+LineEnding+ + ' T = Public BRANDED OBJECT'+LineEnding+ + ' x: INTEGER;'+LineEnding+ + ' y: INTEGER;'+LineEnding+ + ' METHODS'+LineEnding+ + ' setX(newx: INTEGER) := SetX;'+LineEnding+ + ' setY(newy: INTEGER) := SetY;'+LineEnding+ + ' OVERRIDES'+LineEnding+ + ' moveTo := MoveTo;'+LineEnding+ + ' rMoveTo := RMoveTo;'+LineEnding+ + ' getX := GetX;'+LineEnding+ + ' getY := GetY;'+LineEnding+ + ' END;'+LineEnding+LineEnding+ + ' (* accessors for x & y *)'+LineEnding+ + ' PROCEDURE GetX(self: T): INTEGER ='+LineEnding+ + ' BEGIN'+LineEnding+ + ' RETURN self.x;'+LineEnding+ + ' END GetX;'+LineEnding+LineEnding+ + ' PROCEDURE GetY(self: T): INTEGER ='+LineEnding+ + ' BEGIN'+LineEnding+ + ' RETURN self.y;'+LineEnding+ + ' END GetY;'+LineEnding+LineEnding+ + ' PROCEDURE SetX(self: T; newx: INTEGER) ='+LineEnding+ + ' BEGIN'+LineEnding+ + ' self.x := newx;'+LineEnding+ + ' END SetX;'+LineEnding+LineEnding+ + ' PROCEDURE SetY(self: T; newy: INTEGER) ='+LineEnding+ + ' BEGIN'+LineEnding+ + ' self.y := newy;'+LineEnding+ + ' END SetY;'+LineEnding+LineEnding+ + ' (* move the shape position *)'+LineEnding+ + ' PROCEDURE MoveTo(self: T; newx: INTEGER; newy: INTEGER) ='+LineEnding+ + ' BEGIN'+LineEnding+ + ' self.setX(newx);'+LineEnding+ + ' self.setY(newy);'+LineEnding+ + ' END MoveTo;'+LineEnding+LineEnding+ + ' PROCEDURE RMoveTo(self: T; deltax: INTEGER; deltay: INTEGER) ='+LineEnding+ + ' BEGIN'+LineEnding+ + ' self.moveTo(self.getX() + deltax, self.getY() + deltay);'+LineEnding+ + ' END RMoveTo;'+LineEnding+LineEnding+ + 'BEGIN'+LineEnding+ + 'END Shape.'+LineEnding; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynM3Syn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightermodelica.pas b/components/extrasyn/SyneditHighlighters/synhighlightermodelica.pas new file mode 100644 index 000000000..86ec5625f --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightermodelica.pas @@ -0,0 +1,968 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterModelica.pas, released 2000-11-09. +The Initial Author of this file is Falko Jens Wagner. +Portions created by Falko Jens Wagner are Copyright 2000 Falko Jens Wagner. +All Rights Reserved. + +Contributors to the SynEdit project 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: SynHighlighterModelica.pas,v 1.13 2005/01/28 16:53:24 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +Known Issues: +-------------------------------------------------------------------------------} +unit SynHighlighterModelica; + +{$I synedit.inc} + +interface + +uses + Graphics, + SynEditTypes, + SynEditHighlighter, + Classes; + +type + TtkTokenKind = (tkComment, tkDirective, tkIdentifier, tkKey, tkNull, tkNumber, + tkSpace, tkString, tkSymbol, tkUnknown); + + TRangeState = (rsUnknown, rsString39, rsString34, rsComment); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynModelicaSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fLineNumber: integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: integer; + fToIdent: PChar; + fTokenID: TtkTokenKind; + fTokenPos: integer; + fIdentFuncTable: array[0..137] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fDirectiveAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): integer; + function KeyComp(const aKey: string): boolean; + function Func17: TtkTokenKind; + function Func22: TtkTokenKind; + function Func25: TtkTokenKind; + function Func26: TtkTokenKind; + function Func30: TtkTokenKind; + function Func35: TtkTokenKind; + function Func39: TtkTokenKind; + function Func42: TtkTokenKind; + function Func45: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func54: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func62: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: TtkTokenKind; + function Func88: TtkTokenKind; + function Func91: TtkTokenKind; + function Func98: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func110: TtkTokenKind; + function Func112: TtkTokenKind; + function Func114: TtkTokenKind; + function Func115: TtkTokenKind; + function Func116: TtkTokenKind; + function Func119: TtkTokenKind; + function Func133: TtkTokenKind; + function Func137: TtkTokenKind; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure CRProc; + procedure ColonProc; + procedure DirectiveProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure NullProc; + procedure NumberProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure SymbolProc; + procedure SymbolProcWithEqual; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure AnsiCProc; + procedure String34Proc; + procedure String39Proc; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: string; LineNumber: integer); override; + function GetToken: string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property DirectiveAttri: TSynHighlighterAttributes read fDirectiveAttri + write fDirectiveAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else + Identifiers[I] := False; + end; + case I in ['_', 'A'..'Z', 'a'..'z'] of + True: + begin + if (I > #64) and (I < #91) then mHashTable[I] := Ord(I) - 64 else + if (I > #96) then mHashTable[I] := Ord(I) - 95; + end; + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynModelicaSyn.InitIdent; +var + I: integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := @AltFunc; + Inc(pF); + end; + fIdentFuncTable[17] := @Func17; + fIdentFuncTable[22] := @Func22; + fIdentFuncTable[25] := @Func25; + fIdentFuncTable[26] := @Func26; + fIdentFuncTable[30] := @Func30; + fIdentFuncTable[35] := @Func35; + fIdentFuncTable[39] := @Func39; + fIdentFuncTable[42] := @Func42; + fIdentFuncTable[45] := @Func45; + fIdentFuncTable[47] := @Func47; + fIdentFuncTable[48] := @Func48; + fIdentFuncTable[51] := @Func51; + fIdentFuncTable[52] := @Func52; + fIdentFuncTable[54] := @Func54; + fIdentFuncTable[59] := @Func59; + fIdentFuncTable[60] := @Func60; + fIdentFuncTable[62] := @Func62; + fIdentFuncTable[68] := @Func68; + fIdentFuncTable[69] := @Func69; + fIdentFuncTable[70] := @Func70; + fIdentFuncTable[80] := @Func80; + fIdentFuncTable[81] := @Func81; + fIdentFuncTable[84] := @Func84; + fIdentFuncTable[85] := @Func85; + fIdentFuncTable[88] := @Func88; + fIdentFuncTable[91] := @Func91; + fIdentFuncTable[98] := @Func98; + fIdentFuncTable[106] := @Func106; + fIdentFuncTable[107] := @Func107; + fIdentFuncTable[110] := @Func110; + fIdentFuncTable[112] := @Func112; + fIdentFuncTable[114] := @Func114; + fIdentFuncTable[115] := @Func115; + fIdentFuncTable[116] := @Func116; + fIdentFuncTable[119] := @Func119; + fIdentFuncTable[133] := @Func133; + fIdentFuncTable[137] := @Func137; +end; + +function TSynModelicaSyn.KeyHash(ToHash: PChar): integer; +begin + Result := 0; + while Identifiers[ToHash^] do begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynModelicaSyn.KeyComp(const aKey: string): boolean; +var + I: integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynModelicaSyn.Func17: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func22: TtkTokenKind; +begin + if KeyComp('and') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func25: TtkTokenKind; +begin + if KeyComp('in') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func26: TtkTokenKind; +begin + if KeyComp('end') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func30: TtkTokenKind; +begin + if KeyComp('der') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func35: TtkTokenKind; +begin + if KeyComp('or') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func39: TtkTokenKind; +begin + if KeyComp('Real') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func42: TtkTokenKind; +begin + if KeyComp('for') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func45: TtkTokenKind; +begin + if KeyComp('else') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func47: TtkTokenKind; +begin + if KeyComp('final') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func48: TtkTokenKind; +begin + if KeyComp('block') then Result := tkKey else + if KeyComp('false') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func51: TtkTokenKind; +begin + if KeyComp('package') then Result := tkKey else + if KeyComp('then') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func52: TtkTokenKind; +begin + if KeyComp('not') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func54: TtkTokenKind; +begin + if KeyComp('when') then Result := tkKey else + if KeyComp('model') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func59: TtkTokenKind; +begin + if KeyComp('class') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func60: TtkTokenKind; +begin + if KeyComp('flow') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func62: TtkTokenKind; +begin + if KeyComp('elseif') then Result := tkKey else + if KeyComp('while') then Result := tkKey else + if KeyComp('loop') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func68: TtkTokenKind; +begin + if KeyComp('true') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func69: TtkTokenKind; +begin + if KeyComp('public') then Result := tkKey else + if KeyComp('record') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func70: TtkTokenKind; +begin + if KeyComp('Boolean') then Result := tkKey else + if KeyComp('type') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func80: TtkTokenKind; +begin + if KeyComp('redeclare') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func81: TtkTokenKind; +begin + if KeyComp('connect') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func84: TtkTokenKind; +begin + if KeyComp('partial') then Result := tkKey else + if KeyComp('Integer') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func85: TtkTokenKind; +begin + if KeyComp('input') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func88: TtkTokenKind; +begin + if KeyComp('assert') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func91: TtkTokenKind; +begin + if KeyComp('replaceable') then Result := tkKey else + if KeyComp('discrete') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func98: TtkTokenKind; +begin + if KeyComp('extends') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func106: TtkTokenKind; +begin + if KeyComp('parameter') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func107: TtkTokenKind; +begin + if KeyComp('external') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func110: TtkTokenKind; +begin + if KeyComp('function') then Result := tkKey else + if KeyComp('equation') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func112: TtkTokenKind; +begin + if KeyComp('algorithm') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func114: TtkTokenKind; +begin + if KeyComp('constant') then Result := tkKey else + if KeyComp('terminate') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func115: TtkTokenKind; +begin + if KeyComp('protected') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func116: TtkTokenKind; +begin + if KeyComp('connector') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func119: TtkTokenKind; +begin + if KeyComp('output') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func133: TtkTokenKind; +begin + if KeyComp('annotation') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.Func137: TtkTokenKind; +begin + if KeyComp('nondiscrete') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynModelicaSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynModelicaSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 138 then + Result := fIdentFuncTable[HashKey]() + else + Result := tkIdentifier; +end; + +procedure TSynModelicaSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := @AndSymbolProc; + #39: fProcTable[I] := @AsciiCharProc; + #13: fProcTable[I] := @CRProc; + ':': fProcTable[I] := @ColonProc; + '#': fProcTable[I] := @DirectiveProc; + '>': fProcTable[I] := @GreaterProc; + 'A'..'Z', 'a'..'z', '_': + fProcTable[I] := @IdentProc; + #10: fProcTable[I] := @LFProc; + '<': fProcTable[I] := @LowerProc; + '-': fProcTable[I] := @MinusProc; + #0: fProcTable[I] := @NullProc; + '0'..'9': + fProcTable[I] := @NumberProc; + '|': fProcTable[I] := @OrSymbolProc; + '+': fProcTable[I] := @PlusProc; + '.': fProcTable[I] := @PointProc; + '/': fProcTable[I] := @SlashProc; + #1..#9, #11, #12, #14..#32: + fProcTable[I] := @SpaceProc; + #34: fProcTable[I] := @StringProc; + '~', '[', ']', '@', '{', '}', '(', ')', ';', ',': + fProcTable[I] := @SymbolProc; + '*', '^', '=', '%', '!': + fProcTable[I] := @SymbolProcWithEqual; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynModelicaSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fDirectiveAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective); + AddAttribute(fDirectiveAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange(@DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterModelica; + fRange := rsUnknown; +end; + +procedure TSynModelicaSyn.SetLine(const NewValue: string; LineNumber: integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynModelicaSyn.AndSymbolProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] in ['=', '&'] then + Inc(Run); +end; + +procedure TSynModelicaSyn.AsciiCharProc; +begin + fRange := rsString39; + fTokenID := tkString; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13, #39]; + if fLine[Run] = #39 then begin + fRange := rsUnknown; + Inc(Run); + end; +end; + +procedure TSynModelicaSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then + Inc(Run); +end; + +procedure TSynModelicaSyn.ColonProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] = ':' then + Inc(Run); +end; + +procedure TSynModelicaSyn.DirectiveProc; +begin + fTokenID := tkDirective; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynModelicaSyn.GreaterProc; +begin + Inc(Run); + fTokenID := tkSymbol; + case fLine[Run] of + '=': Inc(Run); + '>': begin + Inc(Run); + if fLine[Run] = '=' then + Inc(Run); + end; + end; +end; + +procedure TSynModelicaSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynModelicaSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynModelicaSyn.LowerProc; +begin + Inc(Run); + fTokenID := tkSymbol; + case fLine[Run] of + '=': Inc(Run); + '<': begin + Inc(Run); + if fLine[Run] = '=' then + Inc(Run); + end; + end; +end; + +procedure TSynModelicaSyn.MinusProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] in ['=', '-', '>'] then + Inc(Run); +end; + +procedure TSynModelicaSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynModelicaSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', '.', 'u', 'U', 'l', 'L', 'x', 'X', 'e', 'E', 'f', 'F'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynModelicaSyn.OrSymbolProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] in ['=', '|'] then + Inc(Run); +end; + +procedure TSynModelicaSyn.PlusProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] in ['=', '+'] then + Inc(Run); +end; + +procedure TSynModelicaSyn.PointProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if (fLine[Run] = '.') and (fLine[Run + 1] = '.') then + Inc(Run, 2); +end; + +procedure TSynModelicaSyn.SlashProc; +begin + Inc(Run); + case fLine[Run] of + '/': + begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + '*': + begin + fRange := rsComment; + inc(Run); + if fLine[Run] in [#0, #10, #13] then + fTokenID := tkComment + else + AnsiCProc; + end; + else + fTokenID := tkSymbol; + if fLine[Run] = '=' then + Inc(Run); + end; +end; + +procedure TSynModelicaSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + Inc(Run); + until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]); +end; + +procedure TSynModelicaSyn.StringProc; +begin + fRange := rsString34; + Inc(Run); + if fLine[Run] in [#0, #10, #13] then + fTokenID := tkString + else + String34Proc; +end; + +procedure TSynModelicaSyn.SymbolProc; +begin + Inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynModelicaSyn.SymbolProcWithEqual; +begin + Inc(Run); + fTokenID := tkSymbol; + if fLine[Run] = '=' then + Inc(Run); +end; + +procedure TSynModelicaSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynModelicaSyn.AnsiCProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + fTokenID := tkComment; + repeat + if (fLine[Run] = '*') and (fLine[Run + 1] = '/') then begin + inc(Run, 2); + fRange := rsUnknown; + break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynModelicaSyn.String39Proc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + fTokenID := tkString; + repeat + if fLine[Run] = #39 then begin + inc(Run); + fRange := rsUnknown; + break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynModelicaSyn.String34Proc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + fTokenID := tkString; + repeat + case fLine[Run] of + #34: + begin + Inc(Run); + fRange := rsUnknown; + break; + end; + #92: + begin + Inc(Run); + if fLine[Run] = #34 then + Inc(Run); + end; + else + Inc(Run); + end; + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynModelicaSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsComment: AnsiCProc; + rsString39: String39Proc; + rsString34: String34Proc; + else + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; +end; + +function TSynModelicaSyn.GetDefaultAttribute( + Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynModelicaSyn.GetEol: boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynModelicaSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynModelicaSyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynModelicaSyn.GetTokenEx(out TokenStart :PChar; out TokenLength :integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +function TSynModelicaSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynModelicaSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkDirective: Result := fDirectiveAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else + Result := nil; + end; +end; + +function TSynModelicaSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynModelicaSyn.GetTokenPos: integer; +begin + Result := fTokenPos; +end; + +procedure TSynModelicaSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynModelicaSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynModelicaSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynModelicaSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterModelica; +end; + +class function TSynModelicaSyn.GetLanguageName: string; +begin + Result := SYNS_LangModelica; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynModelicaSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterprogress.pas b/components/extrasyn/SyneditHighlighters/synhighlighterprogress.pas new file mode 100644 index 000000000..a789ad9e2 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterprogress.pas @@ -0,0 +1,1169 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterProgress.pas, released 2000-04-20. +The Initial Author of the Original Code is Bruno Mikkelsen. +Portions written by Bruno Mikkelsen are copyright 2000 Bruno Mikkelsen. +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: SynHighlighterProgress.pas,v 1.17 2005/01/28 16:53:24 maelh Exp $ + +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 Progress Syntax highlighter for SynEdit) +@author(Bruno Mikkelsen ) +@created(2000-04-16) +@lastmod(2000-06-20) +The SynHighlighterProgress provides SynEdit with a syntax highlighter for the +Progress programming language. +Thanks to Michael Hieke for providing a sample highlighter on which this +highlighter is based. +} +unit SynHighlighterProgress; + +{$I synedit.inc} + +interface + +uses + Classes, + Controls, Graphics, + SynEditTypes, SynEditHighlighter, SynHighlighterHashEntries; + +type + {Enumerates the different tokens in Progress.} + TtkTokenKind = (tkComment, tkEvent, tkIdentifier, tkInclude, tkKey, + tkNonReserved, tkNull, tkNumber, tkPreprocessor, tkSpace, tkDataType, + tkString, tkSymbol, tkUnknown); + + {Enumerates the ranges in Progress syntax.} + TRangeState = (rsNone, rsInclude, rsPreprocessorDef, rsPreprocessor, + rsComment); + + {Used to hold extra rangeinfo in the Lines.Objects pointer.} + TRangeInfo = packed record + case boolean of + false: (Ptr: Pointer); + true : (Range: Word; + Level: Word); + end; + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + + { TSynProgressSyn } + + TSynProgressSyn = class(TSynCustomHighLighter) + private + fLine: PChar; + fLineNumber: Integer; + fRange: TRangeState; + fCommentLevel: Integer; + fIncludeLevel: Integer; + fPreProcessorLevel: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fIdentChars: TSynIdentChars; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fCommentAttri: TSynHighlighterAttributes; + fEventAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fIncludeAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNonReservedKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fPreprocessorAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fDataTypeAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fHashList: TSynHashEntryList; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure DoAddKeyword(AKeyword: string; AKind: integer); + + procedure AsciiCharProc; + procedure CommentRangeProc; + procedure IncludeRangeProc; + procedure PreprocessorRangeProc; + procedure PreprocessorDefinitionProc; + procedure PreprocessorDefinitionRangeProc; + procedure BraceOpenProc; + procedure IdentProc; + procedure NullProc; + procedure NumberProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + procedure SymbolProc; + + protected + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override; + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: String; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; +{$IFDEF DEBUG} + public + property Keywords: TSynHashEntryList read fHashList; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine({$IFDEF FPC}const {$ENDIF} NewValue: string; LineNumber: Integer); override; + function GetToken: string; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + property IdentChars: TSynIdentChars read GetIdentchars write fIdentChars; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property EventAttri: TSynHighlighterAttributes read fEventAttri + write fEventAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property IncludeAttri: TSynHighlighterAttributes read fIncludeAttri + write fIncludeAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NonReservedKeyAttri: TSynHighlighterAttributes + read fNonReservedKeyAttri write fNonReservedKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property PreprocessorAttri: TSynHighlighterAttributes + read fPreprocessorAttri write fPreprocessorAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property DataTypeAttri: TSynHighlighterAttributes read fDataTypeAttri + write fDataTypeAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +const + DefaultKeywords: string = + 'accum accumulate active-window add alias ' + + 'all alter ambig ambiguous analyze ' + + 'analyze-resume analyze-suspend and any apply ' + + 'as asc ascending assign at ' + + 'attr-space authorization auto-return avail available ' + + 'background before-hide begins bell between ' + + 'bin blank break btos by ' + + 'byte call can-do can-find case ' + + 'case-sensitive center centered check chr ' + + 'clear clipboard col colon color ' + + 'column column-label columns compiler control ' + + 'count-of cpstream create ctos current ' + + 'current-changed current-lang current-language current-window cursor ' + + 'database dataservers dbcodepage dbcollation dbname ' + + 'dbparam dbrestrictions dbtaskid dbtype dbversion ' + + 'dde deblank debug-list debugger decimals ' + + 'declare def default default-noxlate default-window ' + + 'define delete delimiter desc descending ' + + 'dict dictionary disable disconnect disp ' + + 'display distinct do dos down ' + + 'drop each editing else ' + + 'elseif enable encode end endif ' + + 'entry error-status escape etime except ' + + 'exclusive exclusive-lock exists export false ' + + 'fetch field fields file-info file-information ' + + 'fill find find-case-sensitive find-global find-next-occurrence ' + + 'find-prev-occurrence find-select find-wrap-around first first-of ' + + 'focus font font-based-grid for form ' + + 'format frame frame-col frame-db frame-down ' + + 'frame-field frame-file frame-index frame-line frame-name ' + + 'frame-row frame-val frame-value from from-chars ' + + 'from-pixels gateways get-byte get-codepages get-collations ' + + 'get-key-value getbyte glob global ' + + 'global-define go-on go-pending grant graphic-edge ' + + 'group having header help hide ' + + 'if import in index ' + + 'indicator input input-output insert into ' + + 'is is-attr-space join kblabel key-code ' + + 'key-function key-label keycode keyfunction keylabel ' + + 'keys keyword label last last-event ' + + 'last-key last-of lastkey ldbname leave ' + + 'library like line-count line-counter line-number ' + + 'listing locked long lookup machine-class ' + + 'map member memptr message ' + + 'message-lines mouse mpe new next ' + + 'next-prompt no no-attr-space no-error no-fill ' + + 'no-help no-hide no-label no-labels no-lock ' + + 'no-map no-message no-pause no-prefetch no-undo ' + + 'no-validate no-wait not null num-aliases ' + + 'num-dbs num-entries of off old ' + + 'on open opsys option ' + + 'or os-append os-command os-copy os-create-dir ' + + 'os-delete os-dir os-rename os2 os400 ' + + 'otherwise output overlay page page-bottom ' + + 'page-num page-number page-top param parameter ' + + 'pause pdbname persistent pixels preprocess ' + + 'privileges proc-handle proc-status process program-name ' + + 'progress prompt prompt-for promsgs propath ' + + 'proversion put put-byte put-key-value putbyte ' + + 'query query-tuning quit r-index rcode-information ' + + 'readkey recid record-length rectangle ' + + 'release repeat reposition retain retry ' + + 'return revert revoke run save ' + + 'schema scop scoped scoped-define screen ' + + 'screen-io screen-lines scroll sdbname search ' + + 'seek select self sequence session ' + + 'set setuserid share share-lock shared ' + + 'short show-stats skip some space ' + + 'status stream stream-io string-xref system-dialog ' + + 'table term terminal text text-cursor ' + + 'text-height text-seg-growth then this-procedure ' + + 'time title to top-only trans ' + + 'transaction trigger triggers trim true ' + + 'undefine underline undo unformatted union ' + + 'unique unix unless-hidden unsigned-short up ' + + 'update use-index use-revvideo use-underline user ' + + 'userid using v6frame value values ' + + 'view view-as vms wait-for web-context ' + + 'when where while window window-maximized ' + + 'window-minimized window-normal with work-table workfile ' + + 'write xcode xref yes _actailog ' + + '_actbilog _actbuffer _actindex _actiofile _actiotype ' + + '_actlock _actother _actpws _actrecord _actserver ' + + '_actspace _actsummary _block _buffstatus _cbit ' + + '_checkpoint _connect _control _db _dbstatus ' + + '_dcm _field _field-trig _file _file-trig ' + + '_filelist _index _index-field _license _list ' + + '_lock _lockreq _logging _memory _msg ' + + '_mstrblk _pcontrol _segments _sequence _serial-num ' + + '_servers _startup _trace _trans _user ' + + '_userio _userlock _view _view-col _view-ref'; + + DefaultNonReservedKeywords: string = + 'abs absolute accelerator across add-events-procedure ' + + 'add-first add-last advise alert-box allow-replication ' + + 'ansi-only anywhere append appl-alert appl-alert-boxes ' + + 'application as-cursor ask-overwrite attachment auto-endkey ' + + 'auto-end-key auto-go auto-indent auto-resize auto-zap ' + + 'available-formats average avg backwards base-key ' + + 'batch batch-mode bgc bgcolor ' + + 'binary bind-where block-iteration-display border-bottom border-bottom-chars ' + + 'border-bottom-pixels border-left border-left-chars border-left-pixels border-right ' + + 'border-right-chars border-right-pixels border-top border-top-chars border-top-pixels ' + + 'both bottom box box-select box-selectable ' + + 'browse browse-header btn-down-arrow btn-left-arrow btn-right-arrow ' + + 'btn-up-arrow buffer buffer-chars buffer-compare buffer-copy ' + + 'buffer-lines button buttons cache cache-size ' + + 'cancel-break cancel-button can-query can-set caps ' + + 'cdecl character_length charset checked clear-select ' + + 'clear-selection code codepage codepage-convert col-of ' + + 'colon-align colon-aligned color-table column-bgcolor column-dcolor ' + + 'column-fgcolor column-font column-label-bgcolor column-label-dcolor column-label-fgcolor ' + + 'column-label-font column-of column-scrolling com1 com2 ' + + 'com3 com4 com5 com6 com7 ' + + 'com8 com9 combo-box command complete ' + + 'com-self con connect connected ' + + 'constrained contains contents context context-popup ' + + 'control-container convert convert-3d-colors convert-to-offset count ' + + 'cpcase cpcoll cpinternal cplog cpprint ' + + 'cprcodein cprcodeout cpterm crc-value create-control ' + + 'create-result-list-entry create-test-file current_date current-column ' + + 'current-iteration current-result-row current-row-modified current-value cursor-char ' + + 'cursor-line cursor-offset data-entry-return data-type date-format ' + + 'day db-references dcolor dde-error dde-id ' + + 'dde-item dde-name dde-topic debug default-button ' + + 'default-extension defined delete-current-row delete-selected-row delete-selected-rows ' + + 'deselect-focused-row deselect-rows deselect-selected-row design-mode dialog-box ' + + 'dialog-help dir disabled display-message display-type ' + + 'drag-enabled drop-down drop-down-list dump dynamic ' + + 'echo edge edge-chars edge-pixels edit-can-undo ' + + 'editor edit-undo empty end-key entered ' + + 'eq error error-col error-column error-row ' + + 'events event-type exp expand extended ' + + 'extent external extract fetch-selected-row fgc ' + + 'fgcolor file filename file-name ' + + 'file-offset file-type filled fill-in filters ' + + 'first-child first-column first-proc first-procedure first-server ' + + 'first-tab-item fixed-only focused-row font-table force-file ' + + 'foreground forwards frame-spacing frame-x frame-y ' + + 'frequency from-current full-height full-height-chars full-height-pixels ' + + 'full-pathname full-width full-width-chars full-width-pixels function ' + + 'ge get-blue get-blue-value get-char-property get-double ' + + 'get-dynamic get-file get-float get-green get-green-value ' + + 'get-iteration get-license get-long get-message get-number ' + + 'get-pointer-value get-red get-red-value get-repositioned-row get-selected ' + + 'get-selected-widget get-short get-signature get-size get-string ' + + 'get-tab-item get-text-height get-text-height-chars get-text-height-pixels get-text-width ' + + 'get-text-width-chars get-text-width-pixels get-unsigned-short grayed grid-factor-h ' + + 'grid-factor-horizontal grid-factor-v grid-factor-vertical grid-set grid-snap ' + + 'grid-unit-height grid-unit-height-chars grid-unit-height-pixels grid-unit-width grid-unit-width-chars ' + + 'grid-unit-width-pixels grid-visible gt height height-chars ' + + 'height-pixels help-context hidden horizontal hwnd ' + + 'image image-down image-insensitive image-size image-size-chars ' + + 'image-size-pixels image-up immediate-display indexed-reposition index-hint ' + + 'info information init initial initial-dir ' + + 'initial-filter initiate inner inner-chars inner-lines ' + + 'insert-backtab insert-file insert-row insert-string insert-tab ' + + 'internal-entries is-lead-byte is-row-selected is-selected item ' + + 'items-per-row join-by-sqldb keep-frame-z-order keep-messages keep-tab-order ' + + 'key keyword-all label-bgc label-bgcolor label-dc ' + + 'label-dcolor label-fgc label-fgcolor label-font label-pfc ' + + 'label-pfcolor labels languages large large-to-small ' + + 'last-child last-proc last-procedure last-server last-tab-item ' + + 'lc le leading left-aligned left-trim ' + + 'length line list-events list-items list-query-attrs ' + + 'list-set-attrs list-widgets load load-control loadcontrols ' + + 'load-icon load-image load-image-down load-image-insensitive load-image-up ' + + 'load-mouse-pointer load-small-icon log-id lookahead lower ' + + 'lpt0 lpt1 lpt2 lpt3 lpt4 ' + + 'lpt5 lpt6 lpt7 lpt8 lpt9 ' + + 'lt manual-highlight margin-extra margin-height margin-height-chars ' + + 'margin-height-pixels margin-width margin-width-chars margin-width-pixels matches ' + + 'max max-chars max-data-guess max-height ' + + 'max-height-chars max-height-pixels maximize maximum max-rows ' + + 'max-size max-value max-width max-width-chars max-width-pixels ' + + 'memory menu menubar menu-bar menu-item ' + + 'menu-key menu-mouse message-area message-area-font message-line ' + + 'min min-height min-height-chars min-height-pixels minimum ' + + 'min-size min-value min-width min-width-chars min-width-pixels ' + + 'mod modified modulo month mouse-pointer ' + + 'movable move-after move-after-tab-item move-before move-before-tab-item ' + + 'move-column move-to-bottom move-to-eof move-to-top multiple ' + + 'multiple-key multitasking-interval must-exist name native ' + + 'ne new-row next-column next-sibling next-tab-item ' + + 'next-value no-apply no-assign no-bind-where no-box ' + + 'no-column-scrolling no-convert no-current-value no-debug no-drag ' + + 'no-echo no-focus no-index-hint no-join-by-sqldb no-lookahead ' + + 'no-return-value no-row-markers no-scrolling no-separate-connection no-separators ' + + 'no-underline no-word-wrap num-buttons num-columns num-copies ' + + 'numeric numeric-format num-formats num-items num-iterations ' + + 'num-lines num-locked-columns num-messages num-results num-selected ' + + 'num-selected-rows num-selected-widgets num-tabs num-to-retain octet_length ' + + 'ok ok-cancel on-frame on-frame-border ordinal ' + + 'orientation os-drives os-error ' + + 'os-getenv outer outer-join override owner ' + + 'paged page-size page-width parent partial-key ' + + 'pascal pathname pfc pfcolor pinnable ' + + 'pixels-per-col pixels-per-column pixels-per-row popup-menu popup-only ' + + 'position precision preselect prev prev-column ' + + 'prev-sibling prev-tab-item primary printer-control-handle printer-name ' + + 'printer-port printer-setup private-data prn procedure ' + + 'progress-source proxy put-double put-float put-long ' + + 'put-short put-string put-unsigned-short query-off-end question ' + + 'radio-buttons radio-set random raw-transfer read-file ' + + 'read-only real recursive refresh refreshable ' + + 'remote remove-events-list replace replace-selection-text replication-create ' + + 'replication-delete replication-write request resizable resize ' + + 'retry-cancel return-inserted returns return-to-start-dir return-value ' + + 'right-aligned right-trim round row ' + + 'row-markers row-of rule rule-row rule-y ' + + 'save-file screen-value scrollable scrollbar-h scrollbar-horizontal ' + + 'scroll-bars scrollbar-v scrollbar-vertical scroll-delta scrolled-row-pos ' + + 'scrolled-row-position scroll-horiz-value scrolling scroll-offset scroll-to-current-row ' + + 'scroll-to-item scroll-to-selected-row scroll-vert-value se-check-pools section ' + + 'se-enable-off se-enable-on selectable selected selected-items ' + + 'select-focused-row selection-end selection-list selection-start selection-text ' + + 'select-next-row select-prev-row select-repositioned-row select-row send ' + + 'sensitive se-num-pools separate-connection separators server ' + + 'set-blue set-blue-value set-break set-cell-focus set-contents ' + + 'set-dynamic set-green set-green-value set-leakpoint set-pointer-value ' + + 'set-property set-red set-red-value set-repositioned-row set-selection ' + + 'set-size set-wait-state se-use-message side-label-handle side-labels ' + + 'silent simple single size size-chars ' + + 'size-pixels slider smallint sort source ' + + 'sql sqrt start status-area status-area-font ' + + 'status-bar stdcall stenciled stopped stored-procedure ' + + 'string sub-average sub-count sub-max sub-maximum ' + + 'sub-menu sub-menu-help sub-min sub-minimum substitute ' + + 'substr substring sub-total subtype sum ' + + 'suppress-warnings system-alert-boxes system-help tab-position target ' + + 'temp-dir temp-directory temp-table terminate text-selected ' + + 'three-d through thru tic-marks time-source ' + + 'title-bgc title-bgcolor title-dc title-dcolor title-fgc ' + + 'title-fgcolor title-font today toggle-box ' + + 'tool-bar tooltip tooltips top topic ' + + 'to-rowid total trailing trunc truncate ' + + 'type unbuffered unique-id unload upper ' + + 'use use-dict-exps use-filename use-text v6display ' + + 'validate validate-condition validate-message valid-event valid-handle ' + + 'var variable vertical virtual-height virtual-height-chars ' + + 'virtual-height-pixels virtual-width virtual-width-chars virtual-width-pixels visible ' + + 'wait warning weekday widget-enter widget-leave ' + + 'widget-pool width width-chars width-pixels window-name ' + + 'window-state window-system word-wrap x ' + + 'x-of y year year-offset yes-no ' + + 'yes-no-cancel y-of'; + + DefaultEvents: string = + 'abort any-key any-printable append-line backspace ' + + 'back-tab block blue bottom-column break-line ' + + 'bs cancel cancel-move cancel-pick cancel-resize ' + + 'choices choose close compile container-event ' + + 'copy cr ctrl-alt-del ctrl-break ctrl-g ' + + 'ctrl-j ctrl-l cursor-down cursor-left cursor-right ' + + 'cursor-up cut data-refresh-line data-refresh-page dde-notify ' + + 'default-action default-pop-up del del-char delete-char ' + + 'delete-character delete-column delete-end-line delete-field delete-line ' + + 'delete-word del-line deselect deselect-extend deselection ' + + 'deselection-extend dismiss-menu dos-end down-arrow editor-backtab ' + + 'editor-tab empty-selection end-box-selection end-error endkey ' + + 'end-move end-resize end-search enter enter-menubar ' + + 'erase esc execute exit ' + + 'ff find-next find-previous focus-in formfeed ' + + 'forward get go goto help-key ' + + 'home horiz-end horiz-home horiz-scroll-drag ins ' + + 'ins-char insert-column insert-field insert-field-data insert-field-label ' + + 'insert-here insert-mode ins-line iteration-changed left ' + + 'left-arrow left-end left-mouse-click left-mouse-dblclick left-mouse-down ' + + 'left-mouse-up lf line-del line-down line-erase ' + + 'linefeed line-ins line-left line-right line-up ' + + 'main-menu menu-drop middle-mouse-click middle-mouse-dblclick middle-mouse-down ' + + 'middle-mouse-up mouse-extend-click mouse-extend-dblclick mouse-extend-down mouse-extend-drag ' + + 'mouse-extend-up mouse-menu-click mouse-menu-dblclick mouse-menu-down mouse-menu-drag ' + + 'mouse-menu-up mouse-move mouse-move-click mouse-move-dblclick mouse-move-down ' + + 'mouse-move-drag mouse-move-up mouse-select-click mouse-select-dblclick mouse-select-down ' + + 'mouse-select-drag mouse-select-up move new-line next-error ' + + 'next-frame next-page next-scrn next-word object ' + + 'off-end off-home open-line-above options out-of-data ' + + 'page-down page-erase page-left page-right page-right-text ' + + 'page-up parent-window-close paste pgdn pgup ' + + 'pick pick-area pick-both popup-menu-key prev-frame ' + + 'prev-page prev-scrn prev-word recall red ' + + 'remove reports reset resume-display ' + + 'right right-arrow right-end right-mouse-click ' + + 'right-mouse-dblclick right-mouse-down right-mouse-up row-display row-entry ' + + 'row-leave save-as scrollbar-drag scroll-left ' + + 'scroll-mode scroll-notify scroll-right select-extend selection ' + + 'selection-extend settings shift-tab start-box-selection start-extend-box-selection ' + + 'start-move start-resize start-search stop stop-display ' + + 'tab top-column u1 u10 u2 ' + + 'u3 u4 u5 u6 u7 ' + + 'u8 u9 unix-end up-arrow value-changed ' + + 'white window-close window-resized window-restored'; + + DefaultDataTypes: string = + 'char character com-handle date dec ' + + 'decimal double float handle int ' + + 'integer log logical raw rowid ' + + 'widget widget-handle'; + +procedure Register; + +implementation + +uses + SynEditStrConst; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure Register; +begin + RegisterComponents('SynEdit', [TSynProgressSyn]); +end; + +{------------------------------------------------------------------------------} + +procedure MakeIdentTable; +var + c: char; +begin + FillChar(Identifiers, SizeOf(Identifiers), 0); + for c := 'a' to 'z' do + Identifiers[c] := TRUE; + for c := 'A' to 'Z' do + Identifiers[c] := TRUE; + for c := '0' to '9' do + Identifiers[c] := TRUE; + Identifiers['_'] := TRUE; + Identifiers['-'] := TRUE; + + FillChar(mHashTable, SizeOf(mHashTable), 0); + for c := 'a' to 'z' do + mHashTable[c] := 1 + Ord(c) - Ord('a'); + for c := 'A' to 'Z' do + mHashTable[c] := 1 + Ord(c) - Ord('A'); + for c := '0' to '9' do + mHashTable[c] := 27 + Ord(c) - Ord('0'); + mHashTable['_'] := 37; + mHashTable['-'] := 38; +end; + +function TSynProgressSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in fIdentChars do + begin +{$IFOPT Q-} + Result := 3 * Result + mHashTable[ToHash^]; +{$ELSE} + Result := (3 * Result + mHashTable[ToHash^]) and $FFFFFF; +{$ENDIF} + inc(ToHash); + end; + Result := Result and $3FF; + fStringLen := ToHash - fToIdent; +end; + +function TSynProgressSyn.KeyComp(const aKey: string): Boolean; +var + i: integer; + pKey1, pKey2: PChar; +begin + pKey1 := fToIdent; + // Note: fStringLen is always > 0 ! + pKey2 := pointer(aKey); + for i := 1 to fStringLen do + begin + if mHashTable[pKey1^] <> mHashTable[pKey2^] then + begin + Result := FALSE; + exit; + end; + Inc(pKey1); + Inc(pKey2); + end; + Result := TRUE; +end; + +function TSynProgressSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + Entry: TSynHashEntry; +begin + fToIdent := MayBe; + Entry := fHashList[KeyHash(MayBe)]; + while Assigned(Entry) do begin + if Entry.KeywordLen > fStringLen then + break + else if Entry.KeywordLen = fStringLen then + if KeyComp(Entry.Keyword) then begin + Result := TtkTokenKind(Entry.Kind); + exit; + end; + Entry := Entry.Next; + end; + Result := tkIdentifier; +end; + +procedure TSynProgressSyn.DoAddKeyword(AKeyword: string; AKind: integer); +var + HashValue: integer; +begin + HashValue := KeyHash(PChar(AKeyword)); + fHashList[HashValue] := TSynHashEntry.Create(AKeyword, AKind); +end; + +procedure TSynProgressSyn.MakeMethodTables; +var + i: char; +begin + for I := #0 to #255 do + case I of + #0: fProcTable[I] := @NullProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc; + 'A'..'Z','a'..'z','_': fProcTable[I] := @IdentProc; + '0'..'9': fProcTable[I] := @NumberProc; + '''': fProcTable[I] := @AsciiCharProc; + '"': fProcTable[I] := @StringProc; + '{': fProcTable[I] := @BraceOpenProc; + '+','-','*','@',':','=','<','>','.','^','(',')','[',']': + fProcTable[I] := @SymbolProc; + '&': fProcTable[I] := @PreprocessorDefinitionProc; + '/': fProcTable[I] := @SlashProc; + else + fProcTable[I] := @UnknownProc; + end; +end; + +constructor TSynProgressSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fHashList := TSynHashEntryList.Create; + + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Foreground := clRed; + AddAttribute(fCommentAttri); + + fEventAttri := TSynHighlighterAttributes.Create(SYNS_AttrEvent); + fEventAttri.Foreground := clOlive; + AddAttribute(fEventAttri); + + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + fIdentifierAttri.Foreground := clNavy; + AddAttribute(fIdentifierAttri); + + fIncludeAttri := TSynHighlighterAttributes.Create(SYNS_AttrInclude); + fIncludeAttri.Foreground := clPurple; + AddAttribute(fIncludeAttri); + + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Foreground := clMaroon; + AddAttribute(fKeyAttri); + + fNonreservedKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrNonReservedKeyword); + fNonReservedKeyAttri.Foreground := clTeal; + AddAttribute(fNonReservedKeyAttri); + + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clMaroon; + AddAttribute(fNumberAttri); + + fPreprocessorAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor); + fPreprocessorAttri.Foreground := clPurple; + AddAttribute(fPreProcessorAttri); + + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fDataTypeAttri := TSynHighlighterAttributes.Create(SYNS_AttrDataType); + fDataTypeAttri.Foreground := clSilver; + AddAttribute(fDataTypeAttri); + + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clBlue; + AddAttribute(fStringAttri); + + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + + MakeMethodTables; + fDefaultFilter := SYNS_FilterProgress; + fIdentChars := TSynValidStringChars + ['-']; + + EnumerateKeywords(Ord(tkKey), DefaultKeywords, IdentChars, @DoAddKeyword); + EnumerateKeywords(Ord(tkNonReserved), DefaultNonReservedKeywords, + IdentChars, @DoAddKeyword); + EnumerateKeywords(Ord(tkEvent), DefaultEvents, IdentChars, @DoAddKeyword); + EnumerateKeywords(Ord(tkDataType), DefaultDataTypes, IdentChars, + @DoAddKeyword); + SetAttributesOnChange(@DefHighlightChange); +end; + +destructor TSynProgressSyn.Destroy; +begin + fHashList.Free; + inherited Destroy; +end; + +procedure TSynProgressSyn.SetLine({$IFDEF FPC}const {$ENDIF}NewValue: string; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynProgressSyn.IdentProc; +begin + fTokenID := IdentKind(fLine + Run); + inc(Run, fStringLen); +end; + +procedure TSynProgressSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynProgressSyn.NumberProc; +var + p: PChar; +begin + fTokenID := tkNumber; + p := PChar(@fLine[Run]); + repeat + Inc(p); + until not (p^ in ['0'..'9']); + Run := p - fLine; +end; + +procedure TSynProgressSyn.PreprocessorDefinitionProc; +var + p: PChar; +begin + fTokenID := tkPreprocessor; + p := PChar(@fLine[Run]); + while p^ <> #0 do + begin + case p^ of + '~': if (p+1)^ = #0 then + fRange := rsPreprocessorDef; + end; + inc(p); + end; + Run := p - fLine; +end; + +procedure TSynProgressSyn.SpaceProc; +var + p: PChar; +begin + fTokenID := tkSpace; + p := PChar(@fLine[Run]); + repeat + Inc(p); + until not (p^ in [#1..#9, #11, #12, #14..#32]); + Run := p - fLine; +end; + +procedure TSynProgressSyn.StringProc; +var + p: PChar; +begin + fTokenID := tkString; + p := PChar(@fLine[Run]); + repeat + Inc(p); + until (p^ = #0) or (p^ = '"'); + if (p^ = '"') then Inc(p); + Run := p - fLine; +end; + +procedure TSynProgressSyn.SymbolProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynProgressSyn.UnknownProc; +begin + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynProgressSyn.AsciiCharProc; +var + p: PChar; +begin + fTokenID := tkString; + p := PChar(@fLine[Run]); + repeat + inc(p); + until (p^ = #0) or (p^ = ''''); + if (p^ = '''') then Inc(p); + Run := p - fLine; +end; + +procedure TSynProgressSyn.SlashProc; +var + p: PChar; +begin + p := PChar(@fLine[Run]); + inc(p); + case p^ of + '*': begin {c style comments} + fTokenID := tkComment; + fRange := rsComment; + fCommentLevel := 1; + inc(p); + while (p^ <> #0) and (fRange = rsComment) do + begin + case p^ of + '*': begin + inc(p); + if p^ = '/' then + begin + inc(p); + dec(fCommentLevel); + if FCommentLevel = 0 then + fRange := rsNone; + end; + end; + '/': begin + inc(p); + if p^ = '*' then + begin + inc(p); + inc(fCommentLevel); // Max 65535 commentlevels. + end; + end; + else + inc(p); + end; + end; + end; + else {division} + fTokenID := tkSymbol; + end; + Run := p - fLine; +end; + +procedure TSynProgressSyn.CommentRangeProc; +var + p: PChar; +begin + fTokenID := tkComment; + p := PChar(@fLine[Run]); + + if p^ = #0 then + begin + NullProc; + exit; + end; + + while (p^ <> #0) and (fRange = rsComment) do + begin + case p^ of + '*': begin + inc(p); + if p^ = '/' then + begin + inc(p); + dec(fCommentLevel); + if fCommentLevel = 0 then + fRange := rsNone; + end; + end; + '/': begin + inc(p); + if p^ = '*' then + begin + inc(p); + inc(fCommentLevel); + end; + end; + else + inc(p); + end; + end; + Run := p - fLine; +end; + +procedure TSynProgressSyn.IncludeRangeProc; +var + p: PChar; +begin + fTokenID := tkInclude; + p := PChar(@fLine[Run]); + + if p^ = #0 then + begin + NullProc; + exit; + end; + + while p^ <> #0 do + begin + case p^ of + '}': begin + dec(fIncludeLevel); + if fIncludeLevel = 0 then + begin + fRange := rsNone; + break; + end + else + inc(p); + end; + else + inc(p); + end; + end; + Run := p - fLine; +end; + +procedure TSynProgressSyn.PreprocessorRangeProc; +var + p: PChar; +begin + fTokenID := tkPreprocessor; + p := PChar(@fLine[Run]); + + if p^ = #0 then + begin + NullProc; + exit; + end; + + while (p^ <> #0) and (fRange = rsPreprocessor) do + begin + case p^ of + '{': inc(fPreprocessorLevel); + '}': begin + dec(fPreprocessorLevel); + if fPreprocessorLevel = 0 then + fRange := rsNone; + end; + end; + inc(p); + end; + Run := p - fLine; +end; + +procedure TSynProgressSyn.PreprocessorDefinitionRangeProc; +var + p: PChar; +begin + fTokenID := tkPreprocessor; + p := PChar(@fLine[Run]); + + if Run = 0 then + fRange := rsNone; + + if p^ = #0 then + begin + NullProc; + exit; + end; + + while p^ <> #0 do + begin + case p^ of + '~': if (p+1)^ = #0 then + fRange := rsPreprocessorDef; + end; + inc(p); + end; + Run := p - fLine; +end; + +procedure TSynProgressSyn.BraceOpenProc; +var + p: PChar; + + function LevelCount: Integer; + begin + if fTokenID = tkInclude then + Result := fIncludeLevel + else + Result := fPreprocessorLevel; + end; + +begin + p := PChar(@fLine[Run]); + + inc(p); + case p^ of + 'A'..'Z', 'a'..'z', '_': fTokenID := tkInclude; + '&' : fTokenID := tkPreprocessor; + else + fTokenID := tkUnknown; + end; + + case fTokenID of + tkInclude : fIncludeLevel := 1; + tkPreprocessor: fPreprocessorLevel := 1; + end; + + while LevelCount > 0 do + begin + case p^ of + #0 : begin + if fTokenID = tkInclude then + fRange := rsInclude + else + fRange := rsPreprocessor; + break; + end; + '}': case fTokenID of + tkInclude : dec(fIncludeLevel); + tkPreprocessor: dec(fPreprocessorLevel); + end; + '{': case fTokenID of + tkInclude : inc(fIncludeLevel); + tkPreprocessor: inc(fPreprocessorLevel); + end; + end; + inc(p); + end; + Run := p - fLine; +end; + +procedure TSynProgressSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsInclude : IncludeRangeProc; + rsPreprocessor : PreprocessorRangeProc; + rsPreprocessorDef: PreprocessorDefinitionRangeProc; + rsComment : CommentRangeProc; + else + fProcTable[fLine[Run]]; + end; +end; + +function TSynProgressSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + Result := nil; +end; + +function TSynProgressSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynProgressSyn.GetRange: Pointer; +var + rng: TRangeInfo; +begin + rng.Range := Ord(fRange); + rng.Level := 0; + case fRange of + rsComment : rng.Level := fCommentLevel; + rsInclude : rng.Level := fIncludeLevel; + rsPreProcessor: rng.Level := fPreProcessorLevel; + end; + Result := rng.Ptr; +end; + +function TSynProgressSyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynProgressSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynProgressSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkEvent: Result := fEventAttri; + tkIdentifier: Result := fIdentifierAttri; + tkInclude: Result := fIncludeAttri; + tkKey: Result := fKeyAttri; + tkNonReserved: Result := fNonReservedKeyAttri; + tkNumber: Result := fNumberAttri; + tkPreprocessor: Result := fPreprocessorAttri; + tkSpace: Result := fSpaceAttri; + tkDataType: Result := fDataTypeAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fSymbolAttri; + else Result := nil; + end; +end; + +function TSynProgressSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynProgressSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynProgressSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + + +procedure TSynProgressSyn.ResetRange; +begin + fRange := rsNone; + fCommentLevel := 0; + fIncludeLevel := 0; + fPreprocessorLevel := 0; +end; + +procedure TSynProgressSyn.SetRange(Value: Pointer); +var + rng: TRangeInfo; +begin + rng := TRangeInfo(Value); + fRange := TRangeState(rng.Range); + fCommentLevel := 0; + fIncludeLevel := 0; + fPreprocessorLevel := 0; + case fRange of + rsComment : fCommentLevel := rng.Level; + rsInclude : fIncludeLevel := rng.Level; + rsPreProcessor: fPreprocessorLevel := rng.Level; + end; +end; + +function TSynProgressSyn.GetIdentChars: TSynIdentChars; +begin + Result := fIdentChars; +end; + +function TSynProgressSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterProgress; +end; + +class function TSynProgressSyn.GetLanguageName: string; +begin + Result := SYNS_LangProgress; +end; + +function TSynProgressSyn.GetSampleSource: String; +begin + Result := '&scoped-define FirstChar 65'#13#10+ + '&scoped-define LastChar 90'#13#10+ + #13#10+ + 'def var i as int no-undo.'#13#10+ + 'def var s as char no-undo.'#13#10+ + #13#10+ + 'function GetRandomChar returns char (input SomeValue as int):'#13#10+ + ' return chr(random({&FirstChar}, {&LastChar})).'#13#10+ + 'end.'#13#10+ + #13#10+ + 'procedure ClearString:'#13#10+ + ' def input-output param str as char no-undo.'#13#10+ + ' str = "".'#13#10+ + 'end.'#13#10+ + #13#10+ + 'run ClearString(input-output s).'#13#10+ + 'do i = 1 to 100:'#13#10+ + ' s = s + GetRandomChar(17).'#13#10+ + 'end.'#13#10+ + 'display s.'; +end; + +initialization + MakeIdentTable; + RegisterPlaceableHighlighter(TSynProgressSyn); + +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterrc.pas b/components/extrasyn/SyneditHighlighters/synhighlighterrc.pas new file mode 100644 index 000000000..f292c61c8 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterrc.pas @@ -0,0 +1,1231 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterRC.pas, released 2004-06-12. +The initial author of this file is Yiannis Mandravellos. +All Rights Reserved. + +Contributors to the SynEdit project 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: SynHighlighterRC.pas,v 1.9 2005/12/31 07:34:36 skyweb Exp $ + +You may retrieve the latest version of SynEdit from the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} + +{$IFNDEF QSYNHIGHLIGHTERRC} +unit SynHighlighterRC; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + Controls, + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = (tkComment, tkDirective, tkIdentifier, tkKey, tkNull, + tkNumber, tkSpace, tkString, tkSymbol, tkUnknown); + + TRangeState = (rsUnknown, rsDirective, rsComment); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TSynRCSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: integer; + fToIdent: PChar; + fTokenPos: integer; + fTokenID: TtkTokenKind; + fLineNumber: integer; + fIdentFuncTable: array[0..199] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fDirecAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): integer; + function KeyComp(const aKey: string): boolean; + + // number id functions + function Func33: TtkTokenKind; + function Func39: TtkTokenKind; + function Func41: TtkTokenKind; + function Func43: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func60: TtkTokenKind; + function Func61: TtkTokenKind; + function Func62: TtkTokenKind; + function Func66: TtkTokenKind; + function Func68: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func75: TtkTokenKind; + function Func77: TtkTokenKind; + function Func78: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func87: TtkTokenKind; + function Func89: TtkTokenKind; + function Func90: TtkTokenKind; + function Func94: TtkTokenKind; + function Func97: TtkTokenKind; + function Func98: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func105: TtkTokenKind; + function Func107: TtkTokenKind; + function Func109: TtkTokenKind; + function Func110: TtkTokenKind; + function Func111: TtkTokenKind; + function Func113: TtkTokenKind; + function Func117: TtkTokenKind; + function Func118: TtkTokenKind; + function Func120: TtkTokenKind; + function Func121: TtkTokenKind; + function Func125: TtkTokenKind; + function Func126: TtkTokenKind; + function Func127: TtkTokenKind; + function Func128: TtkTokenKind; + function Func130: TtkTokenKind; + function Func134: TtkTokenKind; + function Func139: TtkTokenKind; + function Func140: TtkTokenKind; + function Func146: TtkTokenKind; + function Func147: TtkTokenKind; + function Func150: TtkTokenKind; + function Func156: TtkTokenKind; + function Func158: TtkTokenKind; + function Func164: TtkTokenKind; + function Func171: TtkTokenKind; + function Func196: TtkTokenKind; + function Func199: TtkTokenKind; + + // symbol functions + procedure CommentProc; + procedure CRProc; + procedure DirectiveProc; + procedure IdentProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure QuoteProc; + procedure SlashProc; + procedure SpaceProc; + procedure SymbolProc; + procedure UnknownProc; + + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(Maybe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: Boolean; override; + public + class function GetCapabilities: TSynHighlighterCapabilities; override; + class function GetLanguageName: string; override; + public + constructor Create(aOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(index: integer): TSynHighlighterAttributes; override; + function GetEol: boolean; override; + function GetRange: pointer; override; + function GetTokenID: TtkTokenKind; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + procedure SetLine(const NewValue: string; LineNumber: integer); override; + function GetToken: string; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: integer; override; + procedure Next; override; + procedure SetRange(value: pointer); override; + procedure ResetRange; override; + function UseUserSettings(SettingIndex: integer): boolean; override; + procedure EnumUserSettings(Settings: TStrings); override; + function GetSampleSource: string; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property DirecAttri: TSynHighlighterAttributes read fDirecAttri write fDirecAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst, SynEditStrConstExtra; +{$ENDIF} + +const + MAXNumFunc = 199; // ** don't forget to change + +var + Identifiers: array[#0..#255] of bytebool; + mHashTable: array[#0..#255] of integer; + +procedure MakeIdentTable; +var + i, j: char; +begin + for i:= #0 to #255 do + begin + case i of + '_', '0'..'9', 'a'..'z','A','Z': identifiers[i]:= TRUE; + else + identifiers[i]:= FALSE; + end; + j:= UpCase(i); + case i of + '_', 'a'..'z', 'A'..'Z': mHashTable[i]:= ord(j) -64; + else + mHashTable[i]:= 0; + end; + end; +end; + +{ TSynRCSyn } + +procedure TSynRCSyn.InitIdent; +var + i: integer; + pF: PIdentFuncTableFunc; +begin + pF:= PIdentFuncTableFunc(@fIdentFuncTable); + for i:= low(fIdentFuncTable) to high(fIdentFuncTable) do + begin + pF^:= {$ifdef FPC} @ {$endif}AltFunc; + inc(pF); + end; + // number func set + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF} Func33; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF} Func39; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF} Func47; + fIdentFuncTable[48] := {$IFDEF FPC}@{$ENDIF} Func48; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF} Func53; + fIdentFuncTable[54] := {$IFDEF FPC}@{$ENDIF} Func54; + fIdentFuncTable[55] := {$IFDEF FPC}@{$ENDIF} Func55; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF} Func60; + fIdentFuncTable[61] := {$IFDEF FPC}@{$ENDIF} Func61; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF} Func62; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[68] := {$IFDEF FPC}@{$ENDIF} Func68; + fIdentFuncTable[71] := {$IFDEF FPC}@{$ENDIF} Func71; + fIdentFuncTable[72] := {$IFDEF FPC}@{$ENDIF} Func72; + fIdentFuncTable[75] := {$IFDEF FPC}@{$ENDIF} Func75; + fIdentFuncTable[77] := {$IFDEF FPC}@{$ENDIF} Func77; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF} Func78; + fIdentFuncTable[81] := {$IFDEF FPC}@{$ENDIF} Func81; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF} Func82; + fIdentFuncTable[83] := {$IFDEF FPC}@{$ENDIF} Func83; + fIdentFuncTable[84] := {$IFDEF FPC}@{$ENDIF} Func84; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF} Func87; + fIdentFuncTable[89] := {$IFDEF FPC}@{$ENDIF} Func89; + fIdentFuncTable[90] := {$IFDEF FPC}@{$ENDIF} Func90; + fIdentFuncTable[94] := {$IFDEF FPC}@{$ENDIF} Func94; + fIdentFuncTable[97] := {$IFDEF FPC}@{$ENDIF} Func97; + fIdentFuncTable[98] := {$IFDEF FPC}@{$ENDIF} Func98; + fIdentFuncTable[100] := {$IFDEF FPC}@{$ENDIF} Func100; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF} Func101; + fIdentFuncTable[102] := {$IFDEF FPC}@{$ENDIF} Func102; + fIdentFuncTable[105] := {$IFDEF FPC}@{$ENDIF} Func105; + fIdentFuncTable[107] := {$IFDEF FPC}@{$ENDIF} Func107; + fIdentFuncTable[109] := {$IFDEF FPC}@{$ENDIF} Func109; + fIdentFuncTable[110] := {$IFDEF FPC}@{$ENDIF} Func110; + fIdentFuncTable[111] := {$IFDEF FPC}@{$ENDIF} Func111; + fIdentFuncTable[113] := {$IFDEF FPC}@{$ENDIF} Func113; + fIdentFuncTable[117] := {$IFDEF FPC}@{$ENDIF} Func117; + fIdentFuncTable[118] := {$IFDEF FPC}@{$ENDIF} Func118; + fIdentFuncTable[120] := {$IFDEF FPC}@{$ENDIF} Func120; + fIdentFuncTable[121] := {$IFDEF FPC}@{$ENDIF} Func121; + fIdentFuncTable[125] := {$IFDEF FPC}@{$ENDIF} Func125; + fIdentFuncTable[126] := {$IFDEF FPC}@{$ENDIF} Func126; + fIdentFuncTable[127] := {$IFDEF FPC}@{$ENDIF} Func127; + fIdentFuncTable[128] := {$IFDEF FPC}@{$ENDIF} Func128; + fIdentFuncTable[130] := {$IFDEF FPC}@{$ENDIF} Func130; + fIdentFuncTable[134] := {$IFDEF FPC}@{$ENDIF} Func134; + fIdentFuncTable[139] := {$IFDEF FPC}@{$ENDIF} Func139; + fIdentFuncTable[140] := {$IFDEF FPC}@{$ENDIF} Func140; + fIdentFuncTable[146] := {$IFDEF FPC}@{$ENDIF} Func146; + fIdentFuncTable[147] := {$IFDEF FPC}@{$ENDIF} Func147; + fIdentFuncTable[150] := {$IFDEF FPC}@{$ENDIF} Func150; + fIdentFuncTable[156] := {$IFDEF FPC}@{$ENDIF} Func156; + fIdentFuncTable[158] := {$IFDEF FPC}@{$ENDIF} Func158; + fIdentFuncTable[164] := {$IFDEF FPC}@{$ENDIF} Func164; + fIdentFuncTable[171] := {$IFDEF FPC}@{$ENDIF} Func171; + fIdentFuncTable[196] := {$IFDEF FPC}@{$ENDIF} Func196; + fIdentFuncTable[199] := {$IFDEF FPC}@{$ENDIF} Func199; +end; + +function TSynRCSyn.KeyComp(const aKey: string): boolean; +var + i: integer; + tmp: pchar; +begin + tmp:= fToIdent; + if length(aKey) = fStringLen then + begin + result:= TRUE; + for i:= 1 to fStringLen do + begin + if tmp^ <> akey[i] then + begin + result:= FALSE; + break; + end; + inc(tmp); + end; + end + else + result:= FALSE; +end; + +function TSynRCSyn.KeyHash(ToHash: PChar): integer; +begin + result:= 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen:= ToHash -fToIdent; +end; + +function TSynRCSyn.AltFunc: TtkTokenKind; +begin + result:= tkIdentifier; +end; + +function TSynRCSyn.IdentKind(Maybe: PChar): TtkTokenKind; +var + HashKey: integer; +begin + fToIdent:= Maybe; + HashKey:= KeyHash(maybe); + if HashKey <= MAXNumFunc then + result:= fIdentFuncTable[HashKey] {$ifdef FPC} () {$endif} + else + result:= tkIdentifier; +end; + +constructor TSynRCSyn.Create(aOwner: TComponent); +begin + inherited; + fCommentAttri:= TSynHighlighterAttributes.Create(SYNS_AttrComment); + AddAttribute(fCommentAttri); + + fDirecAttri:= TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor); + AddAttribute(fDirecAttri); + + fIdentifierAttri:= TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fKeyAttri:= TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + + fNumberAttri:= TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + + fSpaceAttri:= TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fStringAttri:= TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + + fSymbolAttri:= TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange({$ifdef FPC} @ {$endif}DefHighlightChange); + InitIdent; + MakeMethodTables; + fRange:= rsUnknown; + fDefaultFilter:= SYNS_FilterRC; +end; + +destructor TSynRCSyn.Destroy; +begin + inherited; +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynRCSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynRCSyn.SetLine(const NewValue: string; LineNumber: integer); +begin + fLine:= PChar(NewValue); + Run:= 0; + fLineNumber:= LineNumber; + Next; +end; + +// ** insert symbol procs/num funcs + +function TSynRCSyn.Func33: TtkTokenKind; +begin + if KeyComp('ALT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func39: TtkTokenKind; +begin + if KeyComp('CHECKED') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func41: TtkTokenKind; +begin + if KeyComp('ICON') then result:= tkKey + else + if KeyComp('ASCII') then result:= tkKey + else + if KeyComp('HELP') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func43: TtkTokenKind; +begin + if KeyComp('BLOCK') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func47: TtkTokenKind; +begin + if KeyComp('RCDATA') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func48: TtkTokenKind; +begin + if KeyComp('DIALOG') then result:= tkKey + else + if KeyComp('FIXED') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func53: TtkTokenKind; +begin + if KeyComp('MENU') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func54: TtkTokenKind; +begin + if KeyComp('CLASS') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func55: TtkTokenKind; +begin + if KeyComp('FONT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func60: TtkTokenKind; +begin + if KeyComp('PURE') then result:= tkKey + else + if KeyComp('GRAYED') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func61: TtkTokenKind; +begin + if KeyComp('BITMAP') then result:= tkKey + else + if KeyComp('VALUE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func62: TtkTokenKind; +begin + if KeyComp('SHIFT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func66: TtkTokenKind; +begin + if KeyComp('FILEOS') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func68: TtkTokenKind; +begin + if KeyComp('LANGUAGE') then result:= tkKey + else + if KeyComp('STATE3') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func71: TtkTokenKind; +begin + if KeyComp('CHECKBOX') then result:= tkKey + else + if KeyComp('PRELOAD') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func72: TtkTokenKind; +begin + if KeyComp('CTEXT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func75: TtkTokenKind; +begin + if KeyComp('MOVEABLE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func77: TtkTokenKind; +begin + if KeyComp('DIALOGEX') then result:= tkKey + else + if KeyComp('FILEFLAGS') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func78: TtkTokenKind; +begin + if KeyComp('CAPTION') then result:= tkKey + else + if KeyComp('DISCARDABLE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func81: TtkTokenKind; +begin + if KeyComp('LTEXT') then result:= tkKey + else + if KeyComp('STYLE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func82: TtkTokenKind; +begin + if KeyComp('MENUEX') then result:= tkKey + else + if KeyComp('IMPURE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func83: TtkTokenKind; +begin + if KeyComp('INACTIVE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func84: TtkTokenKind; +begin + if KeyComp('POPUP') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func87: TtkTokenKind; +begin + if KeyComp('RTEXT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func89: TtkTokenKind; +begin + if KeyComp('COMBOBOX') then result:= tkKey + else + if KeyComp('LOADONCALL') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func90: TtkTokenKind; +begin + if KeyComp('MENUBREAK') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func94: TtkTokenKind; +begin + if KeyComp('CURSOR') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func97: TtkTokenKind; +begin + if KeyComp('CONTROL') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func98: TtkTokenKind; +begin + if KeyComp('FILETYPE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func100: TtkTokenKind; +begin + if KeyComp('MENUITEM') then result:= tkKey + else + if KeyComp('SCROLLBAR') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func101: TtkTokenKind; +begin + if KeyComp('LISTBOX') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func102: TtkTokenKind; +begin + if KeyComp('VERSION') then result:= tkKey + else + if KeyComp('COMMENTS') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func105: TtkTokenKind; +begin + if KeyComp('PUSHBOX') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func107: TtkTokenKind; +begin + if KeyComp('EDITTEXT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func109: TtkTokenKind; +begin + if KeyComp('MESSAGETABLE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func110: TtkTokenKind; +begin + if KeyComp('EXSTYLE') then result:= tkKey + else + if KeyComp('VIRTKEY') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func111: TtkTokenKind; +begin + if KeyComp('MENUBARBREAK') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func113: TtkTokenKind; +begin + if KeyComp('SEPARATOR') then result:= tkKey + else + if KeyComp('SPECIALBUILD') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func117: TtkTokenKind; +begin + if KeyComp('NOINVERT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func118: TtkTokenKind; +begin + if KeyComp('GROUPBOX') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func120: TtkTokenKind; +begin + if KeyComp('ACCELERATORS') then result:= tkKey + else + if KeyComp('COMPANYNAME') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func121: TtkTokenKind; +begin + if KeyComp('FILEFLAGSMASK') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func125: TtkTokenKind; +begin + if KeyComp('AUTO3STATE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func126: TtkTokenKind; +begin + if KeyComp('INTERNALNAME') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func127: TtkTokenKind; +begin + if KeyComp('STRINGTABLE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func128: TtkTokenKind; +begin + if KeyComp('AUTOCHECKBOX') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func130: TtkTokenKind; +begin + if KeyComp('PRODUCTNAME') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func134: TtkTokenKind; +begin + if KeyComp('FILEVERSION') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func139: TtkTokenKind; +begin + if KeyComp('RADIOBUTTON') then result:= tkKey + else + if KeyComp('PRIVATEBUILD') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func140: TtkTokenKind; +begin + if KeyComp('FILESUBTYPE') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func146: TtkTokenKind; +begin + if KeyComp('VERSIONINFO') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func147: TtkTokenKind; +begin + if KeyComp('LEGALTRADEMARKS') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func150: TtkTokenKind; +begin + if KeyComp('ORIGINALFILENAME') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func156: TtkTokenKind; +begin + if KeyComp('CHARACTERISTICS') then result:= tkKey + else + if KeyComp('PUSHBUTTON') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func158: TtkTokenKind; +begin + if KeyComp('LEGALCOPYRIGHT') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func164: TtkTokenKind; +begin + if KeyComp('FILEDESCRIPTION') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func171: TtkTokenKind; +begin + if KeyComp('DEFPUSHBUTTON') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func196: TtkTokenKind; +begin + if KeyComp('AUTORADIOBUTTON') then result:= tkKey + else + result:= tkIdentifier; +end; + +function TSynRCSyn.Func199: TtkTokenKind; +begin + if KeyComp('PRODUCTVERSION') then result:= tkKey + else + result:= tkIdentifier; +end; + +procedure TSynRCSyn.MakeMethodTables; +var + i: char; +begin + for i:= #0 to #255 do + case i of + #0: fProcTable[i]:= {$ifdef FPC} @ {$endif}NullProc; + #13: fProcTable[i]:= {$ifdef FPC} @ {$endif}CRProc; + #10: fProcTable[i]:= {$ifdef FPC} @ {$endif}LFProc; + '/': fProcTable[i]:= {$ifdef FPC} @ {$endif}SlashProc; + '"': fProcTable[i]:= {$ifdef FPC} @ {$endif}QuoteProc; + '#': fProcTable[i]:= {$ifdef FPC} @ {$endif}DirectiveProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[i]:= {$ifdef FPC} @ {$endif}IdentProc; + '0'..'9': fProcTable[i]:= {$ifdef FPC} @ {$endif}NumberProc; + #1..#9, #11, #12, #14..#32: fPRocTable[i]:= {$ifdef FPC} @ {$endif}SpaceProc; + '|', ',', '{', '}': fProcTable[i]:= {$ifdef FPC} @ {$endif}SymbolProc; + else + fProcTable[i]:= {$ifdef FPC} @ {$endif}UnknownProc; + end; +end; + +procedure TSynRCSyn.QuoteProc; +begin + fTokenId:= tkString; + repeat + inc(Run); + until (fLine[Run] in [#0, #10, #13, #34]); + if fLine[Run] = #34 then + inc(Run); +end; + +procedure TSynRCSyn.SlashProc; +begin + case fLine[Run +1] of + #13: CRPRoc; + #10: LFProc; + '/': + begin + fTokenId:= tkComment; + inc(Run, 2); + while not (fLine[Run] in [#0, #13, #10]) do inc(Run); + end; + '*': + begin + fTokenID:= tkComment; + fRange:= rsComment; + inc(Run, 2); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run +1] = '/' then + begin + inc(Run, 2); + fRange:= rsUnknown; + break; + end + else inc(Run); + #10, #13: break; + else + inc(Run); + end; + end; + else + fTokenId:= tkSymbol; + inc(Run); + end +end; + +procedure TSynRCSyn.CommentProc; +begin + fTokenId:= tkComment; + case fLine[Run] of + #0: NullProc; + #13: CRProc; + #10: LFProc; + else + fTokenId:= tkComment; + repeat + if (fLine[Run] = '*') and (fLine[Run +1] = '/') then + begin + inc(Run, 2); + fRange:= rsUnknown; + break; + end + else + inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynRCSyn.DirectiveProc; +begin + fTokenId:= tkDirective; + repeat + if (fLine[Run] = '/') then + begin + if fLine[Run +1] = '/' then + begin + fRange:= rsUnknown; + exit; + end + else + if fLine[Run +1] = '*' then + begin + fRange:= rsComment; + exit; + end + end; + inc(Run); + until (fLine[Run] in [#0, #13, #10]); +end; + +procedure TSynRCSyn.IdentProc; +begin + fTokenId:= IdentKind((fLine +Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynRCSyn.CRProc; +begin + fTokenID:= tkSpace; + inc(Run); + if fLine[Run] = #10 then + inc(Run); +end; + +procedure TSynRCSyn.LFProc; +begin + inc(Run); + fTokenID:= tkSpace; +end; + +procedure TSynRCSyn.SpaceProc; +begin + inc(Run); + fTokenId:= tkSpace; + while fLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynRCSyn.NullProc; +begin + fTokenId:= tkNull; +end; + +procedure TSynRCSyn.NumberProc; +begin + inc(Run); + fTokenID:= tkNumber; + while (fLine[Run] in ['0'..'9', '.', 'u', 'U', 'e', 'E', 'x', 'X']) or + (fLine[Run] in ['A'..'F', 'a'..'f','L', 'l', '-', '+']) do + begin + case fLine[Run] of + '.': if fLine[Run +1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynRCSyn.SymbolProc; +begin + inc(Run); + fTokenID:= tkSymbol; +end; + +procedure TSynRCSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynRCSyn.Next; +begin + fTokenPos:= Run; + case fRange of + rsDirective: DirectiveProc; + rsComment: CommentProc; + else + fProcTable[fLine[Run]]; + end; +end; + +function TSynRCSyn.GetDefaultAttribute( + index: integer): TSynHighlighterAttributes; +begin + case index of + SYN_ATTR_COMMENT: result:= fCommentAttri; + SYN_ATTR_IDENTIFIER: result:= fIdentifierAttri; + SYN_ATTR_KEYWORD: result:= fKeyAttri; + SYN_ATTR_STRING: result:= fStringAttri; + SYN_ATTR_WHITESPACE: result:= fSpaceAttri; + SYN_ATTR_SYMBOL: result:= fSymbolAttri; + else + result:= nil; + end; +end; + +function TSynRCSyn.GetEOL: boolean; +begin + result:= fTokenID = tkNull; +end; + +function TSynRCSyn.GetRange: pointer; +begin + result:= pointer(fRange); +end; + +function TSynRCSyn.GetToken: string; +var + len: longint; +begin + len:= Run - fTokenPos; + SetString(result, (fLine +fTokenPos), len); +end; + +function TSynRCSyn.GetTokenID: TtkTokenKind; +begin + result:= fTokenID; +end; + +function TSynRCSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: result:= fCommentAttri; + tkDirective: result:= fDirecAttri; + tkIdentifier: result:= fIdentifierAttri; + tkKey: result:= fKeyAttri; + tkNumber: result:= fNumberAttri; + tkSpace: result:= fSpaceAttri; + tkString: result:= fStringAttri; + tkSymbol: result:= fSymbolAttri; + tkUnknown: result:= fSymbolAttri; + else + result:= nil; + end; +end; + +function TSynRCSyn.GetTokenKind: integer; +begin + result:= ord(GetTokenID); +end; + +function TSynRCSyn.GetTokenPos: integer; +begin + result:= fTokenPos; +end; + +procedure TSynRCSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +procedure TSynRCSyn.SetRange(value: pointer); +begin + fRange:= TRangeState(value); +end; + +procedure TSynRCSyn.EnumUserSettings(Settings: TStrings); +begin + // ** ?? +end; + +function TSynRCSyn.UseUserSettings(SettingIndex: integer): boolean; +begin + result:= FALSE; +end; + +function TSynRCSyn.GetIdentChars: TSynIdentChars; +begin + result:= TSynValidStringChars; // ** check +end; + +class function TSynRCSyn.GetCapabilities: TSynHighlighterCapabilities; +begin + result:= inherited GetCapabilities; +end; + +function TSynRCSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterRC; +end; + +class function TSynRCSyn.GetLanguageName: string; +begin + result:= SYNS_LangRC; +end; + +function TSynRCSyn.GetSampleSource: string; +begin + result:= '// Overlay icon for Hardlinks'+LineEnding+ + 'HARDLINK ICON DISCARDABLE IMPURE "..\..\graphics\hardlink.ico"'+LineEnding+LineEnding+ + '// Overlay icon for Junctions'+LineEnding+ + 'JUNCTION ICON DISCARDABLE IMPURE "..\..\graphics\junction.ico"'+LineEnding+LineEnding+ + '// Icons used for various of menu items of NTFS Link'+LineEnding+ + 'MENU_GLYPH_STD BITMAP DISCARDABLE IMPURE "..\..\graphics\menu_glyph_ntfslinkext.bmp"'+LineEnding+ + 'MENU_GLYPH_JUNCTION BITMAP DISCARDABLE IMPURE "..\..\graphics\menu_glyph_junction.bmp"'+LineEnding+ + 'MENU_GLYPH_HARDLINK BITMAP DISCARDABLE IMPURE "..\..\graphics\menu_glyph_hardlink.bmp"'+LineEnding+ + 'MENU_GLYPH_LINKDEL BITMAP DISCARDABLE IMPURE "..\..\graphics\menu_glyph_linkdel.bmp"'+LineEnding+ + 'MENU_GLYPH_EXPLORER BITMAP DISCARDABLE IMPURE "..\..\graphics\menu_glyph_explorer.bmp"'+LineEnding+LineEnding+LineEnding+ + '#define IDC_TFLINKSEXISTINGDIALOG 1000'+LineEnding+ + '#define IDC_CAPTION 100'+LineEnding+ + '#define IDC_MLINKS 102'+LineEnding+ + '#define IDC_BNO 103'+LineEnding+ + '#define IDC_BYES 104'+LineEnding+ + '#define IDC_ICON 105'+LineEnding+ + '#define IDC_BYESDELETE 106'+LineEnding+LineEnding+ + 'IDC_TFLINKSEXISTINGDIALOG DIALOGEX 120 82 266 144'+LineEnding+ + 'EXSTYLE 0x00 | WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE'+LineEnding+ + 'STYLE 0x00 | WS_POPUP | WS_CAPTION | WS_DLGFRAME | DS_MODALFRAME | DS_CENTER | WS_VISIBLE | DS_3DLOOK | DS_FIXEDSYS | WS_SYSMENU'+LineEnding+ + 'CAPTION "NTFS Link"'+LineEnding+ + 'FONT 8, "MS Shell Dlg 2", 400, 0'+LineEnding+ + '{'+LineEnding+ + ' CONTROL "There are junctions pointing to this folder or a subfolder (see list below). If you continue the operation, these links will no longer work. Are you sure?", IDC_CAPTION, "static", WS_CHILD | SS_NOTIFY | SS_LEFT | WS_VISIBLE, 40, 6, 214, 25, 0x00'+LineEnding+ + ' CONTROL "", IDC_MLINKS, "edit", WS_CHILD | ES_MULTILINE | WS_VISIBLE | ES_READONLY, 40, 40, 214, 79, 0x00 | WS_EX_CLIENTEDGE'+LineEnding+ + ' CONTROL "", IDC_BYESDELETE, "button", WS_CHILD | WS_GROUP | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP, 67, 124, 79, 15, 0x00'+LineEnding+ + ' CONTROL "Yes", IDC_BYES, "button", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE | WS_TABSTOP, 150, 124, 50, 15, 0x00'+LineEnding+ + ' CONTROL "No", IDC_BNO, "button", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE | WS_TABSTOP, 204, 124, 50, 15, 0x00'+LineEnding+ + ' CONTROL "", IDC_ICON, "static", SS_ICON | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 10, 32, 32'+LineEnding+ + '}'+LineEnding+LineEnding+ + '// ActivationContext.pas expects this at resource ID 2.'+LineEnding+ + '2 24 "NTFSLink.manifest"'+LineEnding+LineEnding+LineEnding+ + '1 VERSIONINFO'+LineEnding+ + ' FILEVERSION 8,3,0,0'+LineEnding+ + ' FILEOS VOS__WINDOWS32'+LineEnding+ + ' FILETYPE VFT_APP'+LineEnding+ + ' BEGIN'+LineEnding+ + ' BLOCK "StringFileInfo"'+LineEnding+ + ' BEGIN'+LineEnding+ + ' BLOCK "040904E4"'+LineEnding+ + ' BEGIN'+LineEnding+ + ' VALUE "FileDescription", "%APPNAME% %APPVER%\000"'+LineEnding+ + ' VALUE "ProductName", "%APPNAME%\000"'+LineEnding+ + ' VALUE "LegalCopyright", "See GPL license\000"'+LineEnding+ + ' END'+LineEnding+ + ' END'+LineEnding+ + ' BLOCK "VarFileInfo"'+LineEnding+ + ' BEGIN'+LineEnding+ + ' VALUE "Translation", 0x0409 0x04E4'+LineEnding+ + ' END'+LineEnding+ + ' END'+LineEnding + ; + +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynRCSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterruby.pas b/components/extrasyn/SyneditHighlighters/synhighlighterruby.pas new file mode 100644 index 000000000..e8742cef7 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterruby.pas @@ -0,0 +1,794 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterRuby.pas, released 2001-11-13. +The Initial Author of this file is Stefan Ascher. +All Rights Reserved. +Portions by Jan Verhoeven (http://jansfreeware.com/jfdelphi.htm) +"Heredoc" syntax highlighting implementation by Marko Njezic. + +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 cas, 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: SynHighlighterRuby.pas,v 1.11 2005/01/28 16:53:25 maelh Exp $ + +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 Ruby highlighter for SynEdit) +@author(Stefan Ascher ) +@created(21 May 2001) +@lastmod(2001-11-13) +The SynHighlighterVisualLisp unit provides SynEdit with a Ruby highlighter. +} + +{$IFNDEF QSYNHIGHLIGHTERRUBY} +unit SynHighlighterRuby; +{$ENDIF} + + //SynEdit.inc is the synedit.inc from laz 1.2.0 synedit package source if it has changed + //in newer version you might need to copy it again. REmeber to redclare the syn_lazarus define. +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSecondKey, + tkSpace, tkString, tkSymbol, tkUnknown); + +{$IFDEF SYN_HEREDOC} + TRangeState = (rsUnknown, rsHeredoc, rsIndentedHeredoc); + + TRangePointer = packed record + case Boolean of + True : (Ptr: Pointer); + False : (Range: Byte; Length: Byte; Checksum: Word); + end; +{$ELSE} + TRangeState = (rsUnknown); +{$ENDIF} + + TProcTableProc = procedure of object; + +type + TSynRubySyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; +{$IFDEF SYN_HEREDOC} + fHeredocLength : Byte; + fHeredocChecksum : Word; +{$ENDIF} + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fLineNumber: Integer; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fSecondKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyWords: TStrings; + fSecondKeys: TStrings; + + procedure BraceOpenProc; + procedure PointCommaProc; + procedure CRProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure NullProc; + procedure NumberProc; + procedure RoundOpenProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + procedure MakeMethodTables; +{$IFDEF SYN_HEREDOC} + procedure HeredocProc; +{$ENDIF} + procedure SetSecondKeys(const Value: TStrings); + protected + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + function IsKeyword(const AKeyword: string): boolean; override; + function IsSecondKeyWord(aToken: string): Boolean; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + +// procedure SetLine(NewValue: string; LineNumber:Integer); override; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: string; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property SecondKeyAttri: TSynHighlighterAttributes read fSecondKeyAttri + write fSecondKeyAttri; + property SecondKeyWords: TStrings read fSecondKeys write SetSecondKeys; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditMiscProcs, + QSynEditStrConst; +{$ELSE} + SynEditMiscProcs, + SynEditStrConst, SynEditStrConstExtra; +{$ENDIF} + +const + RubyKeysCount = 43; + RubyKeys: array[1..RubyKeysCount] of string = ( + 'ALIAS', 'ATTR', 'BEGIN', 'BREAK', 'CASE', 'CLASS', 'DEF', 'DO', 'ELSE', + 'ELSIF', 'END', 'ENSURE', 'EXIT', 'EXTEND', 'FALSE', 'FOR', 'GETS', 'IF', + 'IN', 'INCLUDE', 'LOAD', 'LOOP', 'MODULE', 'NEXT', 'NIL', 'NOT', 'PRINT', + 'PRIVATE', 'PUBLIC', 'PUTS', 'RAISE', 'REDO', 'REQUIRE', 'RESCUE', 'RETRY', + 'RETURN', 'SELF', 'THEN', 'TRUE', 'UNLESS', 'WHEN', 'WHILE', 'YIELD'); + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': + Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'a'..'z', 'A'..'Z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +function TSynRubySyn.IsKeyword(const AKeyword: string): boolean; +var + First, Last, I, Compare: Integer; + Token: String; +begin + First := 0; + Last := fKeywords.Count - 1; + Result := False; + Token := UpperCase(AKeyword); + + while First <= Last do begin + I := (First + Last) shr 1; + Compare := CompareStr(fKeywords[I], Token); + if Compare = 0 then begin + Result := True; + break; + end else + if Compare < 0 then First := I + 1 else Last := I - 1; + end; +end; { IsKeyWord } + +function TSynRubySyn.IsSecondKeyWord(aToken: String): Boolean; +var + First, Last, I, Compare: Integer; + Token: String; +begin + First := 0; + Last := fSecondKeys.Count - 1; + Result := False; + Token := UpperCase(aToken); + while First <= Last do + begin + I := (First + Last) shr 1; + Compare := CompareStr(fSecondKeys[i], Token); + if Compare = 0 then + begin + Result := True; + break; + end + else + if Compare < 0 then First := I + 1 else Last := I - 1; + end; +end; { IsSecondKeyWord } + +procedure TSynRubySyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '<': fProcTable[I] := {$ifdef FPC} @ {$endif} LowerProc; + '#': fProcTable[I] := {$ifdef FPC} @ {$endif}SlashProc; + '{': fProcTable[I] := {$ifdef FPC} @ {$endif}BraceOpenProc; + ';': fProcTable[I] := {$ifdef FPC} @ {$endif}PointCommaProc; + #13: fProcTable[I] := {$ifdef FPC} @ {$endif}CRProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$ifdef FPC} @ {$endif}IdentProc; + #10: fProcTable[I] := {$ifdef FPC} @ {$endif}LFProc; + #0: fProcTable[I] := {$ifdef FPC} @ {$endif}NullProc; + '0'..'9': fProcTable[I] := {$ifdef FPC} @ {$endif}NumberProc; + '(': fProcTable[I] := {$ifdef FPC} @ {$endif}RoundOpenProc; + '/': fProcTable[I] := {$ifdef FPC} @ {$endif}SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$ifdef FPC} @ {$endif}SpaceProc; + #34, #39: fProcTable[I] := {$ifdef FPC} @ {$endif}StringProc; + else fProcTable[I] := {$ifdef FPC} @ {$endif}UnknownProc; + end; +end; + +constructor TSynRubySyn.Create(AOwner: TComponent); +var + i: integer; +begin + inherited Create(AOwner); + fKeyWords := TStringList.Create; + TStringList(fKeyWords).Sorted := True; + TStringList(fKeyWords).Duplicates := dupIgnore; + fSecondKeys := TStringList.Create; + TStringList(fSecondKeys).Sorted := True; + TStringList(fSecondKeys).Duplicates := dupIgnore; + if not (csDesigning in ComponentState) then + for i := 1 to RubyKeysCount do + fKeyWords.Add(RubyKeys[i]); + + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Foreground := clMaroon; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Foreground := clBlue; + AddAttribute(fKeyAttri); + fSecondKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrSecondReservedWord); + AddAttribute(fSecondKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clGreen; + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clPurple; + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + fSymbolAttri.Foreground := clBlue; + AddAttribute(fSymbolAttri); + SetAttributesOnChange({$ifdef FPC} @ {$endif}DefHighlightChange); + + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterRuby; +end; { Create } + +destructor TSynRubySyn.Destroy; +begin + fKeyWords.Free; + fSecondKeys.Free; + inherited Destroy; +end; { Destroy } + +{$IFDEF SYN_LAZARUS} +procedure TSynRubySyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynRubySyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynRubySyn.BraceOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynRubySyn.PointCommaProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynRubySyn.CRProc; +begin + fTokenID := tkSpace; + case FLine[Run + 1] of + #10: inc(Run, 2); + else inc(Run); + end; +end; + +procedure TSynRubySyn.IdentProc; +begin + while Identifiers[fLine[Run]] do inc(Run); + if IsKeyWord(GetToken) then begin + fTokenId := tkKey; + Exit; + end + else fTokenId := tkIdentifier; + if IsSecondKeyWord(GetToken) + then fTokenId := tkSecondKey + else fTokenId := tkIdentifier; +end; + +procedure TSynRubySyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynRubySyn.LowerProc; +{$IFDEF SYN_HEREDOC} +const + AlphaNumericChars = ['A'..'Z', 'a'..'z', '0'..'9', '_']; +var + i, Len, SkipRun : Integer; + IndentedHeredoc : Boolean; + QuoteChar : Char; +{$ENDIF} +begin +{$IFDEF SYN_HEREDOC} + if FLine[Run + 1] = '<' then + begin + fTokenID := tkSymbol; + + SkipRun := 0; + QuoteChar := #0; + if (FLine[Run + 2] = '-') and (FLine[Run + 3] in ['"', '''', '`']) then + begin + SkipRun := 2; + QuoteChar := FLine[Run + 3]; + end + else + if (FLine[Run + 2] in ['-', '"', '''', '`']) then + begin + SkipRun := 1; + if FLine[Run + 2] <> '-' then + QuoteChar := FLine[Run + 2]; + end; + IndentedHeredoc := (SkipRun > 0) and (FLine[Run + 2] = '-'); + + if (FLine[Run + SkipRun + 2] in AlphaNumericChars) then + begin + inc(Run, 2); + + i := Run; + while FLine[SkipRun + i] in AlphaNumericChars do Inc(i); + Len := i - Run; + + if Len > 255 then + begin + fTokenID := tkUnknown; + Exit; + end; + + if (QuoteChar <> #0) and (FLine[Run + SkipRun + Len] <> QuoteChar) then + begin + fTokenID := tkUnknown; + Exit; + end; + + if IndentedHeredoc then + fRange := rsIndentedHeredoc + else + fRange := rsHeredoc; + fHeredocLength := Len; + fHeredocChecksum := CalcFCS(FLine[Run + SkipRun], Len); + + Inc(Run, SkipRun + Len); + fTokenID := tkString; + end + else + inc(Run, 2); + end + else +{$ENDIF} + begin + inc(Run); + fTokenID := tkSymbol; + end; +end; + +procedure TSynRubySyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynRubySyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynRubySyn.RoundOpenProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynRubySyn.SlashProc; +begin + case FLine[Run] of + '/': + begin + inc(Run); + fTokenId := tkSymbol; + end; + '*': + begin + inc(Run); + fTokenId := tkSymbol; + end; + else + begin + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; + end; + end; +end; + +procedure TSynRubySyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynRubySyn.StringProc; +var + QuoteChar: Char; +begin +// Ha, ha, Strings in Ruby (could be anything)!!!! + +//There are three more ways to construct string literals: %q, %Q, and ``here +//documents.'' +// +//%q and %Q start delimited single- and double-quoted strings. +// +//%q/general single-quoted string/ » general single-quoted string +//%Q!general double-quoted string! » general double-quoted string +//%Q{Seconds/day: #{24*60*60}} » Seconds/day: 86400 +// +//The character following the ``q'' or ``Q'' is the delimiter. If it is an +//opening bracket, brace, parenthesis, or less-than sign, the string is read +//until the matching close symbol is found. Otherwise the string is read until +//the next occurrence of the same delimiter. + + fTokenID := tkString; + QuoteChar := FLine[Run]; // either " or ' + if (FLine[Run + 1] = QuoteChar) and (FLine[Run + 2] = QuoteChar) + then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = QuoteChar; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynRubySyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +{$IFDEF SYN_HEREDOC} +procedure TSynRubySyn.HeredocProc; + + procedure SkipToEOL; + begin + case FLine[Run] of + #0 : NullProc; + #10 : LFProc; + #13 : CRProc; + else + repeat + inc(Run); + until FLine[Run] in [#0, #10, #13]; + end; + end; + +var + i : Integer; +begin + if (FLine[Run] in [#0, #10, #13]) and (fTokenPos = Run) then + begin + fProcTable[ FLine[Run] ]; + Exit; + end; + fTokenID := tkString; + + if fRange = rsIndentedHeredoc then + while FLine[Run] in [#9, #32] do Inc(Run); + + if ((Run = 0) and (fRange = rsHeredoc)) or (fRange = rsIndentedHeredoc) then + begin + i := 0; + + while not (FLine[Run + i] in [#0, #10, #13]) do + begin + if i > fHeredocLength then + begin + SkipToEOL; + Exit; + end; + Inc(i); + end; + + if i <> fHeredocLength then + begin + SkipToEOL; + Exit; + end; + + if (CalcFCS(FLine[Run], i) = fHeredocChecksum) then + begin + fRange := rsUnknown; + Run := Run + i; + Exit; + end; + end; + + SkipToEOL; +end; +{$ENDIF} + +procedure TSynRubySyn.Next; +begin + fTokenPos := Run; +{$IFDEF SYN_HEREDOC} + if fRange in [rsHeredoc, rsIndentedHeredoc] then + HeredocProc + else +{$ENDIF} + fProcTable[fLine[Run]]; +end; + +function TSynRubySyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + else + Result := nil; + end; +end; + +function TSynRubySyn.GetEol: Boolean; +begin + Result := False; + if fTokenId = tkNull then Result := True; +end; + +function TSynRubySyn.GetRange: Pointer; +{$IFDEF SYN_HEREDOC} +var + RangePointer : TRangePointer; +{$ENDIF} +begin +{$IFDEF SYN_HEREDOC} + RangePointer.Range := Ord(fRange); + RangePointer.Length := 0; + RangePointer.Checksum := 0; + if fRange in [rsHeredoc, rsIndentedHeredoc] then + begin + RangePointer.Length := fHeredocLength; + RangePointer.Checksum := fHeredocChecksum; + end; + Result := RangePointer.Ptr; +{$ELSE} + Result := Pointer(fRange); +{$ENDIF} +end; + +function TSynRubySyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynRubySyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynRubySyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkSecondKey: Result := fSecondKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynRubySyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynRubySyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynRubySyn.ResetRange; +begin + fRange := rsUnknown; +{$IFDEF SYN_HEREDOC} + fHeredocLength := 0; + fHeredocChecksum := 0; +{$ENDIF} +end; + +procedure TSynRubySyn.SetRange(Value: Pointer); +{$IFDEF SYN_HEREDOC} +var + RangePointer : TRangePointer; +{$ENDIF} +begin +{$IFDEF SYN_HEREDOC} + RangePointer := TRangePointer(Value); + fRange := TRangeState(RangePointer.Range); + fHeredocLength := 0; + fHeredocChecksum := 0; + if fRange in [rsHeredoc, rsIndentedHeredoc] then + begin + fHeredocLength := RangePointer.Length; + fHeredocChecksum := RangePointer.Checksum; + end; +{$ELSE} + fRange := TRangeState(Value); +{$ENDIF} +end; + +procedure TSynRubySyn.SetSecondKeys(const Value: TStrings); +var + i: Integer; +begin + if Value <> nil then + begin + Value.BeginUpdate; + for i := 0 to Value.Count - 1 do + Value[i] := UpperCase(Value[i]); + Value.EndUpdate; + end; + fSecondKeys.Assign(Value); + DefHighLightChange(nil); +end; + +function TSynRubySyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterRuby; +end; + +class function TSynRubySyn.GetLanguageName: string; +begin + Result := SYNS_LangRuby; +end; + +function TSynRubySyn.GetSampleSource: string; +begin + Result := + '# Factorial'+#13#10+ + 'def fact(n)'+#13#10+ + ' if n == 0'+#13#10+ + ' 1'+#13#10+ + ' else'+#13#10+ + ' n * fact(n-1)'+#13#10+ + ' end'+#13#10+ + 'end'+#13#10+ + 'print fact(ARGV[0].to_i), "\n"'; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynRubySyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightersdd.pas b/components/extrasyn/SyneditHighlighters/synhighlightersdd.pas new file mode 100644 index 000000000..458781560 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightersdd.pas @@ -0,0 +1,726 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterSDD.pas, released 2001-08-20. +The Initial Author of this file is Pieter Polak. +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: SynHighlighterSDD.pas,v 1.14 2005/01/28 16:53:25 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} + +{$IFNDEF QSYNHIGHLIGHTERSDD} +unit SynHighlighterSDD; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = ( + tkComment, + tkIdentifier, + tkKey, + tkDatatype, + tkNumber, + tkNull, + tkSpace, + tkSymbol, + tkUnknown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TRangeState = (rsComment, rsUnKnown); + +type + TSynSDDSyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + fRange: TRangeState; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + fTokenID: TtkTokenKind; + fIdentFuncTable: array[0..141] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fDatatypeAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func21: TtkTokenKind; + function Func23: TtkTokenKind; + function Func30: TtkTokenKind; + function Func36: TtkTokenKind; + function Func41: TtkTokenKind; + function Func43: TtkTokenKind; + function Func47: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func55: TtkTokenKind; + function Func60: TtkTokenKind; + function Func63: TtkTokenKind; + function Func66: TtkTokenKind; + function Func74: TtkTokenKind; + function Func75: TtkTokenKind; + function Func78: TtkTokenKind; + function Func87: TtkTokenKind; + function Func91: TtkTokenKind; + function Func95: TtkTokenKind; + function Func100: TtkTokenKind; + function Func104: TtkTokenKind; + function Func115: TtkTokenKind; + function Func122: TtkTokenKind; + function Func141: TtkTokenKind; + procedure BraceOpenProc; + procedure BraceCommentProc; + procedure NumberProc; + procedure CRProc; + procedure LFProc; + procedure IdentProc; + procedure NullProc; + procedure SpaceProc; + procedure UnknownProc; + procedure SymbolProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + function GetRange: Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property DatatypeAttri: TSynHighlighterAttributes read fDatatypeAttri write fDatatypeAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst; +{$ENDIF} + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable : array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I in ['_', 'A'..'Z', 'a'..'z'] of + True: mHashTable[I] := Ord(J) - 64 + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynSDDSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := {$ifdef FPC} @ {$endif} AltFunc; + Inc(pF); + end; + fIdentFuncTable[21] := {$IFDEF FPC}@{$ENDIF} Func21; + fIdentFuncTable[23] := {$IFDEF FPC}@{$ENDIF} Func23; + fIdentFuncTable[30] := {$IFDEF FPC}@{$ENDIF} Func30; + fIdentFuncTable[36] := {$IFDEF FPC}@{$ENDIF} Func36; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF} Func47; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF} Func52; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF} Func53; + fIdentFuncTable[55] := {$IFDEF FPC}@{$ENDIF} Func55; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF} Func60; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF} Func63; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[74] := {$IFDEF FPC}@{$ENDIF} Func74; + fIdentFuncTable[75] := {$IFDEF FPC}@{$ENDIF} Func75; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF} Func78; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF} Func87; + fIdentFuncTable[91] := {$IFDEF FPC}@{$ENDIF} Func91; + fIdentFuncTable[95] := {$IFDEF FPC}@{$ENDIF} Func95; + fIdentFuncTable[100] := {$IFDEF FPC}@{$ENDIF} Func100; + fIdentFuncTable[104] := {$IFDEF FPC}@{$ENDIF} Func104; + fIdentFuncTable[115] := {$IFDEF FPC}@{$ENDIF} Func115; + fIdentFuncTable[122] := {$IFDEF FPC}@{$ENDIF} Func122; + fIdentFuncTable[141] := {$IFDEF FPC}@{$ENDIF} Func141; +end; + +function TSynSDDSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynSDDSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynSDDSyn.Func21: TtkTokenKind; +begin + if KeyComp('of') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func23: TtkTokenKind; +begin + if KeyComp('end') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func30: TtkTokenKind; +begin + if KeyComp('date') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func36: TtkTokenKind; +begin + if KeyComp('real') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func41: TtkTokenKind; +begin + if KeyComp('var') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func43: TtkTokenKind; +begin + if KeyComp('spec') then Result := tkKey else + if KeyComp('block') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func47: TtkTokenKind; +begin + if KeyComp('time') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func52: TtkTokenKind; +begin + if KeyComp('byte') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func53: TtkTokenKind; +begin + if KeyComp('database') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func55: TtkTokenKind; +begin + if KeyComp('object') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func60: TtkTokenKind; +begin + if KeyComp('keys') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func63: TtkTokenKind; +begin + if KeyComp('array') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func66: TtkTokenKind; +begin + if KeyComp('endblock') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func74: TtkTokenKind; +begin + if KeyComp('objects') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func75: TtkTokenKind; +begin + if KeyComp('owner') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func78: TtkTokenKind; +begin + if KeyComp('integer') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func87: TtkTokenKind; +begin + if KeyComp('string') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func91: TtkTokenKind; +begin + if KeyComp('longint') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func95: TtkTokenKind; +begin + if KeyComp('binarydata') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func100: TtkTokenKind; +begin + if KeyComp('primary') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func104: TtkTokenKind; +begin + if KeyComp('secondary') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func115: TtkTokenKind; +begin + if KeyComp('memotext') then Result := tkDatatype else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func122: TtkTokenKind; +begin + if KeyComp('partition') then Result := tkKey else + if KeyComp('superspec') then Result := tkKey else + if KeyComp('superblock') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.Func141: TtkTokenKind; +begin + if KeyComp('partitions') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSDDSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynSDDSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 142 then Result := fIdentFuncTable[HashKey]{$ifdef FPC} () {$endif} else Result := tkIdentifier; +end; + +procedure TSynSDDSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '{' : fProcTable[I] := {$ifdef FPC} @ {$endif}BraceOpenProc; + '}', + '!', + '%', + '&', + '('..'/', + ':'..'@', + '['..'^', + '`', '~' : fProcTable[I] := {$ifdef FPC} @ {$endif}SymbolProc; + 'A'..'Z', + 'a'..'z', + '_' : fProcTable[I] := {$ifdef FPC} @ {$endif}IdentProc; + '0'..'9' : fProcTable[I] := {$ifdef FPC} @ {$endif}NumberProc; + #0 : fProcTable[I] := {$ifdef FPC} @ {$endif}NullProc; + #1..#32 : fProcTable[I] := {$ifdef FPC} @ {$endif}SpaceProc; + else + fProcTable[I] := {$ifdef FPC} @ {$endif}UnknownProc; + end; +end; { MakeMethodTables } + + +constructor TSynSDDSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Foreground := clNavy; + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + + fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + fKeyAttri.Foreground := clGreen; + AddAttribute(fKeyAttri); + + fDatatypeAttri := TSynHighlighterAttributes.Create(SYNS_AttrDataType); + fDatatypeAttri.Style := [fsBold]; + fDatatypeAttri.Foreground := clTeal; + AddAttribute(fDatatypeAttri); + + fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + + fNumberAttri := TSynHighLighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clBlue; + AddAttribute(fNumberAttri); + + fSymbolAttri := TSynHighLighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + + SetAttributesOnChange({$ifdef FPC} @ {$endif}DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterSDD; + fRange := rsUnknown; +end; { Create } + +{$IFDEF SYN_LAZARUS} +procedure TSynSDDSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynSDDSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + + +procedure TSynSDDSyn.BraceOpenProc; +begin + fRange := rsComment; + BraceCommentProc; + fTokenID := tkComment; +end; { BraceOpenProc } + + +procedure TSynSDDSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + Inc(Run); +end; { IdentProc } + + +procedure TSynSDDSyn.NullProc; +begin + fTokenID := tkNull; +end; { NullProc } + + +procedure TSynSDDSyn.SpaceProc; +begin + fTokenID := tkSpace; + repeat + inc(Run); + until not (fLine[Run] in [#1..#32]); +end; { SpaceProc } + + +procedure TSynSDDSyn.BraceCommentProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + begin + fTokenID := tkComment; + repeat + if fLine[Run] = '}' then + begin + Inc(Run); + fRange := rsUnKnown; + Break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + end; +end; { BraceCommentProc } + + +procedure TSynSDDSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; { UnknownProc } + + +procedure TSynSDDSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsComment: BraceCommentProc; + else + fProcTable[fLine[Run]]; + end; +end; { Next } + + +procedure TSynSDDSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run] = #10 then + inc(Run); +end; { CRProc } + + +procedure TSynSDDSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; { LFProc } + + +function TSynSDDSyn.GetSampleSource: string; +begin + Result := '{ Semanta data dictionary }'#13#10 + + 'database Sample.001;'#13#10 + + 'owner = COAS;'#13#10 + + #13#10 + + 'objects'#13#10 + + ' Test = object'#13#10 + + ' Code : string[4];'#13#10 + + ' Name : string[80];'#13#10 + + ' end;'#13#10 + + 'keys'#13#10 + + ' primary Test.Index = [Code];'#13#10 + + 'end.'; +end; { GetSampleSource } + + +function TSynSDDSyn.GetDefaultAttribute(Index: integer): TSynHighLighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL : Result := fSymbolAttri; + else + Result := nil; + end; +end; { GetDefaultAttribute } + + +function TSynSDDSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; { GetEol } + + +function TSynSDDSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; { GetToken } + + +function TSynSDDSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; { GetTokenId } + + +function TSynSDDSyn.GetTokenAttribute: TSynHighLighterAttributes; +begin + case GetTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkDatatype: Result := fDatatypeAttri; + tkSpace: Result := fSpaceAttri; + tkNumber: Result := fNumberAttri; + tkUnknown: Result := fIdentifierAttri; + tkSymbol: Result := fSymbolAttri; + else + Result := nil; + end; +end; { GetTokenAttribute } + + +function TSynSDDSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; { GetTokenKind } + + +function TSynSDDSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; { GetTokenPos } + + +procedure TSynSDDSyn.ResetRange; +begin + inherited; + fRange := rsUnknown; +end; { ResetRange } + + +procedure TSynSDDSyn.SetRange(Value: Pointer); +begin + inherited; + fRange := TRangeState(Value); +end; { SetRange } + + +function TSynSDDSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; { GetRange } + + +function TSynSDDSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; { GetIdentChars } + +class function TSynSDDSyn.GetLanguageName: string; +begin + Result := SYNS_LangSDD; +end; { GetLanguageName } + + +procedure TSynSDDSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do + begin + case FLine[Run] of + '.': if FLine[Run + 1] = '.' then + Break; + end; + inc(Run); + end; +end; { NumberProc } + + +function TSynSDDSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterSDD; +end; { IsFilterStored } + + +procedure TSynSDDSyn.SymbolProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynSDDSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightersml.pas b/components/extrasyn/SyneditHighlighters/synhighlightersml.pas new file mode 100644 index 000000000..b95b6d7bf --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightersml.pas @@ -0,0 +1,955 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterSML.pas, released 2000-04-17. +The Original Code is based on the dmMLSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is David H. Muir. +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: SynHighlighterSml.pas,v 1.15 2005/01/28 16:53:25 maelh Exp $ + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +Known Issues: +-------------------------------------------------------------------------------} +{ +@abstract(Provides SynEdit with a Standard ML syntax highlighter, with extra options for the standard Basis library.) +@author(David H Muir ) +@created(1999) +@lastmod(2000-06-23) +The SynHighlighterSML.pas unit provides SynEdit text control with a Standard ML highlighter. Many formatting attributes can +be specified, and there is an option to include extra keywords and operators only found in the Basis library, this option can +be disabled for backwards compatibility with older ML compilers that do not have support for the Basis Library. +} + +unit SynHighlighterSml; + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +Type + TtkTokenKind = (tkCharacter, tkComment, tkIdentifier, tkKey, tkNull, tkNumber, + tkOperator, tkSpace, tkString, tkSymbol, tkSyntaxError, tkUnknown); + + TProcTableProc = procedure of object; + TRangeState = (rsUnknown, rsComment, rsMultilineString); + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynSMLSyn = class(TSynCustomHighlighter) + private + fBasis: Boolean; + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + fRange: TRangeState; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fIdentFuncTable: array[0..145] of TIdentFuncTableFunc; + fCharacterAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fOperatorAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fSyntaxErrorAttri: TSynHighlighterAttributes; + function IsValidMLCharacter: Boolean; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func15: TtkTokenKind; + function Func19: TtkTokenKind; + function Func20: TtkTokenKind; + function Func21: TtkTokenKind; + function Func23: TtkTokenKind; + function Func26: TtkTokenKind; + function Func28: TtkTokenKind; + function Func31: TtkTokenKind; + function Func35: TtkTokenKind; + function Func37: TtkTokenKind; + function Func41: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func47: TtkTokenKind; + function Func50: TtkTokenKind; + function Func52: TtkTokenKind; + function Func57: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func62: TtkTokenKind; + function Func66: TtkTokenKind; + function Func68: TtkTokenKind; + function Func74: TtkTokenKind; + function Func76: TtkTokenKind; + function Func80: TtkTokenKind; + function Func82: TtkTokenKind; + function Func88: TtkTokenKind; + function Func92: TtkTokenKind; + function Func97: TtkTokenKind; + function Func101: TtkTokenKind; + function Func111: TtkTokenKind; + function Func114: TtkTokenKind; + function Func126: TtkTokenKind; + function Func145: TtkTokenKind; + procedure CRProc; + procedure CharacterProc; + procedure ColonProc; + procedure CommentProc; + procedure IdentProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure OperatorProc; + procedure RoundBracketOpenProc; + procedure SpaceProc; + procedure StringProc; + procedure SymbolProc; + procedure UnknownProc; + procedure BasisOpProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure StringEndProc; + procedure PoundProc; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + function GetRange: Pointer; override; + procedure ResetRange; override; + procedure SetRange(Value: Pointer); override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber: Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CharacterAttri: TSynHighlighterAttributes read fCharacterAttri + write fCharacterAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property OperatorAttri: TSynHighlighterAttributes read fOperatorAttri + write fOperatorAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + property SyntaxErrorAttri: TSynHighlighterAttributes read fSyntaxErrorAttri + write fSyntaxErrorAttri; + property Basis: Boolean read FBasis write FBasis default True; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst; +{$ENDIF} + +const + Identifiers = [#39, '_', '0'..'9', 'a'..'z', 'A'..'Z']; + +var + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + if I in ['_', 'A'..'Z', 'a'..'z'] then + mHashTable[I] := Ord(UpCase(I)) - 64 + else + mHashTable[I] := 0; + end; +end; + +function TSynSMLSyn.IsValidMLCharacter: Boolean; +var + ASCIIStr: string; + ASCIICode, Error: Integer; +begin + Result := False; + if (fLine[Run] = '"') then + if (Run > 2) and (fLine[Run - 1] <> '\') and (fLine[Run - 2] = '"') then + Result := True + else if (Run > 3) and (fLine[Run - 1] = '\') and (fLine[Run - 2] = '\') + and (fLine[Run - 3] = '"') then + Result := True + else if (Run > 3) and (fLine[Run - 1] in ['a', 'b', 'n', 'r', 't']) and + (fLine[Run - 2] = '\') and (fLine[Run - 3] = '"') then + Result := True + else if (Run > 5) and (fLine[Run - 4] = '\') and (fLine[Run - 5] = '"') then + begin + ASCIIStr := copy(fLine, Run - 2, 3); + Val(ASCIIStr, ASCIICode, Error); + if (Error = 0) and (ASCIICode >= 0) and (ASCIICode <= 255) then + Result := True + end +end; + +procedure TSynSMLSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := {$ifdef FPC} @ {$endif}AltFunc; + Inc(pF); + end; + fIdentFuncTable[15] := {$IFDEF FPC}@{$ENDIF} Func15; + fIdentFuncTable[19] := {$IFDEF FPC}@{$ENDIF} Func19; + fIdentFuncTable[20] := {$IFDEF FPC}@{$ENDIF} Func20; + fIdentFuncTable[21] := {$IFDEF FPC}@{$ENDIF} Func21; + fIdentFuncTable[23] := {$IFDEF FPC}@{$ENDIF} Func23; + fIdentFuncTable[26] := {$IFDEF FPC}@{$ENDIF} Func26; + fIdentFuncTable[28] := {$IFDEF FPC}@{$ENDIF} Func28; + fIdentFuncTable[31] := {$IFDEF FPC}@{$ENDIF} Func31; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF} Func35; + fIdentFuncTable[37] := {$IFDEF FPC}@{$ENDIF} Func37; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF} Func44; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF} Func47; + fIdentFuncTable[50] := {$IFDEF FPC}@{$ENDIF} Func50; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF} Func52; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF} Func57; + fIdentFuncTable[59] := {$IFDEF FPC}@{$ENDIF} Func59; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF} Func60; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF} Func62; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[68] := {$IFDEF FPC}@{$ENDIF} Func68; + fIdentFuncTable[74] := {$IFDEF FPC}@{$ENDIF} Func74; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF} Func76; + fIdentFuncTable[80] := {$IFDEF FPC}@{$ENDIF} Func80; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF} Func82; + fIdentFuncTable[88] := {$IFDEF FPC}@{$ENDIF} Func88; + fIdentFuncTable[92] := {$IFDEF FPC}@{$ENDIF} Func92; + fIdentFuncTable[97] := {$IFDEF FPC}@{$ENDIF} Func97; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF} Func101; + fIdentFuncTable[111] := {$IFDEF FPC}@{$ENDIF} Func111; + fIdentFuncTable[114] := {$IFDEF FPC}@{$ENDIF} Func114; + fIdentFuncTable[126] := {$IFDEF FPC}@{$ENDIF} Func126; + fIdentFuncTable[145] := {$IFDEF FPC}@{$ENDIF} Func145; +end; + +function TSynSMLSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in Identifiers do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynSMLSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; + +function TSynSMLSyn.Func15: TtkTokenKind; +begin + if KeyComp('if') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func19: TtkTokenKind; +begin + if KeyComp('do') then Result := tkKey else + if KeyComp('and') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func20: TtkTokenKind; +begin + if KeyComp('as') then Result := tkKey else + if KeyComp('fn') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func21: TtkTokenKind; +begin + if KeyComp('of') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func23: TtkTokenKind; +begin + if KeyComp('in') then Result := tkKey else + if KeyComp('end') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func26: TtkTokenKind; +begin + if KeyComp('rec') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func28: TtkTokenKind; +begin + if KeyComp('case') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func31: TtkTokenKind; +begin + if KeyComp('op') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func35: TtkTokenKind; +begin + if KeyComp('val') then Result := tkKey else + if KeyComp('sig') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func37: TtkTokenKind; +begin + if KeyComp('let') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func41: TtkTokenKind; +begin + if KeyComp('fun') then Result := tkKey else + if KeyComp('else') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func43: TtkTokenKind; +begin + if KeyComp('local') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func44: TtkTokenKind; +begin + if KeyComp('handle') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func47: TtkTokenKind; +begin + if KeyComp('then') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func50: TtkTokenKind; +begin + if KeyComp('open') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func52: TtkTokenKind; +begin + if KeyComp('raise') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func57: TtkTokenKind; +begin + if KeyComp('while') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func59: TtkTokenKind; +begin + if KeyComp('where') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func60: TtkTokenKind; +begin + if KeyComp('with') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func62: TtkTokenKind; +begin + if KeyComp('infix') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func66: TtkTokenKind; +begin + if KeyComp('andalso') then Result := tkKey else + if KeyComp('type') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func68: TtkTokenKind; +begin + if KeyComp('include') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func74: TtkTokenKind; +begin + if KeyComp('orelse') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func76: TtkTokenKind; +begin + if KeyComp('sharing') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func80: TtkTokenKind; +begin + if KeyComp('infixr') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func82: TtkTokenKind; +begin + if KeyComp('nonfix') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func88: TtkTokenKind; +begin + if KeyComp('abstype') then Result := tkKey else + if KeyComp('eqtype') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func92: TtkTokenKind; +begin + if KeyComp('datatype') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func97: TtkTokenKind; +begin + if KeyComp('functor') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func101: TtkTokenKind; +begin + if KeyComp('struct') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func111: TtkTokenKind; +begin + if KeyComp('exception') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func114: TtkTokenKind; +begin + if KeyComp('signature') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func126: TtkTokenKind; +begin + if KeyComp('withtype') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.Func145: TtkTokenKind; +begin + if KeyComp('structure') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSMLSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynSMLSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 146 then Result := fIdentFuncTable[HashKey]{$ifdef FPC} () {$endif} else Result := tkIdentifier; +end; + +procedure TSynSMLSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #13: fProcTable[I] := {$ifdef FPC} @ {$endif}CRProc; + '#': fProcTable[I] := {$ifdef FPC} @ {$endif}PoundProc; + ':': fProcTable[I] := {$ifdef FPC} @ {$endif}ColonProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$ifdef FPC} @ {$endif}IdentProc; + #10: fProcTable[I] := {$ifdef FPC} @ {$endif}LFProc; + #0: fProcTable[I] := {$ifdef FPC} @ {$endif}NullProc; + '0'..'9': fProcTable[I] := {$ifdef FPC} @ {$endif}NumberProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$ifdef FPC} @ {$endif}SpaceProc; + '"': fProcTable[I] := {$ifdef FPC} @ {$endif}StringProc; + '@', '^': fProcTable[I] := {$ifdef FPC} @ {$endif}BasisOpProc; + '(': fProcTable[I] := {$ifdef FPC} @ {$endif}RoundBracketOpenProc; + '+', '-', '~', '*', '/', '=', '<', '>': fProcTable[i] := {$ifdef FPC} @ {$endif}OperatorProc; + ',', '.', ';': fProcTable[I] := {$ifdef FPC} @ {$endif}SymbolProc; + else + fProcTable[I] := {$ifdef FPC} @ {$endif}UnknownProc; + end; +end; + +constructor TSynSMLSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCharacterAttri := TSynHighlighterAttributes.Create(SYNS_AttrCharacter); + fCharacterAttri.Foreground := clBlue; + AddAttribute(fCharacterAttri); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + fCommentAttri.Foreground := clNavy; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + fKeyAttri.Foreground := clGreen; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + fNumberAttri.Foreground := clRed; + AddAttribute(fNumberAttri); + fOperatorAttri := TSynHighlighterAttributes.Create(SYNS_AttrOperator); + fOperatorAttri.Foreground := clMaroon; + AddAttribute(fOperatorAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + fStringAttri.Foreground := clBlue; + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fSyntaxErrorAttri := TSynHighlighterAttributes.Create(SYNS_AttrSyntaxError); + fSyntaxErrorAttri.Foreground := clRed; + fSyntaxErrorAttri.Style := [fsBold]; + AddAttribute(fSyntaxErrorAttri); + SetAttributesOnChange({$ifdef FPC} @ {$endif}DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterSML; + Basis := True; +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynSMLSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynSMLSyn.SetLine(const NewValue: String; LineNumber: Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynSMLSyn.CRProc; +begin + fTokenID := tkSpace; + Case FLine[Run + 1] of + #10: inc(Run, 2); + else inc(Run); + end; +end; + +procedure TSynSMLSyn.ColonProc; +begin + inc(Run); + if Basis and (fLine[Run] = ':') then begin + fTokenID := tkOperator; + inc(Run); + end + else fTokenID := tkSymbol; +end; + +procedure TSynSMLSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while fLine[Run] in Identifiers do inc(Run); +end; + +procedure TSynSMLSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynSMLSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynSMLSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', '.', 'u', 'U', 'l', 'L', 'x', 'X', 'e', 'E', 'f', 'F'] do + begin + case FLine[Run] of + '.': if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynSMLSyn.OperatorProc; +begin + inc(Run); + fTokenID := tkOperator; +end; + +procedure TSynSMLSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynSMLSyn.StringProc; +begin + fTokenID := tkString; + repeat + if fLine[Run] = '\' then begin + case fLine[Run + 1] of + '"', '\': + Inc(Run); + #00: + begin + Inc(Run); + fRange := rsMultilineString; + Exit; + end; + end; + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, '"']; + if FLine[Run] = '"' then + inc(Run); +end; + +procedure TSynSMLSyn.StringEndProc; +begin + fTokenID := tkString; + + case FLine[Run] of + #0: + begin + NullProc; + Exit; + end; + #10: + begin + LFProc; + Exit; + end; + #13: + begin + CRProc; + Exit; + end; + end; + + fRange := rsUnknown; + + repeat + case FLine[Run] of + #0, #10, #13: Break; + '\': + begin + case fLine[Run + 1] of + '"', '\': + Inc(Run); + #00: + begin + Inc(Run); + fRange := rsMultilineString; + Exit; + end; + end; + end; + '"': Break; + end; + inc(Run); + until fLine[Run] in [#0, #10, #13, '"']; + if FLine[Run] = '"' then + inc(Run); +end; + +procedure TSynSMLSyn.SymbolProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynSMLSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynSMLSyn.BasisOpProc; +begin + inc(Run); + if Basis then fTokenID := tkOperator else fTokenID := tkIdentifier; +end; + +procedure TSynSMLSyn.PoundProc; +begin + Inc(Run); + if (fLine[Run] = '"') then + CharacterProc + else + fTokenID := tkIdentifier; +end; + +procedure TSynSMLSyn.CharacterProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + begin + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13, '"']; + + if IsValidMLCharacter then + fTokenID := tkCharacter + else + begin + if fLine[Run] = '"' then Inc(Run); + fTokenID := tkSyntaxError; + end; + end + end +end; + +procedure TSynSMLSyn.RoundBracketOpenProc; +begin + Inc(Run); + if (fLine[Run] = '*') then + begin + fRange := rsComment; + CommentProc; + fTokenID := tkComment; + end + else + fTokenID := tkIdentifier; +end; + +procedure TSynSMLSyn.CommentProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + begin + fTokenID := tkComment; + repeat + if (fLine[Run] = '*') and + (fLine[Run + 1] = ')') then + begin + Inc(Run, 2); + fRange := rsUnknown; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + end; +end; + +procedure TSynSMLSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsComment: CommentProc; + rsMultilineString: StringEndProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynSMLSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynSMLSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynSMLSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynSMLSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynSMLSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkCharacter: Result := fCharacterAttri; + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkOperator: Result := fOperatorAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkSyntaxError: Result := fSyntaxErrorAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynSMLSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynSMLSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynSMLSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynSMLSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterSML; +end; + +class function TSynSMLSyn.GetLanguageName: string; +begin + Result := SYNS_LangSML; +end; + +function TSynSMLSyn.GetSampleSource: string; +begin + Result := '(* Syntax highlighting *)'#13#10 + + 'load "Real";'#13#10 + + 'fun PrintNumber(x: int) ='#13#10 + + ' let'#13#10 + + ' val Number = real(x) / 10.0;'#13#10 + + ' val Text = "The Number is " ^ Real.toString(~Number) ^ "\n";'#13#10 + + ' in'#13#10 + + ' print Text;'#13#10 + + ' if x = 0 then () else PrintNumber(x-1)'#13#10+ + ' end;' +end; + +procedure TSynSMLSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynSMLSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynSMLSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynSMLSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterst.pas b/components/extrasyn/SyneditHighlighters/synhighlighterst.pas new file mode 100644 index 000000000..50792ea7d --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterst.pas @@ -0,0 +1,1148 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterST.pas, released 2002-07. +ST stands for Structured Text, and it is part of IEC1131 standard for +programming PLCs. +Author of this file is Ruggero Bandera. +Portions created by Ruggero Bandera are Copyright (C) 2002 Ruggero Bandera. +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: SynHighlighterST.pas,v 1.10 2005/01/28 16:53:25 maelh Exp $ by Ruggero Bandera + +You may retrieve the latest version of this file at the SynEdit home page, +located at http://SynEdit.SourceForge.net + +Known Issues: +-------------------------------------------------------------------------------} + +{$IFNDEF QSYNHIGHLIGHTERST} +unit SynHighlighterST; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + + Controls, + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = (tkAsm, tkComment, tkIdentifier, tkKey, tkNull, tkNumber, + tkSpace, tkString, tkSymbol, tkUnknown); + + TRangeState = (rsANil, rsAnsi, rsAnsiAsm, rsAsm, rsBor, rsBorAsm, rsProperty, + rsUnKnown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TSynSTSyn = class(TSynCustomHighlighter) + private + fAsmStart: Boolean; + fRange: TRangeState; + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fIdentFuncTable: array[0..207] of TIdentFuncTableFunc; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fStringAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fAsmAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: string): Boolean; + function Func15: TtkTokenKind; + function Func19: TtkTokenKind; + function Func21: TtkTokenKind; + function Func27: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func47: TtkTokenKind; + function Func49: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func60: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func67: TtkTokenKind; + function Func68: TtkTokenKind; + function Func69: TtkTokenKind; + function Func76: TtkTokenKind; + function Func79: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func87: TtkTokenKind; + function Func88: TtkTokenKind; + function Func93: TtkTokenKind; + function Func95: TtkTokenKind; + function Func96: TtkTokenKind; + function Func99: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func104: TtkTokenKind; + function Func106: TtkTokenKind; + function Func111: TtkTokenKind; + function Func114: TtkTokenKind; + function Func116: TtkTokenKind; + function Func119: TtkTokenKind; + function Func120: TtkTokenKind; + function Func121: TtkTokenKind; + function Func139: TtkTokenKind; + function Func152: TtkTokenKind; + function Func155: TtkTokenKind; + function Func158: TtkTokenKind; + function Func165: TtkTokenKind; + function Func168: TtkTokenKind; + function Func171: TtkTokenKind; + function Func182: TtkTokenKind; + function Func185: TtkTokenKind; + function Func193: TtkTokenKind; + function Func206: TtkTokenKind; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + procedure AddressOpProc; + procedure AsciiCharProc; + procedure AnsiProc; + procedure BorProc; + procedure BraceOpenProc; + procedure ColonOrGreaterProc; + procedure CRProc; + procedure IdentProc; + procedure IntegerProc; + procedure LFProc; + procedure LowerProc; + procedure NullProc; + procedure NumberProc; + procedure PointProc; + procedure RoundOpenProc; + procedure SemicolonProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure SymbolProc; + procedure UnknownProc; + protected + function GetIdentChars: TSynIdentChars; override; + function IsFilterStored: boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetToken: string; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenID: TtkTokenKind; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure ResetRange; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + procedure SetLine(const NewValue: string; LineNumber:Integer); override; + procedure SetRange(Value: Pointer); override; + property IdentChars; + published + property AsmAttri: TSynHighlighterAttributes read fAsmAttri write fAsmAttri; + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst, +{$ELSE} + SynEditStrConst, +{$ENDIF} + SynEditStrConstExtra; + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I of + 'A'..'Z', '_': mHashTable[I] := Ord(J) - 64; + else mHashTable[Char(I)] := 0; + end; + end; +end; + +procedure TSynSTSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := {$ifdef FPC} @ {$endif}AltFunc; + Inc(pF); + end; + fIdentFuncTable[15] := {$IFDEF FPC}@{$ENDIF} Func15; + fIdentFuncTable[19] := {$IFDEF FPC}@{$ENDIF} Func19; + fIdentFuncTable[21] := {$IFDEF FPC}@{$ENDIF} Func21; + fIdentFuncTable[27] := {$IFDEF FPC}@{$ENDIF} Func27; + fIdentFuncTable[28] := {$IFDEF FPC}@{$ENDIF} Func28; + fIdentFuncTable[29] := {$IFDEF FPC}@{$ENDIF} Func29; + fIdentFuncTable[32] := {$IFDEF FPC}@{$ENDIF} Func32; + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF} Func33; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF} Func35; + fIdentFuncTable[36] := {$IFDEF FPC}@{$ENDIF} Func36; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF} Func39; + fIdentFuncTable[40] := {$IFDEF FPC}@{$ENDIF} Func40; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF} Func44; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF} Func47; + fIdentFuncTable[49] := {$IFDEF FPC}@{$ENDIF} Func49; + fIdentFuncTable[51] := {$IFDEF FPC}@{$ENDIF} Func51; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF} Func52; + fIdentFuncTable[56] := {$IFDEF FPC}@{$ENDIF} Func56; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF} Func57; + fIdentFuncTable[58] := {$IFDEF FPC}@{$ENDIF} Func58; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF} Func60; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF} Func62; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF} Func63; + fIdentFuncTable[64] := {$IFDEF FPC}@{$ENDIF} Func64; + fIdentFuncTable[65] := {$IFDEF FPC}@{$ENDIF} Func65; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[67] := {$IFDEF FPC}@{$ENDIF} Func67; + fIdentFuncTable[68] := {$IFDEF FPC}@{$ENDIF} Func68; + fIdentFuncTable[69] := {$IFDEF FPC}@{$ENDIF} Func69; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF} Func76; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF} Func79; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF} Func82; + fIdentFuncTable[83] := {$IFDEF FPC}@{$ENDIF} Func83; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF} Func87; + fIdentFuncTable[88] := {$IFDEF FPC}@{$ENDIF} Func88; + fIdentFuncTable[93] := {$IFDEF FPC}@{$ENDIF} Func93; + fIdentFuncTable[95] := {$IFDEF FPC}@{$ENDIF} Func95; + fIdentFuncTable[96] := {$IFDEF FPC}@{$ENDIF} Func96; + fIdentFuncTable[99] := {$IFDEF FPC}@{$ENDIF} Func99; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF} Func101; + fIdentFuncTable[102] := {$IFDEF FPC}@{$ENDIF} Func102; + fIdentFuncTable[104] := {$IFDEF FPC}@{$ENDIF} Func104; + fIdentFuncTable[106] := {$IFDEF FPC}@{$ENDIF} Func106; + fIdentFuncTable[111] := {$IFDEF FPC}@{$ENDIF} Func111; + fIdentFuncTable[114] := {$IFDEF FPC}@{$ENDIF} Func114; + fIdentFuncTable[116] := {$IFDEF FPC}@{$ENDIF} Func116; + fIdentFuncTable[119] := {$IFDEF FPC}@{$ENDIF} Func119; + fIdentFuncTable[120] := {$IFDEF FPC}@{$ENDIF} Func120; + fIdentFuncTable[121] := {$IFDEF FPC}@{$ENDIF} Func121; + fIdentFuncTable[139] := {$IFDEF FPC}@{$ENDIF} Func139; + fIdentFuncTable[152] := {$IFDEF FPC}@{$ENDIF} Func152; + fIdentFuncTable[155] := {$IFDEF FPC}@{$ENDIF} Func155; + fIdentFuncTable[158] := {$IFDEF FPC}@{$ENDIF} Func158; + fIdentFuncTable[165] := {$IFDEF FPC}@{$ENDIF} Func165; + fIdentFuncTable[168] := {$IFDEF FPC}@{$ENDIF} Func168; + fIdentFuncTable[171] := {$IFDEF FPC}@{$ENDIF} Func171; + fIdentFuncTable[182] := {$IFDEF FPC}@{$ENDIF} Func182; + fIdentFuncTable[185] := {$IFDEF FPC}@{$ENDIF} Func185; + fIdentFuncTable[193] := {$IFDEF FPC}@{$ENDIF} Func193; + fIdentFuncTable[206] := {$IFDEF FPC}@{$ENDIF} Func206; +end; + +function TSynSTSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9','a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; { KeyHash } + +function TSynSTSyn.KeyComp(const aKey: string): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; { KeyComp } + +function TSynSTSyn.Func15: TtkTokenKind; +begin + if KeyComp('IF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func19: TtkTokenKind; +begin + if KeyComp('DO') then Result := tkKey else + if KeyComp('AND') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func21: TtkTokenKind; +begin + if KeyComp('OF') then Result := tkKey else + if KeyComp('AT') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func27: TtkTokenKind; +begin + if KeyComp('BY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func28: TtkTokenKind; +begin + if KeyComp('CASE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func29: TtkTokenKind; +begin + if KeyComp('ON') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func32: TtkTokenKind; +begin + if KeyComp('LABEL') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func33: TtkTokenKind; +begin + if KeyComp('OR') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func35: TtkTokenKind; +begin + if KeyComp('TO') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func36: TtkTokenKind; +begin + if KeyComp('REAL') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func39: TtkTokenKind; +begin + if KeyComp('FOR') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func40: TtkTokenKind; +begin + if KeyComp('ANY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func41: TtkTokenKind; +begin + if KeyComp('ELSE') then Result := tkKey else + if KeyComp('VAR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func43: TtkTokenKind; +begin + if KeyComp('INT') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func44: TtkTokenKind; +begin + if KeyComp('BOOL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func47: TtkTokenKind; +begin + if KeyComp('THEN') then Result := tkKey else + if KeyComp('DINT') then Result := tkKey else + if KeyComp('TIME') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func49: TtkTokenKind; +begin + if KeyComp('NOT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func51: TtkTokenKind; +begin + if KeyComp('ELSIF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func52: TtkTokenKind; +begin + if KeyComp('BYTE') then Result := tkKey else + if KeyComp('FROM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func56: TtkTokenKind; +begin + if KeyComp('INDEX') then + begin + if fRange = rsProperty then Result := tkKey else Result := tkIdentifier; + end + else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func57: TtkTokenKind; +begin + if KeyComp('GOTO') then Result := tkKey else + if KeyComp('WHILE') then Result := tkKey else + if KeyComp('XOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func58: TtkTokenKind; +begin + if KeyComp('EXIT') then Result := tkKey else + Result := tkIdentifier; +end; + + +function TSynSTSyn.Func60: TtkTokenKind; +begin + if KeyComp('STEP') then Result := tkKey else + if KeyComp('WORD') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func62: TtkTokenKind; +begin + if KeyComp('ACTION') then Result := tkKey else + if KeyComp('SINT') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func63: TtkTokenKind; +begin + if KeyComp('ARRAY') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func64: TtkTokenKind; +begin + if KeyComp('DWORD') then Result := tkKey else + if KeyComp('UINT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func65: TtkTokenKind; +begin + if KeyComp('REPEAT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func66: TtkTokenKind; +begin + if KeyComp('TYPE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func67: TtkTokenKind; +begin + if KeyComp('RETAIN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func68: TtkTokenKind; +begin + if KeyComp('UDINT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func69: TtkTokenKind; +begin + if KeyComp('END_IF') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func76: TtkTokenKind; +begin + if KeyComp('UNTIL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func79: TtkTokenKind; +begin + if KeyComp('FINALLY') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func82: TtkTokenKind; +begin + if KeyComp('END_CASE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func83: TtkTokenKind; +begin + if KeyComp('USINT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func87: TtkTokenKind; +begin + if KeyComp('STRING') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func88: TtkTokenKind; +begin + if KeyComp('PROGRAM') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func93: TtkTokenKind; +begin + if KeyComp('END_FOR') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func95: TtkTokenKind; +begin + if KeyComp('END_VAR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func96: TtkTokenKind; +begin + if KeyComp('RETURN') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func99: TtkTokenKind; +begin + if KeyComp('EXTERNAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func101: TtkTokenKind; +begin + if KeyComp('STRUCT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func102: TtkTokenKind; +begin + if KeyComp('FUNCTION') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func104: TtkTokenKind; +begin + if KeyComp('RESOURCE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func106: TtkTokenKind; +begin + if KeyComp('VAR_EXTERNAL') then Result := tkKey else + if KeyComp('CONSTANT') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func111: TtkTokenKind; +begin + if KeyComp('END_WHILE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func114: TtkTokenKind; +begin + if KeyComp('END_STEP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func116: TtkTokenKind; +begin + if KeyComp('END_ACTION') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func119: TtkTokenKind; +begin + if KeyComp('ANY_NUM') then Result := tkKey else + if KeyComp('END_REPEAT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func120: TtkTokenKind; +begin + if KeyComp('END_TYPE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func121: TtkTokenKind; +begin + if KeyComp('VAR_GLOBAL') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func139: TtkTokenKind; +begin + if KeyComp('TRANSITION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func152: TtkTokenKind; +begin + if KeyComp('CONFIGURATION') then Result := tkKey else + if KeyComp('VAR_INPUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func155: TtkTokenKind; +begin + if KeyComp('END_STRUCT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func158: TtkTokenKind; +begin + if KeyComp('END_RESOURCE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func165: TtkTokenKind; +begin + if KeyComp('INITIAL_STEP') then Result := tkKey else + Result := tkIdentifier; +end; + + +function TSynSTSyn.Func168: TtkTokenKind; +begin + if KeyComp('INITIALIZATION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func171: TtkTokenKind; +begin + if KeyComp('VAR_EXTERNAL') then Result := tkKey else + Result := tkIdentifier; +end; + +function TSynSTSyn.Func182: TtkTokenKind; +begin + if KeyComp('VAR_IN_OUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func185: TtkTokenKind; +begin + if KeyComp('VAR_OUTPUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.Func193: TtkTokenKind; +begin + if KeyComp('END_TRANSITION') then Result := tkKey else Result := tkIdentifier; +end; + + +function TSynSTSyn.Func206: TtkTokenKind; +begin + if KeyComp('END_CONFIGURATION') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynSTSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier +end; + +function TSynSTSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 207 then Result := fIdentFuncTable[HashKey]{$ifdef FPC} () {$endif} else + Result := tkIdentifier; +end; + +procedure TSynSTSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NullProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LFProc; + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CRProc; + #1..#9, #11, #12, #14..#32: + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SpaceProc; + '#': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} AsciiCharProc; + '$': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} IntegerProc; + #39: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StringProc; + '0'..'9': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NumberProc; + 'A'..'Z', 'a'..'z', '_': + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} IdentProc; + '{': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} BraceOpenProc; + '}', '!', '"', '%', '&', '('..'/', ':'..'@', '['..'^', '`', '~': + begin + case I of + '(': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} RoundOpenProc; + '.': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} PointProc; + ';': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SemicolonProc; + '/': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SlashProc; + ':', '>': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} ColonOrGreaterProc; + '<': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LowerProc; + '@': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} AddressOpProc; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SymbolProc; + end; + end; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} UnknownProc; + end; +end; + +constructor TSynSTSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fAsmAttri := TSynHighlighterAttributes.Create(SYNS_AttrAssembler); + AddAttribute(fAsmAttri); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style:= [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange({$ifdef FPC} @ {$endif}DefHighlightChange); + + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + fAsmStart := False; + fDefaultFilter := SYNS_FilterST; +end; { Create } + +{$IFDEF SYN_LAZARUS} +procedure TSynSTSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynSTSyn.SetLine(const NewValue: string; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynSTSyn.AddressOpProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] = '@' then inc(Run); +end; + +procedure TSynSTSyn.AsciiCharProc; +begin + fTokenID := tkString; + inc(Run); + while FLine[Run] in ['0'..'9'] do inc(Run); +end; + +procedure TSynSTSyn.BorProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else begin + fTokenID := tkComment; + repeat + if fLine[Run] = '}' then begin + Inc(Run); + if fRange = rsBorAsm then + fRange := rsAsm + else + fRange := rsUnKnown; + break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + end; +end; + +procedure TSynSTSyn.BraceOpenProc; +begin + if fRange = rsAsm then + fRange := rsBorAsm + else + fRange := rsBor; + BorProc; +end; + +procedure TSynSTSyn.ColonOrGreaterProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] = '=' then inc(Run); +end; + +procedure TSynSTSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then inc(Run); +end; + +procedure TSynSTSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynSTSyn.IntegerProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f'] do inc(Run); +end; + +procedure TSynSTSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynSTSyn.LowerProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] in ['=', '>'] then inc(Run); +end; + +procedure TSynSTSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynSTSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynSTSyn.PointProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] in ['.', ')'] then inc(Run); +end; + +procedure TSynSTSyn.AnsiProc; +begin + case fLine[Run] of + #0: NullProc; + #10: LFProc; + #13: CRProc; + else + fTokenID := tkComment; + repeat + if (fLine[Run] = '*') and (fLine[Run + 1] = ')') then begin + Inc(Run, 2); + if fRange = rsAnsiAsm then + fRange := rsAsm + else + fRange := rsUnKnown; + break; + end; + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynSTSyn.RoundOpenProc; +begin + Inc(Run); + case fLine[Run] of + '*': + begin + Inc(Run); + if fRange = rsAsm then + fRange := rsAnsiAsm + else + fRange := rsAnsi; + fTokenID := tkComment; + if not (fLine[Run] in [#0, #10, #13]) then + AnsiProc; + end; + '.': + begin + inc(Run); + fTokenID := tkSymbol; + end; + else + fTokenID := tkSymbol; + end; +end; + +procedure TSynSTSyn.SemicolonProc; +begin + Inc(Run); + fTokenID := tkSymbol; + if fRange = rsProperty then + fRange := rsUnknown; +end; + +procedure TSynSTSyn.SlashProc; +begin + Inc(Run); + if fLine[Run] = '/' then begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end else + fTokenID := tkSymbol; +end; + +procedure TSynSTSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynSTSyn.StringProc; +begin + fTokenID := tkString; + Inc(Run); + while not (fLine[Run] in [#0, #10, #13]) do begin + if fLine[Run] = #39 then begin + Inc(Run); + if fLine[Run] <> #39 then + break; + end; + Inc(Run); + end; +end; + +procedure TSynSTSyn.SymbolProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynSTSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynSTSyn.Next; +begin + fAsmStart := False; + fTokenPos := Run; + case fRange of + rsAnsi, rsAnsiAsm: + AnsiProc; + rsBor, rsBorAsm: + BorProc; + else + fProcTable[fLine[Run]]; + end; +end; + +function TSynSTSyn.GetDefaultAttribute(Index: integer): + TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + else + Result := nil; + end; +end; + +function TSynSTSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynSTSyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynSTSyn.GetTokenID: TtkTokenKind; +begin + if not fAsmStart and (fRange = rsAsm) + and not (fTokenId in [tkNull, tkComment, tkSpace]) + then + Result := tkAsm + else + Result := fTokenId; +end; + +function TSynSTSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case GetTokenID of + tkAsm: Result := fAsmAttri; + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynSTSyn.GetTokenKind: integer; +begin + Result := Ord(GetTokenID); +end; + +function TSynSTSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynSTSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +procedure TSynSTSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynSTSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +function TSynSTSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; +end; + +class function TSynSTSyn.GetLanguageName: string; +begin + Result := SYNS_LangST; +end; + +function TSynSTSyn.IsFilterStored: boolean; +begin + Result := fDefaultFilter <> SYNS_FilterST; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynSTSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightertcltk.pas b/components/extrasyn/SyneditHighlighters/synhighlightertcltk.pas new file mode 100644 index 000000000..9d4b71c77 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightertcltk.pas @@ -0,0 +1,800 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterTclTk.pas, released 2000-05-05. +The Original Code is based on the siTclTkSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Igor Shitikov. +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: SynHighlighterTclTk.pas,v 1.19 2005/01/28 16:53:25 maelh Exp $ + +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 TCL/Tk highlighter for SynEdit) +@author(Igor Shitikov, converted to SynEdit by David Muir ) +@created(5 December 1999, converted to SynEdit April 18, 2000) +@lastmod(2000-06-23) +The SynHighlighterTclTk unit provides SynEdit with a TCL/Tk highlighter. +} + +{$IFNDEF QSYNHIGHLIGHTERTCLTK} +unit SynHighlighterTclTk; +{$ENDIF} + +{$I synedit.inc} + + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + Windows, + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSecondKey, + tkSpace, tkString, tkSymbol, tkUnknown); + + TRangeState = (rsUnknown, rsAnsi, rsPasStyle, rsCStyle); + + TProcTableProc = procedure of object; + +type + TSynTclTkSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fLineNumber: Integer; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fSecondKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fCommentAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyWords: TStrings; + fSecondKeys: TStrings; + procedure BraceOpenProc; + procedure PointCommaProc; + procedure CRProc; + procedure IdentProc; + procedure LFProc; + procedure NullProc; + procedure NumberProc; + procedure RoundOpenProc; + procedure SlashProc; + procedure SpaceProc; + procedure StringProc; + procedure UnknownProc; + procedure MakeMethodTables; + procedure AnsiProc; + procedure PasStyleProc; + procedure CStyleProc; + procedure SetKeyWords(const Value: TStrings); + procedure SetSecondKeys(const Value: TStrings); + function IsKeywordListStored: boolean; + protected + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + function IsKeyword(const AKeyword: string): boolean; override; + function IsSecondKeyWord(aToken: string): Boolean; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + procedure SetLine(const NewValue: string; LineNumber:Integer); override; + function GetToken: string; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + {$IFNDEF SYN_LAZARUS} {$IFNDEF SYN_CLX} + function SaveToRegistry(RootKey: HKEY; Key: string): boolean; override; + function LoadFromRegistry(RootKey: HKEY; Key: string): boolean; override; + {$ENDIF} {$ENDIF} + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property KeyWords: TStrings read fKeyWords write SetKeyWords + stored IsKeywordListStored; + property SecondKeyAttri: TSynHighlighterAttributes read fSecondKeyAttri + write fSecondKeyAttri; + property SecondKeyWords: TStrings read fSecondKeys write SetSecondKeys; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst, SynEditStrConstExtra; +{$ENDIF} + +const + TclTkKeys: array[0..146] of string = ( + 'AFTER', 'APPEND', 'ARRAY', 'BELL', 'BGERROR', 'BINARY', 'BIND', + 'BINDIDPROC', 'BINDPROC', 'BINDTAGS', 'BITMAP', 'BREAK', 'BUTTON', + 'CANVAS', 'CATCH', 'CD', 'CHECKBUTTON', 'CLIPBOARD', 'CLOCK', + 'CLOSE', 'CONCAT', 'CONTINUE', 'DESTROY', 'ELSE', 'ENTRY', 'EOF', + 'ERROR', 'EVAL', 'EVENT', 'EXEC', 'EXIT', 'EXPR', 'FBLOCKED', + 'FCONFIGURE', 'FCOPY', 'FILE', 'FILEEVENT', 'FILENAME', 'FLUSH', + 'FOCUS', 'FONT', 'FOR', 'FOREACH', 'FORMAT', 'FRAME', 'GETS', 'GLOB', + 'GLOBAL', 'GRAB', 'GRID', 'HISTORY', 'HTTP', 'IF', 'IMAGE', 'INCR', + 'INFO', 'INTERP', 'JOIN', 'LABEL', 'LAPPEND', 'LIBRARY', 'LINDEX', + 'LINSERT', 'LIST', 'LISTBOX', 'LLENGTH', 'LOAD', 'LOADTK', 'LOWER', + 'LRANGE', 'LREPLACE', 'LSEARCH', 'LSORT', 'MENU', 'MESSAGE', 'NAMESPACE', + 'NAMESPUPD', 'OPEN', 'OPTION', 'OPTIONS', 'PACK', 'PACKAGE', 'PHOTO', + 'PID', 'PKG_MKINDEX', 'PLACE', 'PROC', 'PUTS', 'PWD', 'RADIOBUTTON', + 'RAISE', 'READ', 'REGEXP', 'REGISTRY', 'REGSUB', 'RENAME', 'RESOURCE', + 'RETURN', 'RGB', 'SAFEBASE', 'SCALE', 'SCAN', 'SEEK', 'SELECTION', + 'SEND', 'SENDOUT', 'SET', 'SOCKET', 'SOURCE', 'SPLIT', 'STRING', 'SUBST', + 'SWITCH', 'TCL', 'TCLVARS', 'TELL', 'TEXT', 'THEN', 'TIME', 'TK', + 'TK_BISQUE', 'TK_CHOOSECOLOR', 'TK_DIALOG', 'TK_FOCUSFOLLOWSMOUSE', + 'TK_FOCUSNEXT', 'TK_FOCUSPREV', 'TK_GETOPENFILE', 'TK_GETSAVEFILE', + 'TK_MESSAGEBOX', 'TK_OPTIONMENU', 'TK_POPUP', 'TK_SETPALETTE', 'TKERROR', + 'TKVARS', 'TKWAIT', 'TOPLEVEL', 'TRACE', 'UNKNOWN', 'UNSET', 'UPDATE', + 'UPLEVEL', 'UPVAR', 'VARIABLE', 'VWAIT', 'WHILE', 'WINFO', 'WM'); + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': + Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'a'..'z', 'A'..'Z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +function TSynTclTkSyn.IsKeyword(const AKeyword: string): boolean; +var + First, Last, I, Compare: Integer; + Token: String; +begin + First := 0; + Last := fKeywords.Count - 1; + Result := False; + Token := UpperCase(AKeyword); + while First <= Last do + begin + I := (First + Last) shr 1; + Compare := CompareStr(fKeywords[i], Token); + if Compare = 0 then + begin + Result := True; + break; + end + else + if Compare < 0 then First := I + 1 else Last := I - 1; + end; +end; { IsKeyWord } + +function TSynTclTkSyn.IsSecondKeyWord(aToken: String): Boolean; +var + First, Last, I, Compare: Integer; + Token: String; +begin + First := 0; + Last := fSecondKeys.Count - 1; + Result := False; + Token := UpperCase(aToken); + while First <= Last do + begin + I := (First + Last) shr 1; + Compare := CompareStr(fSecondKeys[i], Token); + if Compare = 0 then + begin + Result := True; + break; + end + else + if Compare < 0 then First := I + 1 else Last := I - 1; + end; +end; { IsSecondKeyWord } + +procedure TSynTclTkSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '#': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SlashProc; + '{': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} BraceOpenProc; + ';': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} PointCommaProc; + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CRProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} IdentProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LFProc; + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NullProc; + '0'..'9': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NumberProc; + '(': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} RoundOpenProc; + '/': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SpaceProc; + #34: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StringProc; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} UnknownProc; + end; +end; + +constructor TSynTclTkSyn.Create(AOwner: TComponent); +var + i: integer; +begin + inherited Create(AOwner); + fKeyWords := TStringList.Create; + TStringList(fKeyWords).Sorted := True; + TStringList(fKeyWords).Duplicates := dupIgnore; + fSecondKeys := TStringList.Create; + TStringList(fSecondKeys).Sorted := True; + TStringList(fSecondKeys).Duplicates := dupIgnore; + for i := Low(TclTkKeys) to High(TclTkKeys) do + FKeyWords.Add(TclTkKeys[i]); + + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fSecondKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrSecondReservedWord); + fSecondKeyAttri.Style := [fsBold]; + AddAttribute(fSecondKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterTclTk; +end; { Create } + +destructor TSynTclTkSyn.Destroy; +begin + fKeyWords.Free; + fSecondKeys.Free; + inherited Destroy; +end; { Destroy } + +{$IFDEF SYN_LAZARUS} +procedure TSynTclTkSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynTclTkSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynTclTkSyn.AnsiProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + + #13: + begin + CRProc; + exit; + end; + end; + + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = ')' then + begin + fRange := rsUnKnown; + inc(Run, 2); + break; + end else inc(Run); + #10: break; + + #13: break; + else inc(Run); + end; +end; + +procedure TSynTclTkSyn.PasStyleProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + + #13: + begin + CRProc; + exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '}': + begin + fRange := rsUnKnown; + inc(Run); + break; + end; + #10: break; + + #13: break; + else inc(Run); + end; +end; + +procedure TSynTclTkSyn.CStyleProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + + #13: + begin + CRProc; + exit; + end; + end; + + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + fRange := rsUnKnown; + inc(Run, 2); + break; + end else inc(Run); + #10: break; + + #13: break; + else inc(Run); + end; +end; + +procedure TSynTclTkSyn.BraceOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynTclTkSyn.PointCommaProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynTclTkSyn.CRProc; +begin + fTokenID := tkSpace; + Case FLine[Run + 1] of + #10: inc(Run, 2); + else inc(Run); + end; +end; + +procedure TSynTclTkSyn.IdentProc; +begin + while Identifiers[fLine[Run]] do inc(Run); + if IsKeyWord(GetToken) then begin + fTokenId := tkKey; + Exit; + end + else fTokenId := tkIdentifier; + if IsSecondKeyWord(GetToken) + then fTokenId := tkSecondKey + else fTokenId := tkIdentifier; +end; + +procedure TSynTclTkSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynTclTkSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynTclTkSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynTclTkSyn.RoundOpenProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynTclTkSyn.SlashProc; +begin + case FLine[Run + 1] of + '/': + begin + inc(Run, 2); + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; + end; + '*': + begin + inc(Run); + fTokenId := tkSymbol; + end; + else + begin + fTokenID := tkComment; + while FLine[Run] <> #0 do + begin + case FLine[Run] of + #10, #13: break; + end; + inc(Run); + end; + end; + end; +end; + +procedure TSynTclTkSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynTclTkSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) + then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until (FLine[Run] = #34) and (FLine[Pred(Run)] <> '\'); + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynTclTkSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnKnown; +end; + +procedure TSynTclTkSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsAnsi: AnsiProc; + rsPasStyle: PasStyleProc; + rsCStyle: CStyleProc; + else + fProcTable[fLine[Run]]; + end; +end; + +function TSynTclTkSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynTclTkSyn.GetEol: Boolean; +begin + Result := False; + if fTokenId = tkNull then Result := True; +end; + +function TSynTclTkSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynTclTkSyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynTclTkSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynTclTkSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkSecondKey: Result := fSecondKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynTclTkSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynTclTkSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynTclTkSyn.ResetRange; +begin + fRange := rsUnknown; +end; + +procedure TSynTclTkSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynTclTkSyn.SetKeyWords(const Value: TStrings); +var + i: Integer; +begin + if Value <> nil then + begin + Value.BeginUpdate; + for i := 0 to Value.Count - 1 do + Value[i] := UpperCase(Value[i]); + Value.EndUpdate; + end; + fKeyWords.Assign(Value); + DefHighLightChange(nil); +end; + +procedure TSynTclTkSyn.SetSecondKeys(const Value: TStrings); +var + i: Integer; +begin + if Value <> nil then + begin + Value.BeginUpdate; + for i := 0 to Value.Count - 1 do + Value[i] := UpperCase(Value[i]); + Value.EndUpdate; + end; + fSecondKeys.Assign(Value); + DefHighLightChange(nil); +end; + +function TSynTclTkSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterTclTk; +end; + +class function TSynTclTkSyn.GetLanguageName: string; +begin + Result := SYNS_LangTclTk; +end; + +{$IFNDEF SYN_LAZARUS} {$IFNDEF SYN_CLX} +function TSynTclTkSyn.LoadFromRegistry(RootKey: HKEY; Key: string): boolean; +var + r: TBetterRegistry; +begin + r:= TBetterRegistry.Create; + try + r.RootKey := RootKey; + if r.OpenKeyReadOnly(Key) then begin + if r.ValueExists('KeyWords') then KeyWords.Text:= r.ReadString('KeyWords'); + Result := inherited LoadFromRegistry(RootKey, Key); + end + else Result := false; + finally r.Free; end; +end; + +function TSynTclTkSyn.SaveToRegistry(RootKey: HKEY; Key: string): boolean; +var + r: TBetterRegistry; +begin + r:= TBetterRegistry.Create; + try + r.RootKey := RootKey; + if r.OpenKey(Key,true) then begin + Result := true; + r.WriteString('KeyWords', KeyWords.Text); + Result := inherited SaveToRegistry(RootKey, Key); + end + else Result := false; + finally r.Free; end; +end; +{$ENDIF} {$ENDIF} + +function TSynTclTkSyn.IsKeywordListStored: boolean; +var + iKeys: TStringList; + cDefKey: integer; + iIndex: integer; +begin + iKeys := TStringList.Create; + try + iKeys.Assign( KeyWords ); + iIndex := 0; + for cDefKey := Low(TclTkKeys) to High(TclTkKeys) do + begin + if not iKeys.Find( TclTkKeys[cDefKey], iIndex ) then + begin + Result := True; + Exit; + end; + iKeys.Delete( iIndex ); + end; + Result := iKeys.Count <> 0; + finally + iKeys.Free; + end; +end; + +function TSynTclTkSyn.GetSampleSource: string; +begin + Result := + '#!/usr/local/tclsh8.0'#13#10 + + 'if {$argc < 2} {'#13#10 + + ' puts stderr "Usage: $argv0 parameter"'#13#10 + + ' exit 1'#13#10 + + '}'; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynTclTkSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighterunreal.pas b/components/extrasyn/SyneditHighlighters/synhighlighterunreal.pas new file mode 100644 index 000000000..44394671a --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighterunreal.pas @@ -0,0 +1,1953 @@ +{------------------------------------------------------------------------------- +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. + PP - 2001/10/24: +The Original Code is based on the UnrealSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Dean Harmon. +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: SynHighlighterUnreal.pas,v 1.18 2005/01/28 16:53:25 maelh Exp $ + +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 Unreal syntax highlighter for SynEdit) +@author(Dean Harmon) +@created(2000) +@lastmod(2001-06-29) +} + +{$IFNDEF QSYNHIGHLIGHTERUNREAL} +unit SynHighlighterUnreal; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditHighlighter, + QSynEditTypes, +{$ELSE} + Graphics, + Registry, + Windows, // registry constants + SynEditHighlighter, + SynEditTypes, +{$ENDIF} + SysUtils, + Classes; + +const + MAXIDENTTABLE = 238; + +type + TtkTokenKind = ( + tkComment, + tkDirective, + tkIdentifier, + tkKey, + tkKey2, + tkNull, + tkNumber, + tkSpace, + tkString, + tkString2, + tkSymbol, + tkUnknown); + + TxtkTokenKind = ( + xtkAdd, xtkAddAssign, xtkAnd, xtkAndAssign, xtkArrow, xtkAssign, + xtkBitComplement, xtkBraceClose, xtkBraceOpen, xtkColon, xtkComma, + xtkDecrement, xtkDivide, xtkDivideAssign, xtkEllipse, xtkGreaterThan, + xtkGreaterThanEqual, xtkIncOr, xtkIncOrAssign, xtkIncrement, xtkLessThan, + xtkLessThanEqual, xtkLogAnd, xtkLogComplement, xtkLogEqual, xtkLogOr, + xtkMod, xtkModAssign, xtkMultiplyAssign, xtkNotEqual, xtkPoint, xtkQuestion, + xtkRoundClose, xtkRoundOpen, xtkScopeResolution, xtkSemiColon, xtkShiftLeft, + xtkShiftLeftAssign, xtkShiftRight, xtkShiftRightAssign, xtkSquareClose, + xtkSquareOpen, xtkStar, xtkSubtract, xtkSubtractAssign, xtkXor, + xtkXorAssign); + + TRangeState = (rsANil, rsAnsiC, rsDirective, rsDirectiveComment, rsUnKnown); + + TProcTableProc = procedure of Object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of Object; + + TSynUnrealSyn = class(TSynCustomHighlighter) + private + fRange: TRangeState; + fLine: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + FRoundCount: Integer; + FSquareCount: Integer; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + FExtTokenID: TxtkTokenKind; + fLineNumber: Integer; + fIdentFuncTable: array[0..MAXIDENTTABLE] of TIdentFuncTableFunc; + fCommentAttri: TSynHighlighterAttributes; + fDirecAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fInvalidAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fKey2Attri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fString2Attri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func15: TtkTokenKind; + function Func17: TtkTokenKind; + function Func19: TtkTokenKind; + function Func20: TtkTokenKind; + function Func28: TtkTokenKind; + function Func33: TtkTokenKind; + function Func35: TtkTokenKind; + function Func37: TtkTokenKind; + function Func39: TtkTokenKind; + function Func40: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func45: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func50: TtkTokenKind; + function Func51: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func59: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func65: TtkTokenKind; + function Func66: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func73: TtkTokenKind; + function Func74: TtkTokenKind; + function Func76: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func80: TtkTokenKind; + function Func81: TtkTokenKind; + function Func82: TtkTokenKind; + function Func83: TtkTokenKind; + function Func84: TtkTokenKind; + function Func85: TtkTokenKind; + function Func87: TtkTokenKind; + function Func89: TtkTokenKind; + function Func91: TtkTokenKind; + function Func92: TtkTokenKind; + function Func96: TtkTokenKind; + function Func97: TtkTokenKind; + function Func98: TtkTokenKind; + function Func99: TtkTokenKind; + function Func100: TtkTokenKind; + function Func101: TtkTokenKind; + function Func102: TtkTokenKind; + function Func103: TtkTokenKind; + function Func104: TtkTokenKind; + function Func106: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func109: TtkTokenKind; + function Func113: TtkTokenKind; + function Func115: TtkTokenKind; + function Func120: TtkTokenKind; + function Func122: TtkTokenKind; + function Func126: TtkTokenKind; + function Func127: TtkTokenKind; + function Func128: TtkTokenKind; + function Func135: TtkTokenKind; + function Func136: TtkTokenKind; + function Func143: TtkTokenKind; + function Func144: TtkTokenKind; + function Func146: TtkTokenKind; + function Func147: TtkTokenKind; + function Func148: TtkTokenKind; + function Func156: TtkTokenKind; + function Func167: TtkTokenKind; + function Func172: TtkTokenKind; + function Func174: TtkTokenKind; + function Func178: TtkTokenKind; + function Func185: TtkTokenKind; + function Func190: TtkTokenKind; + function Func192: TtkTokenKind; + function Func193: TtkTokenKind; + function Func210: TtkTokenKind; + function Func218: TtkTokenKind; + function Func238: TtkTokenKind; + + procedure AnsiCProc; + procedure AndSymbolProc; + procedure AsciiCharProc; + procedure BraceCloseProc; + procedure BraceOpenProc; + procedure CRProc; + procedure ColonProc; + procedure CommaProc; + procedure DirectiveProc; + procedure EqualProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NotSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure QuestionProc; + procedure RoundCloseProc; + procedure RoundOpenProc; + procedure SemiColonProc; + procedure SlashProc; + procedure SpaceProc; + procedure SquareCloseProc; + procedure SquareOpenProc; + procedure StarProc; + procedure StringProc; + procedure DollarSignProc; + procedure TildeProc; + procedure XOrSymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function GetExtTokenID: TxtkTokenKind; + function IsFilterStored: Boolean; override; + function GetSampleSource: string; override; + public + class function GetCapabilities: TSynHighlighterCapabilities; override; + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetRange: Pointer; override; + function GetTokenID: TtkTokenKind; + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + procedure SetRange(Value: Pointer); override; + procedure ResetRange; override; + function UseUserSettings(settingIndex: integer): boolean; override; + procedure EnumUserSettings(settings: TStrings); override; + property ExtTokenID: TxtkTokenKind read GetExtTokenID; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property DirecAttri: TSynHighlighterAttributes read fDirecAttri + write fDirecAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property InvalidAttri: TSynHighlighterAttributes read fInvalidAttri + write fInvalidAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property Key2Attri: TSynHighlighterAttributes read fKey2Attri write fKey2Attri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SingleStringAttri: TSynHighlighterAttributes read fString2Attri + write fString2Attri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst, SynEditStrConstExtra; +{$ENDIF} + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + Case I in['_', 'a'..'z', 'A'..'Z'] of + True: + begin + if (I > #64) and (I < #91) then mHashTable[I] := Ord(I) - 64 else + if (I > #96) then mHashTable[I] := Ord(I) - 96; + end; + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynUnrealSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := {$IFDEF FPC}@{$ENDIF}AltFunc; + Inc(pF); + end; + fIdentFuncTable[15] := {$IFDEF FPC}@{$ENDIF} Func15; + fIdentFuncTable[17] := {$IFDEF FPC}@{$ENDIF} Func17; + fIdentFuncTable[19] := {$IFDEF FPC}@{$ENDIF} Func19; + fIdentFuncTable[20] := {$IFDEF FPC}@{$ENDIF} Func20; + fIdentFuncTable[28] := {$IFDEF FPC}@{$ENDIF} Func28; + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF} Func33; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF} Func35; + fIdentFuncTable[37] := {$IFDEF FPC}@{$ENDIF} Func37; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF} Func39; + fIdentFuncTable[40] := {$IFDEF FPC}@{$ENDIF} Func40; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[42] := {$IFDEF FPC}@{$ENDIF} Func42; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF} Func44; + fIdentFuncTable[45] := {$IFDEF FPC}@{$ENDIF} Func45; + fIdentFuncTable[48] := {$IFDEF FPC}@{$ENDIF} Func48; + fIdentFuncTable[49] := {$IFDEF FPC}@{$ENDIF} Func49; + fIdentFuncTable[50] := {$IFDEF FPC}@{$ENDIF} Func50; + fIdentFuncTable[51] := {$IFDEF FPC}@{$ENDIF} Func51; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF} Func52; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF} Func53; + fIdentFuncTable[54] := {$IFDEF FPC}@{$ENDIF} Func54; + fIdentFuncTable[55] := {$IFDEF FPC}@{$ENDIF} Func55; + fIdentFuncTable[56] := {$IFDEF FPC}@{$ENDIF} Func56; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF} Func57; + fIdentFuncTable[59] := {$IFDEF FPC}@{$ENDIF} Func59; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF} Func62; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF} Func63; + fIdentFuncTable[64] := {$IFDEF FPC}@{$ENDIF} Func64; + fIdentFuncTable[65] := {$IFDEF FPC}@{$ENDIF} Func65; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[69] := {$IFDEF FPC}@{$ENDIF} Func69; + fIdentFuncTable[70] := {$IFDEF FPC}@{$ENDIF} Func70; + fIdentFuncTable[71] := {$IFDEF FPC}@{$ENDIF} Func71; + fIdentFuncTable[72] := {$IFDEF FPC}@{$ENDIF} Func72; + fIdentFuncTable[73] := {$IFDEF FPC}@{$ENDIF} Func73; + fIdentFuncTable[74] := {$IFDEF FPC}@{$ENDIF} Func74; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF} Func76; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF} Func78; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF} Func79; + fIdentFuncTable[80] := {$IFDEF FPC}@{$ENDIF} Func80; + fIdentFuncTable[81] := {$IFDEF FPC}@{$ENDIF} Func81; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF} Func82; + fIdentFuncTable[83] := {$IFDEF FPC}@{$ENDIF} Func83; + fIdentFuncTable[84] := {$IFDEF FPC}@{$ENDIF} Func84; + fIdentFuncTable[85] := {$IFDEF FPC}@{$ENDIF} Func85; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF} Func87; + fIdentFuncTable[89] := {$IFDEF FPC}@{$ENDIF} Func89; + fIdentFuncTable[91] := {$IFDEF FPC}@{$ENDIF} Func91; + fIdentFuncTable[92] := {$IFDEF FPC}@{$ENDIF} Func92; + fIdentFuncTable[96] := {$IFDEF FPC}@{$ENDIF} Func96; + fIdentFuncTable[97] := {$IFDEF FPC}@{$ENDIF} Func97; + fIdentFuncTable[98] := {$IFDEF FPC}@{$ENDIF} Func98; + fIdentFuncTable[99] := {$IFDEF FPC}@{$ENDIF} Func99; + fIdentFuncTable[100] := {$IFDEF FPC}@{$ENDIF} Func100; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF} Func101; + fIdentFuncTable[102] := {$IFDEF FPC}@{$ENDIF} Func102; + fIdentFuncTable[103] := {$IFDEF FPC}@{$ENDIF} Func103; + fIdentFuncTable[104] := {$IFDEF FPC}@{$ENDIF} Func104; + fIdentFuncTable[106] := {$IFDEF FPC}@{$ENDIF} Func106; + fIdentFuncTable[107] := {$IFDEF FPC}@{$ENDIF} Func107; + fIdentFuncTable[108] := {$IFDEF FPC}@{$ENDIF} Func108; + fIdentFuncTable[109] := {$IFDEF FPC}@{$ENDIF} Func109; + fIdentFuncTable[113] := {$IFDEF FPC}@{$ENDIF} Func113; + fIdentFuncTable[115] := {$IFDEF FPC}@{$ENDIF} Func115; + fIdentFuncTable[120] := {$IFDEF FPC}@{$ENDIF} Func120; + fIdentFuncTable[122] := {$IFDEF FPC}@{$ENDIF} Func122; + fIdentFuncTable[126] := {$IFDEF FPC}@{$ENDIF} Func126; + fIdentFuncTable[127] := {$IFDEF FPC}@{$ENDIF} Func127; + fIdentFuncTable[128] := {$IFDEF FPC}@{$ENDIF} Func128; + fIdentFuncTable[135] := {$IFDEF FPC}@{$ENDIF} Func135; + fIdentFuncTable[136] := {$IFDEF FPC}@{$ENDIF} Func136; + fIdentFuncTable[143] := {$IFDEF FPC}@{$ENDIF} Func143; + fIdentFuncTable[144] := {$IFDEF FPC}@{$ENDIF} Func144; + fIdentFuncTable[146] := {$IFDEF FPC}@{$ENDIF} Func146; + fIdentFuncTable[147] := {$IFDEF FPC}@{$ENDIF} Func147; + fIdentFuncTable[148] := {$IFDEF FPC}@{$ENDIF} Func148; + fIdentFuncTable[156] := {$IFDEF FPC}@{$ENDIF} Func156; + fIdentFuncTable[167] := {$IFDEF FPC}@{$ENDIF} Func167; + fIdentFuncTable[172] := {$IFDEF FPC}@{$ENDIF} Func172; + fIdentFuncTable[174] := {$IFDEF FPC}@{$ENDIF} Func174; + fIdentFuncTable[178] := {$IFDEF FPC}@{$ENDIF} Func178; + fIdentFuncTable[185] := {$IFDEF FPC}@{$ENDIF} Func185; + fIdentFuncTable[190] := {$IFDEF FPC}@{$ENDIF} Func190; + fIdentFuncTable[192] := {$IFDEF FPC}@{$ENDIF} Func192; + fIdentFuncTable[193] := {$IFDEF FPC}@{$ENDIF} Func193; + fIdentFuncTable[210] := {$IFDEF FPC}@{$ENDIF} Func210; + fIdentFuncTable[218] := {$IFDEF FPC}@{$ENDIF} Func218; + fIdentFuncTable[238] := {$IFDEF FPC}@{$ENDIF} Func238; +end; + +function TSynUnrealSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + + while ToHash^ in TSynValidStringChars do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; { KeyHash } + +function TSynUnrealSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Uppercase(Temp^) <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; { KeyComp } + +function TSynUnrealSyn.Func15: TtkTokenKind; +begin + if KeyComp('IF') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func17: TtkTokenKind; +begin + if KeyComp('EACH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func19: TtkTokenKind; +begin + if KeyComp('DO') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func20: TtkTokenKind; +begin + if KeyComp('CACHE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func28: TtkTokenKind; +begin + if KeyComp('CASE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func33: TtkTokenKind; +begin + if KeyComp('NAME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func35: TtkTokenKind; +begin + if KeyComp('CATCH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func37: TtkTokenKind; +begin + if KeyComp('BREAK') then Result := tkKey else + if KeyComp('EXEC') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func39: TtkTokenKind; +begin + if KeyComp('DOT') then Result := tkSymbol else + if KeyComp('FOR') then Result := tkKey else + if KeyComp('RNG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func40: TtkTokenKind; +begin + if KeyComp('SCALE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func41: TtkTokenKind; +begin + if KeyComp('ELSE') then Result := tkKey else + if KeyComp('VAR') then Result := tkKey else + if KeyComp('GUID') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func42: TtkTokenKind; +begin + if KeyComp('FINAL') then Result := tkKey2 else + if KeyComp('FOR') then Result := tkKey else + if KeyComp('SELF') then Result := tkKey else + if KeyComp('NEW') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func43: TtkTokenKind; +begin + if KeyComp('NEW') then Result := tkKey else + if KeyComp('INT') then Result := tkKey else + if KeyComp('SELF') then Result := tkKey else + if KeyComp('LOCAL') then Result := tkKey else + if KeyComp('FALSE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func44: TtkTokenKind; +begin + if KeyComp('FALSE') then Result := tkKey else + if KeyComp('BOOL') then Result := tkKey else + if KeyComp('LOCAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func45: TtkTokenKind; +begin + if KeyComp('BOOL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func48: TtkTokenKind; +begin + if KeyComp('MESH') then Result := tkKey else + if KeyComp('LONG') then Result := tkKey else + if KeyComp('NONE') then Result := tkKey else + if KeyComp('PLANE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func49: TtkTokenKind; +begin + if KeyComp('GLOBAL') then Result := tkKey else + if KeyComp('MODEL') then Result := tkKey else + if KeyComp('COERCE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func50: TtkTokenKind; +begin + if KeyComp('VOID') then Result := tkKey else + if KeyComp('VECT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func51: TtkTokenKind; +begin + if KeyComp('DELETE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func52: TtkTokenKind; +begin + if KeyComp('BYTE') then Result := tkKey else + if KeyComp('INIT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func53: TtkTokenKind; +begin + if KeyComp('ENUM') then Result := tkKey else + if KeyComp('ROT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func54: TtkTokenKind; +begin + if KeyComp('CLASS') then Result := tkKey else + if KeyComp('CONFIG') then Result := tkKey else + if KeyComp('FLOAT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func55: TtkTokenKind; +begin + if KeyComp('SKIP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func56: TtkTokenKind; +begin + if KeyComp('FOREACH') then Result := tkKey else + if KeyComp('OUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func57: TtkTokenKind; +begin + if KeyComp('AUTO') then Result := tkKey else + if KeyComp('GOTO') then Result := tkKey else + if KeyComp('WHILE') then Result := tkKey else + if KeyComp('PLACEABLE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func59: TtkTokenKind; +begin + if KeyComp('DELEGATE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func62: TtkTokenKind; +begin + if KeyComp('EDFINDABLE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func63: TtkTokenKind; +begin + if KeyComp('COLOR') then Result := tkKey else + if KeyComp('ARRAY') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func64: TtkTokenKind; +begin + if KeyComp('TRUE') then Result := tkKey else + if KeyComp('RELIABLE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func65: TtkTokenKind; +begin + if KeyComp('STATE') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func66: TtkTokenKind; +begin + if KeyComp('EVENT') then Result := tkKey else + if KeyComp('LENGTH') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func69: TtkTokenKind; +begin + if KeyComp('DEFAULT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func70: TtkTokenKind; +begin + if KeyComp('STOP') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func71: TtkTokenKind; +begin + if KeyComp('CONST') then Result := tkKey2 else + if KeyComp('NATIVE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func72: TtkTokenKind; +begin + if KeyComp('LATENT') then Result := tkKey2 else + if KeyComp('STATIC') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func73: TtkTokenKind; +begin + if KeyComp('SOUND') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func74: TtkTokenKind; +begin + if KeyComp('CROSS') then Result := tkSymbol else + if KeyComp('MUTABLE') then Result := tkKey else + if KeyComp('COORDS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func76: TtkTokenKind; +begin + if KeyComp('UNTIL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func78: TtkTokenKind; +begin + if KeyComp('TRAVEL') then Result := tkKey else + if KeyComp('REMOVE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func79: TtkTokenKind; +begin + if KeyComp('SUPER') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func80: TtkTokenKind; +begin + if KeyComp('INPUT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func81: TtkTokenKind; +begin + if KeyComp('DEPRECATED') then Result := tkKey2 else + if KeyComp('ALWAYS') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func82: TtkTokenKind; +begin + if KeyComp('SWITCH') then Result := tkKey else + if KeyComp('ASSERT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func83: TtkTokenKind; +begin + if KeyComp('EXPANDS') then Result := tkKey else + if KeyComp('VECTOR') then Result := tkKey else + if KeyComp('WITHIN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func84: TtkTokenKind; +begin + if KeyComp('ABSTRACT') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func85: TtkTokenKind; +begin + if KeyComp('INSERT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func87: TtkTokenKind; +begin + if KeyComp('LOCALIZED') then Result := tkKey2 else + if KeyComp('STRING') then Result := tkKey else + if KeyComp('IGNORES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func89: TtkTokenKind; +begin + if KeyComp('INSTANCED') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func91: TtkTokenKind; +begin + if KeyComp('EXTENDS') then Result := tkKey else + if KeyComp('PRIVATE') then Result := tkKey2 else + if KeyComp('SAFEREPLACE') then Result := tkKey2 else + if KeyComp('IMPORT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func92: TtkTokenKind; +begin + if KeyComp('BUTTON') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func96: TtkTokenKind; +begin + if KeyComp('RETURN') then Result := tkKey else + if KeyComp('DEPENDSON') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func97: TtkTokenKind; +begin + if KeyComp('POINTER') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func98: TtkTokenKind; +begin + if KeyComp('EXPLICIT') then Result := tkKey else + if KeyComp('EXPORT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func99: TtkTokenKind; +begin + if KeyComp('UNRELIABLE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func100: TtkTokenKind; +begin + if KeyComp('HIDEPARENT') then Result := tkKey else + if KeyComp('AUTOMATED') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func101: TtkTokenKind; +begin + if KeyComp('CONTINUE') then Result := tkKey else + if KeyComp('REGISTER') then Result := tkKey else + if KeyComp('STRUCT') then Result := tkKey else + if KeyComp('SINGULAR') then Result := tkKey2 else + if KeyComp('EDITINLINE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func102: TtkTokenKind; +begin + if KeyComp('FUNCTION') then Result := tkKey else + if KeyComp('OPTIONAL') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func103: TtkTokenKind; +begin + if KeyComp('GLOBALCONFIG') then Result := tkKey else + if KeyComp('CACHEEXEMPT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func104: TtkTokenKind; +begin + if KeyComp('SIMULATED') then Result := tkKey2 else + if KeyComp('CPPTEXT') then Result := tkKey else Result := tkIdentifier; + +end; + +function TSynUnrealSyn.Func106: TtkTokenKind; +begin + if KeyComp('ITERATOR') then Result := tkKey else + if KeyComp('PROTECTED') then Result := tkKey2 else + if KeyComp('NOTPLACEABLE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func107: TtkTokenKind; +begin + if KeyComp('ROTATOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func108: TtkTokenKind; +begin + if KeyComp('OPERATOR') then Result := tkKey else + if KeyComp('INVARIANT') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func109: TtkTokenKind; +begin + if KeyComp('EDITCONST') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func113: TtkTokenKind; +begin + if KeyComp('TEXTURE') then Result := tkKey else + if KeyComp('PARSECONFIG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func115: TtkTokenKind; +begin + if KeyComp('INTRINSIC') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func120: TtkTokenKind; +begin + if KeyComp('TRANSIENT') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func122: TtkTokenKind; +begin + if KeyComp('REPLICATION') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func126: TtkTokenKind; +begin + if KeyComp('ENUMCOUNT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func127: TtkTokenKind; +begin + if KeyComp('NOEXPORT') then Result := tkKey2 else + if KeyComp('BOUNDINGBOX') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func128: TtkTokenKind; +begin + if KeyComp('HIDECATEGORIES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func135: TtkTokenKind; +begin + if KeyComp('HIDEDROPDOWN') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func136: TtkTokenKind; +begin + if KeyComp('ARRAYCOUNT') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func143: TtkTokenKind; +begin + if KeyComp('EDITINLINENEW') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func144: TtkTokenKind; +begin + if KeyComp('NOUSERCREATE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func146: TtkTokenKind; +begin + if KeyComp('EDITINLINEUSE') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func147: TtkTokenKind; +begin + if KeyComp('PREOPERATOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func148: TtkTokenKind; +begin + if KeyComp('PEROBJECTCONFIG') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func156: TtkTokenKind; +begin + if KeyComp('SCRIPTCONST') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func167: TtkTokenKind; +begin + if KeyComp('SHOWCATEGORIES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func172: TtkTokenKind; +begin + if KeyComp('EDITCONSTARRAY') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func174: TtkTokenKind; +begin + if KeyComp('BOUNDINGVOLUME') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func178: TtkTokenKind; +begin + if KeyComp('POSTOPERATOR') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func185: TtkTokenKind; +begin + if KeyComp('COLLAPSECATEGORIES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func190: TtkTokenKind; +begin + if KeyComp('EDITINLINENOTIFY') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func192: TtkTokenKind; +begin + if KeyComp('DONTCOLLAPSECATEGORIES') then Result := tkKey else + if KeyComp('NOTEDITINLINENEW') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func193: TtkTokenKind; +begin + if KeyComp('NATIVEREPLICATION') then Result := tkKey2 else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func210: TtkTokenKind; +begin + if KeyComp('DEFAULTPROPERTIES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func218: TtkTokenKind; +begin + if KeyComp('EXPORTSTRUCTS') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.Func238: TtkTokenKind; +begin + if KeyComp('DONTCOLLAPSECATEGORIES') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynUnrealSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynUnrealSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < MAXIDENTTABLE + 1 then Result := fIdentFuncTable[HashKey]{$IFDEF FPC}(){$ENDIF} else Result := tkIdentifier; +end; + +procedure TSynUnrealSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + '&': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} AndSymbolProc; + #39: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} AsciiCharProc; + '}': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} BraceCloseProc; + '{': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} BraceOpenProc; + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CRProc; + ':': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} ColonProc; + ',': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CommaProc; + '#': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} DirectiveProc; + '=': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} EqualProc; + '>': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} GreaterProc; + '?': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} QuestionProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} IdentProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LFProc; + '<': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LowerProc; + '-': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} MinusProc; + '%': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} ModSymbolProc; + '!': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NotSymbolProc; + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NullProc; + '0'..'9': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NumberProc; + '|': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} OrSymbolProc; + '+': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} PlusProc; + '.': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} PointProc; + ')': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} RoundCloseProc; + '(': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} RoundOpenProc; + ';': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SemiColonProc; + '/': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SlashProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SpaceProc; + ']': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SquareCloseProc; + '[': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SquareOpenProc; + '*': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StarProc; + #34: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StringProc; + '$', '@': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} DollarSignProc; + '~': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} TildeProc; + '^': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} XOrSymbolProc; + else fProcTable[I] := {$IFDEF FPC}@{$ENDIF} UnknownProc; + end; +end; + +constructor TSynUnrealSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style:= [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fInvalidAttri := TSynHighlighterAttributes.Create(SYNS_AttrIllegalChar); + AddAttribute(fInvalidAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style:= [fsBold]; + AddAttribute(fKeyAttri); + fKey2Attri := TSynHighlighterAttributes.Create(SYNS_AttrSecondReservedWord); + fKey2Attri.Style:= [fsBold]; + AddAttribute(fKey2Attri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + fSpaceAttri.Foreground := clWindow; + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fString2Attri := TSynHighlighterAttributes.Create(SYNS_AttrSingleString); + AddAttribute(fString2Attri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + fDirecAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective); + AddAttribute(fDirecAttri); + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + InitIdent; + MakeMethodTables; + fRange := rsUnknown; + fDefaultFilter := SYNS_FilterCPP; +end; { Create } + +{$IFDEF SYN_LAZARUS} +procedure TSynUnrealSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynUnrealSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; { SetLine } + +procedure TSynUnrealSyn.AnsiCProc; +begin + fTokenID := tkComment; + case FLine[Run] of + #0: + begin + NullProc; + exit; + end; + #10: + begin + LFProc; + exit; + end; + #13: + begin + CRProc; + exit; + end; + end; + + while FLine[Run] <> #0 do + case FLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + inc(Run, 2); + if fRange = rsDirectiveComment then + fRange := rsDirective + else + fRange := rsUnKnown; + break; + end else + inc(Run); + #10: break; + #13: break; + else inc(Run); + end; +end; + +procedure TSynUnrealSyn.AndSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {and assign} + begin + inc(Run, 2); + FExtTokenID := xtkAndAssign; + end; + '&': {logical and} + begin + inc(Run, 2); + FExtTokenID := xtkLogAnd; + end; + else {and} + begin + inc(Run); + FExtTokenID := xtkAnd; + end; + end; +end; + +procedure TSynUnrealSyn.AsciiCharProc; +begin + fTokenID := tkString2; + repeat + case FLine[Run] of + #0, #10, #13: break; + #92: {backslash} + {if we have an escaped single quote it doesn't count} + if FLine[Run + 1] = #39 then inc(Run); + end; + inc(Run); + until FLine[Run] = #39; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynUnrealSyn.BraceCloseProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceClose; +end; + +procedure TSynUnrealSyn.BraceOpenProc; +begin + inc(Run); + fTokenId := tkSymbol; + FExtTokenID := xtkBraceOpen; +end; + +procedure TSynUnrealSyn.CRProc; +begin + fTokenID := tkSpace; + Inc(Run); + if fLine[Run + 1] = #10 then Inc(Run); +end; + +procedure TSynUnrealSyn.ColonProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + ':': {scope resolution operator} + begin + inc(Run, 2); + FExtTokenID := xtkScopeResolution; + end; + else {colon} + begin + inc(Run); + FExtTokenID := xtkColon; + end; + end; +end; + +procedure TSynUnrealSyn.CommaProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkComma; +end; + +procedure TSynUnrealSyn.DirectiveProc; +begin + if fLine[Run] in [#0, #10, #13] then begin + if (Run <= 0) then + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end else begin + fTokenID := tkDirective; + while TRUE do + case fLine[Run] of + '/': // comment? + begin + if fLine[Run + 1] = '/' then // is end of directive as well + break + else if fLine[Run + 1] = '*' then begin // might be embedded only + fRange := rsDirectiveComment; + break; + end else + Inc(Run); + end; + #0, #10, #13: + begin + fRange := rsUnknown; + break; + end; + else Inc(Run); + end; + end; +end; + +procedure TSynUnrealSyn.EqualProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {logical equal} + begin + inc(Run, 2); + FExtTokenID := xtkLogEqual; + end; + else {assign} + begin + inc(Run); + FExtTokenID := xtkAssign; + end; + end; +end; + +procedure TSynUnrealSyn.GreaterProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {greater than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkGreaterThanEqual; + end; + '>': + begin + if FLine[Run + 2] = '=' then {shift right assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftRightAssign; + end + else {shift right} + begin + inc(Run, 2); + FExtTokenID := xtkShiftRight; + end; + end; + else {greater than} + begin + inc(Run); + FExtTokenID := xtkGreaterThan; + end; + end; +end; + +procedure TSynUnrealSyn.QuestionProc; +begin + fTokenID := tkSymbol; {conditional} + FExtTokenID := xtkQuestion; + inc(Run); +end; + +procedure TSynUnrealSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynUnrealSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynUnrealSyn.LowerProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {less than or equal to} + begin + inc(Run, 2); + FExtTokenID := xtkLessThanEqual; + end; + '<': + begin + if FLine[Run + 2] = '=' then {shift left assign} + begin + inc(Run, 3); + FExtTokenID := xtkShiftLeftAssign; + end + else {shift left} + begin + inc(Run, 2); + FExtTokenID := xtkShiftLeft; + end; + end; + else {less than} + begin + inc(Run); + FExtTokenID := xtkLessThan; + end; + end; +end; + +procedure TSynUnrealSyn.MinusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {subtract assign} + begin + inc(Run, 2); + FExtTokenID := xtkSubtractAssign; + end; + '-': {decrement} + begin + inc(Run, 2); + FExtTokenID := xtkDecrement; + end; + '>': {arrow} + begin + inc(Run, 2); + FExtTokenID := xtkArrow; + end; + else {subtract} + begin + inc(Run); + FExtTokenID := xtkSubtract; + end; + end; +end; + +procedure TSynUnrealSyn.ModSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {mod assign} + begin + inc(Run, 2); + FExtTokenID := xtkModAssign; + end; + else {mod} + begin + inc(Run); + FExtTokenID := xtkMod; + end; + end; +end; + +procedure TSynUnrealSyn.NotSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {not equal} + begin + inc(Run, 2); + FExtTokenID := xtkNotEqual; + end; + else {not} + begin + inc(Run); + FExtTokenID := xtkLogComplement; + end; + end; +end; + +procedure TSynUnrealSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynUnrealSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in + ['0'..'9', 'A'..'F', 'a'..'f', '.', 'u', 'U', 'l', 'L', 'x', 'X'] do + begin + case FLine[Run] of + '.': + if FLine[Run + 1] = '.' then break; + end; + inc(Run); + end; +end; + +procedure TSynUnrealSyn.OrSymbolProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {or assign} + begin + inc(Run, 2); + FExtTokenID := xtkIncOrAssign; + end; + '|': {logical or} + begin + inc(Run, 2); + FExtTokenID := xtkLogOr; + end; + else {or} + begin + inc(Run); + FExtTokenID := xtkIncOr; + end; + end; +end; + +procedure TSynUnrealSyn.PlusProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {add assign} + begin + inc(Run, 2); + FExtTokenID := xtkAddAssign; + end; + '+': {increment} + begin + inc(Run, 2); + FExtTokenID := xtkIncrement; + end; + else {add} + begin + inc(Run); + FExtTokenID := xtkAdd; + end; + end; +end; + +procedure TSynUnrealSyn.PointProc; +begin + fTokenID := tkSymbol; + if (FLine[Run + 1] = '.') and (FLine[Run + 2] = '.') then + begin {ellipse} + inc(Run, 3); + FExtTokenID := xtkEllipse; + end + else {point} + begin + inc(Run); + FExtTokenID := xtkPoint; + end; +end; + +procedure TSynUnrealSyn.RoundCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkRoundClose; + dec(FRoundCount); +end; + +procedure TSynUnrealSyn.RoundOpenProc; +begin + inc(Run); + FTokenID := tkSymbol; + FExtTokenID := xtkRoundOpen; + inc(FRoundCount); +end; + +procedure TSynUnrealSyn.SemiColonProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSemiColon; +end; + +procedure TSynUnrealSyn.SlashProc; +begin + case FLine[Run + 1] of + '/': {c++ style comments} + begin + fTokenID := tkComment; + inc(Run, 2); + while not (fLine[Run] in [#0, #10, #13]) do Inc(Run); + end; + '*': {c style comments} + begin + fTokenID := tkComment; + if fRange <> rsDirectiveComment then + fRange := rsAnsiC; + inc(Run, 2); + while fLine[Run] <> #0 do + case fLine[Run] of + '*': + if fLine[Run + 1] = '/' then + begin + inc(Run, 2); + if fRange = rsDirectiveComment then + fRange := rsDirective + else + fRange := rsUnKnown; + break; + end else inc(Run); + #10, #13: + begin + if fRange = rsDirectiveComment then + fRange := rsAnsiC; + break; + end; + else inc(Run); + end; + end; + '=': {divide assign} + begin + inc(Run, 2); + fTokenID := tkSymbol; + FExtTokenID := xtkDivideAssign; + end; + else {divide} + begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkDivide; + end; + end; +end; + +procedure TSynUnrealSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynUnrealSyn.SquareCloseProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareClose; + dec(FSquareCount); +end; + +procedure TSynUnrealSyn.SquareOpenProc; +begin + inc(Run); + fTokenID := tkSymbol; + FExtTokenID := xtkSquareOpen; + inc(FSquareCount); +end; + +procedure TSynUnrealSyn.StarProc; +begin + fTokenID := tkSymbol; + case FLine[Run + 1] of + '=': {multiply assign} + begin + inc(Run, 2); + FExtTokenID := xtkMultiplyAssign; + end; + else {star} + begin + inc(Run); + FExtTokenID := xtkStar; + end; + end; +end; + +procedure TSynUnrealSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + #92: {backslash} + case FLine[Run + 1] of + #10: inc(Run); {line continuation character} + #34: inc(Run); {escaped quote doesn't count} + #92: inc(Run); + end; + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynUnrealSyn.DollarSignProc; +begin + fTokenID := tkSymbol; + inc(run); +end; + + +procedure TSynUnrealSyn.TildeProc; +begin + inc(Run); {bitwise complement} + fTokenId := tkSymbol; + FExtTokenID := xtkBitComplement; +end; + +procedure TSynUnrealSyn.XOrSymbolProc; +begin + fTokenID := tkSymbol; + Case FLine[Run + 1] of + '=': {xor assign} + begin + inc(Run, 2); + FExtTokenID := xtkXorAssign; + end; + else {xor} + begin + inc(Run); + FExtTokenID := xtkXor; + end; + end; +end; + +procedure TSynUnrealSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynUnrealSyn.Next; +begin + fTokenPos := Run; + case fRange of + rsAnsiC, rsDirectiveComment: AnsiCProc; + rsDirective: DirectiveProc; + else + begin + fRange := rsUnknown; + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynUnrealSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT : Result := fCommentAttri; + SYN_ATTR_KEYWORD : Result := fKeyAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_STRING : Result := fStringAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_SYMBOL : Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynUnrealSyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynUnrealSyn.GetRange: Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynUnrealSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynUnrealSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynUnrealSyn.GetExtTokenID: TxtkTokenKind; +begin + Result := FExtTokenID; +end; + + +function TSynUnrealSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterCPP; +end; { IsFilterStored } + + +function TSynUnrealSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkDirective: Result := fDirecAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkKey2: Result := fKey2Attri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkString2: Result := fString2Attri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fInvalidAttri; + else Result := nil; + end; +end; + +function TSynUnrealSyn.GetTokenKind: integer; +begin + Result := Ord(GetTokenID); +end; + +function TSynUnrealSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +procedure TSynUnrealSyn.ResetRange; +begin + fRange:= rsUnknown; +end; + +procedure TSynUnrealSyn.SetRange(Value: Pointer); +begin + fRange := TRangeState(Value); +end; + +procedure TSynUnrealSyn.EnumUserSettings(settings: TStrings); +begin + { returns the user settings that exist in the registry } +{$IFNDEF SYN_LAZARUS} + {$IFNDEF SYN_CLX} + with TBetterRegistry.Create do + begin + try + RootKey := HKEY_LOCAL_MACHINE; + if OpenKeyReadOnly('\SOFTWARE\Borland\C++Builder') then + begin + try + GetKeyNames(settings); + finally + CloseKey; + end; + end; + finally + Free; + end; + end; + {$ENDIF} +{$ENDIF} +end; + +function TSynUnrealSyn.UseUserSettings(settingIndex: integer): boolean; +// Possible parameter values: +// index into TStrings returned by EnumUserSettings +// Possible return values: +// true : settings were read and used +// false: problem reading settings or invalid version specified - old settings +// were preserved +{$IFNDEF SYN_LAZARUS} + {$IFNDEF SYN_CLX} + function ReadCPPBSettings(settingIndex: integer): boolean; + + function ReadCPPBSetting(settingTag: string; attri: TSynHighlighterAttributes; key: string): boolean; + + function ReadCPPB1(settingTag: string; attri: TSynHighlighterAttributes; name: string): boolean; + var + i: integer; + begin + for i := 1 to Length(name) do + if name[i] = ' ' then name[i] := '_'; + Result := attri.LoadFromBorlandRegistry(HKEY_CURRENT_USER, + '\SOFTWARE\Borland\C++Builder\'+settingTag+'\Highlight',name,true); + end; { ReadCPPB1 } + + function ReadCPPB3OrMore(settingTag: string; attri: TSynHighlighterAttributes; key: string): boolean; + begin + Result := attri.LoadFromBorlandRegistry(HKEY_CURRENT_USER, + '\Software\Borland\C++Builder\'+settingTag+'\Editor\Highlight', + key,false); + end; { ReadCPPB3OrMore } + + begin { ReadCPPBSetting } + try + if (settingTag[1] = '1') + then Result := ReadCPPB1(settingTag,attri,key) + else Result := ReadCPPB3OrMore(settingTag,attri,key); + except Result := false; end; + end; { ReadCPPBSetting } + + var + tmpStringAttri : TSynHighlighterAttributes; + tmpNumberAttri : TSynHighlighterAttributes; + tmpKeyAttri : TSynHighlighterAttributes; + tmpSymbolAttri : TSynHighlighterAttributes; + tmpCommentAttri : TSynHighlighterAttributes; + tmpIdentifierAttri: TSynHighlighterAttributes; + tmpInvalidAttri : TSynHighlighterAttributes; + tmpSpaceAttri : TSynHighlighterAttributes; + tmpDirecAttri : TSynHighlighterAttributes; + s : TStringList; + + begin { ReadCPPBSettings } + s := TStringList.Create; + try + EnumUserSettings(s); + if settingIndex >= s.Count then Result := false + else begin + tmpStringAttri := TSynHighlighterAttributes.Create(''); + tmpNumberAttri := TSynHighlighterAttributes.Create(''); + tmpKeyAttri := TSynHighlighterAttributes.Create(''); + tmpSymbolAttri := TSynHighlighterAttributes.Create(''); + tmpCommentAttri := TSynHighlighterAttributes.Create(''); + tmpIdentifierAttri:= TSynHighlighterAttributes.Create(''); + tmpInvalidAttri := TSynHighlighterAttributes.Create(''); + tmpSpaceAttri := TSynHighlighterAttributes.Create(''); + tmpDirecAttri := TSynHighlighterAttributes.Create(''); + tmpStringAttri .Assign(fStringAttri); + tmpNumberAttri .Assign(fNumberAttri); + tmpKeyAttri .Assign(fKeyAttri); + tmpSymbolAttri .Assign(fSymbolAttri); + tmpCommentAttri .Assign(fCommentAttri); + tmpIdentifierAttri.Assign(fIdentifierAttri); + tmpInvalidAttri .Assign(fInvalidAttri); + tmpSpaceAttri .Assign(fSpaceAttri); + tmpDirecAttri .Assign(fDirecAttri); + Result := ReadCPPBSetting(s[settingIndex],fCommentAttri,'Comment') and + ReadCPPBSetting(s[settingIndex],fIdentifierAttri,'Identifier') and + ReadCPPBSetting(s[settingIndex],fInvalidAttri,'Illegal Char') and + ReadCPPBSetting(s[settingIndex],fKeyAttri,'Reserved word') and + ReadCPPBSetting(s[settingIndex],fNumberAttri,'Integer') and + ReadCPPBSetting(s[settingIndex],fSpaceAttri,'Whitespace') and + ReadCPPBSetting(s[settingIndex],fStringAttri,'String') and + ReadCPPBSetting(s[settingIndex],fSymbolAttri,'Symbol') and + ReadCPPBSetting(s[settingIndex],fDirecAttri,'Preprocessor'); + if not Result then begin + fStringAttri .Assign(tmpStringAttri); + fString2Attri .Assign(tmpStringAttri); + fNumberAttri .Assign(tmpNumberAttri); + fKeyAttri .Assign(tmpKeyAttri); + fKey2Attri .Assign(tmpKeyAttri); + fSymbolAttri .Assign(tmpSymbolAttri); + fCommentAttri .Assign(tmpCommentAttri); + fIdentifierAttri.Assign(tmpIdentifierAttri); + fInvalidAttri.Assign(tmpInvalidAttri); + fSpaceAttri .Assign(tmpSpaceAttri); + fDirecAttri .Assign(tmpDirecAttri); + end; + tmpStringAttri .Free; + tmpNumberAttri .Free; + tmpKeyAttri .Free; + tmpSymbolAttri .Free; + tmpCommentAttri .Free; + tmpIdentifierAttri.Free; + tmpInvalidAttri .Free; + tmpSpaceAttri .Free; + tmpDirecAttri .Free; + end; + finally s.Free; end; + end; { ReadCPPBSettings } + {$ENDIF} +{$ENDIF} + +begin +{$IFDEF SYN_CLX} + Result := False; +{$ELSE} + {$IFDEF SYN_LAZARUS} + Result := False; + {$ELSE} + Result := ReadCPPBSettings(settingIndex); + {$ENDIF} +{$ENDIF} +end; { TSynUnrealSyn.UseUserSettings } + +function TSynUnrealSyn.GetIdentChars: TSynIdentChars; +begin + Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; +end; + +class function TSynUnrealSyn.GetLanguageName: string; +begin + Result := SYNS_LangUnreal; +end; + +class function TSynUnrealSyn.GetCapabilities: TSynHighlighterCapabilities; +begin + Result := inherited GetCapabilities + [hcUserSettings]; +end; + +function TSynUnrealSyn.GetSampleSource: string; +begin + Result := '//----Comment-----------------------------------------------------------'#13#10+ + 'class TestObject expands Object native;'#13#10+ + #13#10+ + '#exec MESH IMPORT MESH=Something ANIVFILE=MODELS\Something.3D DATAFILE=MODELS\Something.3D X=0 Y=0 Z=0 MLOD=0'#13#10+ + #13#10+ + 'var() Sound HitSound;'#13#10+ + 'function Cast()'#13#10+ + '{'#13#10+ + ' Super.Cast();'#13#10+ + ' CastTime = 50;'#13#10+ + ' GatherEffect = Spawn( class''SomethingCorona'',,, GetStartLoc(), Pawn(Owner).ViewRotation );'#13#10+ + ' GatherEffect.SetFollowPawn( Pawn(Owner) );'#13#10+ + '}'#13#10+ + #13#10+ + 'defaultproperties'#13#10+ + '{'#13#10+ + ' PickupMessage="You have picked up a thing."'#13#10+ + '}'; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynUnrealSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlighteruri.pas b/components/extrasyn/SyneditHighlighters/synhighlighteruri.pas new file mode 100644 index 000000000..0c3c7f9f3 --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlighteruri.pas @@ -0,0 +1,736 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterURI.pas, released 2003-04-10. +The initial author of this file is Maël Hörz. +All Rights Reserved. + +Contributors to the SynEdit project 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: SynHighlighterURI.pas,v 1.17 2004/09/03 10:52:41 maelh Exp $ + +You may retrieve the latest version of SynEdit from the SynEdit home page, +located at http://SynEdit.SourceForge.net + +-------------------------------------------------------------------------------} +{ +@abstract(Provides an URI syntax highlighter for SynEdit) +@author(Maël Hörz) +@created(2003) +@lastmod(2003-10-21) +http://www.mh-nexus.de + +The SynHighlighterURI unit implements an URI syntax highlighter for SynEdit. + +Recognition of URIs is based on the information provided in the document +"Uniform Resource Identifiers (URI): Generic Syntax" of "The Internet Society", +that can be found at http://www.ietf.org/rfc/rfc2396.txt. + +Also interesting is http://www.freesoft.org/CIE/RFC/1738/33.htm which describes +general URL syntax and major protocols. + +these protocols are recognized: +------------------------------- +http:// +https:// +ftp:// +mailto: +news: or news:// +nntp:// +telnet:// +gopher:// +prospero:// +wais:// + +as well as commonly used shorthands: +------------------------------------ +someone@somewhere.org +www.host.org +} + +{$IFNDEF QSYNHIGHLIGHTERURI} +unit SynHighlighterURI; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = (tkNull, tkSpace, tkFtpLink, tkGopherLink, + tkHttpLink, tkHttpsLink, tkMailtoLink, tkNewsLink, tkNntpLink, + tkProsperoLink, tkTelnetLink, tkWaisLink, tkWebLink, tkUnknown, tkNullChar); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + + TAlreadyVisitedURIFunc = function (URI: string): Boolean of object; + + TSynURISyn = class(TSynCustomHighlighter) + private + fLine: PChar; + fLineNumber: Integer; + fLineStr: string; + fMayBeProtocol: PChar; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + FTokenID: TtkTokenKind; + fTokenPos: Integer; + fIdentFuncTable: array[0..97] of TIdentFuncTableFunc; + fIdentifierAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fURIAttri: TSynHighlighterAttributes; + fVisitedURIAttri: TSynHighlighterAttributes; + FAlreadyVisitedURI: TAlreadyVisitedURIFunc; + + function KeyComp(const Key: string): Boolean; + function KeyHash(ToHash: PChar): Integer; + procedure InitIdent; + procedure MakeMethodTables; + + procedure CRProc; + procedure LFProc; + procedure NullProc; + procedure ProtocolProc; + procedure SpaceProc; + procedure UnknownProc; + + function AltFunc: TtkTokenKind; + function FtpFunc: TtkTokenKind; + function GopherFunc: TtkTokenKind; + function HttpFunc: TtkTokenKind; + function HttpsFunc: TtkTokenKind; + function MailtoFunc: TtkTokenKind; + function NewsFunc: TtkTokenKind; + function NntpFunc: TtkTokenKind; + function ProsperoFunc: TtkTokenKind; + function TelnetFunc: TtkTokenKind; + function WaisFunc: TtkTokenKind; + function WebFunc: TtkTokenKind; + + function IsValidEmailAddress: Boolean; + function IsValidURI: Boolean; + function IsValidWebLink: Boolean; + + procedure SetURIAttri(const Value: TSynHighlighterAttributes); + procedure SetVisitedURIAttri(const Value: TSynHighlighterAttributes); + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + procedure SetAlreadyVisitedURIFunc(Value: TAlreadyVisitedURIFunc); + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDefaultAttribute(Index: Integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + procedure SetLine(const NewValue: string; LineNumber: Integer); override; + function GetToken: string; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: Integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property URIAttri: TSynHighlighterAttributes read fURIAttri write SetURIAttri; + property VisitedURIAttri: TSynHighlighterAttributes read fVisitedURIAttri + write SetVisitedURIAttri; + end; + +const + SYN_ATTR_URI = 6; + SYN_ATTR_VISITEDURI = 7; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst, +{$ELSE} + SynEditStrConst, +{$ENDIF} + SynEditStrConstExtra; + +const + AlphaNum = ['0'..'9', 'A'..'Z', 'a'..'z']; + Mark = ['-', '_', '.', '!', '~', '*', '''', '(' , ')']; + Unreserved = Mark + AlphaNum; + Reserved = [';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '%', '#']; + URIChars = Reserved + Unreserved; + NeverAtEnd = Mark - [''''] + Reserved - ['/', '$']; + URIBreakChars = [#0..#255] - URIChars - [#0..#32]; + EMailAddressChars = ['.', '_', '-', '@'] + AlphaNum; + NeverAtEMailAddressEnd = ['.', '@']; + +var + HashTable: array[#0..#255] of Integer; + +procedure MakeHashTable; +var + c: Char; + u: Byte; +begin + FillChar(HashTable, sizeof(HashTable), 0); + + for c := 'A' to 'Z' do + begin + u := Ord(UpCase(c)); + HashTable[c] := (u * u - 64) div 771; + end; + + for c := 'a' to 'z' do + begin + u := Ord(UpCase(c)); + HashTable[c] := (u * u - 64) div 771; + end; + + HashTable[':'] := HashTable['Z'] + 1; + HashTable['/'] := HashTable['Z'] + 2; +end; + +procedure TSynURISyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := {$IFDEF FPC}@{$ENDIF}AltFunc; + Inc(pF); + end; + + fIdentFuncTable[27] := {$IFDEF FPC}@{$ENDIF}WebFunc; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF}NewsFunc; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF}MailtoFunc; + fIdentFuncTable[58] := {$IFDEF FPC}@{$ENDIF}FtpFunc; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF}WaisFunc; + fIdentFuncTable[65] := {$IFDEF FPC}@{$ENDIF}NewsFunc; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF}NntpFunc; + fIdentFuncTable[67] := {$IFDEF FPC}@{$ENDIF}HttpFunc; + fIdentFuncTable[77] := {$IFDEF FPC}@{$ENDIF}GopherFunc; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF}TelnetFunc; + fIdentFuncTable[75] := {$IFDEF FPC}@{$ENDIF}HttpsFunc; + fIdentFuncTable[97] := {$IFDEF FPC}@{$ENDIF}ProsperoFunc; +end; + +function TSynURISyn.KeyComp(const Key: string): Boolean; +var + I: Integer; +begin + Result := True; + for I := 1 to fStringLen do + if HashTable[fMayBeProtocol[I - 1]] <> HashTable[Key[I]] then + begin + Result := False; + break; + end; +end; + +function TSynURISyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['A'..'Z', 'a'..'z'] do + begin + inc(Result, HashTable[ToHash^]); + inc(ToHash); + end; + + if ToHash^ = ':' then + begin + inc(Result, HashTable[ToHash^]); + inc(ToHash); + + if ToHash^ = '/' then + begin + inc(Result, HashTable[ToHash^]); + inc(ToHash); + + if ToHash^ = '/' then + begin + inc(Result, HashTable[ToHash^]); + inc(ToHash); + end; + end; + end; + fStringLen := ToHash - fMayBeProtocol; +end; + +function TSynURISyn.AltFunc: TtkTokenKind; +begin + Result := tkUnknown; +end; + +procedure TSynURISyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CRProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LFProc; + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NullProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SpaceProc; + 'A'..'Z', 'a'..'z': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}ProtocolProc; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF}UnknownProc; + end; +end; + +constructor TSynURISyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + + fURIAttri := TSynHighlighterAttributes.Create(SYNS_AttrURI); + fURIAttri.Foreground := clBlue; + fURIAttri.Style := [fsUnderline]; + AddAttribute(fURIAttri); + + fVisitedURIAttri := TSynHighlighterAttributes.Create(SYNS_AttrVisitedURI); + fVisitedURIAttri.Foreground := clPurple; + fVisitedURIAttri.Style := [fsUnderline]; + AddAttribute(fVisitedURIAttri); + + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterURI; +end; + +destructor TSynURISyn.Destroy; +begin + inherited; + // the other attributes are automatically freed because of AddAttribute() + fSpaceAttri.Free; + fIdentifierAttri.Free; +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynURISyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynURISyn.SetLine(const NewValue: string; LineNumber: Integer); +begin + fLineStr := NewValue; + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynURISyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then + Inc(Run); +end; + +procedure TSynURISyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynURISyn.NullProc; +begin + if Run < Length(fLineStr) then + begin + inc(Run); + fTokenID := tkNullChar; + end + else + fTokenID := tkNull +end; + +procedure TSynURISyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynURISyn.UnknownProc; +begin + if IsValidEmailAddress then + fTokenID := tkMailtoLink + else + begin + {$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else + {$ENDIF} + inc(Run); + fTokenID := tkUnknown; + end; +end; + +procedure TSynURISyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynURISyn.GetDefaultAttribute(Index: Integer): TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_URI: Result := fURIAttri; + SYN_ATTR_VISITEDURI: Result := fVisitedURIAttri; + else + Result := nil; + end; +end; + +function TSynURISyn.GetEol: Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynURISyn.GetToken: string; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynURISyn.GetTokenAttribute: TSynHighlighterAttributes; +var + Visited: Boolean; +begin + case GetTokenID of + tkSpace: Result := fSpaceAttri; + tkFtpLink, tkGopherLink, tkHttpLink, tkHttpsLink, tkMailtoLink, tkNewsLink, + tkNntpLink, tkProsperoLink, tkTelnetLink, tkWaisLink, tkWebLink: + begin + Visited := False; + if Assigned(FAlreadyVisitedURI) then + Visited := FAlreadyVisitedURI(GetToken); + if Visited then + Result := fVisitedURIAttri + else + Result := fURIAttri; + end; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynURISyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynURISyn.GetTokenKind: Integer; +begin + Result := Ord(fTokenId); +end; + +function TSynURISyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynURISyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars + [#0]; +end; + +class function TSynURISyn.GetLanguageName: string; +begin + Result := SYNS_LangURI; +end; + +function TSynURISyn.GetSampleSource: string; +begin + Result := 'Universal Resource Identifier highlighting'#13#10#13#10 + + 'http://www.somewhere.org'#13#10 + + 'ftp://superhost.org/downloads/gems.zip'#13#10 + + 'www.w3c.org'#13#10 + + 'mailto:big@lebowski.edu'#13#10 + + 'douglas@adams.lod'#13#10 + + 'news:comp.lang.pascal.borland'; +end; + +function TSynURISyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterURI; +end; + +procedure TSynURISyn.SetAlreadyVisitedURIFunc(Value: TAlreadyVisitedURIFunc); +begin + FAlreadyVisitedURI := Value; +end; + +procedure TSynURISyn.SetURIAttri(const Value: TSynHighlighterAttributes); +begin + fURIAttri.Assign(Value); +end; + +procedure TSynURISyn.SetVisitedURIAttri(const Value: TSynHighlighterAttributes); +begin + fVisitedURIAttri.Assign(Value); +end; + +function TSynURISyn.IsValidEmailAddress: Boolean; +var + StartPos, AtPos, DotPos: Integer; +begin + StartPos := Run; + + AtPos := -1; + DotPos := -1; + while fLine[Run] in EMailAddressChars do + begin + if fLine[Run] = '@' then + AtPos := Run + else if fLine[Run] = '.' then + // reject array of dots: "neighbour" dots are not allowed + if (Run = StartPos) or (DotPos >= 0) and (DotPos = Run - 1) then + break + else + DotPos := Run; + Inc(Run); + end; + + while (Run > StartPos) and (fLine[Run - 1] in NeverAtEMailAddressEnd) do + dec(Run); + + while (DotPos >= Run) or (DotPos > -1) and (fLine[DotPos] <> '.') do + Dec(DotPos); + + Result := (StartPos < AtPos) and (AtPos < Run - 1) and (DotPos > AtPos + 1); + if not Result then Run := StartPos; +end; + +function TSynURISyn.IsValidURI: Boolean; +var + ProtocolEndPos, DotPos: Integer; + + function IsRelativePath: Boolean; + begin + Result := (DotPos - 1 >= 0) and + ((fLine[DotPos - 1] = '/') and (fLine[DotPos + 2] = '/')) or + ((fLine[DotPos - 1] = '\') and (fLine[DotPos + 2] = '\')); + end; + +begin + ProtocolEndPos := Run; + + DotPos := -1; + while fLine[Run] in URIChars do + begin + if fLine[Run] = '.' then + // reject array of dots: "neighbour" dots are not allowed + if (DotPos >= 0) and (DotPos = Run - 1) and not IsRelativePath then + break + else + DotPos := Run; + inc(Run); + end; + + while (Run > ProtocolEndPos) and (fLine[Run - 1] in NeverAtEnd) do + dec(Run); + + Result := Run > ProtocolEndPos; +end; + +function TSynURISyn.IsValidWebLink: Boolean; +var + WWWEndPos, DotPos, SecondDotPos: Integer; + + function IsRelativePath: Boolean; + begin + Result := (DotPos - 1 >= 0) and + ((fLine[DotPos - 1] = '/') and (fLine[DotPos + 2] = '/')) or + ((fLine[DotPos - 1] = '\') and (fLine[DotPos + 2] = '\')); + end; + +begin + WWWEndPos := Run; + + DotPos := -1; + SecondDotPos := -1; + while fLine[Run] in URIChars do + begin + if fLine[Run] = '.' then + // reject array of dots: "neighbour" dots are not allowed + if (DotPos >= 0) and (DotPos = Run - 1) and not IsRelativePath then + break + else + begin + DotPos := Run; + if SecondDotPos = -2 then SecondDotPos := DotPos; + if SecondDotPos = -1 then SecondDotPos := -2; + end; + inc(Run); + end; + + while (Run > WWWEndPos) and (fLine[Run - 1] in NeverAtEnd) do + dec(Run); + + Result := (Run > WWWEndPos) and (fLine[WWWEndPos] = '.') and + (SecondDotPos > WWWEndPos + 1) and (SecondDotPos < Run); +end; + +procedure TSynURISyn.ProtocolProc; +var + HashKey: Integer; +begin + if IsValidEmailAddress then + fTokenID := tkMailtoLink + else + begin + fMayBeProtocol := fLine + Run; + HashKey := KeyHash(fMayBeProtocol); + inc(Run, fStringLen); + + if HashKey <= 97 then + fTokenID := fIdentFuncTable[HashKey] {$IFDEF FPC}(){$ENDIF} + else + fTokenID := tkUnknown; + end; +end; + +function TSynURISyn.FtpFunc: TtkTokenKind; +begin + if KeyComp('ftp://') and IsValidURI then + Result := tkFtpLink + else + Result := tkUnknown; +end; + +function TSynURISyn.GopherFunc: TtkTokenKind; +begin + if KeyComp('gopher://') and IsValidURI then + Result := tkGopherLink + else + Result := tkUnknown; +end; + +function TSynURISyn.HttpFunc: TtkTokenKind; +begin + if KeyComp('http://') and IsValidURI then + Result := tkHttpLink + else + Result := tkUnknown; +end; + +function TSynURISyn.HttpsFunc: TtkTokenKind; +begin + if KeyComp('https://') and IsValidURI then + Result := tkHttpsLink + else + Result := tkUnknown; +end; + +function TSynURISyn.MailtoFunc: TtkTokenKind; +begin + if KeyComp('mailto:') and IsValidURI then + Result := tkMailtoLink + else + Result := tkUnknown; +end; + +function TSynURISyn.NewsFunc: TtkTokenKind; +begin + if KeyComp('news:') and IsValidURI then + Result := tkNewsLink + else + Result := tkUnknown; +end; + +function TSynURISyn.NntpFunc: TtkTokenKind; +begin + if KeyComp('nntp://') and IsValidURI then + Result := tkNntpLink + else + Result := tkUnknown; +end; + +function TSynURISyn.ProsperoFunc: TtkTokenKind; +begin + if KeyComp('prospero://') and IsValidURI then + Result := tkProsperoLink + else + Result := tkUnknown; +end; + +function TSynURISyn.TelnetFunc: TtkTokenKind; +begin + if KeyComp('telnet://') and IsValidURI then + Result := tkTelnetLink + else + Result := tkUnknown; +end; + +function TSynURISyn.WaisFunc: TtkTokenKind; +begin + if KeyComp('wais://') and IsValidURI then + Result := tkWaisLink + else + Result := tkUnknown; +end; + +function TSynURISyn.WebFunc: TtkTokenKind; +begin + if KeyComp('www') and IsValidWebLink then + Result := tkWebLink + else + Result := tkUnknown; +end; + + +initialization + MakeHashTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynURISyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightervbscript.pas b/components/extrasyn/SyneditHighlighters/synhighlightervbscript.pas new file mode 100644 index 000000000..5b30b724a --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightervbscript.pas @@ -0,0 +1,1030 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterVBScript.pas, released 2000-04-18. +The Original Code is based on the lbVBSSyn.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Luiz C. Vaz de Brito. +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: SynHighlighterVBScript.pas,v 1.15.2.2 2007/05/24 11:17:58 etrusco Exp $ + +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 VBScript highlighter for SynEdit) +@author(Luiz C. Vaz de Brito, converted to SynEdit by David Muir ) +@created(20 January 1999, converted to SynEdit April 18, 2000) +@lastmod(2000-06-23) +The SynHighlighterVBScript unit provides SynEdit with a VisualBasic Script (.vbs) highlighter. +Thanks to Primoz Gabrijelcic and Martin Waldenburg. +} + +{$IFNDEF QSYNHIGHLIGHTERVBSCRIPT} +unit SynHighlighterVBScript; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + QGraphics, + QSynEditHighlighter, + QSynEditTypes, +{$ELSE} + Graphics, + Registry, + SynEditHighlighter, + SynEditTypes, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, + tkString, tkSymbol, tkUnknown); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function: TtkTokenKind of object; + +type + TSynVBScriptSyn = class(TSynCustomHighLighter) + private + fLine: PChar; + fLineNumber: Integer; + fProcTable: array[#0..#255] of TProcTableProc; + Run: LongInt; + fStringLen: Integer; + fToIdent: PChar; + fTokenPos: Integer; + FTokenID: TtkTokenKind; + fCommentAttri: TSynHighlighterAttributes; + fIdentifierAttri: TSynHighlighterAttributes; + fKeyAttri: TSynHighlighterAttributes; + fNumberAttri: TSynHighlighterAttributes; + fSpaceAttri: TSynHighlighterAttributes; + fStringAttri: TSynHighlighterAttributes; + fSymbolAttri: TSynHighlighterAttributes; + fIdentFuncTable: array[0..133] of TIdentFuncTableFunc; + function KeyHash(ToHash: PChar): Integer; + function KeyComp(const aKey: String): Boolean; + function Func15: TtkTokenKind; + function Func17: TtkTokenKind; + function Func18: TtkTokenKind; + function Func19: TtkTokenKind; + function Func20: TtkTokenKind; + function Func23: TtkTokenKind; + function Func26: TtkTokenKind; + function Func28: TtkTokenKind; + function Func29: TtkTokenKind; + function Func32: TtkTokenKind; + function Func33: TtkTokenKind; + function Func35: TtkTokenKind; + function Func36: TtkTokenKind; + function Func37: TtkTokenKind; + function Func38: TtkTokenKind; + function Func39: TtkTokenKind; + function Func41: TtkTokenKind; + function Func42: TtkTokenKind; + function Func43: TtkTokenKind; + function Func44: TtkTokenKind; + function Func46: TtkTokenKind; + function Func47: TtkTokenKind; + function Func48: TtkTokenKind; + function Func49: TtkTokenKind; + function Func52: TtkTokenKind; + function Func53: TtkTokenKind; + function Func54: TtkTokenKind; + function Func55: TtkTokenKind; + function Func56: TtkTokenKind; + function Func57: TtkTokenKind; + function Func58: TtkTokenKind; + function Func59: TtkTokenKind; + function Func60: TtkTokenKind; + function Func62: TtkTokenKind; + function Func63: TtkTokenKind; + function Func64: TtkTokenKind; + function Func66: TtkTokenKind; + function Func69: TtkTokenKind; + function Func70: TtkTokenKind; + function Func71: TtkTokenKind; + function Func72: TtkTokenKind; + function Func74: TtkTokenKind; + function Func76: TtkTokenKind; + function Func78: TtkTokenKind; + function Func79: TtkTokenKind; + function Func81: TtkTokenKind; + function Func85: TtkTokenKind; + function Func87: TtkTokenKind; + function Func89: TtkTokenKind; + function Func91: TtkTokenKind; + function Func98: TtkTokenKind; + function Func102: TtkTokenKind; + function Func105: TtkTokenKind; + function Func107: TtkTokenKind; + function Func108: TtkTokenKind; + function Func112: TtkTokenKind; + function Func118: TtkTokenKind; + function Func126: TtkTokenKind; + function Func133: TtkTokenKind; + procedure ApostropheProc; + procedure CRProc; + procedure DateProc; + procedure GreaterProc; + procedure IdentProc; + procedure LFProc; + procedure LowerProc; + procedure NullProc; + procedure NumberProc; + procedure SpaceProc; + procedure StringProc; + procedure SymbolProc; + procedure UnknownProc; + function AltFunc: TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe: PChar): TtkTokenKind; + procedure MakeMethodTables; + protected + function GetIdentChars: TSynIdentChars; override; + function GetSampleSource: string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName: string; override; + public + constructor Create(AOwner: TComponent); override; + function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; + override; + function GetEol: Boolean; override; + function GetTokenID: TtkTokenKind; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + procedure SetLine(const NewValue: String; LineNumber:Integer); override; + function GetToken: String; override; + function GetTokenAttribute: TSynHighlighterAttributes; override; + function GetTokenKind: integer; override; + function GetTokenPos: Integer; override; + procedure Next; override; + published + property CommentAttri: TSynHighlighterAttributes read fCommentAttri + write fCommentAttri; + property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri + write fIdentifierAttri; + property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property NumberAttri: TSynHighlighterAttributes read fNumberAttri + write fNumberAttri; + property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri + write fSpaceAttri; + property StringAttri: TSynHighlighterAttributes read fStringAttri + write fStringAttri; + property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri + write fSymbolAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst; +{$ENDIF} + +var + Identifiers: array[#0..#255] of ByteBool; + mHashTable: array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J: Char; +begin + for I := #0 to #255 do + begin + Case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True; + else Identifiers[I] := False; + end; + J := UpCase(I); + Case I in['_', 'a'..'z', 'A'..'Z'] of + True: mHashTable[I] := Ord(J) - 64 + else mHashTable[I] := 0; + end; + end; +end; + +procedure TSynVBScriptSyn.InitIdent; +var + I: Integer; + pF: PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin + pF^ := {$IFDEF FPC}@{$ENDIF}AltFunc; + Inc(pF); + end; + fIdentFuncTable[15] := {$IFDEF FPC}@{$ENDIF} Func15; + fIdentFuncTable[17] := {$IFDEF FPC}@{$ENDIF} Func17; + fIdentFuncTable[18] := {$IFDEF FPC}@{$ENDIF} Func18; + fIdentFuncTable[19] := {$IFDEF FPC}@{$ENDIF} Func19; + fIdentFuncTable[20] := {$IFDEF FPC}@{$ENDIF} Func20; + fIdentFuncTable[23] := {$IFDEF FPC}@{$ENDIF} Func23; + fIdentFuncTable[26] := {$IFDEF FPC}@{$ENDIF} Func26; + fIdentFuncTable[28] := {$IFDEF FPC}@{$ENDIF} Func28; + fIdentFuncTable[29] := {$IFDEF FPC}@{$ENDIF} Func29; + fIdentFuncTable[32] := {$IFDEF FPC}@{$ENDIF} Func32; + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF} Func33; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF} Func35; + fIdentFuncTable[36] := {$IFDEF FPC}@{$ENDIF} Func36; + fIdentFuncTable[37] := {$IFDEF FPC}@{$ENDIF} Func37; + fIdentFuncTable[38] := {$IFDEF FPC}@{$ENDIF} Func38; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF} Func39; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[42] := {$IFDEF FPC}@{$ENDIF} Func42; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF} Func44; + fIdentFuncTable[46] := {$IFDEF FPC}@{$ENDIF} Func46; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF} Func47; + fIdentFuncTable[48] := {$IFDEF FPC}@{$ENDIF} Func48; + fIdentFuncTable[49] := {$IFDEF FPC}@{$ENDIF} Func49; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF} Func52; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF} Func53; + fIdentFuncTable[54] := {$IFDEF FPC}@{$ENDIF} Func54; + fIdentFuncTable[55] := {$IFDEF FPC}@{$ENDIF} Func55; + fIdentFuncTable[56] := {$IFDEF FPC}@{$ENDIF} Func56; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF} Func57; + fIdentFuncTable[58] := {$IFDEF FPC}@{$ENDIF} Func58; + fIdentFuncTable[59] := {$IFDEF FPC}@{$ENDIF} Func59; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF} Func60; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF} Func62; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF} Func63; + fIdentFuncTable[64] := {$IFDEF FPC}@{$ENDIF} Func64; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[69] := {$IFDEF FPC}@{$ENDIF} Func69; + fIdentFuncTable[70] := {$IFDEF FPC}@{$ENDIF} Func70; + fIdentFuncTable[71] := {$IFDEF FPC}@{$ENDIF} Func71; + fIdentFuncTable[72] := {$IFDEF FPC}@{$ENDIF} Func72; + fIdentFuncTable[74] := {$IFDEF FPC}@{$ENDIF} Func74; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF} Func76; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF} Func78; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF} Func79; + fIdentFuncTable[81] := {$IFDEF FPC}@{$ENDIF} Func81; + fIdentFuncTable[85] := {$IFDEF FPC}@{$ENDIF} Func85; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF} Func87; + fIdentFuncTable[89] := {$IFDEF FPC}@{$ENDIF} Func89; + fIdentFuncTable[91] := {$IFDEF FPC}@{$ENDIF} Func91; + fIdentFuncTable[98] := {$IFDEF FPC}@{$ENDIF} Func98; + fIdentFuncTable[102] := {$IFDEF FPC}@{$ENDIF} Func102; + fIdentFuncTable[105] := {$IFDEF FPC}@{$ENDIF} Func105; + fIdentFuncTable[107] := {$IFDEF FPC}@{$ENDIF} Func107; + fIdentFuncTable[108] := {$IFDEF FPC}@{$ENDIF} Func108; + fIdentFuncTable[112] := {$IFDEF FPC}@{$ENDIF} Func112; + fIdentFuncTable[118] := {$IFDEF FPC}@{$ENDIF} Func118; + fIdentFuncTable[126] := {$IFDEF FPC}@{$ENDIF} Func126; + fIdentFuncTable[133] := {$IFDEF FPC}@{$ENDIF} Func133; +end; + +function TSynVBScriptSyn.KeyHash(ToHash: PChar): Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; { KeyHash } + +function TSynVBScriptSyn.KeyComp(const aKey: String): Boolean; +var + I: Integer; + Temp: PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if mHashTable[Temp^] <> mHashTable[aKey[i]] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end else Result := False; +end; { KeyComp } + +function TSynVBScriptSyn.Func15: TtkTokenKind; +begin + if KeyComp('If') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func17: TtkTokenKind; +begin + if KeyComp('Each') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func18: TtkTokenKind; +begin + if KeyComp('Me') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func19: TtkTokenKind; +begin + if KeyComp('Do') then Result := tkKey else + if KeyComp('And') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func20: TtkTokenKind; +begin + if KeyComp('As') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func23: TtkTokenKind; +begin + if KeyComp('End') then Result := tkKey else + if KeyComp('In') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func26: TtkTokenKind; +begin + if KeyComp('Dim') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func28: TtkTokenKind; +begin + if KeyComp('Case') then Result := tkKey else + if KeyComp('Call') then Result := tkKey else + if KeyComp('Is') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func29: TtkTokenKind; +begin + if KeyComp('On') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func32: TtkTokenKind; +begin + if KeyComp('Mod') then Result := tkKey else + if KeyComp('Get') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func33: TtkTokenKind; +begin + if KeyComp('Or') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func35: TtkTokenKind; +begin + if KeyComp('To') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func36: TtkTokenKind; +begin + if KeyComp('Rem') then + begin + Result := tkComment; + fStringLen := 0; + ApostropheProc; + end + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func37: TtkTokenKind; +begin + if KeyComp('Let') then Result := tkKey else + if KeyComp('Like') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func38: TtkTokenKind; +begin + if KeyComp('Imp') then Result := tkKey else + if KeyComp('EndIf') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func39: TtkTokenKind; +begin + if KeyComp('For') then Result := tkKey else + if KeyComp('Debug') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func41: TtkTokenKind; +begin + if KeyComp('Else') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func42: TtkTokenKind; +begin + if KeyComp('Sub') then Result := tkKey else + if KeyComp('New') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func43: TtkTokenKind; +begin + if KeyComp('False') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func44: TtkTokenKind; +begin + if KeyComp('Eqv') then Result := tkKey else + if KeyComp('Set') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func46: TtkTokenKind; +begin + if KeyComp('Wend') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func47: TtkTokenKind; +begin + if KeyComp('Then') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func48: TtkTokenKind; +begin + if KeyComp('Erase') then Result := tkKey else + if KeyComp('Long') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func49: TtkTokenKind; +begin + if KeyComp('ReDim') then Result := tkKey else + if KeyComp('Not') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func52: TtkTokenKind; +begin + if KeyComp('Byte') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func53: TtkTokenKind; +begin + if KeyComp('Enum') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func54: TtkTokenKind; +begin + if KeyComp('Class') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func55: TtkTokenKind; +begin + if KeyComp('Shared') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func56: TtkTokenKind; +begin + if KeyComp('ByRef') then Result := tkKey else + if KeyComp('ElseIf') then Result := tkKey else + if KeyComp('LSet') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func57: TtkTokenKind; +begin + if KeyComp('Xor') then Result := tkKey else + if KeyComp('While') then Result := tkKey else + if KeyComp('GoTo') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func58: TtkTokenKind; +begin + if KeyComp('Loop') then Result := tkKey else + if KeyComp('Exit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func59: TtkTokenKind; +begin + if KeyComp('Double') then + Result := tkKey + else if KeyComp('Null') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func60: TtkTokenKind; +begin + if KeyComp('With') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func62: TtkTokenKind; +begin + if KeyComp('ByVal') then Result := tkKey else + if KeyComp('RSet') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func63: TtkTokenKind; +begin + if KeyComp('Next') then Result := tkKey else + if KeyComp('Public') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func64: TtkTokenKind; +begin + if KeyComp('Select') then Result := tkKey else + if KeyComp('Boolean') then Result := tkKey else + if KeyComp('True') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func66: TtkTokenKind; +begin + if KeyComp('Event') then + Result := tkKey + else if KeyComp('Single') then + Result := tkKey + else if KeyComp('Type') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func69: TtkTokenKind; +begin + if KeyComp('default') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func70: TtkTokenKind; +begin + if KeyComp('Stop') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func71: TtkTokenKind; +begin + if KeyComp('Const') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func72: TtkTokenKind; +begin + if KeyComp('Static') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func74: TtkTokenKind; +begin + if KeyComp('Error') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func76: TtkTokenKind; +begin + if KeyComp('Until') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func78: TtkTokenKind; +begin + if KeyComp('Integer') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func79: TtkTokenKind; +begin + if KeyComp('Empty') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func81: TtkTokenKind; +begin + if KeyComp('Resume') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func85: TtkTokenKind; +begin + if KeyComp('Variant') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func87: TtkTokenKind; +begin + if KeyComp('Nothing') then + Result := tkKey + else if KeyComp('TypeOf') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func89: TtkTokenKind; +begin + if KeyComp('Option') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func91: TtkTokenKind; +begin + if KeyComp('Private') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func98: TtkTokenKind; +begin + if KeyComp('Explicit') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func102: TtkTokenKind; +begin + if KeyComp('Function') then Result := tkKey else + if KeyComp('Optional') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func105: TtkTokenKind; +begin + if KeyComp('Randomize') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func107: TtkTokenKind; +begin + if KeyComp('Currency') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func108: TtkTokenKind; +begin + if KeyComp('Preserve') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func112: TtkTokenKind; +begin + if KeyComp('ParamArray') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func118: TtkTokenKind; +begin + if KeyComp('RaiseEvent') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func126: TtkTokenKind; +begin + if KeyComp('Implements') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.Func133: TtkTokenKind; +begin + if KeyComp('property') then Result := tkKey else Result := tkIdentifier; +end; + +function TSynVBScriptSyn.AltFunc: TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynVBScriptSyn.IdentKind(MayBe: PChar): TtkTokenKind; +var + HashKey: Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 134 then + Result := fIdentFuncTable[HashKey] {$IFDEF FPC}(){$ENDIF} + else + Result := tkIdentifier; +end; + +procedure TSynVBScriptSyn.MakeMethodTables; +var + I: Char; +begin + for I := #0 to #255 do + case I of + #39: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} ApostropheProc; + #13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CRProc; + '#': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} DateProc; + '>': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} GreaterProc; + 'A'..'Z', 'a'..'z', '_': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} IdentProc; + #10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LFProc; + '<': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LowerProc; + #0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NullProc; + '0'..'9': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NumberProc; + #1..#9, #11, #12, #14..#32: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SpaceProc; + #34: fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StringProc; + '&', '{', '}', ':', ',', '=', '^', '-', + '+', '.', '(', ')', ';', '/', '*': fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SymbolProc; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} UnknownProc; + end; +end; + +constructor TSynVBScriptSyn.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + AddAttribute(fCommentAttri); + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + AddAttribute(fIdentifierAttri); + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + AddAttribute(fKeyAttri); + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + AddAttribute(fNumberAttri); + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + AddAttribute(fSpaceAttri); + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + AddAttribute(fStringAttri); + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + AddAttribute(fSymbolAttri); + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + fDefaultFilter := SYNS_FilterVBScript; + InitIdent; + MakeMethodTables; +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynVBScriptSyn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynVBScriptSyn.SetLine(const NewValue: String; LineNumber:Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynVBScriptSyn.ApostropheProc; +begin + fTokenID := tkComment; + repeat + inc(Run); + until fLine[Run] in [#0, #10, #13]; +end; + +procedure TSynVBScriptSyn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then inc(Run); +end; + +procedure TSynVBScriptSyn.DateProc; +begin + fTokenID := tkString; + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = '#'; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynVBScriptSyn.GreaterProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if fLine[Run] = '=' then Inc(Run); +end; + +procedure TSynVBScriptSyn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do inc(Run); +end; + +procedure TSynVBScriptSyn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynVBScriptSyn.LowerProc; +begin + fTokenID := tkSymbol; + Inc(Run); + if fLine[Run] in ['=', '>'] then Inc(Run); +end; + +procedure TSynVBScriptSyn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynVBScriptSyn.NumberProc; +begin + inc(Run); + fTokenID := tkNumber; + while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do inc(Run); +end; + +procedure TSynVBScriptSyn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run); +end; + +procedure TSynVBScriptSyn.StringProc; +begin + fTokenID := tkString; + if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13: break; + end; + inc(Run); + until FLine[Run] = #34; + if FLine[Run] <> #0 then inc(Run); +end; + +procedure TSynVBScriptSyn.SymbolProc; +begin + inc(Run); + fTokenID := tkSymbol; +end; + +procedure TSynVBScriptSyn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkIdentifier; +end; + +procedure TSynVBScriptSyn.Next; +begin + fTokenPos := Run; + fProcTable[fLine[Run]]; +end; + +function TSynVBScriptSyn.GetDefaultAttribute(Index: integer): + TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT: Result := fCommentAttri; + SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri; + SYN_ATTR_KEYWORD: Result := fKeyAttri; + SYN_ATTR_STRING: Result := fStringAttri; + SYN_ATTR_WHITESPACE: Result := fSpaceAttri; + SYN_ATTR_SYMBOL: Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynVBScriptSyn.GetEol: Boolean; +begin + Result := fTokenId = tkNull; +end; + +function TSynVBScriptSyn.GetToken: String; +var + Len: LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynVBScriptSyn.GetTokenID: TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynVBScriptSyn.GetTokenAttribute: TSynHighlighterAttributes; +begin + case fTokenID of + tkComment: Result := fCommentAttri; + tkIdentifier: Result := fIdentifierAttri; + tkKey: Result := fKeyAttri; + tkNumber: Result := fNumberAttri; + tkSpace: Result := fSpaceAttri; + tkString: Result := fStringAttri; + tkSymbol: Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + else Result := nil; + end; +end; + +function TSynVBScriptSyn.GetTokenKind: integer; +begin + Result := Ord(fTokenId); +end; + +function TSynVBScriptSyn.GetTokenPos: Integer; +begin + Result := fTokenPos; +end; + +function TSynVBScriptSyn.GetIdentChars: TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynVBScriptSyn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterVBScript; +end; + +class function TSynVBScriptSyn.GetLanguageName: string; +begin + Result := SYNS_LangVBSScript; +end; + +function TSynVBScriptSyn.GetSampleSource: string; +begin + Result := ''' Syntax highlighting'#13#10 + + 'function printNumber()'#13#10 + + ' number = 12345'#13#10 + + ' document.write("The number is " + number)'#13#10 + + ' for i = 0 to 10'#13#10 + + ' x = x + 1.0'#13#10 + + ' next'#13#10 + + 'end function'; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynVBScriptSyn); +{$ENDIF} +end. diff --git a/components/extrasyn/SyneditHighlighters/synhighlightervrml97.pas b/components/extrasyn/SyneditHighlighters/synhighlightervrml97.pas new file mode 100644 index 000000000..d56dd130a --- /dev/null +++ b/components/extrasyn/SyneditHighlighters/synhighlightervrml97.pas @@ -0,0 +1,5028 @@ +{------------------------------------------------------------------------------- +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: SynHighlighterVrml.pas, released 2002-10-21. +The Original Code is based on: SynHighlighterJScript.pas, released 2000-04-14. +The Original Code is based on the mwJScript.pas file from the +mwEdit component suite by Martin Waldenburg and other developers, the Initial +Author of this file is Tony de Buys. +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: SynHighlighterVrml97.pas,v 1.6 2004/07/31 16:20:08 markonjezic Exp $ + +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 Vrml97/X3D/JavaScript highlighter for SynEdit) +@author(Massimo Maria Ghisalberti (nissl@mammuth.it) +@created(november 2002 [December 1999, converted to SynEdit April 14, 2000]) +@lastmod(2002-11-03) +The SynHighlighterVrml97 unit provides SynEdit with a Vrml97/X3D/JavaScript (.wrl;*.x3d) highlighter. +The highlighter formats Vrml97/X3D source code highlighting keywords, strings, numbers and characters. +} + +{$IFNDEF QSYNHIGHLIGHTERVRML97} +unit SynHighlighterVrml97; +{$ENDIF} + +{$I synedit.inc} + +interface + +uses +{$IFDEF SYN_CLX} + Qt, + QControls, + QGraphics, + QSynEditTypes, + QSynEditHighlighter, +{$ELSE} + //Windows, +// Messages, + //Registry, + Controls, + Graphics, + SynEditTypes, + SynEditHighlighter, +{$ENDIF} + SysUtils, + Classes; + +type + TtkTokenKind = ( + tkComment, + tkIdentifier, + tkKey, + tkNull, + tkNumber, + tkSpace, + tkString, + tkSymbol, + tkUnknown, + tkNonReservedKey, + tkEvent, + tkVrmlAppearance, + tkVrmlAttribute, + tkVrmlDefinition, + tkVrmlEvent, + tkVrmlGrouping, + tkVrmlInterpolator, + tkVrmlLight, + tkVrmlNode, + tkVrmlParameter, + tkVrmlproto, + tkVrmlSensor, + tkVrmlShape, + tkVrmlShape_Hint, + tkVrmlTime_dependent, + tkVrmlViewpoint, + tkVrmlWorldInfo, + tkX3DDocType, + tkX3DHeader); + + TRangeState = (rsNormalText, rsComment, rsX3DHeader, rsX3DDocType); + + TProcTableProc = procedure of object; + + PIdentFuncTableFunc = ^TIdentFuncTableFunc; + TIdentFuncTableFunc = function :TtkTokenKind of object; + +type + TSynVrml97Syn = class(TSynCustomHighLighter) + private + fRange :TRangeState; + isDoctype :boolean; + fLine :PChar; + fLineNumber :Integer; + fProcTable :array[#0..#255] of TProcTableProc; + Run :LongInt; + fStringLen :Integer; + fToIdent :PChar; + fTokenPos :Integer; + FTokenID :TtkTokenKind; + fIdentFuncTable :array[0..354] of TIdentFuncTableFunc; + fCommentAttri :TSynHighlighterAttributes; + fIdentifierAttri :TSynHighlighterAttributes; + fKeyAttri :TSynHighlighterAttributes; + fNonReservedKeyAttri :TSynHighlighterAttributes; + fEventAttri :TSynHighlighterAttributes; + fNumberAttri :TSynHighlighterAttributes; + fSpaceAttri :TSynHighlighterAttributes; + fStringAttri :TSynHighlighterAttributes; + fSymbolAttri :TSynHighlighterAttributes; + + fVrmlAppearanceAttri :TSynHighlighterAttributes; + fVrmlAttributeAttri :TSynHighlighterAttributes; + fVrmlDefinitionAttri :TSynHighlighterAttributes; + fVrmlEventAttri :TSynHighlighterAttributes; + fVrmlGroupingAttri :TSynHighlighterAttributes; + fVrmlInterpolatorAttri :TSynHighlighterAttributes; + fVrmlLightAttri :TSynHighlighterAttributes; + fVrmlNodeAttri :TSynHighlighterAttributes; + fVrmlParameterAttri :TSynHighlighterAttributes; + fVrmlprotoAttri :TSynHighlighterAttributes; + fVrmlSensorAttri :TSynHighlighterAttributes; + fVrmlShapeAttri :TSynHighlighterAttributes; + fVrmlShape_HintAttri :TSynHighlighterAttributes; + fVrmlTime_dependentAttri :TSynHighlighterAttributes; + fVrmlViewpointAttri :TSynHighlighterAttributes; + fVrmlWorldInfoAttri :TSynHighlighterAttributes; + fX3DDocTypeAttri :TSynHighlighterAttributes; + fX3DHeaderAttri :TSynHighlighterAttributes; + + function KeyHash(ToHash :PChar) :Integer; + function KeyComp(const aKey :string) :Boolean; + function Func5 :TtkTokenKind; + function Func15 :TtkTokenKind; + function Func17 :TtkTokenKind; + function Func18 :TtkTokenKind; + function Func19 :TtkTokenKind; + function Func22 :TtkTokenKind; + function Func23 :TtkTokenKind; + function Func25 :TtkTokenKind; + function Func26 :TtkTokenKind; + function Func27 :TtkTokenKind; + function Func28 :TtkTokenKind; + function Func29 :TtkTokenKind; + function Func30 :TtkTokenKind; + function Func31 :TtkTokenKind; + function Func32 :TtkTokenKind; + function Func33 :TtkTokenKind; + function Func34 :TtkTokenKind; + function Func35 :TtkTokenKind; + function Func36 :TtkTokenKind; + function Func37 :TtkTokenKind; + function Func38 :TtkTokenKind; + function Func39 :TtkTokenKind; + function Func40 :TtkTokenKind; + function Func41 :TtkTokenKind; + function Func42 :TtkTokenKind; + function Func43 :TtkTokenKind; + function Func44 :TtkTokenKind; + function Func45 :TtkTokenKind; + function Func46 :TtkTokenKind; + function Func47 :TtkTokenKind; + function Func48 :TtkTokenKind; + function Func49 :TtkTokenKind; + function Func50 :TtkTokenKind; + function Func51 :TtkTokenKind; + function Func52 :TtkTokenKind; + function Func53 :TtkTokenKind; + function Func54 :TtkTokenKind; + function Func55 :TtkTokenKind; + function Func56 :TtkTokenKind; + function Func57 :TtkTokenKind; + function Func58 :TtkTokenKind; + function Func59 :TtkTokenKind; + function Func60 :TtkTokenKind; + function Func61 :TtkTokenKind; + function Func62 :TtkTokenKind; + function Func63 :TtkTokenKind; + function Func64 :TtkTokenKind; + function Func65 :TtkTokenKind; + function Func66 :TtkTokenKind; + function Func67 :TtkTokenKind; + function Func68 :TtkTokenKind; + function Func69 :TtkTokenKind; + function Func70 :TtkTokenKind; + function Func71 :TtkTokenKind; + function Func72 :TtkTokenKind; + function Func73 :TtkTokenKind; + function Func74 :TtkTokenKind; + function Func75 :TtkTokenKind; + function Func76 :TtkTokenKind; + function Func77 :TtkTokenKind; + function Func78 :TtkTokenKind; + function Func79 :TtkTokenKind; + function Func80 :TtkTokenKind; + function Func81 :TtkTokenKind; + function Func82 :TtkTokenKind; + function Func83 :TtkTokenKind; + function Func84 :TtkTokenKind; + function Func85 :TtkTokenKind; + function Func86 :TtkTokenKind; + function Func87 :TtkTokenKind; + function Func88 :TtkTokenKind; + function Func89 :TtkTokenKind; + function Func90 :TtkTokenKind; + function Func91 :TtkTokenKind; + function Func92 :TtkTokenKind; + function Func93 :TtkTokenKind; + function Func94 :TtkTokenKind; + function Func95 :TtkTokenKind; + function Func96 :TtkTokenKind; + function Func97 :TtkTokenKind; + function Func98 :TtkTokenKind; + function Func99 :TtkTokenKind; + function Func100 :TtkTokenKind; + function Func101 :TtkTokenKind; + function Func102 :TtkTokenKind; + function Func103 :TtkTokenKind; + function Func104 :TtkTokenKind; + function Func105 :TtkTokenKind; + function Func106 :TtkTokenKind; + function Func107 :TtkTokenKind; + function Func108 :TtkTokenKind; + function Func109 :TtkTokenKind; + function Func110 :TtkTokenKind; + function Func111 :TtkTokenKind; + function Func112 :TtkTokenKind; + function Func113 :TtkTokenKind; + function Func114 :TtkTokenKind; + function Func115 :TtkTokenKind; + function Func116 :TtkTokenKind; + function Func117 :TtkTokenKind; + function Func118 :TtkTokenKind; + function Func119 :TtkTokenKind; + function Func120 :TtkTokenKind; + function Func121 :TtkTokenKind; + function Func122 :TtkTokenKind; + function Func123 :TtkTokenKind; + function Func124 :TtkTokenKind; + function Func125 :TtkTokenKind; + function Func126 :TtkTokenKind; + function Func128 :TtkTokenKind; + function Func129 :TtkTokenKind; + function Func130 :TtkTokenKind; + function Func131 :TtkTokenKind; + function Func132 :TtkTokenKind; + function Func133 :TtkTokenKind; + function Func134 :TtkTokenKind; + function Func135 :TtkTokenKind; + function Func136 :TtkTokenKind; + function Func137 :TtkTokenKind; + function Func138 :TtkTokenKind; + function Func139 :TtkTokenKind; + function Func140 :TtkTokenKind; + function Func141 :TtkTokenKind; + function Func142 :TtkTokenKind; + function Func143 :TtkTokenKind; + function Func144 :TtkTokenKind; + function Func145 :TtkTokenKind; + function Func146 :TtkTokenKind; + function Func147 :TtkTokenKind; + function Func148 :TtkTokenKind; + function Func149 :TtkTokenKind; + function Func150 :TtkTokenKind; + function Func151 :TtkTokenKind; + function Func153 :TtkTokenKind; + function Func154 :TtkTokenKind; + function Func155 :TtkTokenKind; + function Func156 :TtkTokenKind; + function Func157 :TtkTokenKind; + function Func158 :TtkTokenKind; + function Func159 :TtkTokenKind; + function Func160 :TtkTokenKind; + function Func161 :TtkTokenKind; + function Func162 :TtkTokenKind; + function Func164 :TtkTokenKind; + function Func166 :TtkTokenKind; + function Func167 :TtkTokenKind; + function Func168 :TtkTokenKind; + function Func169 :TtkTokenKind; + function Func170 :TtkTokenKind; + function Func171 :TtkTokenKind; + function Func172 :TtkTokenKind; + function Func173 :TtkTokenKind; + function Func174 :TtkTokenKind; + function Func175 :TtkTokenKind; + function Func176 :TtkTokenKind; + function Func177 :TtkTokenKind; + function Func178 :TtkTokenKind; + function Func179 :TtkTokenKind; + function Func180 :TtkTokenKind; + function Func181 :TtkTokenKind; + function Func182 :TtkTokenKind; + function Func183 :TtkTokenKind; + function Func184 :TtkTokenKind; + function Func185 :TtkTokenKind; + function Func186 :TtkTokenKind; + function Func188 :TtkTokenKind; + function Func189 :TtkTokenKind; + function Func190 :TtkTokenKind; + function Func194 :TtkTokenKind; + function Func196 :TtkTokenKind; + function Func198 :TtkTokenKind; + function Func199 :TtkTokenKind; + function Func200 :TtkTokenKind; + function Func202 :TtkTokenKind; + function Func204 :TtkTokenKind; + function Func206 :TtkTokenKind; + function Func209 :TtkTokenKind; + function Func210 :TtkTokenKind; + function Func212 :TtkTokenKind; + function Func213 :TtkTokenKind; + function Func214 :TtkTokenKind; + function Func215 :TtkTokenKind; + function Func216 :TtkTokenKind; + function Func217 :TtkTokenKind; + function Func218 :TtkTokenKind; + function Func220 :TtkTokenKind; + function Func221 :TtkTokenKind; + function Func222 :TtkTokenKind; + function Func223 :TtkTokenKind; + function Func226 :TtkTokenKind; + function Func229 :TtkTokenKind; + function Func233 :TtkTokenKind; + function Func234 :TtkTokenKind; + function Func235 :TtkTokenKind; + function Func236 :TtkTokenKind; + function Func237 :TtkTokenKind; + function Func239 :TtkTokenKind; + function Func245 :TtkTokenKind; + function Func252 :TtkTokenKind; + function Func255 :TtkTokenKind; + function Func260 :TtkTokenKind; + function Func262 :TtkTokenKind; + function Func263 :TtkTokenKind; + function Func264 :TtkTokenKind; + function Func267 :TtkTokenKind; + function Func271 :TtkTokenKind; + function Func278 :TtkTokenKind; + function Func280 :TtkTokenKind; + function Func283 :TtkTokenKind; + function Func284 :TtkTokenKind; + function Func289 :TtkTokenKind; + function Func292 :TtkTokenKind; + function Func303 :TtkTokenKind; + function Func307 :TtkTokenKind; + function Func308 :TtkTokenKind; + function Func318 :TtkTokenKind; + function Func320 :TtkTokenKind; + function Func354 :TtkTokenKind; + procedure AndSymbolProc; + procedure CommentProc; + procedure DiesisCommentProc; + procedure X3DDocTypeOpenProc; + procedure X3DDocTypeProc; + procedure X3DHeaderOpenProc; + procedure X3DHeaderProc; + procedure InCommentProc; + procedure CRProc; + procedure IdentProc; + procedure LFProc; + procedure MinusProc; + procedure ModSymbolProc; + procedure NullProc; + procedure NumberProc; + procedure OrSymbolProc; + procedure PlusProc; + procedure PointProc; + procedure SlashProc; + procedure SpaceProc; + procedure StarProc; + procedure StringProc; + procedure SymbolProc; + procedure UnknownProc; + function AltFunc :TtkTokenKind; + procedure InitIdent; + function IdentKind(MayBe :PChar) :TtkTokenKind; + procedure MakeMethodTables; + function NextTokenIs(T :string) :Boolean; + protected + function GetIdentChars :TSynIdentChars; override; + function GetSampleSource :string; override; + function IsFilterStored: Boolean; override; + public + class function GetLanguageName :string; override; + public + constructor Create(AOwner :TComponent); override; + function GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; + override; + function GetEol :Boolean; override; + function GetRange :Pointer; override; + function GetTokenID :TtkTokenKind; + procedure SetLine(const NewValue :string; LineNumber :Integer); override; + function GetToken :string; override; + {$IFDEF SYN_LAZARUS} + procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override; + {$ENDIF} + function GetTokenAttribute :TSynHighlighterAttributes; override; + function GetTokenKind :integer; override; + function GetTokenPos :Integer; override; + procedure Next; override; + procedure SetRange(Value :Pointer); override; + procedure ResetRange; override; + published + property NonReservedKeyAttri :TSynHighlighterAttributes read fNonReservedKeyAttri write fNonReservedKeyAttri; + property NumberAttri :TSynHighlighterAttributes read fNumberAttri write fNumberAttri; + property SpaceAttri :TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri; + property StringAttri :TSynHighlighterAttributes read fStringAttri write fStringAttri; + property SymbolAttri :TSynHighlighterAttributes read fSymbolAttri write fSymbolAttri; + property CommentAttri :TSynHighlighterAttributes read fCommentAttri write fCommentAttri; + property IdentifierAttri :TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri; + property EcmaScriptKeyAttri :TSynHighlighterAttributes read fKeyAttri write fKeyAttri; + property EcmaScriptEventAttri :TSynHighlighterAttributes read fEventAttri write fEventAttri; + + property VrmlAppearanceAttri :TSynHighlighterAttributes read fVrmlAppearanceAttri write fVrmlAppearanceAttri; + property VrmlAttributeAttri :TSynHighlighterAttributes read fVrmlAttributeAttri write fVrmlAttributeAttri; + property VrmlDefinitionAttri :TSynHighlighterAttributes read fVrmlDefinitionAttri write fVrmlDefinitionAttri; + property VrmlEventAttri :TSynHighlighterAttributes read fVrmlEventAttri write fVrmlEventAttri; + property VrmlGroupingAttri :TSynHighlighterAttributes read fVrmlGroupingAttri write fVrmlGroupingAttri; + property VrmlInterpolatorAttri :TSynHighlighterAttributes read fVrmlInterpolatorAttri write fVrmlInterpolatorAttri; + property VrmlLightAttri :TSynHighlighterAttributes read fVrmlLightAttri write fVrmlLightAttri; + property VrmlNodeAttri :TSynHighlighterAttributes read fVrmlNodeAttri write fVrmlNodeAttri; + property VrmlParameterAttri :TSynHighlighterAttributes read fVrmlParameterAttri write fVrmlParameterAttri; + property VrmlprotoAttri :TSynHighlighterAttributes read fVrmlprotoAttri write fVrmlprotoAttri; + property VrmlSensorAttri :TSynHighlighterAttributes read fVrmlSensorAttri write fVrmlSensorAttri; + property VrmlShapeAttri :TSynHighlighterAttributes read fVrmlShapeAttri write fVrmlShapeAttri; + property VrmlShape_HintAttri :TSynHighlighterAttributes read fVrmlShape_HintAttri write fVrmlShape_HintAttri; + property VrmlTime_dependentAttri :TSynHighlighterAttributes read fVrmlTime_dependentAttri write fVrmlTime_dependentAttri; + property VrmlViewpointAttri :TSynHighlighterAttributes read fVrmlViewpointAttri write fVrmlViewpointAttri; + property VrmlWorldInfoAttri :TSynHighlighterAttributes read fVrmlWorldInfoAttri write fVrmlWorldInfoAttri; + property X3DDocTypeAttri :TSynHighlighterAttributes read fX3DDocTypeAttri write fX3DDocTypeAttri; + property X3DHeaderAttri :TSynHighlighterAttributes read fX3DHeaderAttri write fX3DHeaderAttri; + end; + +implementation + +uses +{$IFDEF SYN_CLX} + QSynEditStrConst; +{$ELSE} + SynEditStrConst, SynEditStrConstExtra; +{$ENDIF} + +var + Identifiers :array[#0..#255] of ByteBool; + mHashTable :array[#0..#255] of Integer; + +procedure MakeIdentTable; +var + I, J :Char; +begin + for I := #0 to #255 do + begin + case I of + '_', '0'..'9', 'a'..'z', 'A'..'Z' :Identifiers[I] := True; + else + Identifiers[I] := False; + end; + J := UpCase(I); + case I in ['_', 'A'..'Z', 'a'..'z'] of + True :mHashTable[I] := Ord(J) - 64 + else + mHashTable[I] := 0; + end; + end; +end; + +procedure TSynVrml97Syn.InitIdent; +var + I :Integer; + pF :PIdentFuncTableFunc; +begin + pF := PIdentFuncTableFunc(@fIdentFuncTable); + for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do + begin + pF^ := {$IFDEF FPC}@{$ENDIF}AltFunc; + Inc(pF); + end; + fIdentFuncTable[5] := {$IFDEF FPC}@{$ENDIF} Func5; + fIdentFuncTable[15] := {$IFDEF FPC}@{$ENDIF} Func15; + fIdentFuncTable[17] := {$IFDEF FPC}@{$ENDIF} Func17; + fIdentFuncTable[18] := {$IFDEF FPC}@{$ENDIF} Func18; + fIdentFuncTable[19] := {$IFDEF FPC}@{$ENDIF} Func19; + fIdentFuncTable[22] := {$IFDEF FPC}@{$ENDIF} Func22; + fIdentFuncTable[23] := {$IFDEF FPC}@{$ENDIF} Func23; + fIdentFuncTable[25] := {$IFDEF FPC}@{$ENDIF} Func25; + fIdentFuncTable[26] := {$IFDEF FPC}@{$ENDIF} Func26; + fIdentFuncTable[27] := {$IFDEF FPC}@{$ENDIF} Func27; + fIdentFuncTable[28] := {$IFDEF FPC}@{$ENDIF} Func28; + fIdentFuncTable[29] := {$IFDEF FPC}@{$ENDIF} Func29; + fIdentFuncTable[30] := {$IFDEF FPC}@{$ENDIF} Func30; + fIdentFuncTable[31] := {$IFDEF FPC}@{$ENDIF} Func31; + fIdentFuncTable[32] := {$IFDEF FPC}@{$ENDIF} Func32; + fIdentFuncTable[33] := {$IFDEF FPC}@{$ENDIF} Func33; + fIdentFuncTable[34] := {$IFDEF FPC}@{$ENDIF} Func34; + fIdentFuncTable[35] := {$IFDEF FPC}@{$ENDIF} Func35; + fIdentFuncTable[36] := {$IFDEF FPC}@{$ENDIF} Func36; + fIdentFuncTable[37] := {$IFDEF FPC}@{$ENDIF} Func37; + fIdentFuncTable[38] := {$IFDEF FPC}@{$ENDIF} Func38; + fIdentFuncTable[39] := {$IFDEF FPC}@{$ENDIF} Func39; + fIdentFuncTable[40] := {$IFDEF FPC}@{$ENDIF} Func40; + fIdentFuncTable[41] := {$IFDEF FPC}@{$ENDIF} Func41; + fIdentFuncTable[42] := {$IFDEF FPC}@{$ENDIF} Func42; + fIdentFuncTable[43] := {$IFDEF FPC}@{$ENDIF} Func43; + fIdentFuncTable[44] := {$IFDEF FPC}@{$ENDIF} Func44; + fIdentFuncTable[45] := {$IFDEF FPC}@{$ENDIF} Func45; + fIdentFuncTable[46] := {$IFDEF FPC}@{$ENDIF} Func46; + fIdentFuncTable[47] := {$IFDEF FPC}@{$ENDIF} Func47; + fIdentFuncTable[48] := {$IFDEF FPC}@{$ENDIF} Func48; + fIdentFuncTable[49] := {$IFDEF FPC}@{$ENDIF} Func49; + fIdentFuncTable[50] := {$IFDEF FPC}@{$ENDIF} Func50; + fIdentFuncTable[51] := {$IFDEF FPC}@{$ENDIF} Func51; + fIdentFuncTable[52] := {$IFDEF FPC}@{$ENDIF} Func52; + fIdentFuncTable[53] := {$IFDEF FPC}@{$ENDIF} Func53; + fIdentFuncTable[54] := {$IFDEF FPC}@{$ENDIF} Func54; + fIdentFuncTable[55] := {$IFDEF FPC}@{$ENDIF} Func55; + fIdentFuncTable[56] := {$IFDEF FPC}@{$ENDIF} Func56; + fIdentFuncTable[57] := {$IFDEF FPC}@{$ENDIF} Func57; + fIdentFuncTable[58] := {$IFDEF FPC}@{$ENDIF} Func58; + fIdentFuncTable[59] := {$IFDEF FPC}@{$ENDIF} Func59; + fIdentFuncTable[60] := {$IFDEF FPC}@{$ENDIF} Func60; + fIdentFuncTable[61] := {$IFDEF FPC}@{$ENDIF} Func61; + fIdentFuncTable[62] := {$IFDEF FPC}@{$ENDIF} Func62; + fIdentFuncTable[63] := {$IFDEF FPC}@{$ENDIF} Func63; + fIdentFuncTable[64] := {$IFDEF FPC}@{$ENDIF} Func64; + fIdentFuncTable[65] := {$IFDEF FPC}@{$ENDIF} Func65; + fIdentFuncTable[66] := {$IFDEF FPC}@{$ENDIF} Func66; + fIdentFuncTable[67] := {$IFDEF FPC}@{$ENDIF} Func67; + fIdentFuncTable[68] := {$IFDEF FPC}@{$ENDIF} Func68; + fIdentFuncTable[69] := {$IFDEF FPC}@{$ENDIF} Func69; + fIdentFuncTable[70] := {$IFDEF FPC}@{$ENDIF} Func70; + fIdentFuncTable[71] := {$IFDEF FPC}@{$ENDIF} Func71; + fIdentFuncTable[72] := {$IFDEF FPC}@{$ENDIF} Func72; + fIdentFuncTable[73] := {$IFDEF FPC}@{$ENDIF} Func73; + fIdentFuncTable[74] := {$IFDEF FPC}@{$ENDIF} Func74; + fIdentFuncTable[75] := {$IFDEF FPC}@{$ENDIF} Func75; + fIdentFuncTable[76] := {$IFDEF FPC}@{$ENDIF} Func76; + fIdentFuncTable[77] := {$IFDEF FPC}@{$ENDIF} Func77; + fIdentFuncTable[78] := {$IFDEF FPC}@{$ENDIF} Func78; + fIdentFuncTable[79] := {$IFDEF FPC}@{$ENDIF} Func79; + fIdentFuncTable[80] := {$IFDEF FPC}@{$ENDIF} Func80; + fIdentFuncTable[81] := {$IFDEF FPC}@{$ENDIF} Func81; + fIdentFuncTable[82] := {$IFDEF FPC}@{$ENDIF} Func82; + fIdentFuncTable[83] := {$IFDEF FPC}@{$ENDIF} Func83; + fIdentFuncTable[84] := {$IFDEF FPC}@{$ENDIF} Func84; + fIdentFuncTable[85] := {$IFDEF FPC}@{$ENDIF} Func85; + fIdentFuncTable[86] := {$IFDEF FPC}@{$ENDIF} Func86; + fIdentFuncTable[87] := {$IFDEF FPC}@{$ENDIF} Func87; + fIdentFuncTable[88] := {$IFDEF FPC}@{$ENDIF} Func88; + fIdentFuncTable[89] := {$IFDEF FPC}@{$ENDIF} Func89; + fIdentFuncTable[90] := {$IFDEF FPC}@{$ENDIF} Func90; + fIdentFuncTable[91] := {$IFDEF FPC}@{$ENDIF} Func91; + fIdentFuncTable[92] := {$IFDEF FPC}@{$ENDIF} Func92; + fIdentFuncTable[93] := {$IFDEF FPC}@{$ENDIF} Func93; + fIdentFuncTable[94] := {$IFDEF FPC}@{$ENDIF} Func94; + fIdentFuncTable[95] := {$IFDEF FPC}@{$ENDIF} Func95; + fIdentFuncTable[96] := {$IFDEF FPC}@{$ENDIF} Func96; + fIdentFuncTable[97] := {$IFDEF FPC}@{$ENDIF} Func97; + fIdentFuncTable[98] := {$IFDEF FPC}@{$ENDIF} Func98; + fIdentFuncTable[99] := {$IFDEF FPC}@{$ENDIF} Func99; + fIdentFuncTable[100] := {$IFDEF FPC}@{$ENDIF} Func100; + fIdentFuncTable[101] := {$IFDEF FPC}@{$ENDIF} Func101; + fIdentFuncTable[102] := {$IFDEF FPC}@{$ENDIF} Func102; + fIdentFuncTable[103] := {$IFDEF FPC}@{$ENDIF} Func103; + fIdentFuncTable[104] := {$IFDEF FPC}@{$ENDIF} Func104; + fIdentFuncTable[105] := {$IFDEF FPC}@{$ENDIF} Func105; + fIdentFuncTable[106] := {$IFDEF FPC}@{$ENDIF} Func106; + fIdentFuncTable[107] := {$IFDEF FPC}@{$ENDIF} Func107; + fIdentFuncTable[108] := {$IFDEF FPC}@{$ENDIF} Func108; + fIdentFuncTable[109] := {$IFDEF FPC}@{$ENDIF} Func109; + fIdentFuncTable[110] := {$IFDEF FPC}@{$ENDIF} Func110; + fIdentFuncTable[111] := {$IFDEF FPC}@{$ENDIF} Func111; + fIdentFuncTable[112] := {$IFDEF FPC}@{$ENDIF} Func112; + fIdentFuncTable[113] := {$IFDEF FPC}@{$ENDIF} Func113; + fIdentFuncTable[114] := {$IFDEF FPC}@{$ENDIF} Func114; + fIdentFuncTable[115] := {$IFDEF FPC}@{$ENDIF} Func115; + fIdentFuncTable[116] := {$IFDEF FPC}@{$ENDIF} Func116; + fIdentFuncTable[117] := {$IFDEF FPC}@{$ENDIF} Func117; + fIdentFuncTable[118] := {$IFDEF FPC}@{$ENDIF} Func118; + fIdentFuncTable[119] := {$IFDEF FPC}@{$ENDIF} Func119; + fIdentFuncTable[120] := {$IFDEF FPC}@{$ENDIF} Func120; + fIdentFuncTable[121] := {$IFDEF FPC}@{$ENDIF} Func121; + fIdentFuncTable[122] := {$IFDEF FPC}@{$ENDIF} Func122; + fIdentFuncTable[123] := {$IFDEF FPC}@{$ENDIF} Func123; + fIdentFuncTable[124] := {$IFDEF FPC}@{$ENDIF} Func124; + fIdentFuncTable[125] := {$IFDEF FPC}@{$ENDIF} Func125; + fIdentFuncTable[126] := {$IFDEF FPC}@{$ENDIF} Func126; + fIdentFuncTable[128] := {$IFDEF FPC}@{$ENDIF} Func128; + fIdentFuncTable[129] := {$IFDEF FPC}@{$ENDIF} Func129; + fIdentFuncTable[130] := {$IFDEF FPC}@{$ENDIF} Func130; + fIdentFuncTable[131] := {$IFDEF FPC}@{$ENDIF} Func131; + fIdentFuncTable[132] := {$IFDEF FPC}@{$ENDIF} Func132; + fIdentFuncTable[133] := {$IFDEF FPC}@{$ENDIF} Func133; + fIdentFuncTable[134] := {$IFDEF FPC}@{$ENDIF} Func134; + fIdentFuncTable[135] := {$IFDEF FPC}@{$ENDIF} Func135; + fIdentFuncTable[136] := {$IFDEF FPC}@{$ENDIF} Func136; + fIdentFuncTable[137] := {$IFDEF FPC}@{$ENDIF} Func137; + fIdentFuncTable[138] := {$IFDEF FPC}@{$ENDIF} Func138; + fIdentFuncTable[139] := {$IFDEF FPC}@{$ENDIF} Func139; + fIdentFuncTable[140] := {$IFDEF FPC}@{$ENDIF} Func140; + fIdentFuncTable[141] := {$IFDEF FPC}@{$ENDIF} Func141; + fIdentFuncTable[142] := {$IFDEF FPC}@{$ENDIF} Func142; + fIdentFuncTable[143] := {$IFDEF FPC}@{$ENDIF} Func143; + fIdentFuncTable[144] := {$IFDEF FPC}@{$ENDIF} Func144; + fIdentFuncTable[145] := {$IFDEF FPC}@{$ENDIF} Func145; + fIdentFuncTable[146] := {$IFDEF FPC}@{$ENDIF} Func146; + fIdentFuncTable[147] := {$IFDEF FPC}@{$ENDIF} Func147; + fIdentFuncTable[148] := {$IFDEF FPC}@{$ENDIF} Func148; + fIdentFuncTable[149] := {$IFDEF FPC}@{$ENDIF} Func149; + fIdentFuncTable[150] := {$IFDEF FPC}@{$ENDIF} Func150; + fIdentFuncTable[151] := {$IFDEF FPC}@{$ENDIF} Func151; + fIdentFuncTable[153] := {$IFDEF FPC}@{$ENDIF} Func153; + fIdentFuncTable[154] := {$IFDEF FPC}@{$ENDIF} Func154; + fIdentFuncTable[155] := {$IFDEF FPC}@{$ENDIF} Func155; + fIdentFuncTable[156] := {$IFDEF FPC}@{$ENDIF} Func156; + fIdentFuncTable[157] := {$IFDEF FPC}@{$ENDIF} Func157; + fIdentFuncTable[158] := {$IFDEF FPC}@{$ENDIF} Func158; + fIdentFuncTable[159] := {$IFDEF FPC}@{$ENDIF} Func159; + fIdentFuncTable[160] := {$IFDEF FPC}@{$ENDIF} Func160; + fIdentFuncTable[161] := {$IFDEF FPC}@{$ENDIF} Func161; + fIdentFuncTable[162] := {$IFDEF FPC}@{$ENDIF} Func162; + fIdentFuncTable[164] := {$IFDEF FPC}@{$ENDIF} Func164; + fIdentFuncTable[166] := {$IFDEF FPC}@{$ENDIF} Func166; + fIdentFuncTable[167] := {$IFDEF FPC}@{$ENDIF} Func167; + fIdentFuncTable[168] := {$IFDEF FPC}@{$ENDIF} Func168; + fIdentFuncTable[169] := {$IFDEF FPC}@{$ENDIF} Func169; + fIdentFuncTable[170] := {$IFDEF FPC}@{$ENDIF} Func170; + fIdentFuncTable[171] := {$IFDEF FPC}@{$ENDIF} Func171; + fIdentFuncTable[172] := {$IFDEF FPC}@{$ENDIF} Func172; + fIdentFuncTable[173] := {$IFDEF FPC}@{$ENDIF} Func173; + fIdentFuncTable[174] := {$IFDEF FPC}@{$ENDIF} Func174; + fIdentFuncTable[175] := {$IFDEF FPC}@{$ENDIF} Func175; + fIdentFuncTable[176] := {$IFDEF FPC}@{$ENDIF} Func176; + fIdentFuncTable[177] := {$IFDEF FPC}@{$ENDIF} Func177; + fIdentFuncTable[178] := {$IFDEF FPC}@{$ENDIF} Func178; + fIdentFuncTable[179] := {$IFDEF FPC}@{$ENDIF} Func179; + fIdentFuncTable[180] := {$IFDEF FPC}@{$ENDIF} Func180; + fIdentFuncTable[181] := {$IFDEF FPC}@{$ENDIF} Func181; + fIdentFuncTable[182] := {$IFDEF FPC}@{$ENDIF} Func182; + fIdentFuncTable[183] := {$IFDEF FPC}@{$ENDIF} Func183; + fIdentFuncTable[184] := {$IFDEF FPC}@{$ENDIF} Func184; + fIdentFuncTable[185] := {$IFDEF FPC}@{$ENDIF} Func185; + fIdentFuncTable[186] := {$IFDEF FPC}@{$ENDIF} Func186; + fIdentFuncTable[188] := {$IFDEF FPC}@{$ENDIF} Func188; + fIdentFuncTable[189] := {$IFDEF FPC}@{$ENDIF} Func189; + fIdentFuncTable[190] := {$IFDEF FPC}@{$ENDIF} Func190; + fIdentFuncTable[194] := {$IFDEF FPC}@{$ENDIF} Func194; + fIdentFuncTable[196] := {$IFDEF FPC}@{$ENDIF} Func196; + fIdentFuncTable[198] := {$IFDEF FPC}@{$ENDIF} Func198; + fIdentFuncTable[199] := {$IFDEF FPC}@{$ENDIF} Func199; + fIdentFuncTable[200] := {$IFDEF FPC}@{$ENDIF} Func200; + fIdentFuncTable[202] := {$IFDEF FPC}@{$ENDIF} Func202; + fIdentFuncTable[204] := {$IFDEF FPC}@{$ENDIF} Func204; + fIdentFuncTable[206] := {$IFDEF FPC}@{$ENDIF} Func206; + fIdentFuncTable[209] := {$IFDEF FPC}@{$ENDIF} Func209; + fIdentFuncTable[210] := {$IFDEF FPC}@{$ENDIF} Func210; + fIdentFuncTable[212] := {$IFDEF FPC}@{$ENDIF} Func212; + fIdentFuncTable[213] := {$IFDEF FPC}@{$ENDIF} Func213; + fIdentFuncTable[214] := {$IFDEF FPC}@{$ENDIF} Func214; + fIdentFuncTable[215] := {$IFDEF FPC}@{$ENDIF} Func215; + fIdentFuncTable[216] := {$IFDEF FPC}@{$ENDIF} Func216; + fIdentFuncTable[217] := {$IFDEF FPC}@{$ENDIF} Func217; + fIdentFuncTable[218] := {$IFDEF FPC}@{$ENDIF} Func218; + fIdentFuncTable[220] := {$IFDEF FPC}@{$ENDIF} Func220; + fIdentFuncTable[221] := {$IFDEF FPC}@{$ENDIF} Func221; + fIdentFuncTable[222] := {$IFDEF FPC}@{$ENDIF} Func222; + fIdentFuncTable[223] := {$IFDEF FPC}@{$ENDIF} Func223; + fIdentFuncTable[226] := {$IFDEF FPC}@{$ENDIF} Func226; + fIdentFuncTable[229] := {$IFDEF FPC}@{$ENDIF} Func229; + fIdentFuncTable[233] := {$IFDEF FPC}@{$ENDIF} Func233; + fIdentFuncTable[234] := {$IFDEF FPC}@{$ENDIF} Func234; + fIdentFuncTable[235] := {$IFDEF FPC}@{$ENDIF} Func235; + fIdentFuncTable[236] := {$IFDEF FPC}@{$ENDIF} Func236; + fIdentFuncTable[237] := {$IFDEF FPC}@{$ENDIF} Func237; + fIdentFuncTable[239] := {$IFDEF FPC}@{$ENDIF} Func239; + fIdentFuncTable[245] := {$IFDEF FPC}@{$ENDIF} Func245; + fIdentFuncTable[252] := {$IFDEF FPC}@{$ENDIF} Func252; + fIdentFuncTable[255] := {$IFDEF FPC}@{$ENDIF} Func255; + fIdentFuncTable[260] := {$IFDEF FPC}@{$ENDIF} Func260; + fIdentFuncTable[262] := {$IFDEF FPC}@{$ENDIF} Func262; + fIdentFuncTable[263] := {$IFDEF FPC}@{$ENDIF} Func263; + fIdentFuncTable[264] := {$IFDEF FPC}@{$ENDIF} Func264; + fIdentFuncTable[267] := {$IFDEF FPC}@{$ENDIF} Func267; + fIdentFuncTable[271] := {$IFDEF FPC}@{$ENDIF} Func271; + fIdentFuncTable[278] := {$IFDEF FPC}@{$ENDIF} Func278; + fIdentFuncTable[280] := {$IFDEF FPC}@{$ENDIF} Func280; + fIdentFuncTable[283] := {$IFDEF FPC}@{$ENDIF} Func283; + fIdentFuncTable[284] := {$IFDEF FPC}@{$ENDIF} Func284; + fIdentFuncTable[289] := {$IFDEF FPC}@{$ENDIF} Func289; + fIdentFuncTable[292] := {$IFDEF FPC}@{$ENDIF} Func292; + fIdentFuncTable[303] := {$IFDEF FPC}@{$ENDIF} Func303; + fIdentFuncTable[307] := {$IFDEF FPC}@{$ENDIF} Func307; + fIdentFuncTable[308] := {$IFDEF FPC}@{$ENDIF} Func308; + fIdentFuncTable[318] := {$IFDEF FPC}@{$ENDIF} Func318; + fIdentFuncTable[320] := {$IFDEF FPC}@{$ENDIF} Func320; + fIdentFuncTable[354] := {$IFDEF FPC}@{$ENDIF} Func354; +end; + +function TSynVrml97Syn.KeyHash(ToHash :PChar) :Integer; +begin + Result := 0; + while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do + begin + inc(Result, mHashTable[ToHash^]); + inc(ToHash); + end; + fStringLen := ToHash - fToIdent; +end; + +function TSynVrml97Syn.KeyComp(const aKey :string) :Boolean; +var + I :Integer; + Temp :PChar; +begin + Temp := fToIdent; + if Length(aKey) = fStringLen then + begin + Result := True; + for i := 1 to fStringLen do + begin + if Temp^ <> aKey[i] then + begin + Result := False; + break; + end; + inc(Temp); + end; + end + else + Result := False; +end; + +//------------------------------------------------------------------------------ + +function TSynVrml97Syn.Func5 :TtkTokenKind; +begin + if KeyComp('E') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func15 :TtkTokenKind; +begin + if KeyComp('DEF') then + Result := tkVrmlProto + else + if KeyComp('FACE') then + Result := tkVrmlParameter + else + if KeyComp('if') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func17 :TtkTokenKind; +begin + if KeyComp('back') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func18 :TtkTokenKind; +begin + if KeyComp('head') then + Result := tkKey + else + if KeyComp('big') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func19 :TtkTokenKind; +begin + if KeyComp('do') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func22 :TtkTokenKind; +begin + if KeyComp('abs') then + Result := tkNonReservedKey + else + if KeyComp('go') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func23 :TtkTokenKind; +begin + if KeyComp('in') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func25 :TtkTokenKind; +begin + if KeyComp('ALL') then + Result := tkVrmlParameter + else + if KeyComp('Area') then + Result := tkNonReservedKey + else + if KeyComp('PI') then + Result := tkNonReservedKey + else + if KeyComp('All') then + Result := tkNonReservedKey + else + if KeyComp('all') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func26 :TtkTokenKind; +begin + if KeyComp('Arc2D') then + Result := tkVrmlShape + else + if KeyComp('LN10') then + Result := tkNonReservedKey + else + if KeyComp('LN2') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func27 :TtkTokenKind; +begin + if KeyComp('OFF') then + Result := tkVrmlParameter + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func28 :TtkTokenKind; +begin + if KeyComp('X3D') then + Result := tkVrmlProto + else + if KeyComp('IS') then + Result := tkVrmlProto + else + if KeyComp('Fog') then + Result := tkVrmlNode + else + if KeyComp('case') then + Result := tkKey + else + if KeyComp('call') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func29 :TtkTokenKind; +begin + if KeyComp('ON') then + Result := tkVrmlParameter + else + if KeyComp('on') then + Result := tkVrmlAttribute + else + if KeyComp('ccw') then + Result := tkVrmlAttribute + else + if KeyComp('NaN') then + Result := tkKey + else + if KeyComp('Embed') then + Result := tkNonReservedKey + else + if KeyComp('ceil') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func30 :TtkTokenKind; +begin + if KeyComp('Date') then + Result := tkNonReservedKey + else + if KeyComp('char') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func31 :TtkTokenKind; +begin + if KeyComp('LOD') then + Result := tkVrmlGrouping + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func32 :TtkTokenKind; +begin + if KeyComp('FILE') then + Result := tkVrmlParameter + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func33 :TtkTokenKind; +begin + if KeyComp('BOLD') then + Result := tkVrmlParameter + else + if KeyComp('bold') then + Result := tkNonReservedKey + else + if KeyComp('name') then + Result := tkNonReservedKey + else + if KeyComp('find') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func34 :TtkTokenKind; +begin + if KeyComp('log') then + Result := tkNonReservedKey + else + if KeyComp('java') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func35 :TtkTokenKind; +begin + if KeyComp('TO') then + Result := tkVrmlProto + else + if KeyComp('Image') then + Result := tkNonReservedKey + else + if KeyComp('image') then + Result := tkVrmlAttribute + else + if KeyComp('tan') then + Result := tkNonReservedKey + else + if KeyComp('catch') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func36 :TtkTokenKind; +begin + if KeyComp('field') then + Result := tkVrmlEvent + else + if KeyComp('min') then + Result := tkNonReservedKey + else + if KeyComp('hash') then + Result := tkNonReservedKey + else + if KeyComp('atan2') then + Result := tkNonReservedKey + else + if KeyComp('atan') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func37 :TtkTokenKind; +begin + if KeyComp('side') then + Result := tkVrmlAttribute + else + if KeyComp('Cone') then + Result := tkVrmlShape + else + if KeyComp('break') then + Result := tkKey + else + if KeyComp('href') then + Result := tkNonReservedKey + else + if KeyComp('cos') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func38 :TtkTokenKind; +begin + if KeyComp('click') then + Result := tkNonReservedKey + else + if KeyComp('acos') then + Result := tkNonReservedKey + else + if KeyComp('max') then + Result := tkNonReservedKey + else + if KeyComp('callee') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func39 :TtkTokenKind; +begin + if KeyComp('meta') then + Result := tkKey + else + if KeyComp('LOG10E') then + Result := tkNonReservedKey + else + if KeyComp('LOG2E') then + Result := tkNonReservedKey + else + if KeyComp('checked') then + Result := tkNonReservedKey + else + if KeyComp('clear') then + Result := tkNonReservedKey + else + if KeyComp('for') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func40 :TtkTokenKind; +begin + if KeyComp('scale') then + Result := tkVrmlAttribute + else + if KeyComp('eval') then + Result := tkNonReservedKey + else + if KeyComp('src') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func41 :TtkTokenKind; +begin + if KeyComp('key') then + Result := tkVrmlAttribute + else + if KeyComp('Box') then + Result := tkVrmlShape + else + if KeyComp('else') then + Result := tkKey + else + if KeyComp('var') then + Result := tkKey + else + if KeyComp('home') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func42 :TtkTokenKind; +begin + if KeyComp('self') then + Result := tkNonReservedKey + else + if KeyComp('Math') then + Result := tkNonReservedKey + else + if KeyComp('sin') then + Result := tkNonReservedKey + else + if KeyComp('new') then + Result := tkKey + else + if KeyComp('sub') then + Result := tkNonReservedKey + else + if KeyComp('final') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func43 :TtkTokenKind; +begin + if KeyComp('LEFT') then + Result := tkVrmlParameter + else + if KeyComp('choice') then + Result := tkVrmlAttribute + else + if KeyComp('endCap') then + Result := tkVrmlAttribute + else + if KeyComp('FALSE') then + Result := tkVrmlParameter + else + if KeyComp('FALSE') then + Result := tkVrmlProto + else + if KeyComp('enabled') then + Result := tkVrmlAttribute + else + if KeyComp('asin') then + Result := tkNonReservedKey + else + if KeyComp('Frame') then + Result := tkNonReservedKey + else + if KeyComp('false') then + Result := tkKey + else + if KeyComp('int') then + Result := tkKey + else + if KeyComp('left') then + Result := tkNonReservedKey + else + if KeyComp('align') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func44 :TtkTokenKind; +begin + if KeyComp('info') then + Result := tkVrmlAttribute + else + if KeyComp('Hidden') then + Result := tkNonReservedKey + else + if KeyComp('UTC') then + Result := tkNonReservedKey + else + if KeyComp('package') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func45 :TtkTokenKind; +begin + if KeyComp('range') then + Result := tkVrmlAttribute + else + if KeyComp('USE') then + Result := tkVrmlProto + else + if KeyComp('CLAMP') then + Result := tkVrmlParameter + else + if KeyComp('exp') then + Result := tkNonReservedKey + else + if KeyComp('match') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func46 :TtkTokenKind; +begin + if KeyComp('Scene') then + Result := tkVrmlProto + else + if KeyComp('Link') then + Result := tkNonReservedKey + else + if KeyComp('link') then + Result := tkNonReservedKey + else + if KeyComp('body') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func47 :TtkTokenKind; +begin + if KeyComp('Disk2D') then + Result := tkVrmlShape + else + if KeyComp('time') then + Result := tkVrmlAttribute + else + if KeyComp('Radio') then + Result := tkNonReservedKey + else + if KeyComp('tags') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func48 :TtkTokenKind; +begin + if KeyComp('NONE') then + Result := tkVrmlParameter + else + if KeyComp('join') then + Result := tkNonReservedKey + else + if KeyComp('embeds') then + Result := tkNonReservedKey + else + if KeyComp('blink') then + Result := tkNonReservedKey + else + if KeyComp('fixed') then + Result := tkNonReservedKey + else + if KeyComp('slice') then + Result := tkNonReservedKey + else + if KeyComp('long') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func49 :TtkTokenKind; +begin + if KeyComp('xml') then + Result := tkKey + else + if KeyComp('Shape') then + Result := tkVrmlShape + else + if KeyComp('speed') then + Result := tkVrmlAttribute + else + if KeyComp('SHAPE') then + Result := tkVrmlParameter + else + if KeyComp('escape') then + Result := tkNonReservedKey + else + if KeyComp('Global') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func50 :TtkTokenKind; +begin + if KeyComp('open') then + Result := tkNonReservedKey + else + if KeyComp('void') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func51 :TtkTokenKind; +begin + if KeyComp('top') then + Result := tkVrmlAttribute + else + if KeyComp('url') then + Result := tkVrmlAttribute + else + if KeyComp('charAt') then + Result := tkNonReservedKey + else + if KeyComp('URL') then + Result := tkNonReservedKey + else + if KeyComp('caller') then + Result := tkNonReservedKey + else + if KeyComp('delete') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func52 :TtkTokenKind; +begin + if KeyComp('Form') then + Result := tkNonReservedKey + else + if KeyComp('form') then + Result := tkNonReservedKey + else + if KeyComp('hspace') then + Result := tkNonReservedKey + else + if KeyComp('byte') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func53 :TtkTokenKind; +begin + if KeyComp('Site') then + Result := tkVrmlNode + else + if KeyComp('Shape2D') then + Result := tkVrmlShape + else + if KeyComp('minBack') then + Result := tkVrmlAttribute + else + if KeyComp('blur') then + Result := tkNonReservedKey + else + if KeyComp('enum') then + Result := tkKey + else + if KeyComp('pageX') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func54 :TtkTokenKind; +begin + if KeyComp('Circle2D') then + Result := tkVrmlShape + else + if KeyComp('ITALIC') then + Result := tkVrmlParameter + else + if KeyComp('pow') then + Result := tkNonReservedKey + else + if KeyComp('close') then + Result := tkNonReservedKey + else + if KeyComp('search') then + Result := tkNonReservedKey + else + if KeyComp('images') then + Result := tkNonReservedKey + else + if KeyComp('class') then + Result := tkKey + else + if KeyComp('float') then + Result := tkKey + else + if KeyComp('Float') then + Result := tkNonReservedKey + else + if KeyComp('pageY') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func55 :TtkTokenKind; +begin + if KeyComp('MFVec2f') then + Result := tkVrmlDefinition + else + if KeyComp('coord') then + Result := tkVrmlAttribute + else + if KeyComp('maxBack') then + Result := tkVrmlAttribute + else + if KeyComp('MFVec3f') then + Result := tkVrmlDefinition + else + if KeyComp('reload') then + Result := tkNonReservedKey + else + if KeyComp('Object') then + Result := tkNonReservedKey + else + if KeyComp('watch') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func56 :TtkTokenKind; +begin + if KeyComp('SIDES') then + Result := tkVrmlParameter + else + if KeyComp('level') then + Result := tkVrmlAttribute + else + if KeyComp('pitch') then + Result := tkVrmlAttribute + else + if KeyComp('this') then + Result := tkKey + else + if KeyComp('alert') then + Result := tkNonReservedKey + else + if KeyComp('sup') then + Result := tkNonReservedKey + else + if KeyComp('domain') then + Result := tkNonReservedKey + else + if KeyComp('index') then + Result := tkNonReservedKey + else + if KeyComp('concat') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func57 :TtkTokenKind; +begin + if KeyComp('beginCap') then + Result := tkVrmlAttribute + else + if KeyComp('height') then + Result := tkVrmlAttribute + else + if KeyComp('MFNode') then + Result := tkVrmlDefinition + else + if KeyComp('AUTO') then + Result := tkVrmlParameter + else + if KeyComp('isNaN') then + Result := tkNonReservedKey + else + if KeyComp('small') then + Result := tkNonReservedKey + else + if KeyComp('while') then + Result := tkKey + else + if KeyComp('height') then + Result := tkNonReservedKey + else + if KeyComp('goto') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func58 :TtkTokenKind; +begin + if KeyComp('GeoLOD') then + Result := tkVrmlAttribute + else + if KeyComp('WRAP') then + Result := tkVrmlParameter + else + if KeyComp('loop') then + Result := tkVrmlAttribute + else + if KeyComp('cookie') then + Result := tkNonReservedKey + else + if KeyComp('closed') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func59 :TtkTokenKind; +begin + if KeyComp('Anchor') then + Result := tkVrmlGrouping + else + if KeyComp('SOLID') then + Result := tkVrmlParameter + else + if KeyComp('size') then + Result := tkVrmlAttribute + else + if KeyComp('NULL') then + Result := tkVrmlParameter + else + if KeyComp('solid') then + Result := tkVrmlAttribute + else + if KeyComp('NULL') then + Result := tkVrmlProto + else + if KeyComp('parse') then + Result := tkNonReservedKey + else + if KeyComp('anchor') then + Result := tkNonReservedKey + else + if KeyComp('double') then + Result := tkKey + else + if KeyComp('Null') then + Result := tkNonReservedKey + else + if KeyComp('null') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func60 :TtkTokenKind; +begin + if KeyComp('SFImage') then + Result := tkVrmlDefinition + else + if KeyComp('jump') then + Result := tkVrmlAttribute + else + if KeyComp('collide') then + Result := tkVrmlAttribute + else + if KeyComp('with') then + Result := tkKey + else + if KeyComp('replace') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func61 :TtkTokenKind; +begin + if KeyComp('SFVec3f') then + Result := tkVrmlDefinition + else + if KeyComp('SFVec2f') then + Result := tkVrmlDefinition + else + if KeyComp('onLoad') then + Result := tkEvent + else + if KeyComp('value') then + Result := tkNonReservedKey + else + if KeyComp('Layer') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func62 :TtkTokenKind; +begin + if KeyComp('MFInt32') then + Result := tkVrmlDefinition + else + if KeyComp('RIGHT') then + Result := tkVrmlParameter + else + if KeyComp('action') then + Result := tkNonReservedKey + else + if KeyComp('getDate') then + Result := tkNonReservedKey + else + if KeyComp('getDay') then + Result := tkNonReservedKey + else + if KeyComp('border') then + Result := tkNonReservedKey + else + if KeyComp('host') then + Result := tkNonReservedKey + else + if KeyComp('frames') then + Result := tkNonReservedKey + else + if KeyComp('right') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func63 :TtkTokenKind; +begin + if KeyComp('PUBLIC') then + Result := tkKey + else + if KeyComp('color') then + Result := tkVrmlAttribute + else + if KeyComp('Inline') then + Result := tkVrmlGrouping + else + if KeyComp('SFNode') then + Result := tkVrmlDefinition + else + if KeyComp('spine') then + Result := tkVrmlAttribute + else + if KeyComp('Color') then + Result := tkVrmlNode + else + if KeyComp('Array') then + Result := tkNonReservedKey + else + if KeyComp('next') then + Result := tkNonReservedKey + else + if KeyComp('try') then + Result := tkKey + else + if KeyComp('public') then + Result := tkKey + else + if KeyComp('Packages') then + Result := tkNonReservedKey + else + if KeyComp('logon') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func64 :TtkTokenKind; +begin + if KeyComp('Boolean') then + Result := tkNonReservedKey + else + if KeyComp('Select') then + Result := tkNonReservedKey + else + if KeyComp('select') then + Result := tkNonReservedKey + else + if KeyComp('taint') then + Result := tkNonReservedKey + else + if KeyComp('focus') then + Result := tkNonReservedKey + else + if KeyComp('boolean') then + Result := tkKey + else + if KeyComp('width') then + Result := tkNonReservedKey + else + if KeyComp('TRUE') then + Result := tkVrmlParameter + else + if KeyComp('true') then + Result := tkKey + else + if KeyComp('screen') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func65 :TtkTokenKind; +begin + if KeyComp('CENTER') then + Result := tkVrmlParameter + else + if KeyComp('REPEAT') then + Result := tkVrmlParameter + else + if KeyComp('VRML') then + Result := tkVrmlProto + else + if KeyComp('center') then + Result := tkVrmlAttribute + else + if KeyComp('filename') then + Result := tkNonReservedKey + else + if KeyComp('links') then + Result := tkNonReservedKey + else + if KeyComp('method') then + Result := tkNonReservedKey + else + if KeyComp('random') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func66 :TtkTokenKind; +begin + if KeyComp('X3DNode') then + Result := tkVrmlProto + else + if KeyComp('FAMILY') then + Result := tkVrmlParameter + else + if KeyComp('length') then + Result := tkVrmlAttribute + else + if KeyComp('family') then + Result := tkVrmlAttribute + else + if KeyComp('TYPE') then + Result := tkVrmlParameter + else + if KeyComp('type') then + Result := tkVrmlAttribute + else + if KeyComp('MFTime') then + Result := tkVrmlDefinition + else + if KeyComp('vspace') then + Result := tkNonReservedKey + else + if KeyComp('title') then + Result := tkNonReservedKey + else + if KeyComp('type') then + Result := tkNonReservedKey + else + if KeyComp('appName') then + Result := tkNonReservedKey + else + if KeyComp('floor') then + Result := tkNonReservedKey + else + if KeyComp('event') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func67 :TtkTokenKind; +begin + if KeyComp('onClick') then + Result := tkEvent + else + if KeyComp('onChange') then + Result := tkEvent + else + if KeyComp('reset') then + Result := tkNonReservedKey + else + if KeyComp('Reset') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func68 :TtkTokenKind; +begin + if KeyComp('Joint') then + Result := tkVrmlNode + else + if KeyComp('backUrl') then + Result := tkVrmlAttribute + else + if KeyComp('SFInt32') then + Result := tkVrmlDefinition + else + if KeyComp('language') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func69 :TtkTokenKind; +begin + if KeyComp('SFBool') then + Result := tkVrmlDefinition + else + if KeyComp('fieldName') then + Result := tkVrmlAttribute + else + if KeyComp('Text') then + Result := tkVrmlShape + else + if KeyComp('spacing') then + Result := tkVrmlAttribute + else + if KeyComp('DEFAULT') then + Result := tkVrmlParameter + else + if KeyComp('port') then + Result := tkNonReservedKey + else + if KeyComp('Text') then + Result := tkNonReservedKey + else + if KeyComp('text') then + Result := tkNonReservedKey + else + if KeyComp('default') then + Result := tkKey + else + if KeyComp('debugger') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func70 :TtkTokenKind; +begin + if KeyComp('Applet') then + Result := tkNonReservedKey + else + if KeyComp('stop') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func71 :TtkTokenKind; +begin + if KeyComp('Sphere') then + Result := tkVrmlShape + else + if KeyComp('offset') then + Result := tkVrmlAttribute + else + if KeyComp('target') then + Result := tkNonReservedKey + else + if KeyComp('Checkbox') then + Result := tkNonReservedKey + else + if KeyComp('encoding') then + Result := tkNonReservedKey + else + if KeyComp('forms') then + Result := tkNonReservedKey + else + if KeyComp('const') then + Result := tkKey + else + if KeyComp('native') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func72 :TtkTokenKind; +begin + if KeyComp('SFTime') then + Result := tkVrmlDefinition + else + if KeyComp('radius') then + Result := tkVrmlAttribute + else + if KeyComp('ENUMS') then + Result := tkVrmlParameter + else + if KeyComp('round') then + Result := tkNonReservedKey + else + if KeyComp('sort') then + Result := tkNonReservedKey + else + if KeyComp('bgColor') then + Result := tkNonReservedKey + else + if KeyComp('static') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func73 :TtkTokenKind; +begin + if KeyComp('children') then + Result := tkVrmlAttribute + else + if KeyComp('Sound') then + Result := tkVrmlNode + else + if KeyComp('MFFloat') then + Result := tkVrmlDefinition + else + if KeyComp('FORMAT') then + Result := tkVrmlParameter + else + if KeyComp('normal') then + Result := tkVrmlAttribute + else + if KeyComp('Normal') then + Result := tkVrmlNode + else + if KeyComp('italics') then + Result := tkNonReservedKey + else + if KeyComp('Number') then + Result := tkNonReservedKey + else + if KeyComp('opener') then + Result := tkNonReservedKey + else + if KeyComp('selected') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func74 :TtkTokenKind; +begin + if KeyComp('PARTS') then + Result := tkVrmlParameter + else + if KeyComp('headlight') then + Result := tkVrmlAttribute + else + if KeyComp('point') then + Result := tkVrmlAttribute + else + if KeyComp('sqrt') then + Result := tkNonReservedKey + else + if KeyComp('SQRT2') then + Result := tkNonReservedKey + else + if KeyComp('parent') then + Result := tkNonReservedKey + else + if KeyComp('setDate') then + Result := tkNonReservedKey + else + if KeyComp('menubar') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func75 :TtkTokenKind; +begin + if KeyComp('minAngle') then + Result := tkVrmlAttribute + else + if KeyComp('Billboard') then + Result := tkVrmlGrouping + else + if KeyComp('write') then + Result := tkNonReservedKey + else + if KeyComp('RegExp') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func76 :TtkTokenKind; +begin + if KeyComp('bindTime') then + Result := tkVrmlAttribute + else + if KeyComp('fgColor') then + Result := tkNonReservedKey + else + if KeyComp('split') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func77 :TtkTokenKind; +begin + if KeyComp('Group') then + Result := tkVrmlGrouping + else + if KeyComp('maxAngle') then + Result := tkVrmlAttribute + else + if KeyComp('javaEnabled') then + Result := tkNonReservedKey + else + if KeyComp('indexOf') then + Result := tkNonReservedKey + else + if KeyComp('print') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func78 :TtkTokenKind; +begin + if KeyComp('BINDINGS') then + Result := tkVrmlParameter + else + if KeyComp('CULLING') then + Result := tkVrmlParameter + else + if KeyComp('anchors') then + Result := tkNonReservedKey + else + if KeyComp('confirm') then + Result := tkNonReservedKey + else + if KeyComp('pathname') then + Result := tkNonReservedKey + else + if KeyComp('start') then + Result := tkKey + else + if KeyComp('charCodeAt') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func79 :TtkTokenKind; +begin + if KeyComp('Material') then + Result := tkVrmlAppearance + else + if KeyComp('material') then + Result := tkVrmlAttribute + else + if KeyComp('SFFloat') then + Result := tkVrmlDefinition + else + if KeyComp('ROUTE') then + Result := tkVrmlProto + else + if KeyComp('Plugin') then + Result := tkNonReservedKey + else + if KeyComp('getTime') then + Result := tkNonReservedKey + else + if KeyComp('refresh') then + Result := tkNonReservedKey + else + if KeyComp('scroll') then + Result := tkNonReservedKey + else + if KeyComp('finally') then + Result := tkKey + else + if KeyComp('super') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func80 :TtkTokenKind; +begin + if KeyComp('appearance') then + Result := tkVrmlAttribute + else + if KeyComp('Appearance') then + Result := tkVrmlAppearance + else + if KeyComp('short') then + Result := tkKey + else + if KeyComp('layers') then + Result := tkNonReservedKey + else + if KeyComp('input') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func81 :TtkTokenKind; +begin + if KeyComp('ArcClose2D') then + Result := tkVrmlShape + else + if KeyComp('source') then + Result := tkVrmlAttribute + else + if KeyComp('style') then + Result := tkVrmlAttribute + else + if KeyComp('STYLE') then + Result := tkVrmlParameter + else + if KeyComp('getYear') then + Result := tkNonReservedKey + else + if KeyComp('interface') then + Result := tkKey + else + if KeyComp('style') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func82 :TtkTokenKind; +begin + if KeyComp('diskAngle') then + Result := tkVrmlAttribute + else + if KeyComp('Switch') then + Result := tkVrmlGrouping + else + if KeyComp('MFColor') then + Result := tkVrmlDefinition + else + if KeyComp('addChildren') then + Result := tkVrmlAttribute + else + if KeyComp('onBlur') then + Result := tkEvent + else + if KeyComp('strike') then + Result := tkNonReservedKey + else + if KeyComp('valueOf') then + Result := tkNonReservedKey + else + if KeyComp('moveBy') then + Result := tkNonReservedKey + else + if KeyComp('switch') then + Result := tkKey + else + if KeyComp('zIndex') then + Result := tkNonReservedKey + else + if KeyComp('Undefined') then + Result := tkNonReservedKey + else + if KeyComp('undefined') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func83 :TtkTokenKind; +begin + if KeyComp('Segment') then + Result := tkVrmlShape + else + if KeyComp('CONVEX') then + Result := tkVrmlParameter + else + if KeyComp('vector') then + Result := tkVrmlAttribute + else + if KeyComp('convex') then + Result := tkVrmlAttribute + else + if KeyComp('netscape') then + Result := tkNonReservedKey + else + if KeyComp('toolbar') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func84 :TtkTokenKind; +begin + if KeyComp('repeatS') then + Result := tkVrmlAttribute + else + if KeyComp('PROTO') then + Result := tkVrmlProto + else + if KeyComp('isBound') then + Result := tkVrmlAttribute + else + if KeyComp('Submit') then + Result := tkNonReservedKey + else + if KeyComp('submit') then + Result := tkNonReservedKey + else + if KeyComp('unescape') then + Result := tkNonReservedKey + else + if KeyComp('throw') then + Result := tkKey + else + if KeyComp('abstract') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func85 :TtkTokenKind; +begin + if KeyComp('Humanoid') then + Result := tkVrmlShape + else + if KeyComp('PER_FACE') then + Result := tkVrmlParameter + else + if KeyComp('OVERALL') then + Result := tkVrmlParameter + else + if KeyComp('beamWidth') then + Result := tkVrmlAttribute + else + if KeyComp('bottom') then + Result := tkVrmlAttribute + else + if KeyComp('repeatT') then + Result := tkVrmlAttribute + else + if KeyComp('BOTTOM') then + Result := tkVrmlParameter + else + if KeyComp('Script') then + Result := tkVrmlNode + else + if KeyComp('onAbort') then + Result := tkEvent + else + if KeyComp('forward') then + Result := tkNonReservedKey + else + if KeyComp('onDblClick') then + Result := tkEvent + else + if KeyComp('bottom') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func86 :TtkTokenKind; +begin + if KeyComp('display') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func87 :TtkTokenKind; +begin + if KeyComp('Displacer') then + Result := tkVrmlParameter + else + if KeyComp('string') then + Result := tkVrmlAttribute + else + if KeyComp('String') then + Result := tkNonReservedKey + else + if KeyComp('typeof') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func88 :TtkTokenKind; +begin + if KeyComp('DOCTYPE') then + Result := tkKey + else + if KeyComp('SFColor') then + Result := tkVrmlDefinition + else + if KeyComp('isOver') then + Result := tkVrmlAttribute + else + if KeyComp('isActive') then + Result := tkVrmlAttribute + else + if KeyComp('DEFAULTS') then + Result := tkVrmlParameter + else + if KeyComp('Window') then + Result := tkNonReservedKey + else + if KeyComp('window') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func89 :TtkTokenKind; +begin + if KeyComp('Rectangle2D') then + Result := tkVrmlShape + else + if KeyComp('eventIn') then + Result := tkVrmlEvent + else + if KeyComp('location') then + Result := tkVrmlAttribute + else + if KeyComp('Location') then + Result := tkNonReservedKey + else + if KeyComp('location') then + Result := tkNonReservedKey + else + if KeyComp('complete') then + Result := tkNonReservedKey + else + if KeyComp('applets') then + Result := tkNonReservedKey + else + if KeyComp('Option') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func90 :TtkTokenKind; +begin + if KeyComp('creaseAngle') then + Result := tkVrmlAttribute + else + if KeyComp('AudioClip') then + Result := tkVrmlTime_dependent + else + if KeyComp('Cylinder') then + Result := tkVrmlShape + else + if KeyComp('lowsrc') then + Result := tkNonReservedKey + else + if KeyComp('moveTo') then + Result := tkNonReservedKey + else + if KeyComp('unwatch') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func91 :TtkTokenKind; +begin + if KeyComp('ColorRGBA') then + Result := tkVrmlAttribute + else + if KeyComp('content') then + Result := tkNonReservedKey + else + if KeyComp('setTime') then + Result := tkNonReservedKey + else + if KeyComp('import') then + Result := tkKey + else + if KeyComp('extends') then + Result := tkKey + else + if KeyComp('private') then + Result := tkKey + else + if KeyComp('isFinite') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func92 :TtkTokenKind; +begin + if KeyComp('GeoMetadata') then + Result := tkVrmlAttribute + else + if KeyComp('Button') then + Result := tkNonReservedKey + else + if KeyComp('reverse') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func93 :TtkTokenKind; +begin + if KeyComp('xSpacing') then + Result := tkVrmlAttribute + else + if KeyComp('appCodeName') then + Result := tkNonReservedKey + else + if KeyComp('setYear') then + Result := tkNonReservedKey + else + if KeyComp('referrer') then + Result := tkNonReservedKey + else + if KeyComp('elements') then + Result := tkNonReservedKey + else + if KeyComp('onFocus') then + Result := tkEvent + else + if KeyComp('onSelect') then + Result := tkEvent + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func94 :TtkTokenKind; +begin + if KeyComp('whichChoice') then + Result := tkVrmlAttribute + else + if KeyComp('fogType') then + Result := tkVrmlAttribute + else + if KeyComp('leftUrl') then + Result := tkVrmlAttribute + else + if KeyComp('skyAngle') then + Result := tkVrmlAttribute + else + if KeyComp('Textarea') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func95 :TtkTokenKind; +begin + if KeyComp('cycleTime') then + Result := tkVrmlAttribute + else + if KeyComp('zSpacing') then + Result := tkVrmlAttribute + else + if KeyComp('hostname') then + Result := tkNonReservedKey + else + if KeyComp('document') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func96 :TtkTokenKind; +begin + if KeyComp('Background') then + Result := tkVrmlNode + else + if KeyComp('onUnload') then + Result := tkEvent + else + if KeyComp('return') then + Result := tkKey + else + if KeyComp('onReset') then + Result := tkEvent + else + if KeyComp('background') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func97 :TtkTokenKind; +begin + if KeyComp('direction') then + Result := tkVrmlAttribute + else + if KeyComp('parameter') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func98 :TtkTokenKind; +begin + if KeyComp('proxy') then + Result := tkVrmlAttribute + else + if KeyComp('prompt') then + Result := tkNonReservedKey + else + if KeyComp('plugins') then + Result := tkNonReservedKey + else + if KeyComp('export') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func99 :TtkTokenKind; +begin + if KeyComp('GeoOrigin') then + Result := tkVrmlAttribute + else + if KeyComp('eventName') then + Result := tkVrmlAttribute + else + if KeyComp('current') then + Result := tkNonReservedKey + else + if KeyComp('untaint') then + Result := tkNonReservedKey + else + if KeyComp('substr') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func100 :TtkTokenKind; +begin + if KeyComp('CLOCKWISE') then + Result := tkVrmlParameter + else + if KeyComp('status') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func101 :TtkTokenKind; +begin + if KeyComp('FileUpload') then + Result := tkNonReservedKey + else + if KeyComp('writeln') then + Result := tkNonReservedKey + else + if KeyComp('continue') then + Result := tkKey + else + if KeyComp('platform') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func102 :TtkTokenKind; +begin + if KeyComp('X3DChildNode') then + Result := tkVrmlProto + else + if KeyComp('version') then + Result := tkNonReservedKey + else + if KeyComp('keyValue') then + Result := tkVrmlAttribute + else + if KeyComp('fieldType') then + Result := tkVrmlAttribute + else + if KeyComp('bboxSize') then + Result := tkVrmlAttribute + else + if KeyComp('topUrl') then + Result := tkVrmlAttribute + else + if KeyComp('getMonth') then + Result := tkNonReservedKey + else + if KeyComp('Function') then + Result := tkNonReservedKey + else + if KeyComp('function') then + Result := tkKey + else + if KeyComp('parseInt') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func103 :TtkTokenKind; +begin + if KeyComp('SignalPdu') then + Result := tkVrmlGrouping + else + if KeyComp('onError') then + Result := tkEvent + else + if KeyComp('throws') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func104 :TtkTokenKind; +begin + if KeyComp('set_bind') then + Result := tkVrmlAttribute + else + if KeyComp('texCoord') then + Result := tkVrmlAttribute + else + if KeyComp('Coordinate') then + Result := tkVrmlNode + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func105 :TtkTokenKind; +begin + if KeyComp('exitTime') then + Result := tkVrmlAttribute + else + if KeyComp('SQRT1_2') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func106 :TtkTokenKind; +begin + if KeyComp('MFString') then + Result := tkVrmlDefinition + else + if KeyComp('MimeType') then + Result := tkNonReservedKey + else + if KeyComp('instanceof') then + Result := tkKey + else + if KeyComp('protected') then + Result := tkKey + else + if KeyComp('Infinity') then + Result := tkNonReservedKey + else + if KeyComp('scrollBy') then + Result := tkNonReservedKey + else + if KeyComp('getUTCDate') then + Result := tkNonReservedKey + else + if KeyComp('getUTCDay') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func107 :TtkTokenKind; +begin + if KeyComp('collideTime') then + Result := tkVrmlAttribute + else + if KeyComp('taintEnabled') then + Result := tkNonReservedKey + else + if KeyComp('Navigator') then + Result := tkNonReservedKey + else + if KeyComp('navigator') then + Result := tkNonReservedKey + else + if KeyComp('onKeyUp') then + Result := tkEvent + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func108 :TtkTokenKind; +begin + if KeyComp('Collision') then + Result := tkVrmlGrouping + else + if KeyComp('bboxCenter') then + Result := tkVrmlAttribute + else + if KeyComp('geometry') then + Result := tkVrmlAttribute + else + if KeyComp('defaultChecked') then + Result := tkNonReservedKey + else + if KeyComp('options') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func109 :TtkTokenKind; +begin + if KeyComp('enterTime') then + Result := tkVrmlAttribute + else + if KeyComp('minFront') then + Result := tkVrmlAttribute + else + if KeyComp('suffixes') then + Result := tkNonReservedKey + else + if KeyComp('linkColor') then + Result := tkNonReservedKey + else + if KeyComp('resizeBy') then + Result := tkNonReservedKey + else + if KeyComp('fromCharCode') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func110 :TtkTokenKind; +begin + if KeyComp('Contour2D') then + Result := tkVrmlShape + else + if KeyComp('cutOffAngle') then + Result := tkVrmlAttribute + else + if KeyComp('justify') then + Result := tkVrmlAttribute + else + if KeyComp('userAgent') then + Result := tkNonReservedKey + else + if KeyComp('alinkColor') then + Result := tkNonReservedKey + else + if KeyComp('locationbar') then + Result := tkNonReservedKey + else + if KeyComp('handleEvent') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func111 :TtkTokenKind; +begin + if KeyComp('maxFront') then + Result := tkVrmlAttribute + else + if KeyComp('coordIndex') then + Result := tkVrmlAttribute + else + if KeyComp('getSeconds') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func112 :TtkTokenKind; +begin + if KeyComp('Polyline2D') then + Result := tkVrmlShape + else + if KeyComp('rotation') then + Result := tkVrmlAttribute + else + if KeyComp('SFString') then + Result := tkVrmlDefinition + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func113 :TtkTokenKind; +begin + if KeyComp('rightUrl') then + Result := tkVrmlAttribute + else + if KeyComp('texture') then + Result := tkVrmlAttribute + else + if KeyComp('onSubmit') then + Result := tkEvent + else + if KeyComp('parseFloat') then + Result := tkNonReservedKey + else + if KeyComp('getHours') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func114 :TtkTokenKind; +begin + if KeyComp('touchTime') then + Result := tkVrmlAttribute + else + if KeyComp('fontsize') then + Result := tkNonReservedKey + else + if KeyComp('History') then + Result := tkNonReservedKey + else + if KeyComp('history') then + Result := tkNonReservedKey + else + if KeyComp('setMonth') then + Result := tkNonReservedKey + else + if KeyComp('protocol') then + Result := tkNonReservedKey + else + if KeyComp('scrollTo') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func115 :TtkTokenKind; +begin + if KeyComp('X3DBindableNode') then + Result := tkVrmlProto + else + if KeyComp('X3DShapeNode') then + Result := tkVrmlProto + else + if KeyComp('set_scale') then + Result := tkVrmlAttribute + else + if KeyComp('Password') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func116 :TtkTokenKind; +begin + if KeyComp('GeoLocation') then + Result := tkVrmlAttribute + else + if KeyComp('fieldOfView') then + Result := tkVrmlAttribute + else + if KeyComp('shininess') then + Result := tkVrmlAttribute + else + if KeyComp('WorldInfo') then + Result := tkVrmlWorldInfo + else + if KeyComp('toSource') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func117 :TtkTokenKind; +begin + if KeyComp('stopTime') then + Result := tkVrmlAttribute + else + if KeyComp('position') then + Result := tkVrmlAttribute + else + if KeyComp('lastModified') then + Result := tkNonReservedKey + else + if KeyComp('resizeTo') then + Result := tkNonReservedKey + else + if KeyComp('innerHeight') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func118 :TtkTokenKind; +begin + if KeyComp('spatialize') then + Result := tkVrmlAttribute + else + if KeyComp('groundAngle') then + Result := tkVrmlAttribute + else + if KeyComp('skyColor') then + Result := tkVrmlAttribute + else + if KeyComp('PointSet') then + Result := tkVrmlShape + else + if KeyComp('fontcolor') then + Result := tkNonReservedKey + else + if KeyComp('Arguments') then + Result := tkNonReservedKey + else + if KeyComp('arguments') then + Result := tkNonReservedKey + else + if KeyComp('setUTCDate') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func119 :TtkTokenKind; +begin + if KeyComp('colorIndex') then + Result := tkVrmlAttribute + else + if KeyComp('scrollbars') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func120 :TtkTokenKind; +begin + if KeyComp('transient') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func121 :TtkTokenKind; +begin + if KeyComp('personalbar') then + Result := tkNonReservedKey + else + if KeyComp('statusbar') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func122 :TtkTokenKind; +begin + if KeyComp('LoadSensor') then + Result := tkVrmlSensor + else + if KeyComp('X3DLightNode') then + Result := tkVrmlProto + else + if KeyComp('eventOut') then + Result := tkVrmlEvent + else + if KeyComp('avatarSize') then + Result := tkVrmlAttribute + else + if KeyComp('toString') then + Result := tkNonReservedKey + else + if KeyComp('enabledPlugin') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func123 :TtkTokenKind; +begin + if KeyComp('setSeconds') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func124 :TtkTokenKind; +begin + if KeyComp('Transform') then + Result := tkVrmlGrouping + else + if KeyComp('IndexedFaceSet') then + Result := tkVrmlShape_Hint + else + if KeyComp('exposedField') then + Result := tkVrmlEvent + else + if KeyComp('frontUrl') then + Result := tkVrmlAttribute + else + if KeyComp('innerWidth') then + Result := tkNonReservedKey + else + if KeyComp('pageXOffset') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func125 :TtkTokenKind; +begin + if KeyComp('PER_PART') then + Result := tkVrmlParameter + else + if KeyComp('startTime') then + Result := tkVrmlAttribute + else + if KeyComp('previous') then + Result := tkNonReservedKey + else + if KeyComp('setHours') then + Result := tkNonReservedKey + else + if KeyComp('mimeTypes') then + Result := tkNonReservedKey + else + if KeyComp('pageYOffset') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func126 :TtkTokenKind; +begin + if KeyComp('ReceiverPdu') then + Result := tkVrmlGrouping + else + if KeyComp('SpotLight') then + Result := tkVrmlLight + else + if KeyComp('xDimension') then + Result := tkVrmlAttribute + else + if KeyComp('maxExtent') then + Result := tkVrmlAttribute + else + if KeyComp('implements') then + Result := tkKey + else + if KeyComp('onKeyDown') then + Result := tkEvent + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func128 :TtkTokenKind; +begin + if KeyComp('Transform2D') then + Result := tkVrmlGrouping + else + if KeyComp('zDimension') then + Result := tkVrmlAttribute + else + if KeyComp('autoOffset') then + Result := tkVrmlAttribute + else + if KeyComp('MIN_VALUE') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func129 :TtkTokenKind; +begin + if KeyComp('X3DColorNode') then + Result := tkVrmlProto + else + if KeyComp('normalIndex') then + Result := tkVrmlAttribute + else + if KeyComp('lastIndexOf') then + Result := tkNonReservedKey + else + if KeyComp('substring') then + Result := tkNonReservedKey + else + if KeyComp('selectedIndex') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func130 :TtkTokenKind; +begin + if KeyComp('TriangleSet') then + Result := tkVrmlShape + else + if KeyComp('BooleanToggle') then + Result := tkVrmlSensor + else + if KeyComp('priority') then + Result := tkVrmlAttribute + else + if KeyComp('PointLight') then + Result := tkVrmlLight + else + if KeyComp('defaultValue') then + Result := tkNonReservedKey + else + if KeyComp('MAX_VALUE') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func131 :TtkTokenKind; +begin + if KeyComp('TimeTrigger') then + Result := tkVrmlTime_Dependent + else + if KeyComp('KeySensor') then + Result := tkVrmlSensor + else + if KeyComp('GeoCoordinate') then + Result := tkVrmlAttribute + else + if KeyComp('MFRotation') then + Result := tkVrmlDefinition + else + if KeyComp('vlinkColor') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func132 :TtkTokenKind; +begin + if KeyComp('set_height') then + Result := tkVrmlAttribute + else + if KeyComp('description') then + Result := tkVrmlAttribute + else + if KeyComp('eventType') then + Result := tkVrmlAttribute + else + if KeyComp('description') then + Result := tkNonReservedKey + else + if KeyComp('getFullYear') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func133 :TtkTokenKind; +begin + if KeyComp('diffuseColor') then + Result := tkVrmlAttribute + else + if KeyComp('Viewpoint') then + Result := tkVrmlViewpoint + else + if KeyComp('getMinutes') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func134 :TtkTokenKind; +begin + if KeyComp('TriangleSet2D') then + Result := tkVrmlShape + else + if KeyComp('BooleanFilter') then + Result := tkVrmlSensor + else + if KeyComp('X3DUrlObject') then + Result := tkVrmlProto + else + if KeyComp('value_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func135 :TtkTokenKind; +begin + if KeyComp('intensity') then + Result := tkVrmlAttribute + else + if KeyComp('appVersion') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func136 :TtkTokenKind; +begin + if KeyComp('fontStyle') then + Result := tkVrmlAttribute + else + if KeyComp('bottomUrl') then + Result := tkVrmlAttribute + else + if KeyComp('FontStyle') then + Result := tkVrmlNode + else + if KeyComp('toLowerCase') then + Result := tkNonReservedKey + else + if KeyComp('outerHeight') then + Result := tkNonReservedKey + else + if KeyComp('visibility') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func137 :TtkTokenKind; +begin + if KeyComp('SFRotation') then + Result := tkVrmlDefinition + else + if KeyComp('TimeSensor') then + Result := tkVrmlSensor + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func138 :TtkTokenKind; +begin + if KeyComp('horizontal') then + Result := tkVrmlAttribute + else + if KeyComp('PlaneSensor') then + Result := tkVrmlSensor + else + if KeyComp('set_spine') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func139 :TtkTokenKind; +begin + if KeyComp('X3DSoundNode') then + Result := tkVrmlProto + else + if KeyComp('X3DNormalNode') then + Result := tkVrmlProto + else + if KeyComp('toUpperCase') then + Result := tkNonReservedKey + else + if KeyComp('onMouseUp') then + Result := tkEvent + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func140 :TtkTokenKind; +begin + if KeyComp('orientation') then + Result := tkVrmlAttribute + else + if KeyComp('attenuation') then + Result := tkVrmlAttribute + else + if KeyComp('leftToRight') then + Result := tkVrmlAttribute + else + if KeyComp('clearInterval') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func141 :TtkTokenKind; +begin + if KeyComp('ElevationGrid') then + Result := tkVrmlShape + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func142 :TtkTokenKind; +begin + if KeyComp('groundColor') then + Result := tkVrmlAttribute + else + if KeyComp('defaultSelected') then + Result := tkNonReservedKey + else + if KeyComp('clearTimeout') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func143 :TtkTokenKind; +begin + if KeyComp('NurbsCurve') then + Result := tkVrmlShape + else + if KeyComp('translation') then + Result := tkVrmlAttribute + else + if KeyComp('outerWidth') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func144 :TtkTokenKind; +begin + if KeyComp('setFullYear') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func145 :TtkTokenKind; +begin + if KeyComp('X3DMaterialNode') then + Result := tkVrmlProto + else + if KeyComp('Extrusion') then + Result := tkVrmlShape_Hint + else + if KeyComp('setMinutes') then + Result := tkNonReservedKey + else + if KeyComp('setInterval') then + Result := tkNonReservedKey + else + if KeyComp('routeEvent') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func146 :TtkTokenKind; +begin + if KeyComp('Polypoint2D') then + Result := tkVrmlShape + else + if KeyComp('X3DAppearanceNode') then + Result := tkVrmlProto + else + if KeyComp('X3DAppearanceNode') then + Result := tkVrmlProto + else + if KeyComp('getUTCMonth') then + Result := tkNonReservedKey + else + if KeyComp('getElementById') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func147 :TtkTokenKind; +begin + if KeyComp('NurbsSurface') then + Result := tkVrmlShape + else + if KeyComp('NurbsCurve2D') then + Result := tkVrmlShape + else + if KeyComp('setTimeout') then + Result := tkNonReservedKey + else + if KeyComp('onKeyPress') then + Result := tkEvent + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func148 :TtkTokenKind; +begin + if KeyComp('BooleanTrigger') then + Result := tkVrmlSensor + else + if KeyComp('X3DBoundedObject') then + Result := tkVrmlProto + else + if KeyComp('ImageTexture') then + Result := tkVrmlAppearance + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func149 :TtkTokenKind; +begin + if KeyComp('StaticGroup') then + Result := tkVrmlGrouping + else + if KeyComp('X3DTriggerNode') then + Result := tkVrmlProto + else + if KeyComp('IndexedLineSet') then + Result := tkVrmlShape_Hint + else + if KeyComp('cycleInterval') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func150 :TtkTokenKind; +begin + if KeyComp('prototype') then + Result := tkKey + else + if KeyComp('releaseEvents') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func151 :TtkTokenKind; +begin + if KeyComp('TriangleFanSet') then + Result := tkVrmlShape + else + if KeyComp('NurbsGroup') then + Result := tkVrmlGrouping + else + if KeyComp('X3DScriptNode') then + Result := tkVrmlProto + else + if KeyComp('removeChildren') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func153 :TtkTokenKind; +begin + if KeyComp('minPosition') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func154 :TtkTokenKind; +begin + if KeyComp('transparency') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func155 :TtkTokenKind; +begin + if KeyComp('TrimmedSurface') then + Result := tkVrmlShape + else + if KeyComp('maxPosition') then + Result := tkVrmlAttribute + else + if KeyComp('getUTCSeconds') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func156 :TtkTokenKind; +begin + if KeyComp('X3DSensorNode') then + Result := tkVrmlProto + else + if KeyComp('JUSTIFICATION') then + Result := tkVrmlParameter + else + if KeyComp('NavigationInfo') then + Result := tkVrmlNode + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func157 :TtkTokenKind; +begin + if KeyComp('bottomRadius') then + Result := tkVrmlAttribute + else + if KeyComp('TouchSensor') then + Result := tkVrmlSensor + else + if KeyComp('onMouseMove') then + Result := tkEvent + else + if KeyComp('getUTCHours') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func158 :TtkTokenKind; +begin + if KeyComp('specularColor') then + Result := tkVrmlAttribute + else + if KeyComp('onMouseOut') then + Result := tkEvent + else + if KeyComp('onMouseDown') then + Result := tkEvent + else + if KeyComp('setUTCMonth') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func159 :TtkTokenKind; +begin + if KeyComp('crossSection') then + Result := tkVrmlAttribute + else + if KeyComp('fraction_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func160 :TtkTokenKind; +begin + if KeyComp('GeoViewpoint') then + Result := tkVrmlViewpoint + else + if KeyComp('mustEvaluate') then + Result := tkVrmlAttribute + else + if KeyComp('texCoordIndex') then + Result := tkVrmlAttribute + else + if KeyComp('synchronized') then + Result := tkKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func161 :TtkTokenKind; +begin + if KeyComp('SphereSensor') then + Result := tkVrmlSensor + else + if KeyComp('set_fraction') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func162 :TtkTokenKind; +begin + if KeyComp('IntegerTrigger') then + Result := tkVrmlSensor + else + if KeyComp('X3DBackgroundNode') then + Result := tkVrmlProto + else + if KeyComp('toGMTString') then + Result := tkNonReservedKey + else + if KeyComp('onMouseOver') then + Result := tkEvent + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func164 :TtkTokenKind; +begin + if KeyComp('PER_VERTEX') then + Result := tkVrmlParameter + else + if KeyComp('emissiveColor') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func166 :TtkTokenKind; +begin + if KeyComp('DirectionalLight') then + Result := tkVrmlLight + else + if KeyComp('constructor') then + Result := tkKey + else + if KeyComp('getMilliseconds') then + Result := tkNonReservedKey + else + if KeyComp('toUTCString') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func167 :TtkTokenKind; +begin + if KeyComp('setUTCSeconds') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func168 :TtkTokenKind; +begin + if KeyComp('GeoElevationGrid') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func169 :TtkTokenKind; +begin + if KeyComp('defaultStatus') then + Result := tkNonReservedKey + else + if KeyComp('captureEvents') then + Result := tkNonReservedKey + else + if KeyComp('setUTCHours') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func170 :TtkTokenKind; +begin + if KeyComp('X3DCoordinateNode') then + Result := tkVrmlProto + else + if KeyComp('EXTERNPROTO') then + Result := tkVrmlProto + else + if KeyComp('toLocaleString') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func171 :TtkTokenKind; +begin + if KeyComp('BooleanSequencer') then + Result := tkVrmlSensor + else + if KeyComp('topToBottom') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func172 :TtkTokenKind; +begin + if KeyComp('directOutput') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func173 :TtkTokenKind; +begin + if KeyComp('X3DGroupingNode') then + Result := tkVrmlProto + else + if KeyComp('X3DSequencerNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func174 :TtkTokenKind; +begin + if KeyComp('X3DGeometryNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func175 :TtkTokenKind; +begin + if KeyComp('duration_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func176 :TtkTokenKind; +begin + if KeyComp('getUTCFullYear') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func177 :TtkTokenKind; +begin + if KeyComp('StringSensor') then + Result := tkVrmlSensor + else + if KeyComp('MovieTexture') then + Result := tkVrmlTime_Dependent + else + if KeyComp('getUTCMinutes') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func178 :TtkTokenKind; +begin + if KeyComp('X3DGeometry2DNode') then + Result := tkVrmlProto + else + if KeyComp('X3DGeometry3DNode') then + Result := tkVrmlProto + else + if KeyComp('setMilliseconds') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func179 :TtkTokenKind; +begin + if KeyComp('X3DTextureNode') then + Result := tkVrmlProto + else + if KeyComp('PixelTexture') then + Result := tkVrmlAppearance + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func180 :TtkTokenKind; +begin + if KeyComp('FillProperties') then + Result := tkVrmlAttribute + else + if KeyComp('scaleOrientation') then + Result := tkVrmlAttribute + else + if KeyComp('CylinderSensor') then + Result := tkVrmlSensor + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func181 :TtkTokenKind; +begin + if KeyComp('LineProperties') then + Result := tkVrmlAttribute + else + if KeyComp('PER_FACE_INDEXED') then + Result := tkVrmlParameter + else + if KeyComp('visibilityRange') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func182 :TtkTokenKind; +begin + if KeyComp('X3DAppearanceChildNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func183 :TtkTokenKind; +begin + if KeyComp('X3DTexture2DNode') then + Result := tkVrmlProto + else + if KeyComp('hitNormal_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func184 :TtkTokenKind; +begin + if KeyComp('GeoTouchSensor') then + Result := tkVrmlSensor + else + if KeyComp('hitPoint_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func185 :TtkTokenKind; +begin + if KeyComp('IntegerSequencer') then + Result := tkVrmlTime_dependent + else + if KeyComp('rotation_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func186 :TtkTokenKind; +begin + if KeyComp('X3DDragSensorNode') then + Result := tkVrmlProto + else + if KeyComp('set_coordIndex') then + Result := tkVrmlAttribute + else + if KeyComp('axisOfRotation') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func188 :TtkTokenKind; +begin + if KeyComp('MultiTexture') then + Result := tkVrmlAttribute + else + if KeyComp('CoordinateDeformer') then + Result := tkVrmlNode + else + if KeyComp('setUTCFullYear') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func189 :TtkTokenKind; +begin + if KeyComp('ESPDUTransform') then + Result := tkVrmlGrouping + else + if KeyComp('setUTCMinutes') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func190 :TtkTokenKind; +begin + if KeyComp('position_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func194 :TtkTokenKind; +begin + if KeyComp('set_colorIndex') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func196 :TtkTokenKind; +begin + if KeyComp('COUNTERCLOCKWISE') then + Result := tkVrmlParameter + else + if KeyComp('colorPerVertex') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func198 :TtkTokenKind; +begin + if KeyComp('TransmitterPdu') then + Result := tkVrmlGrouping + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func199 :TtkTokenKind; +begin + if KeyComp('ambientIntensity') then + Result := tkVrmlAttribute + else + if KeyComp('visibilityLimit') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func200 :TtkTokenKind; +begin + if KeyComp('X3DTimeDependentNode') then + Result := tkVrmlProto + else + if KeyComp('trackPoint_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func202 :TtkTokenKind; +begin + if KeyComp('X3DFontStyleNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func204 :TtkTokenKind; +begin + if KeyComp('set_normalIndex') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func206 :TtkTokenKind; +begin + if KeyComp('normalPerVertex') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func209 :TtkTokenKind; +begin + if KeyComp('TextureBackground') then + Result := tkVrmlAppearance + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func210 :TtkTokenKind; +begin + if KeyComp('getTimezoneOffset') then + Result := tkNonReservedKey + else + if KeyComp('getUTCMilliseconds') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func212 :TtkTokenKind; +begin + if KeyComp('TriangleStripSet') then + Result := tkVrmlShape + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func213 :TtkTokenKind; +begin + if KeyComp('orientation_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func214 :TtkTokenKind; +begin + if KeyComp('hitTexCoord_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func215 :TtkTokenKind; +begin + if KeyComp('set_orientation') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func216 :TtkTokenKind; +begin + if KeyComp('translation_changed') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func217 :TtkTokenKind; +begin + if KeyComp('TextureCoordinate') then + Result := tkVrmlAppearance + else + if KeyComp('ScalarInterpolator') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func218 :TtkTokenKind; +begin + if KeyComp('ContourPolyline2D') then + Result := tkVrmlShape + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func220 :TtkTokenKind; +begin + if KeyComp('X3DSoundSourceNode') then + Result := tkVrmlProto + else + if KeyComp('NEGATIVE_INFINITY') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func221 :TtkTokenKind; +begin + if KeyComp('PER_PART_INDEXED') then + Result := tkVrmlParameter + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func222 :TtkTokenKind; +begin + if KeyComp('setUTCMilliseconds') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func223 :TtkTokenKind; +begin + if KeyComp('X3DTouchSensorNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func226 :TtkTokenKind; +begin + if KeyComp('ColorInterpolator') then + Result := tkVrmlInterpolator + else + if KeyComp('VisibilitySensor') then + Result := tkVrmlSensor + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func229 :TtkTokenKind; +begin + if KeyComp('X3DInterpolatorNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func233 :TtkTokenKind; +begin + if KeyComp('UNKNOWN_ORDERING') then + Result := tkVrmlParameter + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func234 :TtkTokenKind; +begin + if KeyComp('set_crossSection') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func235 :TtkTokenKind; +begin + if KeyComp('set_texCoordIndex') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func236 :TtkTokenKind; +begin + if KeyComp('NormalInterpolator') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func237 :TtkTokenKind; +begin + if KeyComp('textureTransform') then + Result := tkVrmlAttribute + else + if KeyComp('TextureTransform') then + Result := tkVrmlAppearance + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func239 :TtkTokenKind; +begin + if KeyComp('ProximitySensor') then + Result := tkVrmlSensor + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func245 :TtkTokenKind; +begin + if KeyComp('X3DKeyDeviceSensorNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func252 :TtkTokenKind; +begin + if KeyComp('POSITIVE_INFINITY') then + Result := tkNonReservedKey + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func255 :TtkTokenKind; +begin + if KeyComp('UNKNOWN_FACE_TYPE') then + Result := tkVrmlParameter + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func260 :TtkTokenKind; +begin + if KeyComp('NurbsTextureSurface') then + Result := tkVrmlAppearance + else + if KeyComp('PER_VERTEX_INDEXED') then + Result := tkVrmlParameter + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func262 :TtkTokenKind; +begin + if KeyComp('X3DNetworkSensorNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func263 :TtkTokenKind; +begin + if KeyComp('X3DPrototypeInstance') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func264 :TtkTokenKind; +begin + if KeyComp('X3DComposedGeometryNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func267 :TtkTokenKind; +begin + if KeyComp('CoordinateInterpolator') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func271 :TtkTokenKind; +begin + if KeyComp('CoordinateInterpolator2D') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func278 :TtkTokenKind; +begin + if KeyComp('X3DParametricGeometryNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func280 :TtkTokenKind; +begin + if KeyComp('PositionInterpolator') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func283 :TtkTokenKind; +begin + if KeyComp('X3DTextureCoordinateNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func284 :TtkTokenKind; +begin + if KeyComp('PositionInterpolator2D') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func289 :TtkTokenKind; +begin + if KeyComp('UNKNOWN_SHAPE_TYPE') then + Result := tkVrmlParameter + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func292 :TtkTokenKind; +begin + if KeyComp('MultiTextureCoordinate') then + Result := tkVrmlAttribute + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func303 :TtkTokenKind; +begin + if KeyComp('X3DTextureTransformNode') then + Result := tkVrmlProto + else + if KeyComp('OrientationInterpolator') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func307 :TtkTokenKind; +begin + if KeyComp('GeoPositionInterpolator') then + Result := tkVrmlInterpolator + else + if KeyComp('X3DGeometryPropertyNode') then + Result := tkVrmlProto + else + if KeyComp('X3DTextureTransform2DNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func308 :TtkTokenKind; +begin + if KeyComp('X3DPointingDeviceSensorNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func318 :TtkTokenKind; +begin + if KeyComp('X3DEnvironmentalSensorNode') then + Result := tkVrmlProto + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func320 :TtkTokenKind; +begin + if KeyComp('TextureCoordinateGenerator') then + Result := tkVrmlAppearance + else + Result := tkIdentifier; +end; + +function TSynVrml97Syn.Func354 :TtkTokenKind; +begin + if KeyComp('NurbsPositionInterpolator') then + Result := tkVrmlInterpolator + else + Result := tkIdentifier; +end; + +//------------------------------------------------------------------------------ + +function TSynVrml97Syn.AltFunc :TtkTokenKind; +begin + Result := tkIdentifier; +end; + +function TSynVrml97Syn.IdentKind(MayBe :PChar) :TtkTokenKind; +var + HashKey :Integer; +begin + fToIdent := MayBe; + HashKey := KeyHash(MayBe); + if HashKey < 304 then + Result := fIdentFuncTable[HashKey] {$IFDEF FPC}(){$ENDIF} + else + Result := tkIdentifier; +end; + +constructor TSynVrml97Syn.Create(AOwner :TComponent); +begin + inherited Create(AOwner); + isDoctype := false; + fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment); + fCommentAttri.Style := [fsItalic]; + fCommentAttri.Foreground := clNavy; + fCommentAttri.Background := clGray; + AddAttribute(fCommentAttri); + + fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier); + fIdentifierAttri.Style := []; + fIdentifierAttri.Foreground := clNavy; + fIdentifierAttri.Background := clWhite; + AddAttribute(fIdentifierAttri); + + fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord); + fKeyAttri.Style := [fsBold]; + fKeyAttri.Foreground := clRed; + fKeyAttri.Background := clWhite; + AddAttribute(fKeyAttri); + + fNonReservedKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrNonReservedKeyword); + fNonReservedKeyAttri.Style := [fsItalic]; + fNonReservedKeyAttri.Foreground := clBlack; + fNonReservedKeyAttri.Background := clWhite; + AddAttribute(fNonReservedKeyAttri); + + fEventAttri := TSynHighlighterAttributes.Create(SYNS_AttrEvent); + fEventAttri.Style := [fsItalic]; + fEventAttri.Foreground := clNavy; + fEventAttri.Background := clWhite; + AddAttribute(fEventAttri); + + fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber); + fEventAttri.Style := [fsItalic]; + fEventAttri.Foreground := clNavy; + fEventAttri.Background := clWhite; + AddAttribute(fNumberAttri); + + fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace); + fSpaceAttri.Style := [fsItalic]; + fSpaceAttri.Foreground := clNavy; + fSpaceAttri.Background := clWhite; + AddAttribute(fSpaceAttri); + + fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString); + fStringAttri.Style := [fsItalic]; + fStringAttri.Foreground := clNavy; + fStringAttri.Background := clWhite; + AddAttribute(fStringAttri); + + fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol); + fSymbolAttri.Style := [fsItalic]; + fSymbolAttri.Foreground := clNavy; + fSymbolAttri.Background := clWhite; + AddAttribute(fSymbolAttri); + //-- vrml + fVrmlAppearanceAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlAppearance); + fVrmlAppearanceAttri.Style := [fsItalic]; + fVrmlAppearanceAttri.Foreground := clNavy; + fVrmlAppearanceAttri.Background := clWhite; + AddAttribute(fVrmlAppearanceAttri); + + fVrmlAttributeAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlAttribute); + fVrmlAttributeAttri.Style := [fsItalic]; + fVrmlAttributeAttri.Foreground := clNavy; + fVrmlAttributeAttri.Background := clGray; + AddAttribute(fVrmlAttributeAttri); + + fVrmlDefinitionAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlDefinition); + fVrmlDefinitionAttri.Style := [fsItalic]; + fVrmlDefinitionAttri.Foreground := clNavy; + fVrmlDefinitionAttri.Background := clRed; + AddAttribute(fVrmlDefinitionAttri); + + fVrmlEventAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlEvent); + fVrmlEventAttri.Style := [fsBold]; + fVrmlEventAttri.Foreground := clRed; + fVrmlEventAttri.Background := clWhite; + AddAttribute(fVrmlEventAttri); + + fVrmlGroupingAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlGrouping); + fVrmlGroupingAttri.Style := [fsBold]; + fVrmlGroupingAttri.Foreground := clNavy; + fVrmlGroupingAttri.Background := clWhite; + AddAttribute(fVrmlGroupingAttri); + + fVrmlInterpolatorAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlInterpolator); + fVrmlInterpolatorAttri.Style := [fsItalic]; + fVrmlInterpolatorAttri.Foreground := clLime; + fVrmlInterpolatorAttri.Background := clWhite; + AddAttribute(fVrmlInterpolatorAttri); + + fVrmlLightAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlLight); + fVrmlLightAttri.Style := [fsItalic]; + fVrmlLightAttri.Foreground := clTeal; + fVrmlLightAttri.Background := clWhite; + AddAttribute(fVrmlLightAttri); + + fVrmlNodeAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlNode); + fVrmlNodeAttri.Style := [fsItalic, fsBold]; + fVrmlNodeAttri.Foreground := clGreen; + fVrmlNodeAttri.Background := clWhite; + AddAttribute(fVrmlNodeAttri); + + fVrmlParameterAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlParameter); + fVrmlParameterAttri.Style := [fsBold]; + fVrmlParameterAttri.Foreground := $F0CAA6; //clSkyBlue + fVrmlParameterAttri.Background := clWhite; + AddAttribute(fVrmlParameterAttri); + + fVrmlprotoAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlProto); + fVrmlprotoAttri.Style := [fsBold]; + fVrmlprotoAttri.Foreground := clRed; + fVrmlprotoAttri.Background := clWhite; + AddAttribute(fVrmlprotoAttri); + + fVrmlSensorAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlSensor); + fVrmlSensorAttri.Style := [fsBold]; + fVrmlSensorAttri.Foreground := clOlive; + fVrmlSensorAttri.Background := clWhite; + AddAttribute(fVrmlSensorAttri); + + fVrmlShapeAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlShape); + fVrmlShapeAttri.Style := [fsBold]; + fVrmlShapeAttri.Foreground := clPurple; + fVrmlShapeAttri.Background := clWhite; + AddAttribute(fVrmlShapeAttri); + + fVrmlShape_HintAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlShape_Hint); + fVrmlShape_HintAttri.Style := [fsItalic]; + fVrmlShape_HintAttri.Foreground := clPurple; + fVrmlShape_HintAttri.Background := clWhite; + AddAttribute(fVrmlShape_HintAttri); + + fVrmlTime_dependentAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlTime_dependent); + fVrmlTime_dependentAttri.Style := [fsItalic]; + fVrmlTime_dependentAttri.Foreground := clOlive; + fVrmlTime_dependentAttri.Background := clWhite; + AddAttribute(fVrmlTime_dependentAttri); + + fVrmlViewpointAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlViewpoint); + fVrmlViewpointAttri.Style := [fsItalic]; + fVrmlViewpointAttri.Foreground := clGreen; + fVrmlViewpointAttri.Background := clWhite; + AddAttribute(fVrmlViewpointAttri); + + fVrmlWorldInfoAttri := TSynHighlighterAttributes.Create(SYNS_AttrVrmlWorldInfo); + fVrmlWorldInfoAttri.Style := [fsItalic]; + fVrmlWorldInfoAttri.Foreground := clMaroon; + fVrmlWorldInfoAttri.Background := clWhite; + AddAttribute(fVrmlWorldInfoAttri); + + fX3DDocTypeAttri := TSynHighLighterAttributes.Create(SYNS_AttrX3DDocType); + fX3DDocTypeAttri.Style := [fsItalic]; + fX3DDocTypeAttri.Foreground := clMaroon; + fX3DDocTypeAttri.Background := clWhite; + AddAttribute(fX3DDocTypeAttri); + + fX3DHeaderAttri := TSynHighLighterAttributes.Create(SYNS_AttrX3DHeader); + fX3DHeaderAttri.Style := [fsItalic]; + fX3DHeaderAttri.Foreground := clMaroon; + fX3DHeaderAttri.Background := clWhite; + AddAttribute(fX3DHeaderAttri); + + SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange); + InitIdent; + MakeMethodTables; + fDefaultFilter := SYNS_FilterVrml97; + fRange := rsNormalText; +end; + +{$IFDEF SYN_LAZARUS} +procedure TSynVrml97Syn.GetTokenEx(out TokenStart: PChar; out TokenLength: integer); +begin + TokenLength := Run - fTokenPos; + TokenStart := FLine + fTokenPos; +end; +{$ENDIF} + +procedure TSynVrml97Syn.SetLine(const NewValue :string; LineNumber :Integer); +begin + fLine := PChar(NewValue); + Run := 0; + fLineNumber := LineNumber; + Next; +end; + +procedure TSynVrml97Syn.MakeMethodTables; +var + I :Char; +begin + for I := #0 to #255 do + case I of + '&' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} AndSymbolProc; + #13 :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} CRProc; + '#' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} DiesisCommentProc; + 'A'..'Z', 'a'..'z', '_' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} IdentProc; + #10 :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} LFProc; + '-' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} MinusProc; + '%' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} ModSymbolProc; + #0 :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NullProc; + '0'..'9' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} NumberProc; + '|' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} OrSymbolProc; + '+' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} PlusProc; + '.' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} PointProc; + '/' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SlashProc; + #1..#9, #11, #12, #14..#32 :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SpaceProc; + '*' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StarProc; + '"', #39 :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} StringProc; + '?' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} X3DHeaderOpenProc; + '!' :fProcTable[I] := {$IFDEF FPC}@{$ENDIF} X3DDocTypeOpenProc; + '~', '{', '}', ',', '(', ')', '[', ']', ':', ';', '=', '<', '>' : + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} SymbolProc; + else + fProcTable[I] := {$IFDEF FPC}@{$ENDIF} UnknownProc; + end; +end; + +procedure TSynVrml97Syn.AndSymbolProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] in ['=', '&'] then inc(Run); +end; + +function TSynVrml97Syn.NextTokenIs(T :string) :Boolean; +var + I, Len :Integer; +begin + Result := True; + Len := Length(T); + for I := 1 to Len do + if (fLine[Run + I] <> T[I]) then + begin + Result := False; + Break; + end; +end; + +procedure TSynVrml97Syn.InCommentProc; +begin + if (fLine[Run + 1] = '-') and (fLine[Run + 2] = '-') then + begin + Inc(Run); + fTokenID := tkComment; + fRange := rsComment; + Inc(Run, 2); + repeat + Inc(Run); + if (fLine[Run] = '-') and (fLine[Run + 1] = '-') then + begin + fRange := rsNormalText; + Inc(Run, 2); + break; + end; + until fLine[Run] in [#0, #10, #13]; + Exit; + end; +end; + +procedure TSynVrml97Syn.DiesisCommentProc; +begin + if fLine[Run] = #0 then + fTokenID := tkNull + else + begin + fTokenID := tkComment; + repeat + inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynVrml97Syn.X3DHeaderOpenProc; +begin + Inc(Run); + fRange := rsX3DHeader; + X3DHeaderProc; + fTokenID := tkX3DHeader; +end; + +procedure TSynVrml97Syn.X3DHeaderProc; +begin + case fLine[Run] of + #0 :NullProc; + #10 :LFProc; + #13 :CRProc; + else + begin + fTokenID := tkX3DHeader; + repeat + if (fLine[Run] = '?') then + begin + Inc(Run, 1); + fRange := rsNormalText; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + end; +end; + +procedure TSynVrml97Syn.X3DDocTypeOpenProc; +begin + if NextTokenIs('DOCTYPE') then + begin + fRange := rsX3DDocType; + X3DDocTypeProc; + fTokenID := tkX3DDocType; + end + else + if NextTokenIs('--') then + begin + fRange := rsComment; + InCommentProc; + fTokenID := tkComment; + end + else + fTokenID := tkSymbol; +end; + +procedure TSynVrml97Syn.X3DDocTypeProc; +begin + case fLine[Run] of + #0 :NullProc; + #10 :LFProc; + #13 :CRProc; + else + begin + fTokenID := tkX3DDocType; + repeat + if (fLine[Run + 1] = '>') then + begin + Inc(Run, 1); + fRange := rsNormalText; + Break; + end; + if not (fLine[Run] in [#0, #10, #13]) then + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + end; +end; + +procedure TSynVrml97Syn.CommentProc; +begin + if fLine[Run] = #0 then + fTokenID := tkNull + else + begin + fTokenID := tkComment; + repeat + if ((fLine[Run] = '*') and (fLine[Run + 1] = '/')) + or + ((fLine[Run] = '-') and (fLine[Run + 1] = '-')) then + begin + fRange := rsNormalText; + inc(Run, 2); + break; + end; + inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; +end; + +procedure TSynVrml97Syn.CRProc; +begin + fTokenID := tkSpace; + inc(Run); + if fLine[Run] = #10 then inc(Run); +end; + +procedure TSynVrml97Syn.IdentProc; +begin + fTokenID := IdentKind((fLine + Run)); + inc(Run, fStringLen); + while Identifiers[fLine[Run]] do + inc(Run); +end; + +procedure TSynVrml97Syn.LFProc; +begin + fTokenID := tkSpace; + inc(Run); +end; + +procedure TSynVrml97Syn.MinusProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] in ['=', '-', '>'] then inc(Run); +end; + +procedure TSynVrml97Syn.ModSymbolProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] = '=' then inc(Run); +end; + +procedure TSynVrml97Syn.NullProc; +begin + fTokenID := tkNull; +end; + +procedure TSynVrml97Syn.NumberProc; +var + idx1 :Integer; // token[1] + isHex :Boolean; +begin + fTokenID := tkNumber; + isHex := False; + idx1 := Run; + Inc(Run); + while FLine[Run] in ['0'..'9', '.', 'a'..'f', 'A'..'F', 'x', 'X'] do + begin + case FLine[Run] of + '.' : + if FLine[Succ(Run)] = '.' then + Break; + 'a'..'f', 'A'..'F' : + if not isHex then + Break; + 'x', 'X' : + begin + if (FLine[idx1] <> '0') or (Run > Succ(idx1)) then + Break; + if not (FLine[Succ(Run)] in ['0'..'9', 'a'..'f', 'A'..'F']) then + Break; + isHex := True; + end; + end; + Inc(Run); + end; +end; + +procedure TSynVrml97Syn.OrSymbolProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] in ['=', '|'] then inc(Run); +end; + +procedure TSynVrml97Syn.PlusProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] in ['=', '+'] then inc(Run); +end; + +procedure TSynVrml97Syn.PointProc; +begin + fTokenID := tkSymbol; + inc(Run); + if (fLine[Run] = '.') and (fLine[Run + 1] = '.') then inc(Run, 2); +end; + +procedure TSynVrml97Syn.SlashProc; +begin + Inc(Run); + case fLine[Run] of + '/' : + begin + fTokenID := tkComment; + repeat + Inc(Run); + until fLine[Run] in [#0, #10, #13]; + end; + '*' : + begin + fTokenID := tkComment; + fRange := rsComment; + repeat + Inc(Run); + if (fLine[Run] = '*') and (fLine[Run + 1] = '/') then + begin + fRange := rsNormalText; + Inc(Run, 2); + break; + end; + until fLine[Run] in [#0, #10, #13]; + end; + '=' : + begin + Inc(Run); + fTokenID := tkSymbol; + end; + else + fTokenID := tkSymbol; + end; +end; + +procedure TSynVrml97Syn.SpaceProc; +begin + inc(Run); + fTokenID := tkSpace; + while FLine[Run] in [#1..#9, #11, #12, #14..#32] do + inc(Run); +end; + +procedure TSynVrml97Syn.StarProc; +begin + fTokenID := tkSymbol; + inc(Run); + if fLine[Run] = '=' then inc(Run); +end; + +procedure TSynVrml97Syn.StringProc; +var + l_strChar :string; +begin + fTokenID := tkString; + l_strChar := FLine[Run]; // We could have '"' or #39 + if (FLine[Run + 1] = l_strChar) and (FLine[Run + 2] = l_strChar) then inc(Run, 2); + repeat + case FLine[Run] of + #0, #10, #13 :break; + end; + inc(Run); + until (FLine[Run] = l_strChar) and (FLine[Pred(Run)] <> '\'); + if FLine[Run] <> #0 then + Inc(Run); +end; + +procedure TSynVrml97Syn.SymbolProc; +begin + inc(Run); + fTokenId := tkSymbol; +end; + +procedure TSynVrml97Syn.UnknownProc; +begin +{$IFDEF SYN_MBCSSUPPORT} + if FLine[Run] in LeadBytes then + Inc(Run, 2) + else +{$ENDIF} + inc(Run); + fTokenID := tkUnknown; +end; + +procedure TSynVrml97Syn.Next; +begin + fTokenPos := Run; + case fRange of + rsX3DHeader :X3DHeaderProc; + rsX3DDocType :X3DDocTypeProc; + rsComment :CommentProc; + else + begin + fProcTable[fLine[Run]]; + end; + end; +end; + +function TSynVrml97Syn.GetDefaultAttribute(Index :integer) :TSynHighlighterAttributes; +begin + case Index of + SYN_ATTR_COMMENT :Result := fCommentAttri; + SYN_ATTR_IDENTIFIER :Result := fIdentifierAttri; + SYN_ATTR_KEYWORD :Result := fKeyAttri; + SYN_ATTR_STRING :Result := fStringAttri; + SYN_ATTR_WHITESPACE :Result := fSpaceAttri; + SYN_ATTR_SYMBOL :Result := fSymbolAttri; + else + Result := nil; + end; +end; + +function TSynVrml97Syn.GetEol :Boolean; +begin + Result := fTokenID = tkNull; +end; + +function TSynVrml97Syn.GetRange :Pointer; +begin + Result := Pointer(fRange); +end; + +function TSynVrml97Syn.GetToken :string; +var + Len :LongInt; +begin + Len := Run - fTokenPos; + SetString(Result, (FLine + fTokenPos), Len); +end; + +function TSynVrml97Syn.GetTokenID :TtkTokenKind; +begin + Result := fTokenId; +end; + +function TSynVrml97Syn.GetTokenAttribute :TSynHighlighterAttributes; +begin + case GetTokenID of + tkComment :Result := fCommentAttri; + tkIdentifier :Result := fIdentifierAttri; + tkKey :Result := fKeyAttri; + tkNonReservedKey :Result := fNonReservedKeyAttri; + tkEvent :Result := fEventAttri; + tkNumber :Result := fNumberAttri; + tkSpace :Result := fSpaceAttri; + tkString :Result := fStringAttri; + tkSymbol :Result := fSymbolAttri; + tkUnknown: Result := fIdentifierAttri; + // vrml + tkVrmlAppearance :Result := fVrmlAppearanceAttri; + tkVrmlAttribute :Result := fVrmlAttributeAttri; + tkVrmlDefinition :Result := fVrmlDefinitionAttri; + tkVrmlEvent :Result := fVrmlEventAttri; + tkVrmlGrouping :Result := fVrmlGroupingAttri; + tkVrmlInterpolator :Result := fVrmlInterpolatorAttri; + tkVrmlLight :Result := fVrmlLightAttri; + tkVrmlNode :Result := fVrmlNodeAttri; + tkVrmlParameter :Result := fVrmlParameterAttri; + tkVrmlproto :Result := fVrmlprotoAttri; + tkVrmlSensor :Result := fVrmlSensorAttri; + tkVrmlShape :Result := fVrmlShapeAttri; + tkVrmlShape_Hint :Result := fVrmlShape_HintAttri; + tkVrmlTime_dependent :Result := fVrmlTime_dependentAttri; + tkVrmlViewpoint :Result := fVrmlViewpointAttri; + tkVrmlWorldInfo :Result := fVrmlWorldInfoAttri; + tkX3DDocType :Result := fX3DDocTypeAttri; + tkX3DHeader :Result := fX3DHeaderAttri; + //-- + else + Result := nil; + end; +end; + +function TSynVrml97Syn.GetTokenKind :integer; +begin + Result := Ord(fTokenId); +end; + +function TSynVrml97Syn.GetTokenPos :Integer; +begin + Result := fTokenPos; +end; + +procedure TSynVrml97Syn.ResetRange; +begin + fRange := rsNormalText; +end; + +procedure TSynVrml97Syn.SetRange(Value :Pointer); +begin + fRange := TRangeState(Value); +end; + +function TSynVrml97Syn.GetIdentChars :TSynIdentChars; +begin + Result := TSynValidStringChars; +end; + +function TSynVrml97Syn.IsFilterStored: Boolean; +begin + Result := fDefaultFilter <> SYNS_FilterVrml97; +end; + +class function TSynVrml97Syn.GetLanguageName :string; +begin + Result := SYNS_LangVrml97; +end; + +function TSynVrml97Syn.GetSampleSource :string; +begin + Result := + '#VRML V2.0 utf8'#13#10 + + 'Transform {'#13#10 + + ' children ['#13#10 + + ' NavigationInfo { headlight FALSE } # We''ll add our own light'#13#10 + + ''#13#10 + + ' DirectionalLight { # First child'#13#10 + + ' direction 0 0 -1 # Light illuminating the scene'#13#10 + + ' }'#13#10 + + ''#13#10 + + ' Transform { # Second child - a red sphere'#13#10 + + ' translation 3 0 1'#13#10 + + ' children ['#13#10 + + ' Shape {'#13#10 + + ' geometry Sphere { radius 2.3 }'#13#10 + + ' appearance Appearance {'#13#10 + + ' material Material { diffuseColor 1 0 0 } # Red'#13#10 + + ' }'#13#10 + + ' }'#13#10 + + ' ]'#13#10 + + ' }'#13#10 + + ''#13#10 + + ' Transform { # Third child - a blue box '#13#10 + + ' translation -2.4 .2 1'#13#10 + + ' rotation 0 1 1 .9'#13#10 + + ' children ['#13#10 + + ' Shape {'#13#10 + + ' geometry Box {}'#13#10 + + ' appearance Appearance {'#13#10 + + ' material Material { diffuseColor 0 0 1 } # Blue'#13#10 + + ' }'#13#10 + + ' }'#13#10 + + ' ]'#13#10 + + ' }'#13#10 + + ''#13#10 + + ' ] # end of children for world'#13#10 + + '}'#13#10 + + 'DEF Example_2 Script {'#13#10 + + ' field SFNode myself USE Example_2'#13#10 + + ' field SFNode root USE ROOT_TRANSFORM'#13#10 + + ' field MFString url "foo.wrl"'#13#10 + + ' eventIn MFNode nodesLoaded'#13#10 + + ' eventIn SFBool trigger_event'#13#10 + + ''#13#10 + + ' url "javascript:'#13#10 + + ' function trigger_event(value, ts){'#13#10 + + ' // do something and then fetch values'#13#10 + + ' Browser.createVRMLFromURL(url, myself, ''nodesLoaded'');'#13#10 + + ' }'#13#10 + + ''#13#10 + + ' function nodesLoaded(value, timestamp){'#13#10 + + ' if (value.length > 5) {'#13#10 + + ' // do something more than 5 nodes in this MFNode...'#13#10 + + ' }'#13#10 + + ' root.addChildren = value;'#13#10 + + ' }"'#13#10 + + '}'; +end; + +initialization + MakeIdentTable; +{$IFNDEF SYN_CPPB_1} + RegisterPlaceableHighlighter(TSynVrml97Syn); +{$ENDIF} +end. diff --git a/components/extrasyn/TestHighlighters/Mat Lab 6.hgl b/components/extrasyn/TestHighlighters/Mat Lab 6.hgl new file mode 100644 index 000000000..6921b77a1 --- /dev/null +++ b/components/extrasyn/TestHighlighters/Mat Lab 6.hgl @@ -0,0 +1,531 @@ + + + ******* Please read carefully ************************* + * Please, make any changes in this file very carefuly!* + * It is much more convinient to use native designer! * + ******************************************************* + + + + MATLAB 6 + m M + Standard + + + Vitaly Nevzorov + nevzorov@yahoo.com + www.delphist.com + Copyright (c) Vitaly Nevzorov, 2002 + N/A + Created based on UltraEdit:matlab6.txt + + + 1 + 0 + 37612.5510459259 + Beta + + + + + + + + + + 16777215 + 0 + + + + 16777215 + 128 + + + + + !&qt;$&'()*+,-./:;<=>?@[\]^{|}~ + True + False + False + False + + + 16777215 + 32768 + + + break + case + catch + else + elseif + end + for + function + global + if + otherwise + persistent + return + switch + try + while + + + + 16777215 + 16711680 + + + abs + acos + acosh + add_annotation + add_block + add_line + add_param + all + and + any + asin + asinh + assignin + atan + atan2 + atanh + balance + beep + bitand + bitcmp + bitget + bitor + bitset + bitshift + bitxor + builtin + callstats + cat + cd + ceil + cell + cell2struct + cellhorzcat + cells + char + chdir + check_system + chol + cholinc + cholupdate + class + clc + clear + clock + close_system + colon + compare_system + computer + conj + contourc + conv2 + copyobj + cos + cosh + cputime + ctranspose + cumprod + cumsum + dbclear + dbcont + dbdown + dbquit + dbstack + dbstatus + dbstep + dbstop + dbtype + dbup + delete + delete_annotation + delete_block + delete_line + delete_param + det + diag + diary + diff + disp + display + dongarra + dos + double + dragrect + drawnow + echo + eig + eps + eq + error + errortrap + eval + evalc + evalin + exist + exit + exp + expm + eye + fclose + feature + feof + ferror + feval + fft + fftn + fftw + fgets + fieldnames + fields + filesep + fill + fill3 + filter + find + find_system + findpackage + findstr + findtype + finite + fix + floor + fopen + format + fprintf + frame2im + fread + fscanf + fschange + fseek + ftell + full + func2str + functions + functionscalled + fwrite + ge + getenv + getframe + gs_get_buttonmotion + gt + handle + handle2struct + hardcopy + hcreate + help + hess + hittest + home + horzcat + hregister + i + ieee + ifft + ifftn + im2frame + imag + import + inf + Inf + inferiorto + inmem + input + inputname + int16 + int32 + int8 + inv + isa + iscell + ischar + isempty + isequal + isfinite + isglobal + ishandle + isieee + isinf + isjava + isletter + islogical + isnan + isreal + isruntime + isspace + issparse + isstr + isstudent + j + java + javaArray + javaMethod + javaObject + java_array + java_method + java_object + keyboard + lasterr + lastwarn + ldivide + le + length + license + load + log + log2 + logical + loglog + lookfor + lower + lt + ltitr + lu + luinc + magic + matlabpath + matlabroot + max + methods + mexext + mfilename + mimofr + min + minus + mislocked + mldivide + mlock + mod + more + movie + mpower + mrdivide + mtimes + munlock + nan + NaN + nargin + nargout + ndims + ne + new_system + norm + not + numel + ones + open_system + or + pack + pause + permute + pfile + pi + plot + plot3 + plus + pow2 + power + prod + qr + qrupdate + quit + qz + rand + randn + rbbox + rcond + rdivide + real + rehash + rem + reset + reshape + rmappdata + round + rtwgen + runtime + save + save_system + schur + selectmoveresize + semilogx + semilogy + setappdata + setstr + sign + sim + simulink + simver + sin + single + sinh + size + sldebug + sort + sparse + sparsfun + sprintf + sqrt + sscanf + str2func + strcmp + strcmpi + strfind + string + strncmp + strncmpi + strrep + struct + struct2cell + struct2handle + subsasgn + subsindex + subsref + sum + superiorto + svd + system + system_dependent + tan + tanh + tic + times + toc + transpose + tril + triu + trmginput + type + u_convert_to_gobject + uigetfile + uimenufcn + uint16 + uint32 + uint8 + uipushtool + uiputfile + uisetcolor + uisetfont + uitoggletool + uitoolbar + uminus + unix + uplus + upper + version + vertcat + vms + waitfor + waitforbuttonpress + warning + what + which + who + whos + xlate + zeros + + + + 16777215 + 16711808 + + + axes + dir + figure + findobj + gcbf + gcbo + gcf + gco + get + get_param + gcbh + image + light + line + patch + pwd + rectangle + set + set_param + sf + surface + text + uicontrol + uimenu + uicontextmenu + + + + 16777215 + 33023 + + + + + - + = + // + / + \ + % + & + > + < + ^ + ! + { + } + | + + + + 16777215 + 8388608 + + + + 16777215 + 8388608 + + + % + + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + True + False + + + + 16777215 + 255 + + + + 16777215 + 255 + + + ' + ' + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + False + False + + + Rule file for UniHighlighter Delphi component (Copyright(C) Fantasist(walking_in_the_sky@yahoo.com), Vit(nevzorov@yahoo.com), 2002) + diff --git a/components/extrasyn/TestHighlighters/Ruby.hgl b/components/extrasyn/TestHighlighters/Ruby.hgl new file mode 100644 index 000000000..0b6bc68a7 --- /dev/null +++ b/components/extrasyn/TestHighlighters/Ruby.hgl @@ -0,0 +1,1146 @@ + + + ******* Please read carefully ************************* + * Please, make any changes in this file very carefuly!* + * It is much more convinient to use native designer! * + ******************************************************* + + + + Ruby + rb rbw + Standard + + + Vitaly Nevzorov + nevzorov@yahoo.com + www.delphist.com + Copyright (c) Vitaly Nevzorov, 2002 + N/A + Created based on UltraEdit:ruby.txt + + + 1 + 0 + 37612.559736169 + Beta + + + + + + + + + + 16777215 + 0 + + + + 16777215 + 128 + + + + + &qt;'()*+,./<>[]^{|}~ + True + False + False + False + + + 16777215 + 32768 + + + ( + ) + # + #{ + { + } + __FILE__ + __LINE__ + alias + and + begin + break + case + class + def + defined? + do + else + elsif + end + ensure + false + for + if + in + module + next + nil + not + or + quit + redo + rescue + retry + return + self + super + then + true + undef + unless + until + when + while + yield + BEGIN + END + + + + 16777215 + 16711680 + + + ` + ArgumentError + Array + Bignum + Binding + Class + Complex + ConditionVariable + Continuation + DelegateClass + Dir + English + EOFError + Errno::ENOENT + Errno::EPERM + Exception + FalseClass + Fatal + File + File::Stat + Fixnum + Float + FloatDomainError + GetoptLong + Hash + IndexError + Integer + Interrupt + IO + IOError + LoadError + LocalJumpError + MatchData + Method + Module + Mutex + NameError + NilClass + NoMemoryError + NotImplementedError + Numeric + Object + Proc + Pstore + Range + RangeError + Regexp + RegexpError + RuntimeError + ScriptError + SecurityError + SimpleDelegator + Singleton + StandardError + String + Struct + Struct::Tms + Symbol + SyntaxError + SystemCallError + SystemExit + SystemStackError + Tempfile + Thread + ThreadGroup + Time + TrueClass + TypeError + WeakRef + ZeroDivisionError + + + + 16777215 + 16711808 + + + mkmf + win32api + win32ole + BasicSocket + Benchmark + CGI + Comparable + Config + CONFIG + DATA + Date + Enumerable + Errno + FALSE + FileTest + Find + FTP + GC + HTTP + HTTPResponse + IPSocket + Kernel + Marshal + Math + NET + Net::FTP + Net::HTTP + Net::HTTPResponse + Net::POP + Net::APOP + Net::POPMail + Net::SMTP + Net::Telnet + NIL + ObjectSpace + Observable + ParseDate + POP + POPMail + Process + Session + SMTP + Socket + SOCKSSocket + Stat + STDERR + STDIN + STDOUT + TCPServer + TCPSocket + Telnet + Tms + TOPLEVEL_BINDING + TRUE + UDPSocket + UNIXServer + UNIXSocket + Win32API + WIN32OLE + WIN32OLE_EVENT + + + + 16777215 + 33023 + + + &qt; + cutime + cstime + domain + expires + secure + stime + AF_APPLETALK + AF_AX25 + AF_INET6 + AF_INET + AF_IPX + AF_UNIX + AF_UNSPEC + AI_ALL + AI_CANONNAME + AI_MASK + AI_NUMERICHOST + AI_PASSIVE + AI_V4MAPPED_CFG + ARGF + ARGV + Complex::I + Default + E + EXTENDED + EAI_ADDRFAMILY + EAI_AGAIN + EAI_BADFLAGS + EAI_BADHINTS + EAI_FAIL + EAI_FAMILY + EAI_MAX + EAI_MEMORY + EAI_NODATA + EAI_NONAME + EAI_PROTOCOL + EAI_SERVICE + EAI_SOCKTYPE + EAI_SYSTEM + FTP_PORT + IGNORECASE + IP_ADD_MEMBERSHIP + IP_DEFAULT_MULTICAST_LOOP + IP_DEFAULT_MULTICAST_TTL + IP_MAX_MEMBERSHIPS + IP_MULTICAST_IF + IP_MULTICAST_LOOP + IP_MULTICAST_TTL + LOOKUP_INET6 + LOOKUP_INET + LOOKUP_UNSPEC + MSG_DONTROUTE + MSG_OOB + MSG_PEEK + MULTILINE + PF_APPLETALK + PF_AX25 + PF_INET6 + PF_INET + PF_IPX + PF_UNIX + PF_UNSPEC + PI + PLATFORM + PRIO_PGRP + PRIO_PROCESS + PRIO_USER + RUBY_PLATFORM + RUBY_RELEASE_DATE + RUBY_VERSION + SOCK_DGRAM + SOCK_PACKET + SOCK_RAW + SOCK_RDM + SOCK_SEQPACKET + SOCK_STREAM + SOL_ATALK + SOL_AX25 + SOL_IPX + SOL_IP + SOL_SOCKET + SOL_TCP + SOL_UDP + SOPRI_BACKGROUND + SOPRI_INTERACTIVE + SOPRI_NORMAL + SO_BROADCAST + SO_DEBUG + SO_DONTROUTE + SO_ERROR + SO_KEEPALIVE + SO_LINGER + SO_NO_CHECK + SO_OOBINLINE + SO_PRIORITY + SO_RCVBUF + SO_REUSEADDR + SO_SNDBUF + SO_TYPE + TCP_MAXSEG + TCP_NODELAY + WIN32OLE::VERSION + WNOHANG + WUNTRACED + + + + 16777215 + 8388736 + + + . + .. + ... + ! + != + ~ + % + %= + %q + %w + %Q + %W + @ + & + && + &= + * + ** + *= + **= + + + += + +@ + - + -= + -@ + > + >= + >> + >>= + < + <= + <<= + <> + << + <=> + = + == + === + => + =~ + [ + []= + ] + | + || + |= + ||= + ^ + ^= + :: + // + /= + / + _id2ref + __id__ + __send__ + abort + abort_on_exception + abort_on_exception! + abs + abs2 + add + alias_method + alive? + ancestors + append_features + arg + arity + asctime + assoc + at + atan2 + atime + attr + attr_accessor + attr_reader + attr_writer + at_exit + autoload + backtrace + basename + between? + binding + binmode + blksize + blockdev? + block_given? + blocks + broadcast + call + callcc + caller + capitalize + capitalize! + casefold? + catch + ceil + center + chomp + chomp! + chop + chop! + chardev? + chr + chdir + chmod + chown + chroot + class_eval + class_variables + clear + clone + close + closed? + close_read + close_write + cmp + coerce + collect + collect! + compact + compact! + compare + compile + concat + conjugate + const_defined? + const_get + const_set + constants + copy + cp + cos + count + create_makefile + critical + critical= + crypt + ctime + current + day + default + default= + define_finalizer + delete + delete! + delete_at + delete_if + detect + dev + directory? + dirname + dir_config + disable + display + divmod + downcase + downcase! + downto + dump + dup + each + each_byte + each_index + each_key + each_line + each_object + each_pair + each_with_index + egid + egid= + empty? + enable + england + entries + eof + eof? + eql? + equal? + error? + error_message + escape + euid + euid= + eval + exception + exclude_end? + exec + executable? + executable_real? + exist? + exist2? + existw? + exit + exit! + exp + expand_path + extend + extend_object + fail + fcntl + fetch + file? + fileno + fill + find + find_all + find_library + finite? + first + flatten + flatten! + flock + flush + foreach + fork + format + freeze + frexp + frozen? + ftype + garbage_collect + get + getc + getogrp + getpriority + gets + getwd + get_option + gid + gid= + glob + global_variables + gm + gmt? + gmtime + gregorian + gregorian_leap? + grep + grpowned? + gsub + gsub! + has_key? + has_value? + hash + have_func + have_header + have_library + hex + hour + id + id2name + image + include + include? + included_modules + index + indexes + indices + inherited + initialize + integer? + iterator? + intern + ino + inspect + install + instance_eval + instance_methods + instance_of? + instance_variables + ioctl + is_a? + isatty + isdst + italy + jd + join + julian + julian_leap? + kcode + key? + keys + kill + kind_of? + lambda + last + last_match + ldexp + leap? + length + lineno + lineno= + link + list + ljust + load + local + local_variables + localtime + lock + locked? + log + log10 + loop + lstat + main + makedirs + makepath + map + map! + match + max + mday + member? + members + message + method + method_added + method_defined? + method_missing + methods + min + mjd + mkdir + mktime + mode + module_eval + module_function + modulo + mon + month + move + mv + mtime + name + nan? + nesting + new + new1 + new2 + new3 + newsg + neww + next! + nil? + nitems + nlink + nonzero? + now + ns? + oct + open + ordering + ordering= + os? + owned? + p + pack + parsedate + pass + path + pid + pipe + pipe? + polar + pop + popen + pos + pos= + ppid + print + printf + priority + priority= + private + private_methods + proc + protected + protected_methods + prune + public_methods + private_class_method + private_instance_methods + protected_instance_methods + public_class_method + public_instance_methods + public + push + putc + puts + pwd + quiet + quiet= + quiet? + quote + raise + rand + rassoc + reject! + read + readable? + readable_real? + readchar + readline + readlines + readlink + real + rehash + reject + reject! + remainder + remove_const + remove_method + rename + reopen + replace + require + respond_to? + restore + reverse + reverse! + reverse_each + rewind + rdev + rindex + rjust + rmdir + rm_f + round + run + safe_level + safe_unlink + scan + sec + seek + select + send + setgid? + setpgid + setpgrp + setpriority + setsid + setuid? + set_backtrace + set_options + set_trace_func + sg + shift + signal + sin + singleton_methods + singleton_method_added + size + size? + sleep + slice + slice! + socket? + sort + sort! + source + split + sprintf + squeeze + squeeze! + sqrt + srand + start + stat + status + step + sticky? + stop + stop? + store + strftime + strip + strip! + sub + sub! + succ + succ! + superclass + symlink + symlink? + sync + synchronize + sync= + syscall + syscopy + sysread + system + syswrite + swapcase + swapcase! + taint + tainted? + tell + terminate + test + throw + timeout + times + today + to_a + to_ary + to_f + to_i + to_io + to_proc + to_r + to_s + to_str + tr + tr! + trace_var + trap + try_lock + tr_s + tr_s! + truncate + tty? + tv_sec + tv_usec + type + uid + uid= + umask + undef_method + ungetc + uniq + uniq! + unlink + unlock + unpack + unshift + untaint + untrace_var + upcase + upcase! + update + upto + usec + utc + utc? + utime + value? + values + var + wait + wait2 + waitpid + waitpid2 + wakeup + wday + weakref_alive? + write + writable? + writable_real? + yday + year + zero? + zone + Comparisons + + + + 16777215 + 32896 + + + a + accept + addr + add_observer + all + base + bind + binmode= + blockquote + caption + changed + changed? + checkbox + checkbox_group + cmd + code + const_load + content_type + cookies + connect + count_observers + debug_mode + debug_mode= + delete_observer + delete_observers + dir + do_not_reverse_lookup + do_not_reverse_lookup= + escapeElement + escapeHTML + file_field + form + for_fd + getaddress + getaddrinfo + getbinaryfile + gethostbyaddr + gethostbyname + gethostname + getnameinfo + getservbyname + getpeername + getsockname + getsockopt + gettextfile + head + header + hidden + html + img + img_button + invoke + lastresp + listen + local_path + login + lookup_order + lookup_order= + ls + mails + message_loop + multipart_form + notify_observers + on_event + original_filename + out + pair + params + parse + passive + passive= + password_field + peeraddr + popup_menu + port + post + pretty + putbinaryfile + puttextfile + radio_button + radio_groupready + recv + recvfrom + reset + resume + resume= + retrbinary + retrlinew + return_code + rfc1123_date + scrolling_list + sendmail + setsockopt + shutdown + socketpair + storbinary + storlines + submit + telnetmode + telnetmode= + text_field + textarea + top + uidl + unescape + unescapeElement + unescapeHTML + waitfor + welcome + Call + + + + 16777215 + 16744448 + + + @@a + @@b + @@c + @@d + @@e + @@f + @@g + @@h + @@i + @@j + @@k + @@l + @@m + @@n + @@o + @@p + @@q + @@r + @@s + @@t + @@u + @@v + @@w + @@x + @@y + @@z + @y + @z + + + + 16777215 + 8388608 + + + + 16777215 + 8388608 + + + =begin + =end + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + False + False + + + + 16777215 + 255 + + + + 16777215 + 255 + + + ' + ' + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + False + False + + + + 16777215 + 255 + + + + 16777215 + 255 + + + ' + ' + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + False + False + + + Rule file for UniHighlighter Delphi component (Copyright(C) Fantasist(walking_in_the_sky@yahoo.com), Vit(nevzorov@yahoo.com), 2002) + diff --git a/components/extrasyn/TestHighlighters/TestSynHighlighter.lpi b/components/extrasyn/TestHighlighters/TestSynHighlighter.lpi new file mode 100644 index 000000000..37e2d353f --- /dev/null +++ b/components/extrasyn/TestHighlighters/TestSynHighlighter.lpi @@ -0,0 +1,910 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/extrasyn/TestHighlighters/TestSynHighlighter.lpr b/components/extrasyn/TestHighlighters/TestSynHighlighter.lpr new file mode 100644 index 000000000..ad3cca75d --- /dev/null +++ b/components/extrasyn/TestHighlighters/TestSynHighlighter.lpr @@ -0,0 +1,21 @@ +program TestSynHighlighter; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, synuni, Unit1 + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource := True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/components/extrasyn/TestHighlighters/lua.hgl b/components/extrasyn/TestHighlighters/lua.hgl new file mode 100644 index 000000000..b76d9419d --- /dev/null +++ b/components/extrasyn/TestHighlighters/lua.hgl @@ -0,0 +1,169 @@ + + + ******* Please read carefully ************************* + * Please, make any changes in this file very carefuly!* + * It is much more convinient to use native designer! * + ******************************************************* + + + + Lua + lua + Standard + + + Vitaly Nevzorov + nevzorov@yahoo.com + www.delphist.com + Copyright (c) Vitaly Nevzorov, 2002 + N/A + Created based on UltraEdit:lua.txt + + + 1 + 0 + 37612.5493981713 + Beta + + + + + + + + + + 16777215 + 0 + + + + 16777215 + 128 + + + + + !&qt;%&'()*+,-./:;<>?@[\]^{|} + True + False + False + False + + + 16777215 + 32768 + + + and + break + do + else + elseif + end + for + function + if + in + local + nil + not + or + repeat + return + then + until + while + + + + 16777215 + 16711680 + + + ~= + <= + >= + < + > + == + = + + + - + * + // + / + + + ( + ) + { + } + [ + ] + ; + , + . + .. + ... + + + + 16777215 + 8388608 + + + + 16777215 + 8388608 + + + -- + + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + True + False + + + + 16777215 + 255 + + + + 16777215 + 255 + + + &qt; + &qt; + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + False + False + + + + 16777215 + 255 + + + + 16777215 + 255 + + + ' + ' + !&qt;#$%&'()*+,-./:;<=>?@[\]^`{|}~ + True + False + False + False + + + Rule file for UniHighlighter Delphi component (Copyright(C) Fantasist(walking_in_the_sky@yahoo.com), Vit(nevzorov@yahoo.com), 2002) + diff --git a/components/extrasyn/TestHighlighters/unit1.lfm b/components/extrasyn/TestHighlighters/unit1.lfm new file mode 100644 index 000000000..b3ac3f0a0 --- /dev/null +++ b/components/extrasyn/TestHighlighters/unit1.lfm @@ -0,0 +1,669 @@ +object Form1: TForm1 + Left = 366 + Height = 449 + Top = 155 + Width = 742 + Caption = 'Form1' + ClientHeight = 429 + ClientWidth = 742 + Menu = MainMenu1 + OnCreate = FormCreate + LCLVersion = '1.9.0.0' + inline SynEdit1: TSynEdit + Left = 0 + Height = 410 + Top = 19 + Width = 742 + Align = alClient + Font.Height = -13 + Font.Name = 'Courier New' + Font.Pitch = fpFixed + Font.Quality = fqNonAntialiased + ParentColor = False + ParentFont = False + TabOrder = 0 + Gutter.Width = 57 + Gutter.MouseActions = < + item + ClickCount = ccAny + ClickDir = cdDown + Command = emcOnMainGutterClick + end + item + Button = mbRight + Command = emcContextMenu + end> + RightGutter.Width = 0 + RightGutter.MouseActions = < + item + ClickCount = ccAny + ClickDir = cdDown + Command = emcOnMainGutterClick + end + item + Button = mbRight + Command = emcContextMenu + end> + Keystrokes = < + item + Command = ecUp + ShortCut = 38 + end + item + Command = ecSelUp + ShortCut = 8230 + end + item + Command = ecScrollUp + ShortCut = 16422 + end + item + Command = ecDown + ShortCut = 40 + end + item + Command = ecSelDown + ShortCut = 8232 + end + item + Command = ecScrollDown + ShortCut = 16424 + end + item + Command = ecLeft + ShortCut = 37 + end + item + Command = ecSelLeft + ShortCut = 8229 + end + item + Command = ecWordLeft + ShortCut = 16421 + end + item + Command = ecSelWordLeft + ShortCut = 24613 + end + item + Command = ecRight + ShortCut = 39 + end + item + Command = ecSelRight + ShortCut = 8231 + end + item + Command = ecWordRight + ShortCut = 16423 + end + item + Command = ecSelWordRight + ShortCut = 24615 + end + item + Command = ecPageDown + ShortCut = 34 + end + item + Command = ecSelPageDown + ShortCut = 8226 + end + item + Command = ecPageBottom + ShortCut = 16418 + end + item + Command = ecSelPageBottom + ShortCut = 24610 + end + item + Command = ecPageUp + ShortCut = 33 + end + item + Command = ecSelPageUp + ShortCut = 8225 + end + item + Command = ecPageTop + ShortCut = 16417 + end + item + Command = ecSelPageTop + ShortCut = 24609 + end + item + Command = ecLineStart + ShortCut = 36 + end + item + Command = ecSelLineStart + ShortCut = 8228 + end + item + Command = ecEditorTop + ShortCut = 16420 + end + item + Command = ecSelEditorTop + ShortCut = 24612 + end + item + Command = ecLineEnd + ShortCut = 35 + end + item + Command = ecSelLineEnd + ShortCut = 8227 + end + item + Command = ecEditorBottom + ShortCut = 16419 + end + item + Command = ecSelEditorBottom + ShortCut = 24611 + end + item + Command = ecToggleMode + ShortCut = 45 + end + item + Command = ecCopy + ShortCut = 16429 + end + item + Command = ecPaste + ShortCut = 8237 + end + item + Command = ecDeleteChar + ShortCut = 46 + end + item + Command = ecCut + ShortCut = 8238 + end + item + Command = ecDeleteLastChar + ShortCut = 8 + end + item + Command = ecDeleteLastChar + ShortCut = 8200 + end + item + Command = ecDeleteLastWord + ShortCut = 16392 + end + item + Command = ecUndo + ShortCut = 32776 + end + item + Command = ecRedo + ShortCut = 40968 + end + item + Command = ecLineBreak + ShortCut = 13 + end + item + Command = ecSelectAll + ShortCut = 16449 + end + item + Command = ecCopy + ShortCut = 16451 + end + item + Command = ecBlockIndent + ShortCut = 24649 + end + item + Command = ecLineBreak + ShortCut = 16461 + end + item + Command = ecInsertLine + ShortCut = 16462 + end + item + Command = ecDeleteWord + ShortCut = 16468 + end + item + Command = ecBlockUnindent + ShortCut = 24661 + end + item + Command = ecPaste + ShortCut = 16470 + end + item + Command = ecCut + ShortCut = 16472 + end + item + Command = ecDeleteLine + ShortCut = 16473 + end + item + Command = ecDeleteEOL + ShortCut = 24665 + end + item + Command = ecUndo + ShortCut = 16474 + end + item + Command = ecRedo + ShortCut = 24666 + end + item + Command = ecGotoMarker0 + ShortCut = 16432 + end + item + Command = ecGotoMarker1 + ShortCut = 16433 + end + item + Command = ecGotoMarker2 + ShortCut = 16434 + end + item + Command = ecGotoMarker3 + ShortCut = 16435 + end + item + Command = ecGotoMarker4 + ShortCut = 16436 + end + item + Command = ecGotoMarker5 + ShortCut = 16437 + end + item + Command = ecGotoMarker6 + ShortCut = 16438 + end + item + Command = ecGotoMarker7 + ShortCut = 16439 + end + item + Command = ecGotoMarker8 + ShortCut = 16440 + end + item + Command = ecGotoMarker9 + ShortCut = 16441 + end + item + Command = ecSetMarker0 + ShortCut = 24624 + end + item + Command = ecSetMarker1 + ShortCut = 24625 + end + item + Command = ecSetMarker2 + ShortCut = 24626 + end + item + Command = ecSetMarker3 + ShortCut = 24627 + end + item + Command = ecSetMarker4 + ShortCut = 24628 + end + item + Command = ecSetMarker5 + ShortCut = 24629 + end + item + Command = ecSetMarker6 + ShortCut = 24630 + end + item + Command = ecSetMarker7 + ShortCut = 24631 + end + item + Command = ecSetMarker8 + ShortCut = 24632 + end + item + Command = ecSetMarker9 + ShortCut = 24633 + end + item + Command = EcFoldLevel1 + ShortCut = 41009 + end + item + Command = EcFoldLevel2 + ShortCut = 41010 + end + item + Command = EcFoldLevel1 + ShortCut = 41011 + end + item + Command = EcFoldLevel1 + ShortCut = 41012 + end + item + Command = EcFoldLevel1 + ShortCut = 41013 + end + item + Command = EcFoldLevel6 + ShortCut = 41014 + end + item + Command = EcFoldLevel7 + ShortCut = 41015 + end + item + Command = EcFoldLevel8 + ShortCut = 41016 + end + item + Command = EcFoldLevel9 + ShortCut = 41017 + end + item + Command = EcFoldLevel0 + ShortCut = 41008 + end + item + Command = EcFoldCurrent + ShortCut = 41005 + end + item + Command = EcUnFoldCurrent + ShortCut = 41003 + end + item + Command = EcToggleMarkupWord + ShortCut = 32845 + end + item + Command = ecNormalSelect + ShortCut = 24654 + end + item + Command = ecColumnSelect + ShortCut = 24643 + end + item + Command = ecLineSelect + ShortCut = 24652 + end + item + Command = ecTab + ShortCut = 9 + end + item + Command = ecShiftTab + ShortCut = 8201 + end + item + Command = ecMatchBracket + ShortCut = 24642 + end + item + Command = ecColSelUp + ShortCut = 40998 + end + item + Command = ecColSelDown + ShortCut = 41000 + end + item + Command = ecColSelLeft + ShortCut = 40997 + end + item + Command = ecColSelRight + ShortCut = 40999 + end + item + Command = ecColSelPageDown + ShortCut = 40994 + end + item + Command = ecColSelPageBottom + ShortCut = 57378 + end + item + Command = ecColSelPageUp + ShortCut = 40993 + end + item + Command = ecColSelPageTop + ShortCut = 57377 + end + item + Command = ecColSelLineStart + ShortCut = 40996 + end + item + Command = ecColSelLineEnd + ShortCut = 40995 + end + item + Command = ecColSelEditorTop + ShortCut = 57380 + end + item + Command = ecColSelEditorBottom + ShortCut = 57379 + end> + MouseActions = < + item + ShiftMask = [ssShift, ssAlt] + ClickDir = cdDown + Command = emcStartSelections + MoveCaret = True + end + item + Shift = [ssShift] + ShiftMask = [ssShift, ssAlt] + ClickDir = cdDown + Command = emcStartSelections + MoveCaret = True + Option = 1 + end + item + Shift = [ssAlt] + ShiftMask = [ssShift, ssAlt] + ClickDir = cdDown + Command = emcStartColumnSelections + MoveCaret = True + end + item + Shift = [ssShift, ssAlt] + ShiftMask = [ssShift, ssAlt] + ClickDir = cdDown + Command = emcStartColumnSelections + MoveCaret = True + Option = 1 + end + item + Button = mbRight + Command = emcContextMenu + end + item + ClickCount = ccDouble + ClickDir = cdDown + Command = emcSelectWord + MoveCaret = True + end + item + ClickCount = ccTriple + ClickDir = cdDown + Command = emcSelectLine + MoveCaret = True + end + item + ClickCount = ccQuad + ClickDir = cdDown + Command = emcSelectPara + MoveCaret = True + end + item + Button = mbMiddle + ClickDir = cdDown + Command = emcPasteSelection + MoveCaret = True + end + item + Shift = [ssCtrl] + ShiftMask = [ssShift, ssAlt, ssCtrl] + Command = emcMouseLink + end> + MouseTextActions = <> + MouseSelActions = < + item + ClickDir = cdDown + Command = emcStartDragMove + end> + Lines.Strings = ( + 'class Person' + ' attr_reader :name, :age' + ' def initialize(name, age)' + ' @name, @age = name, age' + ' end' + ' def <=>(person) # Comparison operator for sorting' + ' @age <=> person.age' + ' end' + ' def to_s' + ' "#@name (#@age)"' + ' end' + 'end' + ) + VisibleSpecialChars = [vscSpace, vscTabAtLast] + SelectedColor.BackPriority = 50 + SelectedColor.ForePriority = 50 + SelectedColor.FramePriority = 50 + SelectedColor.BoldPriority = 50 + SelectedColor.ItalicPriority = 50 + SelectedColor.UnderlinePriority = 50 + SelectedColor.StrikeOutPriority = 50 + BracketHighlightStyle = sbhsBoth + BracketMatchColor.Background = clNone + BracketMatchColor.Foreground = clNone + BracketMatchColor.Style = [fsBold] + FoldedCodeColor.Background = clNone + FoldedCodeColor.Foreground = clGray + FoldedCodeColor.FrameColor = clGray + MouseLinkColor.Background = clNone + MouseLinkColor.Foreground = clBlue + LineHighlightColor.Background = clNone + LineHighlightColor.Foreground = clNone + inline SynLeftGutterPartList1: TSynGutterPartList + object SynGutterMarks1: TSynGutterMarks + Width = 24 + MouseActions = <> + end + object SynGutterLineNumber1: TSynGutterLineNumber + Width = 17 + MouseActions = <> + MarkupInfo.Background = clBtnFace + MarkupInfo.Foreground = clNone + DigitCount = 2 + ShowOnlyLineNumbersMultiplesOf = 1 + ZeroStart = False + LeadingZeros = False + end + object SynGutterChanges1: TSynGutterChanges + Width = 4 + MouseActions = <> + ModifiedColor = 59900 + SavedColor = clGreen + end + object SynGutterSeparator1: TSynGutterSeparator + Width = 2 + MouseActions = <> + MarkupInfo.Background = clWhite + MarkupInfo.Foreground = clGray + end + object SynGutterCodeFolding1: TSynGutterCodeFolding + MouseActions = < + item + Button = mbRight + Command = emcCodeFoldContextMenu + end + item + ShiftMask = [ssShift] + Button = mbMiddle + ClickCount = ccAny + ClickDir = cdDown + Command = emcCodeFoldCollaps + end + item + Shift = [ssShift] + ShiftMask = [ssShift] + Button = mbMiddle + ClickCount = ccAny + ClickDir = cdDown + Command = emcCodeFoldCollaps + Option = 1 + end + item + ClickCount = ccAny + ClickDir = cdDown + Command = emcNone + end> + MarkupInfo.Background = clNone + MarkupInfo.Foreground = clGray + MouseActionsExpanded = < + item + ClickCount = ccAny + ClickDir = cdDown + Command = emcCodeFoldCollaps + end> + MouseActionsCollapsed = < + item + Shift = [ssCtrl] + ShiftMask = [ssCtrl] + ClickCount = ccAny + ClickDir = cdDown + Command = emcCodeFoldExpand + end + item + ShiftMask = [ssCtrl] + ClickCount = ccAny + ClickDir = cdDown + Command = emcCodeFoldExpand + Option = 1 + end> + end + end + end + object Label1: TLabel + Left = 0 + Height = 15 + Top = 2 + Width = 742 + Align = alTop + Alignment = taCenter + BorderSpacing.Top = 2 + BorderSpacing.Bottom = 2 + Caption = 'Label1' + ParentColor = False + end + object MainMenu1: TMainMenu + left = 152 + top = 40 + object MenuItem1: TMenuItem + Caption = 'Highlighter' + end + end +end diff --git a/components/extrasyn/TestHighlighters/unit1.pas b/components/extrasyn/TestHighlighters/unit1.pas new file mode 100644 index 000000000..ad4122a96 --- /dev/null +++ b/components/extrasyn/TestHighlighters/unit1.pas @@ -0,0 +1,158 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, + SynEdit, Menus, StdCtrls, SynEditHighlighter, + + SynHighlighterADSP21xx, SynHighlighterFortran, SynHighlighterFoxpro, SynHighlighterGalaxy, SynHighlighterBaan, + SynHighlighterHaskell, SynHighlighterCache, {SynHighlighterDfm,} SynHighlighterModelica, SynHighlighterCobol, + {SynHighlighterCPM,} SynHighlighterCS, SynHighlighterDml, SynHighlighterProgress, SynHighlighterEiffel, + SynHighlighterGWS, {SynHighlighterHC11,} SynHighlighterHP48, SynHighlighterVBScript, SynHighlighterUnreal, + SynHighlighterVrml97, SynHighlighterTclTk, SynHighlighterLDraw, SynHighlighterRuby, SynHighlighterInno, + SynHighlighterAsm, SynHighlighterDOT, SynHighlighterIDL, SynHighlighterKix, {SynHighlighterMsg,} + SynHighlighterSDD, SynHighlighterSml, SynHighlighterURI, SynHighlighterM3, SynHighlighterRC, + SynHighlighterST, SynHighlighter8051, SynHighlighterLua, SynHighlighterProlog, SynHighlighterCAC, + SynHighlighterAWK; + +type + + { TForm1 } + + TForm1 = class(TForm) + Label1: TLabel; + MainMenu1: TMainMenu; + MenuItem1: TMenuItem; + SynEdit1: TSynEdit; + procedure MenuClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + { private declarations } + FHighlighters: Array of TSynCustomHighlighter; + public + { public declarations } + end; + +var + Form1: TForm1; + +implementation + +uses + SynUniHighlighter; + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.FormCreate(Sender: TObject); + + procedure SetDefaultColors(const vHighLighter:TSynCustomHighlighter); + begin + if Assigned(vHighLighter.CommentAttribute) then vHighLighter.CommentAttribute.Foreground := clSilver; + if Assigned(vHighLighter.IdentifierAttribute) then vHighLighter.IdentifierAttribute.Foreground := clNone; + if Assigned(vHighLighter.CommentAttribute) then vHighLighter.CommentAttribute.Foreground := $00A2A2A2; + if Assigned(vHighLighter.KeywordAttribute) then vHighLighter.KeywordAttribute.Foreground := clNavy; + //vHighLighter.NumberAttri.ForeGround := $004080FF; + if Assigned(vHighLighter.StringAttribute) then vHighLighter.StringAttribute.ForeGround := $003FB306; + if Assigned(vHighLighter.SymbolAttribute) then vHighLighter.SymbolAttribute.ForeGround := $00A25151; + end; + +var + i, c :Integer; + item :TMenuItem; +begin + SetLength(FHighlighters, 35); + + for i:= low(FHighlighters) to high(FHighlighters) do + FHighlighters[i] := Nil; + + FHighlighters[00] := TSynADSP21xxSyn.Create(self); + FHighlighters[01] := TSynFortranSyn.Create(self); + FHighlighters[02] := TSynFoxproSyn.Create(self); + FHighlighters[03] := TSynGalaxySyn.Create(self); + FHighlighters[04] := TSynBaanSyn.Create(self); + FHighlighters[05] := TSynAWKSyn.Create(self); + FHighlighters[06] := TSynHaskellSyn.Create(self); + FHighlighters[07] := TSynCacheSyn.Create(self); + FHighlighters[08] := TSynModelicaSyn.Create(self); + FHighlighters[09] := TSynCobolSyn.Create(self); + FHighlighters[10] := TSynCSSyn.Create(self); + FHighlighters[11] := TSynDmlSyn.Create(self); + FHighlighters[12] := TSynProgressSyn.Create(self); + FHighlighters[13] := TSynEiffelSyn.Create(self); + FHighlighters[14] := TSynGWScriptSyn.Create(self); + FHighlighters[15] := TSynHP48Syn.Create(self); + FHighlighters[16] := TSynVBScriptSyn.Create(self); + FHighlighters[17] := TSynUnrealSyn.Create(self); + FHighlighters[18] := TSynVrml97Syn.Create(self); + FHighlighters[19] := TSynTclTkSyn.Create(self); + FHighlighters[20] := TSynLDRSyn.Create(self); + FHighlighters[21] := TSynRubySyn.Create(self); + FHighlighters[22] := TSynInnoSyn.Create(self); + FHighlighters[23] := TSynAsmSyn.Create(self); + FHighlighters[24] := TSynDOTSyn.Create(self); + FHighlighters[25] := TSynIdlSyn.Create(self); + FHighlighters[26] := TSynKixSyn.Create(self); + FHighlighters[27] := TSynSDDSyn.Create(self); + FHighlighters[28] := TSynSMLSyn.Create(self); + FHighlighters[29] := TSynURISyn.Create(self); + FHighlighters[30] := TSynM3Syn.Create(self); + FHighlighters[31] := TSynRCSyn.Create(self); + FHighlighters[32] := TSynPrologSyn.Create(Self); + FHighlighters[33] := TSynLuaSyn.Create(Self); + FHighlighters[34] := TSyn8051Syn.Create(Self); + FHighlighters[35] := TSynCACSyn.Create(Self); + + // FHighlighters[06] := TSynGeneralSyn.Create(self); + // FHighlighters[09] := TSynDfmSyn.Create(self); + // FHighlighters[12] := TSynUniSyn.Create(self); + // FHighlighters[12] := TSynCPMSyn.Create(self); + // FHighlighters[30] := TSynMsgSyn.Create(self); + // FHighlighters[36] := TSynSTSyn.Create(self); + + for i:= low(FHighlighters) to high(FHighlighters) do + if Assigned(FHighlighters[i]) then begin + SetDefaultColors(FHighlighters[i]); + item := TMenuItem.Create(self); + item.Tag := i+1; //0 = unknown highlighter + try + if (FHighlighters[i] is TSynUniSyn) and (TSynUniSyn(FHighlighters[i]).Info.General.Name <> '') then + item.Caption := IntToStr(i) + ' - ' + TSynUniSyn(FHighlighters[i]).Info.General.Name + else + item.Caption := IntToStr(i) + ' - ' + TSynCustomHighlighter(FHighlighters[i]).LanguageName; + except + on E : Exception do + ShowMessage(E.Message+LineEnding+' at index '+inttostr(i)); + end; + item.Name := FHighlighters[i].ClassName; + item.OnClick := @MenuClick; + if i > 27 then + WriteLn(I, ' : ',Item.Name,' : ', item.Caption); + MenuItem1.Add(item); + end; + + SynEdit1.Highlighter := FHighlighters[12]; + Label1.Caption := FHighlighters[12].ClassName; +end; + +procedure TForm1.MenuClick(Sender: TObject); +var i,c:Integer; +begin + c:= ComponentCount-1; + if (Sender is TMenuItem) and (TMenuItem(Sender).Tag > 0) then begin + SynEdit1.Highlighter := FHighlighters[TMenuItem(Sender).Tag-1]; + Caption := SynEdit1.Highlighter.LanguageName; + SynEdit1.Text := SynEdit1.Highlighter.SampleSource; + Label1.Caption := Caption; + end; +end; + +end. + + + + diff --git a/components/extrasyn/extrahighlighters.lpk b/components/extrasyn/extrahighlighters.lpk new file mode 100644 index 000000000..5f4399412 --- /dev/null +++ b/components/extrasyn/extrahighlighters.lpk @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/extrasyn/extrahighlighters.pas b/components/extrasyn/extrahighlighters.pas new file mode 100644 index 000000000..1ed411b2b --- /dev/null +++ b/components/extrasyn/extrahighlighters.pas @@ -0,0 +1,26 @@ +{ This file was automatically created by Lazarus. Do not edit! + This source is only used to compile and install the package. + } + +unit ExtraHighlighters; + +{$warn 5023 off : no warning about unused units} +interface + +uses + SynEditStrConstExtra, SynHighlighterADSP21xx, SynHighlighterAsm, + SynHighlighterAWK, SynHighlighterBaan, SynHighlighterCAC, + SynHighlighterCache, SynHighlighterCobol, SynHighlighterCS, + SynHighlighterDml, SynHighlighterDOT, SynHighlighterEiffel, + SynHighlighterFortran, SynHighlighterFoxpro, SynHighlighterGalaxy, + SynHighlighterGWS, SynHighlighterHaskell, SynHighlighterHP48, + SynHighlighterIDL, SynHighlighterInno, SynHighlighterKix, + SynHighlighterLDraw, SynHighlighterLua, SynHighlighterM3, + SynHighlighterModelica, SynHighlighterProgress, SynHighlighterProlog, + SynHighlighterRC, SynHighlighterRuby, SynHighlighterSDD, SynHighlighterSml, + SynHighlighterTclTk, SynHighlighterUnreal, SynHighlighterVBScript, + SynHighlighterVrml97, SynHighlighter8051; + +implementation + +end. diff --git a/components/extrasyn/extrahighlighters_dsgn.lpk b/components/extrasyn/extrahighlighters_dsgn.lpk new file mode 100644 index 000000000..dda396b63 --- /dev/null +++ b/components/extrasyn/extrahighlighters_dsgn.lpk @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/extrasyn/extrahighlighters_dsgn.pas b/components/extrasyn/extrahighlighters_dsgn.pas new file mode 100644 index 000000000..46b061d32 --- /dev/null +++ b/components/extrasyn/extrahighlighters_dsgn.pas @@ -0,0 +1,22 @@ +{ This file was automatically created by Lazarus. Do not edit! + This source is only used to compile and install the package. + } + +unit ExtraHighlighters_Dsgn; + +{$warn 5023 off : no warning about unused units} +interface + +uses + uHighlighterReg, LazarusPackageIntf; + +implementation + +procedure Register; +begin + RegisterUnit('uHighlighterReg', @uHighlighterReg.Register); +end; + +initialization + RegisterPackage('ExtraHighlighters_Dsgn', @Register); +end. diff --git a/components/extrasyn/images.lrs b/components/extrasyn/images.lrs new file mode 100644 index 000000000..09a2f0af9 --- /dev/null +++ b/components/extrasyn/images.lrs @@ -0,0 +1,412 @@ +LazarusResources.Add('TSYN8051SYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#167'IDAT8'#203#205'T' + +#209#18#195' '#8'K'#238#252#239#210'/'#207#30#156#21#237'p'#172#190#140#243 + +#174'`!'#13#164'JA'#216#179'R'#31#167#157#15#138#15';'#0'@'#144' 3'#171'N~]' + +#181#165'c'#10'$'#0#168'u'#230#195#234#215#144#28#154#239#16'd'#207'~'#231'i' + +#216#151#150#179#184#224#23#169#209#219#144#197'dS;)'#22'S8'#23#11#224#13#226 + +'N'#210#135#145'?Cl'#253'Zn"t_'#211' f'#18'B'#139'f~e!'#233'a#'#249#202'o' + +#227'lz'#18'n4'#193#153#14' '#26#151#204'UP'#22'$'#6#192'X'#154#178'$'#145 + +#146#230#223#20#225#199'c'#152'0'#238'_'#191'/='#172#133#133'(r'#173#18#0#0#0 + +#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNADSP21XXSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#167'IDATx'#156#197#148'A'#14#132'0'#12#3#157#21#255#166#188'|8'#20#162 + +#10#18#26#193'a}!'#149#240#212'$'#180#134#208'7-'#253#177#181#237#133'ym'#171 + +'$!'#16#173'5'#0#144#144#168#200#189#191';'#27'dv'#212'fG'#237#197']'#1#194 + +'e&'#16'g'#175'Ft'#21#209#205#217#230#174'%'#220'|,'#1#144#184#130'{'#186#224#170#232#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNAWKSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#162'IDATx'#156#197'TA'#14#195'0'#8'3U'#255']'#250'r'#239#128#134'2'#10 + +#140#181#135#249#144#144#8#140#3'I'#132' '#158'a'#183#233#212#243'F'#240#161 + +#7#0#16'$'#168#170#252#17#30#187#205's'#138#228#251'[pr?3'#214#177'"'#250#160 + +' A'#150#217','#158#151#234'G'#21'='#210#4'Q'#133'{'#152#237'c'#131#253#154 + +''''#216#190#19#150#185#138'{'#136'*d9+'#195#193#134#20#12#174'}'#25'z'#21 + +#145'kN1'#143',)\'#140#241#9#150#210#20'o'#186#160'xk'#153'|'#5'9E'#184#130 + +'$'#154#214#228#20'IA'#230'M'#253'wG'#228#235';- '#207#191#223#23#166#203#128 + +'y'#218#193'='#197#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNBAANSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#158'IDATx'#156#197#148'A'#14#133'0'#8'DgL'#239'-'#158'|'#254#194'o' + +#211' ('#214#133'l'#10'Iy0E'#161' '#188#179#182#31#155'm'#19#201#171#173#0' ' + +'H'#144#153#233#161#245#220'e'#164#146'3B'#22#23'w'#10'y'#239#199#8#233#127 + +'C'#138#253#241'N'#140'8'#183#131';'#129#129#16#201#151're'#157'5'#167'"'#11 + +#187#127'.'#144#10#169'[s1'#135#142#229#196#20#17#186#16#243#180#11#207#170 + +'#'#234#153')'#162'7'#179#243#136#225'i'#146#127':A'#28#189'TVA'#140'p'#31 + +#146#132#139#209#196#136#224'A'#234'C'#253'z"'#156'[8'#0#223#175#223#31#181 + +'p'#130#127#231#29#7#2#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNCACHESYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#170'IDATx'#156#197#148#209#18#132' '#8'E/'#141#255#29'}'#249#221#7#203 + +'%'#148#150#178#153#245#193#136#226'p'#17'U'#8'bn'#148#250#216't{'#16#188#234 + +#10#0#4#9#170'*/'#7#208'{'#246#216'e'#178#10#0''''#132#200'>W'#195':'#173#225 + +#236#197'zI'#0' A~q<'#150'{'#232#244'*'#250#12#247#10'iI'#154#225#236'(M'#177 + +#31#172'f'#231#236#231'Fy'#161'#'#197#189#139#145'HWR'#18'A'#247'k'#28#249'[' + +#133'g'#229#17#249#200#16#209#196'T'#158#192',Mp'#166#3#196#161'%s'#21#140#17 + +'n;'#145#184'h'#205#24'1X'#144'|S'#255#221#17#185'{B['#224#252#245#251#1#239 + +'~'#130'}'#214#12#183#253#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNCACSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#156'IDATx'#156#205#148#203#14#131'0'#12#4#199#21#255'M'#248#242#237'!' + +'4@j'#203#161'i'#165#250#18#14#222'a'#189'y'#152#16's'#181#212'e+'#219#7#226 + +#181#172#0'BB'#165#20#221#172#166'}LN'#1'8'#8'3'#204#146#239#4#1'HG'#183#180 + +#235#21#228#254#155'A'#220#127#158'}'#13'!'#154#254#12#250#194' Q'#28#203'[' + +#159#213'n@'#215'T#'#23'='#162'o'#140't'#169#11#135'5'#142#24'W'#134#136'f' + +#166#242#140'c'''#163';'#29' ^^F'#158#2#31#209#157'"'#137#254#192#167#8'''' + +#144'8'#163#127#219#17#139#174'QV6'#255#252'>'#1'e'#3'zy'#14'*'#128#233#0#0#0 + +#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNCOBOLSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#164'IDATx'#156#197#148#193#18#195' '#8'D'#151#142#255#29#242#229#155 + +#131#19'j'#201#146#218#218#153'r'#145'0'#236#11#130'j'#4#177'f'#173'/'#187 + +#239'_'#136'7'#223#0#128' Aw'#231#135#22#218#199#226'.'#0#188' '#204#132'#' + +#131#26'a'#6#242#233#164'<'#25#20'UH'#171#148#2#17#169#221#225'9'#235#238'_' + +#131'a-'#253#176'r'#174#193#160#252'`"-}'#219'P"'#199'6'#176'<'#196#25#193 + +#148'Z+'#223'W'#145'Y'#243#136'ye'#137#136'b:'#207'0'#180#166#184#211#5#226 + +#172'e'#230')'#208#136't'#28'I'#220#140'F#DC'#230#135#250#239#137#216#253'}' + +#172#205#214#159#223#3#4'm'#132'}'#251'j'#159#227#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNCPMSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#170'IDATx'#156#197#148#193#14#132'0'#8'Dg6'#254#183#245#203'g'#15#196 + +'.'#161#212#224#214'D.'#22#133#215#1'l)'#8'k'#182#217#227'h'#199#31#201'{' + +#219#1'@'#144#160#214#154'nZ'#207#253',V'#1' "H'#144#191#133#173#205#245'1S' + +#4#9#9':'#251'k'#235'@'#9#249#137#138'Q'#145'''z'#183#219#230#157#190#167#197 + +#141#209#227#155#136#240'A!'#218#187#225#211#3#19#137'*'#232#218'%'#223#204 + +#180#134#20#161#139#2#238#170#136#172':'#162#158'9Et1'#198'#\k&gz'#130'8'#181 + +'T'#174#130#28#17#254'b'#9#23#163#201#17'IC'#234'C}{"'#28#143'q'#205#184'~' + +#253'~'#1'{h'#132'y'#186#192'}:'#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNCSSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#168'IDATx'#156#197#148'K'#14#131'0'#12'D'#199'U'#239'M8'#249#176'H' + +#235'Z'#254'%-'#139'Z'#8#172#200#243#152#196'`!'#136'{'#241#156#143's'#156'?' + +#136#143'q'#0#0'A'#130'c'#12'~'#25#170'}D'#182#200#235'r'#139'z'#207'7bKI' + +#159'7z'#0#137#11#13'e'#205#196#226':'#23'1T3'#19#134#6'v.'#172#198#238'n' + +#225#130#252#20#197#23#198#149#4#209'(S}'#130#16'c'#148#189#165#10'AWZ+'#215 + +'.'#201#248#155#181'o9I]0'#140'%B'#152#166#238'&O'#24#255#234#224'HY' + +#213'&'#28'>M%=6'#9#184#25#26#217#241')R'#26'1'#212#10#16#168#230'A'#245#140 + +'x'#224'f'#20'Nj'#159#166#191#158#201#165#211'''~ldN'#212#251#202#159#148#191 + +#237#190#182'|'#0#228'UWN'#127#209#205#130#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNFORTRANSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#156'IDATx'#156#197#148#193#14#195'0'#8'CM'#149#255'.'#253'r'#239#16 + +#141#162#20'"X'#15#227'R*'#197'O'#142'Q'#16#130'xWc~.'#189'~'#16#159'z'#2#0 + +'A'#130#170#202'f'#153#246#8#241'"'#13'/'#1'B'#4#228#221'['#147'qw.&'#203#148 + +'Lr'#143#17#217#233#6#194'@'#254'R'#13#132#215'X'#191#1#237'\'#20'k,'#255#226 + +'rg%'#204''''#130#203#209'B'#176#169#139#149'UG'#212#149')'#194#204'L'#158 + +#192'E'#147#188#233#4#241#245'RY'#5'1by'#14'$6'#163#137#17'A '#245#161#254'{' + +'"'#210#218'3'#174#228#253#250#253#0#195'[xu'#215#131#147'v'#0#0#0#0'IEND' + +#174'B`'#130 +]); +LazarusResources.Add('TSYNFOXPROSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#160'IDATx'#156#197#148'A'#14#132'P'#8'C'#203#196'{'#139''''#239','#136 + +#12#249#1#133'q!'#27'k'#242'y'#214#162#8'A<'#171#205'.'#135#30#127'4'#239#186 + +#3#0'A'#130#170#202'ay'#239''''#197#139#12#188'$'#8#17#144'?'#29'E'#138#190 + +'ra,'#211'&'#152'E'#159'#'#210#163'U'#229#8#7#249#147#163#163'{D'#180#224#218 + +#196#224'EF'#181'-'#247#18#188'2Z'#175#227'Y'#17'\'#142'6'#130'-]'#172#172'>' + +#162#223'Y"'#220#140#241#4'!'#154#226#159'.'#16#167#151#206'*'#200#17#203'''' + +'D'#226'b49"'#9#164'?'#212#183'''"'#163'='#19'J'#158#175#223'/'#206':~u'#198 + +#211#129'k'#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNGALAXYSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#159'IDATx'#156#197#148#209#22'@0'#12'C'#19#199#127#171'/'#143#135'1Lk' + +#197#131#188#24'G'#238#178'v'#27#5#225#155#198#242#152'm~a'#158'l'#2#0'A'#130 + +#204'L'#15'U'#189'C~N'#210#255#238'#'#200#213'P'#7'7r'#16'$'#180#149'X'#130 + +#212#161't'#22#210#141#224'#'#142#211'v#'#132')'#164#211#184#188'*'#216'@a9#' + +#195'U'#227#197#204#3#229#188#164'$B'#205#175#137'0a'#138#150#149'G'#228#157 + +'!'#162#134')'#255'~'#223'l8'#137'q'#152';E'#186#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNIDLSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#150'IDATx'#156#205#148'Q'#14#128'0'#8'C'#139#217#189#197#147#215#143 + +')'#18#28'n'#234#135'6'#198#129#9'o'#132'F'#132' '#222#169#212'c'#209#229'A' + +#241#172'3'#0#16'$'#168#170#188')'#171#157#2'Xd{,'#182#239#153'"'#130'<'#222 + +'5'#184'(n#'#30#232#159#8#27#164#165'6'#23'?]'#175#18'r'#178#31'w'#16#226'.' + +#162#247'#g'#156#187'`'#200#211#219#187']D'#214'8b'#188'2EX3'#149'''p'#163'I' + +#254#233#4#177#247'2'#178#10#218#136#224'?'#137#11'k'#218#136#198'@'#198'M' + +#253#218#17#233'.'#134'D'#242'~'#253#174'R'#198't'#129'8'#17#20'm'#0#0#0#0'I' + +'END'#174'B`'#130 +]); +LazarusResources.Add('TSYNINNOSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#1#17'IDATx'#156#149'T['#178#133' '#12'K'#28#23#214#157#145#238#172#174 + +#172#247#163#30'.'#10#158'G'#134'q'#180#146#244#9'L$'#174'p9VhjK'#251'>'#211 + +#204'l'#222#23#17#4'%-D'#19#153'HI'#153#231#243#134#136#144'T'#228#209#222 + +#185#251#236#144#188'$'#18#177#8'j'#145#200#13#153#141#236'_'#199'{'#137#13 + +#215'B'#184';'#128#129#255#25#187#203'[kE'#174#23#192#175'U'#251'$'#209#157 + +#155'Y'#133' i'#206#191'Wt-Q'#204#136'0'#179#234#232#220#215#226#147#172'^\$' + +#154'Z'#207#133'$'#160'ry'#219'gf'#17#177#206'$'#145#128#128#196'9'#166#194 + +#181#255#133'y4'#240#154#139#237#22'oU'#193#221'I'#2','#28#199#187#190#238#0 + +'$T+|'#152')I'#238#144#254#235'R'#179#187#150#152#177','#254#146#143#26#173 + +#17'fV'#137'J'#202'|i%'#144' '#214#3#199'D'#142#255#202#21'y'#183','#152'd]' + +#20#27#128'~R'#135#221#217#215#169'F'#158'k'#194#211'1'#251#198#244' '#209'S' + +'x'#138#255#179#196#247#204#133#4#127':'#225#3'8_'#191#191#226#15'7'#253#216 + +#193#135#235#237''''#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNKIXSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#154'IDATx'#156#197#148#193#14#128' '#12'C;'#195#127';'#191#188#30#136 + +#138#176#234#212#131'='#8#18#250'R'#24'`'#4#241'M'#165'6'#139'//'#204#179#207 + +#0'@'#144#160#187#243#161'v'#239'4'#178#205#226#190'R'#128'h'#205#228#209'W' + +#184#24'av2'#147#199'H'#22'Q=I'#201#133#140#161#30','#164#6'V'#223#151')'#174 + +'U'#186#127'k'#226#178'M'#175'2'#140#8'vS'#181#243'>E'#207#202'#'#242'N'#137 + +#216#195'T'#158#161#217#26'q'#167#5'b'#203#146'y'#10'bDw'#138'H\'#148'&F'#4 + +#27#146'/'#234#223#21#177#252#221'<'#203#190'?'#191'+'#209'H|u'#31#12#159'B' + +#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNLDRSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#156'IDATx'#156#197#148#193#18#132'0'#8'C'#19#199#255#22#191'<{p'#236 + +'"'#165'+'#213#195#230'"'#206#152#215#8#10#5#225#157#214#227#178#219#254#192 + +#188#217#6#0#130#4#153#153'&'#213#188'K'#207'&/u'#187#245#181'W'#130#8#146 + +#190'N_O n5'#135' '#161'n'#128'9"'#180#160#217#210#23'Y{'#191'?'#167#175#171 + +')'#166#20'S'#208#5'U'#24'F'#17#161#240#232#216'y'#159'"'#178#234#136#186's' + +#136'ha'#14#30#225'Z3'#248#167#7#136'3Ke'#21#228#136#240#253'H'#248'1'#154#28 + +#145'4'#164'>'#212#127'O'#132#233'>)'#136#239#215#239#7'13x}'#20'#a_'#0#0#0#0 + +'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNLUASYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#147'IDAT8'#203#205'T' + +#203#14#128' '#12#235#146#253#183#243#203#235#193#136'S'#17#10'^'#220#133'G' + +#182#166#237#24'F'#16#223#194#247'e'#141'u'#162'x'#137#5#0#8#18#140#8#14'F' + +#169#245#140'j'#6#178'r'#204#27#224#146's'#10'Q'#226#137'8'#12#209#177'S''' + +#210#135'(IY|'#137#234#165'?3'#186#199'y;U/,'#177'$y'#23#166'@'#176'-f'#136#5 + +#201'I!ze'#207#206#227'%'#27#146'5/3'#253#2'qpQ'#190#2'W^!'#137'Fk'#188'IBj' + +#205#223':b'#213'1T'#198#247#251#247#187#1#225'Z~'#127#161#9'V;'#0#0#0#0'IEN' + +'D'#174'B`'#130 +]); +LazarusResources.Add('TSYNM3SYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#159'IDATx'#156#197#148#193#14#132'@'#8'C'#139#153#255#22#191#188#30 + +#200#146#9#2'a'#215#195#246#160#7#167#207#2#138#16#196';-'#187']z'#253'`>' + +#245#4#0#130#4'U'#149'_'#202#189#199#228'm"'#16')'#159'&'#8'7'#184#141#4'YR' + +#242#20'fp'#155'AY'#244'}TH'#159'bM'#16'f'#174'R$'#8';'#250#188'V'#26#21#210 + +'+'#166#144#173'b'#238#13#168#147'D'#4#195#209#190#134'>Ed'#205#17'sg'#137 + +#240'0'#198#19'l'#173')'#254#233#2#241#201'2Y'#5'9"|'#136'$'#154#209#228#136 + +#164'!'#243#161#254'{"'#210'l'#149'V'#242'~'#253#222#246#12'~ya{}'#205#0#0#0 + +#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNMODELICASYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#156'IDATx'#156#197#148#193#14#196' '#8'Dg6'#253#239#210'/'#159'='#216 + +'5'#132'('#197'z'#216'9Xl'#228'e'#132#22#10#194#158#142#246#184#236'z'#145'|' + +#218#9#0#130#4#153#153#22#213's?'#155#183#0'0@'#144' '#239#192#191'\@'#0#144 + +'@'#222'k'#203#239'q'#21#177#164#18#162#155#170'"'#218'Q'#191#250#224#165#139 + +'\G'#216#211#21'M'#190#134's'#27#17#161'p4'#185#192#163#139#200#170'#'#234 + +#153'SD7'#211'x'#132'+'#205#228#159#158' ~^*'#163'`'#140#8#223#178#132#164'5' + +'c'#196#160' '#245#166#254#187'#LFB*'#238#143#223'/'#19#210'xu'#22#11#178#222 + +#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNPROGRESSSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#168'IDATx'#156#197#148#205#18#131'0'#8#132#151#142#239'->'#249#246'@' + +#155'2'#252'('#173#135#238'!2Q'#190'Y'#192'D'#8#226#158'6{'#28'z'#252#144#188 + +#235#14#0#4#9#170'*'#191#212#202'}'#4#176#8'D^AX}'#224#21#17#0#200'O'#166#197 + +#182#174#224#26'a'#159#26'k'#162#173't'#145'M'#217#230#180#144#12'Zq'#233#171 + +'p'#209#201',dJD'#156#212#223#189#138#8'q'#229#210#15#160'gg'#23#169#153'Wj]' + +'D'#214#28'1'#207'l'#17#203#140#241#4#174'5'#205#153'n'#16'o/'#147#171#160'F' + +#132#191#144#196#201'hjD'#209#144#249'P'#255'='#17')'#143#225'@r'#255#250'}' + +#2#251#162#132'}'#164';@'#226#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNPROLOGSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#156'IDAT8'#203#205 + +#148#203#14#196' '#8'E/'#9#255']'#251#229'g'#22#205'Xc'#3'>:'#139'a'#163'$' + +#130#215#3'h'#8#189'3'#191#150#179#156#27#193'G9$'#9#129'('#165#0#128#132'D' + +#181#196#173#177#222'f5'#19#220#155#220#237#31#242#3#22#173#16#233#190#164's' + +#167'Rt'#167'/'#253'k*'#158'V)'#212't'#221'5'#158'K'#136'6k*6pZ'#163#162'!' + +#17'#}'#226'$'#195#187#164#2#216'|'#200'|'#228#8#231#183'z'#166#6'M0'#211#30 + +'6C'#26'6N'#209'u$()'#141#167'"'#166'J'#243'o'#21#177#225'H'#6'f'#239#191#223 + +#15#175#4'~'#129'B'#233#17#200#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNRCSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#158'IDATx'#156#197#148#193#18#132' '#12'C'#147#29#255#219#250#229#241 + +#160#203'@i'#221#170#135#205'Ed'#232'#m'#1#10#194';-'#199'g'#179#237'A'#240 + +'j+'#0#8#18'df'#186#169#22#187#204'l'#242#28'H'#195#140#146#140'?'#225#172#4 + +#233#140'$'#135#223'Y'#129#139'l'#219#231'.'#28#183#234#194#225#174'k'#17' ' + +#218#210'y'#16'*N'#228#150#188#11'v'#25#171#175'G'#238#196'#TlC'#197#133'g' + +#213#17#245#200#20#209#204#28'<'#162'+Mr'#167#19#196#215'K'#229')'#184':'#224 + +#3'0oM'#140#8#10'Ro'#234#191';'#194#236'&'#254#18#223'?'#191';'#155#0#132'q' + +#141'l'#18'\'#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNRUBYSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#169'IDATx'#156#205#148'K'#14#195'0'#8'D'#135#202#247#142's'#242#233 + +#194'-!'#24'dRo'#138'"'#25'Y'#158#199#4#127#132' '#246#162#141#225#236#231#15 + +#226#163#31#0'@'#144'`'#239#157#15'C'#181#175#205#191#0'p!D>'#223#28#225'd' + +#128#0'@'#130'\'#8#22#136#225#130#188'*+'#206'%'#182'L'#213#133#206#143#132 + +#230'$'#164#237't,'''#179#209#172'f'#153#132#172#134'{'#136')M'#235#228#171 + +#155#189'x'#4#221#146#204'}'#197#133'g'#213#17'ue'#138'P3'#131'''0'#173'I' + +#238't'#130#208#230#21#158#130#24#225'N'#23#137'yk'#22#136#160'!y'#143#254'm' + +'G'#228#233'%W'#225#254#243#251#6'J;'#134'{'#179#13#219#161#0#0#0#0'IEND'#174 + +'B`'#130 +]); +LazarusResources.Add('TSYNSDDSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#162'IDATx'#156#197#148'K'#14#132'0'#12'C'#19#196#189#9''''#247',:'#4 + +'0'#137'd`'#129'74T~'#228'C'#235'0'#216';'#205#227#177#198#250#192#188#196'b' + +'f'#6#3#12#17#129#155'J'#239'L`'#247#255#2'8'#173'i'#171'($'#253#180#157#230 + +#177#160'ph"'#131#251#254'5Q'#19#197#192#169#4'E\H'#130#142'o'#186#176'@'#148 + +#141#232#194#20#23#242'@'#215#161#238'm'#192'u'#176#10#2'b'#246'J'#22#204#210 + +#17#186#179'Ed2'#131#231'vhMs'#166#27#196#150#139'r'#21#212#8#250';'#129#254 + +#144'u'#136#162'!'#250'P'#191#158#136#223'='#228'i|'#127#253#254#0'f'#161#136 + +'s:'#191'"W'#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNSMLSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#158'IDATx'#156#197#148#193#14#131'0'#12'C'#29#196#127#19#190#220';T+U' + +#26#211'0'#14#243#5#129#200's'#26#171'1'#130'x'#167#189'=N?'#127'(>'#252#0#0 + +#130#4#221#157#15#213'k'#247#0'6K'#220'H'#152#129#226#196'['#250#181#253#173 + +'j'#214#136#177#178'B'#201#187'x$'#137'('#158#2'='#212#138#198'I'#143#6#17'1' + +#155'/G;'#135'zy'#177#133#169#216#186#11#134'w'#233#190#236'"'#178#234#136'z' + +#165'D'#244'f'#26#207'0'#140'F'#220'i'#129#248#246'RY'#5'9"\6'#18'7'#209#228 + +#136'd '#245'P'#255#157#136#165#219#166' {'#191'~?'#202#173'|k'#145'%'#246#27 + +#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNTCLTKSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#153'IDATx'#156#197#148#193#14#128' '#12'C['#227#127';'#191#188#30'PBp' + +#195')'#7'{'#145' })'#27'@A'#152#211'Z>'#187#237#31#204#155'm'#0' H'#144#153 + +#233#165#170'wq'#241'dv'#18#128#143'h'#13'dh.Z'#163#31#210#233#215'S'#185#195 + +#20'y'#249#8#233#12'_'#6'S'#27'q'#7#169#20#175#212#167'`'#19'Zu?'#131#12'w' + +#132#186#165#143#253#24#164#232'YyD'#222#25'"j'#152#194'#'#154#210#4'w:@\Y2O' + +#129#143#232#206#146#132'Ak|'#132'S'#144'|S'#255#238#8#199#151')'#22#231#159 + +#223#3#136':t}+'#27'='#131#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNUNREALSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#164'IDATx'#156#197#148#193#18#131'0'#8'DY'''#255'-~'#249#246#16#155'2' + +#4#26'R'#15#221#139'8'#178'/k'#162#128'By'#166#214'/'#151'^?'#152'O=ED('#164 + +'PU'#185#169#225'='#6#18#240'E&'#215'p$m'#27#138#17#192#189#148'-'#230#245#23 + +')'#200#219'0'#10#224'S'#199#136#254#184#247#205'8'#203'rjs'#171#245#204#148 + +#141#23#169#171#185'{'#152#172#180#209#195#0'!'#130#174'5w'#174'SxV'#29'Qw' + +#166#136#17#166#243' fk'#146#127':A'#188#179'TFA'#140'p'#159#16')_'#142'&F'#4 + +#27'R?'#212#127#159#8#150#163'&'#17#158#143#223#23#23#229'~'#127#28'?'#215 + +#147#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNVBSCRIPTSYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#22#0#0#0#22#8#2#0#0#0'K'#214#251'l' + +#0#0#0#165'IDATx'#156#197#148#193#14#131'@'#8'D'#135#198#255#22#191'|<'#144 + +'R'#130','#165'z('#151#213#196'y'#12#176'"'#4#241',6;'#14'=n'#136'w'#221#1 + +#128' AU'#229#143#225#218'W'#147'Dd'#228'%#L'#230#226'H'#17#169#161#157#11#0 + +#228#7'J'#130'U'#235#191' "'#11#139#210#182'2'#173'g'#243'g'#19#151'.2"~'#23 + +#5#165#216'bZH'#19#217#133#132'r'#233#205'lm\{'#193#244'~'#223'Ef'#205#17's' + +#229#18#225'f'#140''''#8#173'Y'#252#211#11#196#219#203'd'#21#212#136't'#11'I' + +'4'#163#169#17'EC'#230'C'#253#247'Dd'#184'a.!'#207#215#239#9'J'#151'|{D'#244 + +#249#243#0#0#0#0'IEND'#174'B`'#130 +]); +LazarusResources.Add('TSYNVRML97SYN','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175 + +#0#0#1'%IDATx'#156#173'T['#146#196' '#8#132#212#222#11'n6x3<'#153#251#129'CP' + +'4q'#171#182'+'#149'I'#24#210'4/'#177#181#6#255#129#11#0'0'#225#252#251'Zk' + +#127'2E-\f<'#129#170#186#243#150#200#238#170'*"'#22#210#31#236'{'#17'q'#183 + +#23'"'#15'hw#'#242#215'xo'#173']'#187#204'E'#132#153''''#187#139#202#248#177 + +#159#169#188#166'%'#179','#237'7'#145')'#180'f'#169'j'#244#142#18#150'r'#220 + +#136'>G'#153#200'R#'#162#157#138#136'^'#163'{'#28#246'('#165'<'#12#218#186 + +#216'.'#199#129#136'"'#2#2' '#253#181#148'28'#196#2'A*'#179#229#133#136' '#0 + +#159'1'#20#130#170#18'Q'#173#149#136#6'E'#203#166#244#200#159#244#135#0'3{M' + +#182#169#221#254#150'QF'#160#174#181#206'D'#177'G'''#253#242'._w'#216'T'#224 + +#191#193'W'#217'-6'#193#211#138#3#140#11#217#192#243#237#19#31#143#133#151 + +#152#178'`q'#162#161'F'#190#226'3'#131#197#20#0#252'^'#201#11#223#133#132#185 + +#247'4'#167'C'#138#153'g'#162#221#174'<'#236#189#181'h'#161#232'a'#239'2'#157 + +'7z'#157#218#201#14'G'#16#209#233'9'#159#143#253#201#242#11';'#208'oCZ'#162 + +#230'J'#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/components/extrasyn/images.rc b/components/extrasyn/images.rc new file mode 100644 index 000000000..afeb308e7 --- /dev/null +++ b/components/extrasyn/images.rc @@ -0,0 +1,37 @@ + +TSYNADSP21XXSYN RCDATA "Images\TSYNADSP21XXSYN.png" +TSYNTCLTKSYN RCDATA "Images\TSYNTCLTKSYN.png" +TSYNRUBYSYN RCDATA "Images\TSYNRUBYSYN.png" +TSYNDOTSYN RCDATA "Images\TSYNDOTSYN.png" +TSYNCSSYN RCDATA "Images\TSYNCSSYN.png" +TSYNHASKELLSYN RCDATA "Images\TSYNHASKELLSYN.png" +TSYNFOXPROSYN RCDATA "Images\TSYNFOXPROSYN.png" +TSYNINNOSYN RCDATA "Images\TSYNINNOSYN.png" +TSYNDMLSYN RCDATA "Images\TSYNDMLSYN.png" +TSYNCACSYN RCDATA "Images\TSYNCACSYN.png" +TSYNMODELICASYN RCDATA "Images\TSYNMODELICASYN.png" +TSYNVRML97SYN RCDATA "Images\TSYNVRML97SYN.png" +TSYNHP48SYN RCDATA "Images\TSYNHP48SYN.png" +TSYNCPMSYN RCDATA "Images\TSYNCPMSYN.png" +TSYNKIXSYN RCDATA "Images\TSYNKIXSYN.png" +TSYNPROGRESSSYN RCDATA "Images\TSYNPROGRESSSYN.png" +TSYNEIFFELSYN RCDATA "Images\TSYNEIFFELSYN.png" +TSYNBAANSYN RCDATA "Images\TSYNBAANSYN.png" +TSYNM3SYN RCDATA "Images\TSYNM3SYN.png" +TSYNLDRSYN RCDATA "Images\TSYNLDRSYN.png" +TSYNVBSCRIPTSYN RCDATA "Images\TSYNVBSCRIPTSYN.png" +TSYNUNREALSYN RCDATA "Images\TSYNUNREALSYN.png" +TSYNSMLSYN RCDATA "Images\TSYNSMLSYN.png" +TSYNIDLSYN RCDATA "Images\TSYNIDLSYN.png" +TSYNCOBOLSYN RCDATA "Images\TSYNCOBOLSYN.png" +TSYNGWSCRIPTSYN RCDATA "Images\TSYNGWSCRIPTSYN.png" +TSYNGALAXYSYN RCDATA "Images\TSYNGALAXYSYN.png" +TSYN8051SYN RCDATA "Images\TSYN8051SYN.png" +TSYNASMSYN RCDATA "Images\TSYNASMSYN.png" +TSYNLUASYN RCDATA "Images\TSYNLUASYN.png" +TSYNFORTRANSYN RCDATA "Images\TSYNFORTRANSYN.png" +TSYNPROLOGSYN RCDATA "Images\TSYNPROLOGSYN.png" +TSYNSDDSYN RCDATA "Images\TSYNSDDSYN.png" +TSYNRCSYN RCDATA "Images\TSYNRCSYN.png" +TSYNCACHESYN RCDATA "Images\TSYNCACHESYN.png" +TSYNAWKSYN RCDATA "Images\TSYNAWKSYN.png" diff --git a/components/extrasyn/uhighlighterreg.pas b/components/extrasyn/uhighlighterreg.pas new file mode 100644 index 000000000..3c7950386 --- /dev/null +++ b/components/extrasyn/uhighlighterreg.pas @@ -0,0 +1,46 @@ +unit uHighlighterReg; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, + + SynHighlighterADSP21xx, SynHighlighterFortran, SynHighlighterFoxpro, SynHighlighterGalaxy, SynHighlighterBaan, + SynHighlighterHaskell, SynHighlighterCache, SynHighlighterCS, SynHighlighterDml, SynHighlighterCAC, + SynHighlighterModelica, SynHighlighterCobol, SynHighlighterTclTk, SynHighlighterHP48, SynHighlighterAWK, + SynHighlighterProgress, SynHighlighterEiffel, SynHighlighterGWS, SynHighlighterDOT, SynHighlighterLDraw, + SynHighlighterVBScript, SynHighlighterUnreal, SynHighlighterVrml97, SynHighlighterSml, SynHighlighterIDL, + SynHighlighterRuby, SynHighlighterInno, SynHighlighterAsm, SynHighlighter8051, SynHighlighterLua, + SynHighlighterKix, SynHighlighterSDD, SynHighlighterProlog, SynHighlighterRC, SynHighlighterM3; + +{.$R ImagesPNG.Res} +{.$R ImagesPNG.Res} +{.$R ImagesPNG.Res} + +{.$R *.rc} +{.$R Images.rc} +//failed miserably to use rc files they are not linked in lazarus for some reason although if I delete the res file +//from the disk the compiler complains about the missing file. +procedure Register; + +implementation +uses LResources; + + + +procedure Register; +begin + RegisterComponents('SynEdit Highlighters',[TSynADSP21xxSyn, TSynTclTkSyn, TSynRubySyn, TSynDOTSyn, TSynCSSyn, + TSynHaskellSyn, TSynFoxproSyn, TSynInnoSyn, TSynDmlSyn, TSynCACSyn, + TSynModelicaSyn, TSynVrml97Syn, TSynHP48Syn, TSynKixSyn, TSynAWKSyn, + TSynProgressSyn, TSynEiffelSyn, TSynBaanSyn, TSynM3Syn, TSynLDRSyn, + TSynVBScriptSyn, TSynUnrealSyn, TSynSMLSyn, TSynIdlSyn, TSynCobolSyn, + TSynGWScriptSyn, TSynGalaxySyn, TSyn8051Syn, TSynAsmSyn, TSynLuaSyn, + TSynFortranSyn, TSynPrologSyn, TSynSDDSyn, TSynRCSyn, TSynCacheSyn]); +end; +initialization + {$I Images.lrs} +end. +