Browse Source

+ Added format in interface
+ Some errors in parser fixed, it uses exceptions now
+ Strings now has no more syntax errors.

michael 27 years ago
parent
commit
f122915f75
4 changed files with 47 additions and 41 deletions
  1. 13 11
      fcl/inc/classes.inc
  2. 7 4
      fcl/inc/classesh.inc
  3. 10 11
      fcl/inc/parser.inc
  4. 17 15
      fcl/inc/strings.inc

+ 13 - 11
fcl/inc/classes.inc

@@ -32,14 +32,6 @@
 { Utility routines }
 { Utility routines }
 {$i util.inc}
 {$i util.inc}
 
 
-{!!!TSE 21.09.1998 reimplements exceptions classes}
-{$IFNDEF USE_EXCEPTIONS}
-constructor Exception.Create(Msg : String);
-begin
-  inherited Create;
-end;
-{$ENDIF}
-
 { TBits implementation }
 { TBits implementation }
 {$i bits.inc}
 {$i bits.inc}
 
 
@@ -370,7 +362,12 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.6  1998-10-29 12:47:14  michael
+  Revision 1.7  1998-10-30 14:52:48  michael
+  + Added format in interface
+  + Some errors in parser fixed, it uses exceptions now
+  + Strings now has no more syntax errors.
+
+  Revision 1.6  1998/10/29 12:47:14  michael
   + Implementation of tpoint by WYB
   + Implementation of tpoint by WYB
 
 
   Revision 1.5  1998/09/23 08:41:55  michael
   Revision 1.5  1998/09/23 08:41:55  michael
@@ -415,7 +412,12 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.6  1998-10-29 12:47:14  michael
+  Revision 1.7  1998-10-30 14:52:48  michael
+  + Added format in interface
+  + Some errors in parser fixed, it uses exceptions now
+  + Strings now has no more syntax errors.
+
+  Revision 1.6  1998/10/29 12:47:14  michael
   + Implementation of tpoint by WYB
   + Implementation of tpoint by WYB
 
 
   Revision 1.5  1998/09/23 08:41:55  michael
   Revision 1.5  1998/09/23 08:41:55  michael
@@ -433,4 +435,4 @@ end;
   Revision 1.1  1998/05/04 12:16:01  florian
   Revision 1.1  1998/05/04 12:16:01  florian
     + Initial revisions after making a new directory structure
     + Initial revisions after making a new directory structure
 
 
-}
+}

+ 7 - 4
fcl/inc/classesh.inc

@@ -776,9 +776,7 @@ type
     procedure CheckToken(T: Char);
     procedure CheckToken(T: Char);
     procedure CheckTokenSymbol(const S: string);
     procedure CheckTokenSymbol(const S: string);
     procedure Error(const Ident: string);
     procedure Error(const Ident: string);
-    {!!!!!!
     procedure ErrorFmt(const Ident: string; const Args: array of const);
     procedure ErrorFmt(const Ident: string; const Args: array of const);
-    }
     procedure ErrorStr(const Message: string);
     procedure ErrorStr(const Message: string);
     procedure HexToBinary(Stream: TStream);
     procedure HexToBinary(Stream: TStream);
     function NextToken: Char;
     function NextToken: Char;
@@ -1051,7 +1049,12 @@ function LineStart(Buffer, BufPos: PChar): PChar;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.9  1998-10-24 13:45:35  michael
+  Revision 1.10  1998-10-30 14:52:49  michael
+  + Added format in interface
+  + Some errors in parser fixed, it uses exceptions now
+  + Strings now has no more syntax errors.
+
+  Revision 1.9  1998/10/24 13:45:35  michael
   + Implemented stringlist. Untested, since classes broken.
   + Implemented stringlist. Untested, since classes broken.
 
 
   Revision 1.8  1998/09/23 07:47:41  michael
   Revision 1.8  1998/09/23 07:47:41  michael
@@ -1078,4 +1081,4 @@ function LineStart(Buffer, BufPos: PChar): PChar;
   Revision 1.1  1998/05/04 12:16:01  florian
   Revision 1.1  1998/05/04 12:16:01  florian
     + Initial revisions after making a new directory structure
     + Initial revisions after making a new directory structure
 
 
