Ignore:
Timestamp:
Nov 11, 2009, 11:11:13 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Seznamy objektů přepsány na TFPGObjectList a použití generických typů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Analyzátor gramatiky/UProgram.pas

    r28 r29  
    66
    77uses
    8   Classes, ComCtrls, SysUtils, Math, UGrammer;
     8  Classes, ComCtrls, SysUtils, Math, UGrammer, fgl;
    99
    1010type
     11  TProgramItem = class;
     12
     13  TProgramItemList = specialize TFPGObjectList<TProgramItem>;
     14
    1115  TProgramItem = class
    1216  public
    1317    RuleBefore: TGrammerRule;
    14     Items: TList; // of TProgramItem;
     18    Items: TProgramItemList;
    1519    ItemType: TRuleItemType;
    1620    Rule: TGrammerRule;
     
    8791  Path: TGrammerPath;
    8892  I, II: Integer;
    89   Q: Integer;
    9093  C: Integer;
    9194  Scope: TPossibleCharacters;
     
    9598  ExpectedCharacters: string;
    9699  Level: array of Integer;
    97   LevelLength: Integer;
    98   LevelIsLeft: Boolean;
    99   MaxLevel: Integer;
    100   Different: Boolean;
    101100begin
    102101  SetLength(Path.Items, Length(Path.Items) + 1);
     
    122121      // Possible character selection
    123122      SetLength(Level, 0);
    124       LevelLength := 0;
    125123      for II := 0 to High(Scope.Items) do with Scope.Items[II] do
    126124      begin
     
    202200  I: Integer;
    203201begin
    204   for I := 0 to Items.Count - 1 do with TProgramItem(Items[I]) do begin
     202  for I := 0 to Items.Count - 1 do with Items[I] do begin
    205203    if ItemType = itNonterminal then begin
    206204      if Rule.Name = ARule.Name then begin
     
    221219constructor TProgramItem.Create;
    222220begin
    223   Items := TList.Create;
     221  Items := TProgramItemList.Create;
    224222end;
    225223
     
    228226  I: Integer;
    229227begin
    230   for I := 0 to Items.Count - 1 do with TProgramItem(Items[I]) do begin
     228  for I := 0 to Items.Count - 1 do
     229  with TProgramItem(Items[I]) do begin
    231230    if ItemType = itNonterminal then Delete;
    232231  end;
     
    238237begin
    239238  I := 0;
    240   while I < Items.Count do with TProgramItem(Items[I]) do begin
     239  while I < Items.Count do
     240  with TProgramItem(Items[I]) do begin
    241241    if ItemType = itNonterminal then begin
    242242      if Items.Count = 0 then begin
     
    262262begin
    263263  I := 0;
    264   while I < Items.Count do with TProgramItem(Items[I]) do begin
     264  while I < Items.Count do
     265  with Items[I] do begin
    265266    if ItemType = itNonterminal then begin
    266267      if Rule.Name = ARule.Name then begin
     
    275276
    276277destructor TProgramItem.Destroy;
    277 var
    278   I: Integer;
    279 begin
    280   for I := 0 to Items.Count - 1 do TProgramItem(Items[I]).Free;
    281   Items.Free;
     278begin
     279  Items.Destroy;
    282280  inherited;
    283281end;
     
    289287begin
    290288  if (ItemType = itNonterminal) and (Rule = ARule) then begin
    291     SubProgramItem := TProgramItem(Items[ItemIndex]);
     289    SubProgramItem := Items[ItemIndex];
    292290    RuleBefore := SubProgramItem.RuleBefore;
    293291    Rule := SubProgramItem.Rule;
     
    296294    Items[ItemIndex] := nil;
    297295    for I := 0 to Items.Count - 1 do
    298       if Assigned(Items[I]) then TProgramItem(Items[I]).Free;
     296      if Assigned(Items[I]) then Items[I].Free;
    299297    Items := SubProgramItem.Items;
    300298  end;
    301299  for I := 0 to Items.Count - 1 do
    302     TProgramItem(Items[I]).Join(ARule, ItemIndex);
     300    Items[I].Join(ARule, ItemIndex);
    303301end;
    304302
     
    308306begin
    309307  Result := '';
    310   for I := 0 to Items.Count - 1 do with TProgramItem(Items[I]) do begin
     308  for I := 0 to Items.Count - 1 do with Items[I] do begin
    311309    if ItemType = itTerminal then Result := Result + Value
    312310      else Result := Result + MergeToTerminal;
Note: See TracChangeset for help on using the changeset viewer.