added to ct compiler functions read, readln, write, writeln, finalize, initialize, inc, dec, setlength

git-svn-id: trunk@5764 -
This commit is contained in:
mattias 2004-08-10 18:01:18 +00:00
parent 1f41624a5f
commit 191dae0550
2 changed files with 34 additions and 20 deletions

View File

@ -762,17 +762,7 @@ begin
Result:=xtConstOrdInteger
else if CompareIdentifiers(Identifier,'ORD')=0 then
Result:=xtConstOrdInteger
else if CompareIdentifiers(Identifier,'SUCC')=0 then
Result:=xtCompilerFunc
else if CompareIdentifiers(Identifier,'PREC')=0 then
Result:=xtCompilerFunc
else if CompareIdentifiers(Identifier,'LOW')=0 then
Result:=xtCompilerFunc
else if CompareIdentifiers(Identifier,'HIGH')=0 then
Result:=xtCompilerFunc
else if CompareIdentifiers(Identifier,'LENGTH')=0 then
Result:=xtCompilerFunc
else if CompareIdentifiers(Identifier,'COPY')=0 then
else if IsKeyWordBuiltInFunc.DoIt(Identifier) then
Result:=xtCompilerFunc
// the delphi compiler special types

View File

@ -78,6 +78,7 @@ type
procedure AddExtended(const AKeyWord: shortstring;
const AFunction: TKeyWordFunction;
const ADataFunction: TKeyWordDataFunction);
procedure Add(List: TKeyWordFunctionList);
procedure Sort;
property Sorted: boolean read FSorted;
procedure WriteDebugListing;
@ -85,6 +86,7 @@ type
function AllwaysFalse: boolean;
function Count: integer;
function GetItem(Index: integer): TKeyWordFunctionListItem;
function IndexOf(const AKeyWord: shortstring): integer;
constructor Create;
destructor Destroy; override;
end;
@ -414,6 +416,18 @@ begin
inc(FCount);
end;
procedure TKeyWordFunctionList.Add(List: TKeyWordFunctionList);
var
i: Integer;
begin
for i:=0 to List.FCount-1 do begin
if IndexOf(List.FItems[i].KeyWord)<0 then begin
AddExtended(List.FItems[i].KeyWord,List.FItems[i].DoIt,
List.FItems[i].DoDataFunction);
end;
end;
end;
procedure TKeyWordFunctionList.Sort;
// bucketsort
var i, h, NewMaxHashIndex: integer;
@ -524,6 +538,13 @@ begin
Result:=FItems[Index];
end;
function TKeyWordFunctionList.IndexOf(const AKeyWord: shortstring): integer;
begin
Result:=FCount-1;
while (Result>=0) and (CompareText(FItems[Result].KeyWord,AKeyWord)<>0) do
dec(Result);
end;
function TKeyWordFunctionList.DoItCaseInsensitive(const AKeyWord: shortstring
): boolean;
var i: integer;
@ -862,6 +883,17 @@ begin
Add('PREC',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SUCC',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LENGTH',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SETLENGTH',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('INC',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('DEC',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('INITIALIZE',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('FINALIZE',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('COPY',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SIZEOF',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('WRITE',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('WRITELN',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('READ',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('READLN',{$ifdef FPC}@{$endif}AllwaysTrue);
end;
WordIsTermOperator:=TKeyWordFunctionList.Create;
@ -1154,23 +1186,15 @@ begin
Add('EXTENDED' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('FALSE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('FILE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('HIGH' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('INT64' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LENGTH' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LONGBOOL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LOW' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('NIL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('ORD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('ORD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('POINTER' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('PREC' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('QWORD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('REAL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SHORTSTRING',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SINGLE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SIZEOF' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('STRING' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SUCC' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('TEXT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('TRUE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('WIDECHAR' ,{$ifdef FPC}@{$endif}AllwaysTrue);
@ -1182,10 +1206,10 @@ begin
Add('LONGWORD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('WORD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LONGINT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('COPY' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SMALLINT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('BYTE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
end;
WordIsPredefinedFPCIdentifier.Add(IsKeyWordBuiltInFunc);
WordIsPredefinedDelphiIdentifier:=TKeyWordFunctionList.Create;
KeyWordLists.Add(WordIsPredefinedDelphiIdentifier);