sxsyn, add support for char literals

This commit is contained in:
Basile Burg 2023-11-26 03:24:33 +01:00
parent 1d6442917e
commit 6e2209e3b0
1 changed files with 22 additions and 0 deletions

View File

@ -91,6 +91,7 @@ type
procedure lexFloatingLiteralFractionalPart();
procedure lexExponent();
procedure lexStringLiteral();
procedure lexCharLiteral();
procedure lexRawStringLiteral();
procedure lexLineComment();
procedure lexStarComment();
@ -577,6 +578,25 @@ begin
end;
end;
procedure TSynSxSyn.lexCharLiteral();
begin
fTokKind := TTokenKind.tkStrng;
fTokStop += 1;
while fTokStop <= fLineBuf.length do
begin
case fLineBuf[fTokStop] of
'\' : fTokStop += 2;
#39 :
begin
fTokStop += 1;
exit;
end
else fTokStop += 1;
end;
end;
fTokKind := TTokenKind.tkError;
end;
procedure TSynSxSyn.lexStringLiteral();
var
firstLine: Boolean;
@ -770,6 +790,8 @@ begin
end;
// number
'1' .. '9' : lexIntLiteral();
// char
#39 : lexCharLiteral();
// "string"
'"': lexStringLiteral();
// `string`