-}
+}

+ 10 - 11
fcl/inc/parser.inc

@@ -122,18 +122,15 @@ begin
       toInteger, toFloat:
       toInteger, toFloat:
         Error(SNumberExpected);
         Error(SNumberExpected);
     else
     else
-//      ErrorFmt(SCharExpected, [T]);
-        ErrorStr('"' + T + '"' + SCharExpected);
+      ErrorFmt(SCharExpected, [T]);
     end;
     end;
   end;
   end;
 end;
 end;
 
 
 procedure TParser.CheckTokenSymbol(const S: string);
 procedure TParser.CheckTokenSymbol(const S: string);
 begin
 begin
-  if not TokenSymbolIs(S) then begin
-    // ErrorFmt(SSymbolExpected, [S]);
-    ErrorStr(S + SSymbolExpected);
-  end;
+  if not TokenSymbolIs(S) then 
+    ErrorFmt(SSymbolExpected, [S]);
 end;
 end;
 
 
 Procedure TParser.Error(const Ident: string);
 Procedure TParser.Error(const Ident: string);
@@ -141,17 +138,14 @@ begin
   ErrorStr(Ident);
   ErrorStr(Ident);
 end;
 end;
 
 
-{!!!!!!
 Procedure TParser.ErrorFmt(const Ident: string; const Args: array of const);
 Procedure TParser.ErrorFmt(const Ident: string; const Args: array of const);
 begin
 begin
   ErrorStr(Format(Ident, Args));
   ErrorStr(Format(Ident, Args));
 end;
 end;
-!!!!!!}
 
 
 Procedure TParser.ErrorStr(const Message: string);
 Procedure TParser.ErrorStr(const Message: string);
 begin
 begin
-//  raise EParserError.CreateFmt(SParseError, [Message, FSourceLine]);
-  raise EParserError.Create(Message + SParseError + IntToStr(FSourceLine));
+  raise EParserError.CreateFmt(SParseError, [Message, FSourceLine]);
 end;
 end;
 
 
 
 
