Ignore:
Timestamp:
Nov 11, 2009, 1:43:47 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Chyby v inicializaci objektů.
File:
1 edited

Legend:

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

    r30 r31  
    3030  end;
    3131
     32  { TPossibleCharacter }
     33
    3234  TPossibleCharacter = class
    3335    Character: Char;
    3436    RulePath: TGrammerPath;
    3537    procedure Assign(Source: TPossibleCharacter);
     38    constructor Create;
     39    destructor Destroy; override;
    3640  end;
    3741
     
    138142  I: Integer;
    139143begin
    140   for I := 1 to Length(Text) do AddTerminal(Text[I], False, False);
     144  for I := 1 to Length(Text) do
     145    AddTerminal(Text[I], False, False);
    141146end;
    142147
     
    146151begin
    147152  for I := 0 to Items.Count - 1 do
    148   with Items[I] do begin
    149     Processed := False;
    150   end;
     153    Items[I].Processed := False;
    151154end;
    152155
     
    183186      if UseIndex > 0 then begin
    184187        // Forward generation to upper item
    185        with Path.Items[Path.Items.Add(TPathItem.Create)] do begin
     188        Path.Items.Delete(Path.Items.Count - 1);
     189        with Path.Items[Path.Items.Count - 1] do begin
    186190          NextItemIndex := ItemIndex;
    187191          NextCharIndex := CharIndex;
     
    237241begin
    238242  for I := 0 to Rules.Count - 1 do
    239   with Rules[I] do begin
    240     ClearProcessed;
    241   end;
     243    Rules[I].ClearProcessed;
    242244end;
    243245
     
    250252  for I := 0 to Rules.Count - 1 do with Rules[I] do begin
    251253    for II := 0 to Items.Count - 1 do with Items[II] do begin
    252       if (ItemType = itNonterminal) and (Rule = nil) then begin
     254      if (ItemType = itNonterminal) and (not Assigned(Rule)) then begin
    253255        J := 0;
    254         while (J < Rules.Count) and (Rules[J].Name <> RuleName)  do Inc(J);
     256        while (J < Rules.Count) and (Rules[J].Name <> RuleName) do Inc(J);
    255257        if J < Rules.Count then Rule := Rules[J] else
    256258          raise Exception.Create('Rule link correction failed on rule ' +
     
    309311          NextRule := Rule;
    310312        end;
    311         Path.Items.Count := Path.Items.Count - 1;
     313        Path.Items.Delete(Path.Items.Count - 1);
    312314        NextRule.GetPossibleCharacters(Path, Characters, NextItemIndex + 1, NextCharIndex);
    313315  end;
     
    380382end;
    381383
     384constructor TPossibleCharacter.Create;
     385begin
     386  RulePath := TGrammerPath.Create;
     387end;
     388
     389destructor TPossibleCharacter.Destroy;
     390begin
     391  RulePath.Destroy;
     392  inherited Destroy;
     393end;
     394
    382395{ TPossibleCharacters }
    383396
Note: See TracChangeset for help on using the changeset viewer.