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 lexFloatingLiteralFractionalPart();
procedure lexExponent(); procedure lexExponent();
procedure lexStringLiteral(); procedure lexStringLiteral();
procedure lexCharLiteral();
procedure lexRawStringLiteral(); procedure lexRawStringLiteral();
procedure lexLineComment(); procedure lexLineComment();
procedure lexStarComment(); procedure lexStarComment();
@ -577,6 +578,25 @@ begin
end; end;
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(); procedure TSynSxSyn.lexStringLiteral();
var var
firstLine: Boolean; firstLine: Boolean;
@ -770,6 +790,8 @@ begin
end; end;
// number // number
'1' .. '9' : lexIntLiteral(); '1' .. '9' : lexIntLiteral();
// char
#39 : lexCharLiteral();
// "string" // "string"
'"': lexStringLiteral(); '"': lexStringLiteral();
// `string` // `string`