558 |
|
function TokenFound(var token: TSQLTokens): boolean; virtual; |
559 |
|
function InternalGetNextToken: TSQLTokens; virtual; |
560 |
|
procedure Reset; virtual; |
561 |
+ |
function ReadCharacters(NumOfChars: integer): AnsiString; |
562 |
|
|
563 |
|
{Token stack} |
564 |
|
procedure QueueToken(token: TSQLTokens; text:AnsiString); overload; |
1452 |
|
ResetQueue; |
1453 |
|
end; |
1454 |
|
|
1455 |
+ |
function TSQLTokeniser.ReadCharacters(NumOfChars: integer): AnsiString; |
1456 |
+ |
var i: integer; |
1457 |
+ |
begin |
1458 |
+ |
Result := FLastChar; |
1459 |
+ |
for i := 2 to NumOfChars do |
1460 |
+ |
begin |
1461 |
+ |
if GetNext = sqltEOF then break; |
1462 |
+ |
Result := Result + FLastChar; |
1463 |
+ |
end; |
1464 |
+ |
end; |
1465 |
+ |
|
1466 |
|
function TSQLTokeniser.GetNextToken: TSQLTokens; |
1467 |
|
begin |
1468 |
|
if FQueueState = tsRelease then |
1876 |
|
{$IFEND} |
1877 |
|
{$IFEND} |
1878 |
|
begin |
1867 |
– |
{ThousandSeparator not allowed as by Delphi specs} |
1868 |
– |
if (ThousandSeparator <> DecimalSeparator) and |
1869 |
– |
(Pos(ThousandSeparator, S) <> 0) then |
1870 |
– |
Exit; |
1871 |
– |
|
1879 |
|
for i := length(S) downto 1 do |
1880 |
|
begin |
1881 |
|
if S[i] = AnsiChar(DecimalSeparator) then |
1882 |
|
begin |
1883 |
|
if ds <> 0 then Exit; {only one allowed} |
1884 |
< |
ds := i-1; |
1884 |
> |
ds := i; |
1885 |
|
dec(exponent); |
1886 |
|
system.Delete(S,i,1); |
1887 |
|
end |
1888 |
|
else |
1889 |
< |
if (i > 1) and (S[i] in ['+','-']) and not (S[i-1] in ['e','E']) then |
1890 |
< |
Exit {malformed} |
1889 |
> |
if S[i] in ['+','-'] then |
1890 |
> |
begin |
1891 |
> |
if (i > 1) and not (S[i-1] in ['e','E']) then |
1892 |
> |
Exit; {malformed} |
1893 |
> |
end |
1894 |
|
else |
1895 |
|
if S[i] in ['e','E'] then {scientific notation} |
1896 |
|
begin |
1900 |
|
end |
1901 |
|
else |
1902 |
|
if not (S[i] in ['0'..'9']) then |
1903 |
+ |
{Note: ThousandSeparator not allowed by Delphi specs} |
1904 |
|
Exit; {bad character} |
1905 |
|
end; |
1906 |
|
|
1910 |
|
if Result then |
1911 |
|
begin |
1912 |
|
{adjust scale for decimal point} |
1913 |
< |
Scale := Scale - (exponent - ds - 1); |
1913 |
> |
if ds <> 0 then |
1914 |
> |
Scale := Scale - (exponent - ds); |
1915 |
|
Result := TryStrToInt64(system.copy(S,1,exponent-1),Value); |
1916 |
|
end; |
1917 |
|
end |
1918 |
|
else |
1919 |
|
begin |
1920 |
|
if ds <> 0 then |
1921 |
< |
scale := ds - Length(S); |
1921 |
> |
scale := ds - Length(S) - 1; |
1922 |
|
Result := TryStrToInt64(S,Value); |
1923 |
|
end; |
1924 |
|
end; |