Ignore:
Timestamp:
Nov 11, 2009, 12:56:32 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Inicializace a uvolnění třídy, které byly přepsány ze struktury record.
File:
1 edited

Legend:

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

    r29 r30  
    66
    77uses
    8   Classes, ComCtrls, SysUtils, Math, UGrammer, fgl;
     8  Classes, ComCtrls, SysUtils, UGrammer, fgl;
    99
    1010type
     
    6262begin
    6363  SelectedProgramItem := TopItem;
    64   for I := 0 to High(Path.Items) do with Path.Items[I] do begin
     64  for I := 0 to Path.Items.Count - 1 do
     65  with Path.Items[I] do begin
    6566    SelectedProgramItem.ItemType := itNonterminal;
    6667    if not Assigned(SelectedProgramItem.Rule) then SelectedProgramItem.Rule := Rule;
     
    99100  Level: array of Integer;
    100101begin
    101   SetLength(Path.Items, Length(Path.Items) + 1);
    102   with Path.Items[High(Path.Items)] do begin
     102  Path := TGrammerPath.Create;
     103  Scope := TPossibleCharacters.Create;
     104
     105  with Path.Items[Path.Items.Add(TPathItem.Create)] do begin
    103106    Rule := Grammer.TopRule;
    104107    ItemIndex := 0;
     
    110113    if (Text[I] <> #13) and (Text[I] <> #10) then
    111114    begin
    112       UseIndex := Path.Items[High(Path.Items)].ItemIndex;
    113       UseCharIndex := Path.Items[High(Path.Items)].CharIndex;
    114       UseRule := Path.Items[High(Path.Items)].Rule;
    115       SetLength(Path.Items, Length(Path.Items) - 1);
    116       SetLength(Scope.Items, 0);
     115      UseIndex := Path.Items[Path.Items.Count - 1].ItemIndex;
     116      UseCharIndex := Path.Items[Path.Items.Count - 1].CharIndex;
     117      UseRule := Path.Items[Path.Items.Count - 1].Rule;
     118      Path.Items.Delete(Path.Items.Count - 1);
     119      Scope.Items.Clear;
    117120      Grammer.ClearProcessed;
    118121      UseRule.GetPossibleCharacters(Path, Scope, UseIndex, UseCharIndex);
    119       C := Length(Scope.Items);
     122      C := Scope.Items.Count;
    120123
    121124      // Possible character selection
    122125      SetLength(Level, 0);
    123       for II := 0 to High(Scope.Items) do with Scope.Items[II] do
     126      for II := 0 to Scope.Items.Count - 1 do
     127      with Scope.Items[II] do
    124128      begin
    125129        if (Character = Text[I]) then
     
    174178      end;
    175179
    176       if C < Length(Scope.Items) then begin
     180      if C < Scope.Items.Count then begin
    177181        Path.Assign(Scope.Items[C].RulePath);
    178         for II := 0 to Length(Path.Items) - 1 do with Path.Items[II] do begin
     182        for II := 0 to Path.Items.Count - 1 do
     183        with Path.Items[II] do begin
    179184          if Affected then Inc(CharIndex);
    180185        end;
    181186        Insert(Path, Scope.Items[C].Character);
    182         for II := 0 to Length(Path.Items) - 1 do with Path.Items[II] do begin
     187        for II := 0 to Path.Items.Count - 1 do
     188        with Path.Items[II] do begin
    183189          Affected := False;
    184190        end;
     
    186192      end else begin
    187193        ExpectedCharacters := '';
    188         for II := 0 to Length(Scope.Items) - 1 do
     194        for II := 0 to Scope.Items.Count - 1 do
    189195          ExpectedCharacters := ExpectedCharacters + Scope.Items[II].Character;
    190196        //raise Exception.Create('Parse error. Expected "' + ExpectedCharacters + '" but found "' + Text[I] + '".');
     
    194200    end;
    195201  end;
     202  Path.Destroy;
     203  Scope.Destroy;
    196204end;
    197205
Note: See TracChangeset for help on using the changeset viewer.