Changeset 29 for branches/Analyzátor gramatiky/UProgram.pas
- Timestamp:
- Nov 11, 2009, 11:11:13 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Analyzátor gramatiky/UProgram.pas
r28 r29 6 6 7 7 uses 8 Classes, ComCtrls, SysUtils, Math, UGrammer ;8 Classes, ComCtrls, SysUtils, Math, UGrammer, fgl; 9 9 10 10 type 11 TProgramItem = class; 12 13 TProgramItemList = specialize TFPGObjectList<TProgramItem>; 14 11 15 TProgramItem = class 12 16 public 13 17 RuleBefore: TGrammerRule; 14 Items: T List; // of TProgramItem;18 Items: TProgramItemList; 15 19 ItemType: TRuleItemType; 16 20 Rule: TGrammerRule; … … 87 91 Path: TGrammerPath; 88 92 I, II: Integer; 89 Q: Integer;90 93 C: Integer; 91 94 Scope: TPossibleCharacters; … … 95 98 ExpectedCharacters: string; 96 99 Level: array of Integer; 97 LevelLength: Integer;98 LevelIsLeft: Boolean;99 MaxLevel: Integer;100 Different: Boolean;101 100 begin 102 101 SetLength(Path.Items, Length(Path.Items) + 1); … … 122 121 // Possible character selection 123 122 SetLength(Level, 0); 124 LevelLength := 0;125 123 for II := 0 to High(Scope.Items) do with Scope.Items[II] do 126 124 begin … … 202 200 I: Integer; 203 201 begin 204 for I := 0 to Items.Count - 1 do with TProgramItem(Items[I])do begin202 for I := 0 to Items.Count - 1 do with Items[I] do begin 205 203 if ItemType = itNonterminal then begin 206 204 if Rule.Name = ARule.Name then begin … … 221 219 constructor TProgramItem.Create; 222 220 begin 223 Items := T List.Create;221 Items := TProgramItemList.Create; 224 222 end; 225 223 … … 228 226 I: Integer; 229 227 begin 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 231 230 if ItemType = itNonterminal then Delete; 232 231 end; … … 238 237 begin 239 238 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 241 241 if ItemType = itNonterminal then begin 242 242 if Items.Count = 0 then begin … … 262 262 begin 263 263 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 265 266 if ItemType = itNonterminal then begin 266 267 if Rule.Name = ARule.Name then begin … … 275 276 276 277 destructor 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; 278 begin 279 Items.Destroy; 282 280 inherited; 283 281 end; … … 289 287 begin 290 288 if (ItemType = itNonterminal) and (Rule = ARule) then begin 291 SubProgramItem := TProgramItem(Items[ItemIndex]);289 SubProgramItem := Items[ItemIndex]; 292 290 RuleBefore := SubProgramItem.RuleBefore; 293 291 Rule := SubProgramItem.Rule; … … 296 294 Items[ItemIndex] := nil; 297 295 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; 299 297 Items := SubProgramItem.Items; 300 298 end; 301 299 for I := 0 to Items.Count - 1 do 302 TProgramItem(Items[I]).Join(ARule, ItemIndex);300 Items[I].Join(ARule, ItemIndex); 303 301 end; 304 302 … … 308 306 begin 309 307 Result := ''; 310 for I := 0 to Items.Count - 1 do with TProgramItem(Items[I])do begin308 for I := 0 to Items.Count - 1 do with Items[I] do begin 311 309 if ItemType = itTerminal then Result := Result + Value 312 310 else Result := Result + MergeToTerminal;
Note:
See TracChangeset
for help on using the changeset viewer.