That depends what you are trying to do.
1) Do you want to write a new highlighter?
2) Or do you have a highlighter, and want your code to find out about the word at caret or word at x/y
3) Or something else?
1:
https://wiki.lazarus.freepascal.org/SynEdit_Highlighter2: Use either
function GetHighlighterAttriAtRowCol(XY: TPoint; out Token: string;
out Attri: TSynHighlighterAttributes): boolean;
function GetHighlighterAttriAtRowColEx(XY: TPoint; out Token: string;
out TokenType, Start: Integer;
out Attri: TSynHighlighterAttributes): boolean;
However there is no formal definition for "keyword".
You can compare the attri to the HL.KeywordAttr;
Or you can find out the value of TokenType for whatever HL you use (every HL has its own value for Keyword)
Some HL implement Hl.IsKeyword(txt); But that does not account for context (such as if it appears in strings/comments)
Note that comparing the Attr is only 99%.
You need to check that the HL does return the real Attr, and not a (modified) copy. And you need to repeat the check, on each update. So TokenType is better.
For example the Pas-HL for case labels:
case a of
1..9: ;
CONST_NUM: ;
end;
Will create a mixed new Attri that says "1" is a label and a number.
The Sql HL has in its unit
TtkTokenKind = (tkComment, tkDatatype, tkDefaultPackage, tkException, // DJLP 2000-08-11
tkFunction, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace, tkPLSQL, // DJLP 2000-08-11
tkSQLPlus, tkString, tkSymbol, tkTableName, tkUnknown, tkVariable); // DJLP 2000-08-11
So
if Tokentype = ord(tkKey)
But
function TSynSQLSyn.IsKeyword(const AKeyword: string): boolean;
var
tk: TtkTokenKind;
begin
tk := IdentKind(PChar(AKeyword));
Result := tk in [tkDatatype, tkException, tkFunction, tkKey, tkPLSQL,
tkDefaultPackage];
end;
Indicates there are other values, also used for keywords. So pick the list that you are interested in.