Changeset 31 for branches/Analyzátor gramatiky/UGrammer.pas
- Timestamp:
- Nov 11, 2009, 1:43:47 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Analyzátor gramatiky/UGrammer.pas
r30 r31 30 30 end; 31 31 32 { TPossibleCharacter } 33 32 34 TPossibleCharacter = class 33 35 Character: Char; 34 36 RulePath: TGrammerPath; 35 37 procedure Assign(Source: TPossibleCharacter); 38 constructor Create; 39 destructor Destroy; override; 36 40 end; 37 41 … … 138 142 I: Integer; 139 143 begin 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); 141 146 end; 142 147 … … 146 151 begin 147 152 for I := 0 to Items.Count - 1 do 148 with Items[I] do begin 149 Processed := False; 150 end; 153 Items[I].Processed := False; 151 154 end; 152 155 … … 183 186 if UseIndex > 0 then begin 184 187 // 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 186 190 NextItemIndex := ItemIndex; 187 191 NextCharIndex := CharIndex; … … 237 241 begin 238 242 for I := 0 to Rules.Count - 1 do 239 with Rules[I] do begin 240 ClearProcessed; 241 end; 243 Rules[I].ClearProcessed; 242 244 end; 243 245 … … 250 252 for I := 0 to Rules.Count - 1 do with Rules[I] do begin 251 253 for II := 0 to Items.Count - 1 do with Items[II] do begin 252 if (ItemType = itNonterminal) and ( Rule = nil) then begin254 if (ItemType = itNonterminal) and (not Assigned(Rule)) then begin 253 255 J := 0; 254 while (J < Rules.Count) and (Rules[J].Name <> RuleName) 256 while (J < Rules.Count) and (Rules[J].Name <> RuleName) do Inc(J); 255 257 if J < Rules.Count then Rule := Rules[J] else 256 258 raise Exception.Create('Rule link correction failed on rule ' + … … 309 311 NextRule := Rule; 310 312 end; 311 Path.Items. Count := Path.Items.Count - 1;313 Path.Items.Delete(Path.Items.Count - 1); 312 314 NextRule.GetPossibleCharacters(Path, Characters, NextItemIndex + 1, NextCharIndex); 313 315 end; … … 380 382 end; 381 383 384 constructor TPossibleCharacter.Create; 385 begin 386 RulePath := TGrammerPath.Create; 387 end; 388 389 destructor TPossibleCharacter.Destroy; 390 begin 391 RulePath.Destroy; 392 inherited Destroy; 393 end; 394 382 395 { TPossibleCharacters } 383 396
Note:
See TracChangeset
for help on using the changeset viewer.