@@ -322,7 +316,12 @@ begin
 end;
 end;
 {
 {
   $Log$
   $Log$
-  Revision 1.3  1998-10-02 22:41:28  michael
+  Revision 1.4  1998-10-30 14:52:51  michael
+  + Added format in interface
+  + Some errors in parser fixed, it uses exceptions now
+  + Strings now has no more syntax errors.
+
+  Revision 1.3  1998/10/02 22:41:28  michael
   + Added exceptions for error handling
   + Added exceptions for error handling
 
 
   Revision 1.2  1998/09/23 07:48:11  michael
   Revision 1.2  1998/09/23 07:48:11  michael

+ 17 - 15
fcl/inc/strings.inc

@@ -562,9 +562,9 @@ Var Extra : Longint;
 
 
 begin
 begin
   If FCapacity>64 then
   If FCapacity>64 then
-    Extra:=FCapacity Div 4;
+    Extra:=FCapacity Div 4
   Else If FCapacity>8 Then 
   Else If FCapacity>8 Then 
-    Extra:=16;
+    Extra:=16
   Else 
   Else 
     Extra:=4;
     Extra:=4;
   SetCapacity(FCapacity+Extra); 
   SetCapacity(FCapacity+Extra); 
@@ -574,7 +574,7 @@ end;
 
 
 Procedure TStringList.QuickSort(L, R: Integer);
 Procedure TStringList.QuickSort(L, R: Integer);
 
 
-Var L,R,I,J : Longint;
+Var I,J : Longint;
     Pivot : String;
     Pivot : String;
 
 
 begin
 begin
@@ -603,10 +603,10 @@ Procedure TStringList.InsertItem(Index: Integer; const S: string);
 
 
 begin
 begin
   Changing;
   Changing;
-  If FCount:=Fcapacity then Grow;
+  If FCount=Fcapacity then Grow;
   If Index<FCount then
   If Index<FCount then
     System.Move (FList^[Index],FList^[Index+1],SizeOf(TStringItem));
     System.Move (FList^[Index],FList^[Index+1],SizeOf(TStringItem));
-  Pointer(Flist^[Index].Fstring:=Nil;  // Needed to initialize...
+  Pointer(Flist^[Index].Fstring):=Nil;  // Needed to initialize...
   Flist^[Index].FString:=S;
   Flist^[Index].FString:=S;
   Flist^[Index].Fobject:=Nil;
   Flist^[Index].Fobject:=Nil;
   Inc(FCount);
   Inc(FCount);
@@ -711,8 +711,8 @@ end;
 
 
 Procedure TStringList.SetCapacity(NewCapacity: Integer); 
 Procedure TStringList.SetCapacity(NewCapacity: Integer); 
 
 
-Var NewList : Pointer;
-
+Var NewList,ToFree : Pointer;
+    
 begin
 begin
   If (NewCapacity<0) then 
   If (NewCapacity<0) then 
      Error (SListCapacityError,NewCapacity); 
      Error (SListCapacityError,NewCapacity); 
@@ -725,7 +725,7 @@ begin
     If Assigned(FList) then
     If Assigned(FList) then
       begin
       begin
       System.Move (FList^,NewList^,FCapacity*Sizeof(Pointer));
       System.Move (FList^,NewList^,FCapacity*Sizeof(Pointer));
-      FillWord (NewList^[FCapacity],(NewCapacity-FCapacity)*WordRatio, 0);
+      FillWord (Pchar(NewList)[FCapacity],(NewCapacity-FCapacity)*WordRatio, 0);
       FreeMem (Flist,FCapacity*SizeOf(Pointer));
       FreeMem (Flist,FCapacity*SizeOf(Pointer));
       end;
       end;
     Flist:=NewList;
     Flist:=NewList;
@@ -763,7 +763,7 @@ begin
   FOnChanging:=Nil;
   FOnChanging:=Nil;
   // This will force a dereference. Can be done better...
   // This will force a dereference. Can be done better...
   For I:=0 to FCount-1 do 
   For I:=0 to FCount-1 do 
-    FList^.[I].FString:='';
+    FList^[I].FString:='';
   FCount:=0;
   FCount:=0;
   SetCapacity(0);  
   SetCapacity(0);  
   Inherited destroy;  
   Inherited destroy;  
@@ -782,7 +782,6 @@ begin
         DupIgnore : Exit;
         DupIgnore : Exit;
         DupError : Error(SDuplicateString,0)
         DupError : Error(SDuplicateString,0)
       end;
       end;
-    end;
    InsertItem (Result,S);
    InsertItem (Result,S);
 end;
 end;
 
 
@@ -880,21 +879,19 @@ begin
   If Sorted then
   If Sorted then
     Error (SSortedListError,0)
     Error (SSortedListError,0)
   else 
   else 
-    begin
     If (Index<0) or (Index>FCount) then
     If (Index<0) or (Index>FCount) then
-      Error (SListIndexError,Index);
+      Error (SListIndexError,Index)
     else 
     else 
       InsertItem (Index,S);
       InsertItem (Index,S);
 end;
 end;
 
 
 
 
-
 Procedure TStringList.Sort; 
 Procedure TStringList.Sort; 
 
 
 begin
 begin
   If Not Sorted and FCount>1 then
   If Not Sorted and FCount>1 then
     begin
     begin
-    Changing
+    Changing;
     QuickSOrt(0,FCount-1);
     QuickSOrt(0,FCount-1);
     Changed;
     Changed;
     end;
     end;
@@ -902,7 +899,12 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  1998-10-24 13:45:37  michael
+  Revision 1.5  1998-10-30 14:52:52  michael
+  + Added format in interface
+  + Some errors in parser fixed, it uses exceptions now
+  + Strings now has no more syntax errors.
+
+  Revision 1.4  1998/10/24 13:45:37  michael
   + Implemented stringlist. Untested, since classes broken.
   + Implemented stringlist. Untested, since classes broken.
 
 
   Revision 1.3  1998/05/07 14:16:51  michael
   Revision 1.3  1998/05/07 14:16:51  michael