mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 15:49:21 +02:00
* more hashing for keyword table
This commit is contained in:
parent
55809784b4
commit
88ca7ef542
@ -136,7 +136,7 @@ implementation
|
|||||||
first,last : ttoken;
|
first,last : ttoken;
|
||||||
end;
|
end;
|
||||||
var
|
var
|
||||||
tokenidx:array[2..tokenidlen] of tokenidxrec;
|
tokenidx:array[2..tokenidlen,'A'..'Z'] of tokenidxrec;
|
||||||
|
|
||||||
const
|
const
|
||||||
{ use any special name that is an invalid file name to avoid problems }
|
{ use any special name that is an invalid file name to avoid problems }
|
||||||
@ -149,13 +149,14 @@ implementation
|
|||||||
var
|
var
|
||||||
t : ttoken;
|
t : ttoken;
|
||||||
begin
|
begin
|
||||||
|
fillchar(tokenidx,sizeof(tokenidx),0);
|
||||||
for t:=low(ttoken) to high(ttoken) do
|
for t:=low(ttoken) to high(ttoken) do
|
||||||
begin
|
begin
|
||||||
if not tokeninfo[t].special then
|
if not tokeninfo[t].special then
|
||||||
begin
|
begin
|
||||||
if ord(tokenidx[length(tokeninfo[t].str)].first)=0 then
|
if ord(tokenidx[length(tokeninfo[t].str),tokeninfo[t].str[1]].first)=0 then
|
||||||
tokenidx[length(tokeninfo[t].str)].first:=t;
|
tokenidx[length(tokeninfo[t].str),tokeninfo[t].str[1]].first:=t;
|
||||||
tokenidx[length(tokeninfo[t].str)].last:=t;
|
tokenidx[length(tokeninfo[t].str),tokeninfo[t].str[1]].last:=t;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -170,8 +171,8 @@ implementation
|
|||||||
is_keyword:=false;
|
is_keyword:=false;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
low:=ord(tokenidx[length(s)].first);
|
low:=ord(tokenidx[length(s),s[1]].first);
|
||||||
high:=ord(tokenidx[length(s)].last);
|
high:=ord(tokenidx[length(s),s[1]].last);
|
||||||
while low<high do
|
while low<high do
|
||||||
begin
|
begin
|
||||||
mid:=(high+low+1) shr 1;
|
mid:=(high+low+1) shr 1;
|
||||||
@ -1036,11 +1037,12 @@ implementation
|
|||||||
readstring;
|
readstring;
|
||||||
token:=ID;
|
token:=ID;
|
||||||
idtoken:=ID;
|
idtoken:=ID;
|
||||||
{ keyword or any other known token ? }
|
{ keyword or any other known token,
|
||||||
if length(pattern) in [2..tokenidlen] then
|
pattern is always uppercased }
|
||||||
|
if (pattern[1]<>'_') and (length(pattern) in [2..tokenidlen]) then
|
||||||
begin
|
begin
|
||||||
low:=ord(tokenidx[length(pattern)].first);
|
low:=ord(tokenidx[length(pattern),pattern[1]].first);
|
||||||
high:=ord(tokenidx[length(pattern)].last);
|
high:=ord(tokenidx[length(pattern),pattern[1]].last);
|
||||||
while low<high do
|
while low<high do
|
||||||
begin
|
begin
|
||||||
mid:=(high+low+1) shr 1;
|
mid:=(high+low+1) shr 1;
|
||||||
@ -1637,7 +1639,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.79 1999-04-01 22:05:59 peter
|
Revision 1.80 1999-04-06 11:20:59 peter
|
||||||
|
* more hashing for keyword table
|
||||||
|
|
||||||
|
Revision 1.79 1999/04/01 22:05:59 peter
|
||||||
* '1.' is now parsed as a real
|
* '1.' is now parsed as a real
|
||||||
|
|
||||||
Revision 1.78 1999/03/26 19:10:06 peter
|
Revision 1.78 1999/03/26 19:10:06 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user