Ładny brzuch
^ macie oco mi chodzi
Nie wiem czy jest jakis generator, ja po prostu wzialem kod na kolorowanie assemblera (moj jezyk jest najbardziej zblizony skladnia do asm wlasnie) i zmienilem slowa kluczowe, znaki komentarzy etc. Ponizej zrodlo :
unit SynHighlighterMig; {$I SynEdit.inc} interface uses SysUtils, Classes, {$IFDEF SYN_KYLIX} Qt, QControls, QGraphics, {$ELSE} Windows, Messages, Controls, Graphics, Registry, {$ENDIF} SynEditHighlighter, SynHighlighterHashEntries, SynEditTypes; type TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, tkString, tkSymbol, tkUnknown); TProcTableProc = procedure of object; type TSynMigSyn = 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 SymbolProc; procedure UnknownProc; procedure DoAddKeyword(AKeyword: string; AKind: integer); function IdentKind(MayBe: PChar): TtkTokenKind; procedure MakeMethodTables; protected function GetIdentChars: TSynIdentChars; override; public {$IFNDEF SYN_CPPB_1} class {$ENDIF} //mh 2000-07-14 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(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 SynEditStrConst; var Identifiers: array[#0..#255] of ByteBool; mHashTable: array[#0..#255] of Integer; const //mh: added the following opcodes: aaa, bsf, bsr, bswap, bt, btc, btr, bts, // clc, cld, cli, clts, cmpxchg, daa, das, dec, inc, invd, invlpg, iretw, // lar, lfs, lgdt, lgs, lidt, lldt, lmsw, lsl, lss, ltr, movsx, movzx // popaw, popfw, pusha, pushad, pushaw, pushfw, repnz, repz, 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, setpe, setpo, sets, setz, sgdt, shld, shrd, sidt, // sldt, smsw, stc, std, sti, str, verr, verw, wbinvd, xadd OpCodes: string = 'mov,message,its,sti,gotoline,add,sub,mlt,div,inputdlg,' + 'random,pos,length,copy,lower,upper,sleep,run,self,rnr,sound,dir,goto,' + 'newstr,newint,delstr,delint,inc,dec,readf,book,if,end'; { 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© - Ord('a'); for c := 'A' to 'Z' do mHashTable[c] := 1 + Ord© - Ord('A'); for c := '0' to '9' do mHashTable[c] := 27 + Ord© - Ord('0'); end; function TSynMigSyn.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 TSynMigSyn.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 TSynMigSyn.DoAddKeyword(AKeyword: string; AKind: integer); var HashValue: integer; begin HashValue := KeyHash(PChar(AKeyword)); fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind); end; function TSynMigSyn.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 TSynMigSyn.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; '>': 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; '.', ':', '&', #39, '{', '}', '=', '^', '-', '+', '(', ')', '*': fProcTable[I] := SymbolProc; else fProcTable[I] := UnknownProc; end; end; constructor TSynMigSyn.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 TSynMigSyn.Destroy; begin fKeywords.Free; inherited Destroy; end; procedure TSynMigSyn.SetLine(NewValue: String; LineNumber:Integer); begin fLine := PChar(NewValue); Run := 0; fLineNumber := LineNumber; Next; end; procedure TSynMigSyn.CommentProc; begin fTokenID := tkComment; repeat Inc(Run); until fLine[Run] in [#0, #10, #13]; end; procedure TSynMigSyn.CRProc; begin fTokenID := tkSpace; Inc(Run); if fLine[Run] = #10 then Inc(Run); end; procedure TSynMigSyn.GreaterProc; begin Inc(Run); fTokenID := tkSymbol; if fLine[Run] = '=' then Inc(Run); end; procedure TSynMigSyn.IdentProc; begin fTokenID := IdentKind((fLine + Run)); inc(Run, fStringLen); while Identifiers[fLine[Run]] do inc(Run); end; procedure TSynMigSyn.LFProc; begin fTokenID := tkSpace; inc(Run); end; procedure TSynMigSyn.LowerProc; begin Inc(Run); fTokenID := tkSymbol; if fLine[Run] in ['=', '>'] then Inc(Run); end; procedure TSynMigSyn.NullProc; begin fTokenID := tkNull; end; procedure TSynMigSyn.NumberProc; begin inc(Run); fTokenID := tkNumber; // while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do inc(Run); while FLine[Run] in ['0'..'9', '.', 'a'..'f', 'h', 'A'..'F', 'H'] do //ek 2000-09-23 Inc(Run); end; procedure TSynMigSyn.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 TSynMigSyn.SpaceProc; begin fTokenID := tkSpace; repeat Inc(Run); until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]); end; procedure TSynMigSyn.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 TSynMigSyn.SymbolProc; begin inc(Run); fTokenID := tkSymbol; end; procedure TSynMigSyn.UnknownProc; begin fTokenID := tkIdentifier; inc(Run); end; procedure TSynMigSyn.Next; begin fTokenPos := Run; fProcTable[fLine[Run]]; end; function TSynMigSyn.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 TSynMigSyn.GetEol: Boolean; begin Result := fTokenId = tkNull; end; function TSynMigSyn.GetToken: String; var Len: LongInt; begin Len := Run - fTokenPos; SetString(Result, (FLine + fTokenPos), Len); end; function TSynMigSyn.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 TSynMigSyn.GetTokenKind: integer; begin Result := Ord(fTokenId); end; function TSynMigSyn.GetTokenID: TtkTokenKind; begin Result := fTokenId; end; function TSynMigSyn.GetTokenPos: Integer; begin Result := fTokenPos; end; function TSynMigSyn.GetIdentChars: TSynIdentChars; begin Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; end; {$IFNDEF SYN_CPPB_1} class {$ENDIF} //mh 2000-07-14 function TSynMigSyn.GetLanguageName: string; begin Result := SYNS_LangX86Asm; end; initialization MakeIdentTable; {$IFNDEF SYN_CPPB_1} //mh 2000-07-14 RegisterPlaceableHighlighter(TSynMigSyn); {$ENDIF} end.
poszukaj w folderze synedit programu syngen
poszukaj w folderze synedit programu syngen
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
Nie wiem czy jest jakis generator, ja po prostu wzialem kod na kolorowanie assemblera (moj jezyk jest najbardziej zblizony skladnia do asm wlasnie) i zmienilem slowa kluczowe, znaki komentarzy etc. Ponizej zrodlo :
unit SynHighlighterMig; {$I SynEdit.inc} interface uses SysUtils, Classes, {$IFDEF SYN_KYLIX} Qt, QControls, QGraphics, {$ELSE} Windows, Messages, Controls, Graphics, Registry, {$ENDIF} SynEditHighlighter, SynHighlighterHashEntries, SynEditTypes; type TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, tkString, tkSymbol, tkUnknown); TProcTableProc = procedure of object; type TSynMigSyn = 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 SymbolProc; procedure UnknownProc; procedure DoAddKeyword(AKeyword: string; AKind: integer); function IdentKind(MayBe: PChar): TtkTokenKind; procedure MakeMethodTables; protected function GetIdentChars: TSynIdentChars; override; public {$IFNDEF SYN_CPPB_1} class {$ENDIF} //mh 2000-07-14 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(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 SynEditStrConst; var Identifiers: array[#0..#255] of ByteBool; mHashTable: array[#0..#255] of Integer; const //mh: added the following opcodes: aaa, bsf, bsr, bswap, bt, btc, btr, bts, // clc, cld, cli, clts, cmpxchg, daa, das, dec, inc, invd, invlpg, iretw, // lar, lfs, lgdt, lgs, lidt, lldt, lmsw, lsl, lss, ltr, movsx, movzx // popaw, popfw, pusha, pushad, pushaw, pushfw, repnz, repz, 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, setpe, setpo, sets, setz, sgdt, shld, shrd, sidt, // sldt, smsw, stc, std, sti, str, verr, verw, wbinvd, xadd OpCodes: string = 'mov,message,its,sti,gotoline,add,sub,mlt,div,inputdlg,' + 'random,pos,length,copy,lower,upper,sleep,run,self,rnr,sound,dir,goto,' + 'newstr,newint,delstr,delint,inc,dec,readf,book,if,end'; { 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© - Ord('a'); for c := 'A' to 'Z' do mHashTable[c] := 1 + Ord© - Ord('A'); for c := '0' to '9' do mHashTable[c] := 27 + Ord© - Ord('0'); end; function TSynMigSyn.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 TSynMigSyn.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 TSynMigSyn.DoAddKeyword(AKeyword: string; AKind: integer); var HashValue: integer; begin HashValue := KeyHash(PChar(AKeyword)); fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind); end; function TSynMigSyn.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 TSynMigSyn.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; '>': 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; '.', ':', '&', #39, '{', '}', '=', '^', '-', '+', '(', ')', '*': fProcTable[I] := SymbolProc; else fProcTable[I] := UnknownProc; end; end; constructor TSynMigSyn.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 TSynMigSyn.Destroy; begin fKeywords.Free; inherited Destroy; end; procedure TSynMigSyn.SetLine(NewValue: String; LineNumber:Integer); begin fLine := PChar(NewValue); Run := 0; fLineNumber := LineNumber; Next; end; procedure TSynMigSyn.CommentProc; begin fTokenID := tkComment; repeat Inc(Run); until fLine[Run] in [#0, #10, #13]; end; procedure TSynMigSyn.CRProc; begin fTokenID := tkSpace; Inc(Run); if fLine[Run] = #10 then Inc(Run); end; procedure TSynMigSyn.GreaterProc; begin Inc(Run); fTokenID := tkSymbol; if fLine[Run] = '=' then Inc(Run); end; procedure TSynMigSyn.IdentProc; begin fTokenID := IdentKind((fLine + Run)); inc(Run, fStringLen); while Identifiers[fLine[Run]] do inc(Run); end; procedure TSynMigSyn.LFProc; begin fTokenID := tkSpace; inc(Run); end; procedure TSynMigSyn.LowerProc; begin Inc(Run); fTokenID := tkSymbol; if fLine[Run] in ['=', '>'] then Inc(Run); end; procedure TSynMigSyn.NullProc; begin fTokenID := tkNull; end; procedure TSynMigSyn.NumberProc; begin inc(Run); fTokenID := tkNumber; // while FLine[Run] in ['0'..'9', '.', 'e', 'E'] do inc(Run); while FLine[Run] in ['0'..'9', '.', 'a'..'f', 'h', 'A'..'F', 'H'] do //ek 2000-09-23 Inc(Run); end; procedure TSynMigSyn.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 TSynMigSyn.SpaceProc; begin fTokenID := tkSpace; repeat Inc(Run); until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]); end; procedure TSynMigSyn.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 TSynMigSyn.SymbolProc; begin inc(Run); fTokenID := tkSymbol; end; procedure TSynMigSyn.UnknownProc; begin fTokenID := tkIdentifier; inc(Run); end; procedure TSynMigSyn.Next; begin fTokenPos := Run; fProcTable[fLine[Run]]; end; function TSynMigSyn.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 TSynMigSyn.GetEol: Boolean; begin Result := fTokenId = tkNull; end; function TSynMigSyn.GetToken: String; var Len: LongInt; begin Len := Run - fTokenPos; SetString(Result, (FLine + fTokenPos), Len); end; function TSynMigSyn.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 TSynMigSyn.GetTokenKind: integer; begin Result := Ord(fTokenId); end; function TSynMigSyn.GetTokenID: TtkTokenKind; begin Result := fTokenId; end; function TSynMigSyn.GetTokenPos: Integer; begin Result := fTokenPos; end; function TSynMigSyn.GetIdentChars: TSynIdentChars; begin Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; end; {$IFNDEF SYN_CPPB_1} class {$ENDIF} //mh 2000-07-14 function TSynMigSyn.GetLanguageName: string; begin Result := SYNS_LangX86Asm; end; initialization MakeIdentTable; {$IFNDEF SYN_CPPB_1} //mh 2000-07-14 RegisterPlaceableHighlighter(TSynMigSyn); {$ENDIF} end.
poszukaj w folderze synedit programu syngen
poszukaj w folderze synedit programu syngen
