Changeset 29
- Timestamp:
- Nov 11, 2009, 11:11:13 AM (15 years ago)
- Location:
- branches/Analyzátor gramatiky
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Analyzátor gramatiky/PascalCompiler.lpi
r28 r29 9 9 <Icon Value="0"/> 10 10 <UseXPManifest Value="True"/> 11 <ActiveEditorIndexAtStart Value=" 1"/>11 <ActiveEditorIndexAtStart Value="2"/> 12 12 </General> 13 13 <VersionInfo> 14 14 <ProjectVersion Value=""/> 15 <Language Value=""/>16 <CharSet Value=""/>17 15 </VersionInfo> 18 16 <PublishOptions> … … 37 35 <Filename Value="PascalCompiler.lpr"/> 38 36 <IsPartOfProject Value="True"/> 39 <CursorPos X=" 43" Y="17"/>37 <CursorPos X="1" Y="13"/> 40 38 <TopLine Value="1"/> 41 39 <EditorIndex Value="1"/> 42 <UsageCount Value="2 0"/>40 <UsageCount Value="21"/> 43 41 <Loaded Value="True"/> 44 42 </Unit0> … … 50 48 <ResourceBaseClass Value="Form"/> 51 49 <UnitName Value="UMainForm"/> 52 <CursorPos X=" 54" Y="14"/>53 <TopLine Value=" 1"/>50 <CursorPos X="33" Y="582"/> 51 <TopLine Value="572"/> 54 52 <EditorIndex Value="2"/> 55 <UsageCount Value="2 0"/>53 <UsageCount Value="21"/> 56 54 <Loaded Value="True"/> 57 55 </Unit1> … … 60 58 <IsPartOfProject Value="True"/> 61 59 <UnitName Value="UGrammer"/> 62 <CursorPos X=" 30" Y="34"/>63 <TopLine Value=" 21"/>60 <CursorPos X="62" Y="57"/> 61 <TopLine Value="37"/> 64 62 <EditorIndex Value="0"/> 65 <UsageCount Value="2 0"/>63 <UsageCount Value="21"/> 66 64 <Loaded Value="True"/> 67 65 </Unit2> … … 70 68 <IsPartOfProject Value="True"/> 71 69 <UnitName Value="UProgram"/> 72 <CursorPos X=" 14" Y="4"/>73 <TopLine Value=" 1"/>70 <CursorPos X="5" Y="18"/> 71 <TopLine Value="3"/> 74 72 <EditorIndex Value="3"/> 75 <UsageCount Value="2 0"/>73 <UsageCount Value="21"/> 76 74 <Loaded Value="True"/> 77 75 </Unit3> 78 76 </Units> 79 <JumpHistory Count=" 6" HistoryIndex="5">77 <JumpHistory Count="30" HistoryIndex="29"> 80 78 <Position1> 81 <Filename Value="U Grammer.pas"/>82 <Caret Line=" 13" Column="5" TopLine="1"/>79 <Filename Value="UMainForm.pas"/> 80 <Caret Line="344" Column="1" TopLine="329"/> 83 81 </Position1> 84 82 <Position2> 85 <Filename Value="U Grammer.pas"/>86 <Caret Line=" 4" Column="1" TopLine="1"/>83 <Filename Value="UMainForm.pas"/> 84 <Caret Line="21" Column="50" TopLine="1"/> 87 85 </Position2> 88 86 <Position3> 89 <Filename Value="U Grammer.pas"/>90 <Caret Line="1 3" Column="20" TopLine="1"/>87 <Filename Value="UMainForm.pas"/> 88 <Caret Line="11" Column="52" TopLine="1"/> 91 89 </Position3> 92 90 <Position4> 93 91 <Filename Value="UGrammer.pas"/> 94 <Caret Line=" 22" Column="23" TopLine="9"/>92 <Caret Line="63" Column="1" TopLine="60"/> 95 93 </Position4> 96 94 <Position5> 97 <Filename Value="U Grammer.pas"/>98 <Caret Line=" 28" Column="29" TopLine="16"/>95 <Filename Value="UMainForm.pas"/> 96 <Caret Line="195" Column="31" TopLine="48"/> 99 97 </Position5> 100 98 <Position6> 101 <Filename Value=" PascalCompiler.lpr"/>102 <Caret Line="3 " Column="1" TopLine="1"/>99 <Filename Value="UMainForm.pas"/> 100 <Caret Line="398" Column="29" TopLine="383"/> 103 101 </Position6> 102 <Position7> 103 <Filename Value="UMainForm.pas"/> 104 <Caret Line="410" Column="27" TopLine="395"/> 105 </Position7> 106 <Position8> 107 <Filename Value="UMainForm.pas"/> 108 <Caret Line="419" Column="23" TopLine="404"/> 109 </Position8> 110 <Position9> 111 <Filename Value="UMainForm.pas"/> 112 <Caret Line="428" Column="23" TopLine="413"/> 113 </Position9> 114 <Position10> 115 <Filename Value="UMainForm.pas"/> 116 <Caret Line="438" Column="23" TopLine="360"/> 117 </Position10> 118 <Position11> 119 <Filename Value="UMainForm.pas"/> 120 <Caret Line="564" Column="26" TopLine="549"/> 121 </Position11> 122 <Position12> 123 <Filename Value="UMainForm.pas"/> 124 <Caret Line="645" Column="49" TopLine="629"/> 125 </Position12> 126 <Position13> 127 <Filename Value="UMainForm.pas"/> 128 <Caret Line="656" Column="1" TopLine="628"/> 129 </Position13> 130 <Position14> 131 <Filename Value="UMainForm.pas"/> 132 <Caret Line="601" Column="29" TopLine="586"/> 133 </Position14> 134 <Position15> 135 <Filename Value="UMainForm.pas"/> 136 <Caret Line="620" Column="30" TopLine="605"/> 137 </Position15> 138 <Position16> 139 <Filename Value="UMainForm.pas"/> 140 <Caret Line="111" Column="1" TopLine="96"/> 141 </Position16> 142 <Position17> 143 <Filename Value="UMainForm.pas"/> 144 <Caret Line="368" Column="20" TopLine="353"/> 145 </Position17> 146 <Position18> 147 <Filename Value="UMainForm.pas"/> 148 <Caret Line="370" Column="3" TopLine="355"/> 149 </Position18> 150 <Position19> 151 <Filename Value="UMainForm.pas"/> 152 <Caret Line="372" Column="1" TopLine="357"/> 153 </Position19> 154 <Position20> 155 <Filename Value="UMainForm.pas"/> 156 <Caret Line="349" Column="1" TopLine="334"/> 157 </Position20> 158 <Position21> 159 <Filename Value="UMainForm.pas"/> 160 <Caret Line="372" Column="1" TopLine="358"/> 161 </Position21> 162 <Position22> 163 <Filename Value="UProgram.pas"/> 164 <Caret Line="11" Column="27" TopLine="1"/> 165 </Position22> 166 <Position23> 167 <Filename Value="UProgram.pas"/> 168 <Caret Line="12" Column="3" TopLine="2"/> 169 </Position23> 170 <Position24> 171 <Filename Value="UProgram.pas"/> 172 <Caret Line="8" Column="51" TopLine="1"/> 173 </Position24> 174 <Position25> 175 <Filename Value="UProgram.pas"/> 176 <Caret Line="314" Column="49" TopLine="290"/> 177 </Position25> 178 <Position26> 179 <Filename Value="UProgram.pas"/> 180 <Caret Line="102" Column="1" TopLine="89"/> 181 </Position26> 182 <Position27> 183 <Filename Value="UProgram.pas"/> 184 <Caret Line="98" Column="1" TopLine="86"/> 185 </Position27> 186 <Position28> 187 <Filename Value="UProgram.pas"/> 188 <Caret Line="31" Column="22" TopLine="16"/> 189 </Position28> 190 <Position29> 191 <Filename Value="UProgram.pas"/> 192 <Caret Line="93" Column="3" TopLine="78"/> 193 </Position29> 194 <Position30> 195 <Filename Value="UMainForm.pas"/> 196 <Caret Line="415" Column="43" TopLine="398"/> 197 </Position30> 104 198 </JumpHistory> 105 199 </ProjectOptions> … … 108 202 <PathDelim Value="\"/> 109 203 <SearchPaths> 204 <IncludeFiles Value="$(ProjOutDir)\"/> 110 205 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 111 206 </SearchPaths> 207 <CodeGeneration> 208 <Checks> 209 <IOChecks Value="True"/> 210 <RangeChecks Value="True"/> 211 <OverflowChecks Value="True"/> 212 <StackChecks Value="True"/> 213 </Checks> 214 </CodeGeneration> 112 215 <Other> 113 216 <CompilerPath Value="$(CompPath)"/> -
branches/Analyzátor gramatiky/PascalCompiler.lpr
r28 r29 4 4 5 5 uses 6 Forms, Interfaces,6 Forms, LResources, Interfaces, 7 7 UMainForm in 'UMainForm.pas' {MainForm}, 8 8 UGrammer in 'UGrammer.pas', 9 9 UProgram in 'UProgram.pas'; 10 10 11 {$ R *.res}11 {$IFDEF WINDOWS}{$R PascalCompiler.rc}{$ENDIF} 12 12 13 13 begin 14 {$I PascalCompiler.lrs} 14 15 Application.Initialize; 15 16 Application.CreateForm(TMainForm, MainForm); -
branches/Analyzátor gramatiky/UGrammer.pas
r28 r29 6 6 7 7 uses 8 Classes, ComCtrls, SysUtils, Math, UGrammerRules ;8 Classes, ComCtrls, SysUtils, Math, UGrammerRules, fgl; 9 9 10 10 type … … 55 55 end; 56 56 57 TGrammerItemList = specialize TFPGObjectList<TGrammerItem>; 58 57 59 TGrammerRule = class 58 60 private 59 61 public 60 Ownership: TGrammerRule; 62 Token: Boolean; 63 Parent: TGrammerRule; 61 64 Name: string; 62 65 RuleType: TRuleType; 63 Items: T List; // of TGrammerItem;66 Items: TGrammerItemList; 64 67 procedure ClearProcessed; 65 68 function Add: TGrammerItem; … … 74 77 end; 75 78 79 TGrammerRuleList = specialize TFPGObjectList<TGrammerRule>; 80 76 81 TGrammer = class 77 82 public 78 Rules: T List; // of TGrammerRule;83 Rules: TGrammerRuleList; 79 84 TopRule: TGrammerRule; 80 85 constructor Create; … … 137 142 constructor TGrammerRule.Create; 138 143 begin 139 Ownership:= nil;140 Items := T List.Create;144 Parent := nil; 145 Items := TGrammerItemList.Create; 141 146 end; 142 147 143 148 destructor TGrammerRule.Destroy; 144 var 145 I: Integer; 146 begin 147 for I := 0 to Items.Count - 1 do 148 TGrammerItem(Items[I]).Free; 149 Items.Free; 149 begin 150 Items.Destroy; 150 151 inherited; 151 152 end; … … 184 185 Path.Items[High(Path.Items)].ItemIndex := I; 185 186 //Inc(Path.Items[High(Path.Items)].CharIndex); 186 TGrammerItem(Items[I]).GetPossibleCharacters(Path, Characters);187 Items[I].GetPossibleCharacters(Path, Characters); 187 188 end; 188 189 end; … … 202 203 end else begin 203 204 Path.Items[High(Path.Items)].ItemIndex := UseIndex; 204 TGrammerItem(Items[UseIndex]).GetPossibleCharacters(Path, Characters);205 Items[UseIndex].GetPossibleCharacters(Path, Characters); 205 206 end; 206 207 // Check repetition 207 if (UseIndex > 0) and not TGrammerItem(Items[UseIndex - 1]).Processed then208 if TGrammerItem(Items[UseIndex - 1]).Repetition then begin208 if (UseIndex > 0) and not Items[UseIndex - 1].Processed then 209 if Items[UseIndex - 1].Repetition then begin 209 210 TempPath.Items[High(TempPath.Items)].ItemIndex := UseIndex - 1; 210 TGrammerItem(Items[UseIndex - 1]).GetPossibleCharacters(TempPath, Characters);211 Items[UseIndex - 1].GetPossibleCharacters(TempPath, Characters); 211 212 end; 212 213 end; … … 224 225 I: Integer; 225 226 begin 226 for I := 0 to Rules.Count - 1 do with TGrammerRule(Rules[I])do begin227 for I := 0 to Rules.Count - 1 do with Rules[I] do begin 227 228 ClearProcessed; 228 229 end; … … 235 236 J: Integer; 236 237 begin 237 for I := 0 to Rules.Count - 1 do with TGrammerRule(Rules[I])do begin238 for II := 0 to Items.Count - 1 do with TGrammerItem(Items[II])do begin238 for I := 0 to Rules.Count - 1 do with Rules[I] do begin 239 for II := 0 to Items.Count - 1 do with Items[II] do begin 239 240 if (ItemType = itNonterminal) and (Rule = nil) then begin 240 241 J := 0; 241 while (J < Rules.Count) and ( TGrammerRule(Rules[J]).Name <> RuleName) do Inc(J);242 while (J < Rules.Count) and (Rules[J].Name <> RuleName) do Inc(J); 242 243 if J < Rules.Count then Rule := Rules[J] else 243 244 raise Exception.Create('Rule link correction failed on rule ' + … … 250 251 constructor TGrammer.Create; 251 252 begin 252 Rules := T List.Create;253 Rules := TGrammerRuleList.Create; 253 254 end; 254 255 255 256 destructor TGrammer.Destroy; 256 var 257 I: Integer; 258 begin 259 for I := 0 to Rules.Count - 1 do TGrammerRule(Rules[I]).Free; 260 Rules.Free; 257 begin 258 Rules.Destroy; 261 259 inherited; 262 260 end; … … 322 320 Index := High(Items); 323 321 while not Success and (Index >= 0) do begin 324 with Items[Index] do if TGrammerItem(Rule.Items[ItemIndex]).Repetition then begin322 with Items[Index] do if Rule.Items[ItemIndex].Repetition then begin 325 323 Success := True; 326 324 //Inc(CharIndex); -
branches/Analyzátor gramatiky/UMainForm.lrs
r28 r29 1 { Toto je automaticky generovanÜ zdrojovÜ soubor lazarusu }2 3 1 LazarusResources.Add('TMainForm','FORMDATA',[ 4 2 'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3#1#1#6'Height'#3#141#2#3'Top'#2#0#5 -
branches/Analyzátor gramatiky/UMainForm.pas
r28 r29 6 6 7 7 uses 8 LCLIntf, Messages,SysUtils, Classes, Graphics, Controls, Forms,8 LCLIntf, SysUtils, Classes, Graphics, Controls, Forms, 9 9 Dialogs, StdCtrls, ComCtrls, LResources, UGrammer, UProgram; 10 10 11 11 const 12 DefaultGrammerFileName: string = ' grammer/test.grm';13 DefaultPascalFileName: string = ' pascal/test.pas';12 DefaultGrammerFileName: string = '../../grammer/test.grm'; 13 DefaultPascalFileName: string = '../../pascal/test.pas'; 14 14 15 15 type … … 32 32 private 33 33 procedure ShowProgramNode(Node: TTreeNode; SourceProgram: TProgramItem); 34 { Private declarations }35 34 public 36 35 Grammer: TGrammer; … … 50 49 MainForm: TMainForm; 51 50 51 52 52 implementation 53 54 53 55 54 procedure TMainForm.Button1Click(Sender: TObject); … … 88 87 begin 89 88 with SourceProgram.TopItem do begin 90 MergeNonterminal( TGrammerRule(Grammer.Rules[7]));91 MergeNonterminal( TGrammerRule(Grammer.Rules[9]));92 DeleteNonterminal( TGrammerRule(Grammer.Rules[0]));89 MergeNonterminal(Grammer.Rules[7]); 90 MergeNonterminal(Grammer.Rules[9]); 91 DeleteNonterminal(Grammer.Rules[0]); 93 92 DeleteEmpty; 94 Join( TGrammerRule(Grammer.Rules[17]), 1);95 Join( TGrammerRule(Grammer.Rules[15]), 0);96 Join( TGrammerRule(Grammer.Rules[14]), 0);93 Join(Grammer.Rules[17], 1); 94 Join(Grammer.Rules[15], 0); 95 Join(Grammer.Rules[14], 0); 97 96 end; 98 97 ShowProgramTree(SourceProgram); … … 109 108 C: Char; 110 109 I: Integer; 111 SourceCode: string;112 110 begin 113 111 PascalGrammer := TGrammer.Create; … … 118 116 with WhiteSpace do begin 119 117 Name := 'WhiteSpace'; 118 Token := True; 120 119 RuleType := rtAlternative; 121 120 AddTerminal(' ', False, False); … … 161 160 with Number do begin 162 161 Name := 'Number'; 162 Token := True; 163 163 RuleType := rtSequence; 164 164 AddTerminal('-', True, False); … … 180 180 with Identifier do begin 181 181 Name := 'Identifier'; 182 Token := True; 182 183 RuleType := rtSequence; 183 184 AddRule(AlphabeticCharacter, False, False); … … 198 199 with RuleString do begin 199 200 Name := 'String'; 201 Token := True; 200 202 RuleType := rtSequence; 201 203 AddTerminal('''', False, False); … … 344 346 Memo1.Lines.LoadFromFile(DefaultGrammerFileName); 345 347 Memo2.Lines.LoadFromFile(DefaultPascalFileName); 346 SourceCode := '';347 348 // with Memo1.Lines do 348 349 // for I := 1 to Length(Text) do begin … … 365 366 function TMainForm.ProcessConcatenationItem(ARule: TGrammerRule; ProgramItem: TProgramItem): TGrammerItem; 366 367 var 367 I: Integer;368 368 II: Integer; 369 369 NewRule: TGrammerRule; 370 NewSubRule: TGrammerRule;371 370 RuleItem: TGrammerItem; 372 type373 LowerChars = 'a'..'z';374 371 begin 375 372 with ProgramItem do begin … … 392 389 if Length(Value) > 3 then begin 393 390 NewRule := TGrammerRule.Create; 394 NewRule. Ownership:= ARule;391 NewRule.Parent := ARule; 395 392 NewRule.Name := 'Term'; 396 393 NewRule.AddTerminalText(Copy(Value, 2, Length(Value) - 2)); … … 404 401 end else begin 405 402 NewRule := TGrammerRule.Create; 406 NewRule. Ownership:= ARule;403 NewRule.PArent := ARule; 407 404 NewRule.Name := 'Term'; 408 405 NewRule.AddTerminalText(Value); … … 413 410 end else if TProgramItem(Items[II]).Rule.Name = 'GroupingBlock' then begin 414 411 NewRule := TGrammerRule.Create; 415 NewRule. Ownership:= ARule;412 NewRule.Parent := ARule; 416 413 NewRule.RuleType := rtSequence; 417 414 NewRule.Name := 'Group'; 418 ProcessSeparationItem(NewRule, TProgramItem(Items[II]).Items[1]);415 ProcessSeparationItem(NewRule, Items[II].Items[1]); 419 416 PascalGrammer.Rules.Add(NewRule); 420 417 RuleItem.ItemType := itNonterminal; … … 422 419 end else if TProgramItem(Items[II]).Rule.Name = 'OptionBlock' then begin 423 420 NewRule := TGrammerRule.Create; 424 NewRule. Ownership:= ARule;421 NewRule.Parent := ARule; 425 422 NewRule.RuleType := rtSequence; 426 423 NewRule.Name := 'Option'; 427 ProcessSeparationItem(NewRule, TProgramItem(Items[II]).Items[1]);424 ProcessSeparationItem(NewRule, Items[II].Items[1]); 428 425 PascalGrammer.Rules.Add(NewRule); 429 426 RuleItem.ItemType := itNonterminal; 430 427 RuleItem.Optional := True; 431 428 RuleItem.Rule := NewRule; 432 end else if TProgramItem(Items[II]).Rule.Name = 'RepetitionBlock' then begin429 end else if Items[II].Rule.Name = 'RepetitionBlock' then begin 433 430 NewRule := TGrammerRule.Create; 434 NewRule. Ownership:= ARule;431 NewRule.Parent := ARule; 435 432 NewRule.RuleType := rtSequence; 436 433 NewRule.Name := 'Repetition'; 437 ProcessSeparationItem(NewRule, TProgramItem(Items[II]).Items[1]);434 ProcessSeparationItem(NewRule, Items[II].Items[1]); 438 435 PascalGrammer.Rules.Add(NewRule); 439 436 RuleItem.Repetition := True; … … 456 453 begin 457 454 for I := 0 to PascalGrammer.Rules.Count - 1 do 458 TGrammerRule(PascalGrammer.Rules[I]).Free;455 PascalGrammer.Rules[I].Free; 459 456 PascalGrammer.Rules.Clear; 460 457 with PascalGrammer do begin … … 533 530 PascalGrammer.TopRule := nil; 534 531 with SourceProgram.TopItem do begin 535 with TProgramItem(Items[0])do begin536 for I := 0 to Items.Count - 1 do with TProgramItem(Items[I])do begin532 with Items[0] do begin 533 for I := 0 to Items.Count - 1 do with Items[I] do begin 537 534 NewRule := TGrammerRule.Create; 538 535 with PascalGrammer do 539 536 if TopRule = nil then TopRule := NewRule; 540 NewRule.Name := TProgramItem(Items[0]).Value;541 ProcessSeparationItem(NewRule, TProgramItem(Items[2]));537 NewRule.Name := Items[0].Value; 538 ProcessSeparationItem(NewRule, Items[2]); 542 539 PascalGrammer.Rules.Add(NewRule); 543 540 end; … … 558 555 for II := 0 to Items.Count - 1 do begin 559 556 NewSubRule := TGrammerRule.Create; 560 NewSubRule. Ownership:= ARule;557 NewSubRule.Parent := ARule; 561 558 NewSubRule.Name := ARule.Name; 562 559 RuleItem := ARule.Add; 563 560 RuleItem.ItemType := itNonterminal; 564 561 RuleItem.Rule := NewSubRule; 565 ProcessConcatenationItem(NewSubRule, TProgramItem(Items[II]));562 ProcessConcatenationItem(NewSubRule, Items[II]); 566 563 PascalGrammer.Rules.Add(NewSubRule); 567 564 end; 568 565 end else begin 569 ProcessConcatenationItem(ARule, TProgramItem(Items[0]));566 ProcessConcatenationItem(ARule, Items[0]); 570 567 end; 571 568 end; … … 585 582 NewTreeNode := AddChild(TreeNode, ARule.Name + Attributs); 586 583 for II := 0 to Items.Count - 1 do 587 with TGrammerItem(Items[II])do begin584 with Items[II] do begin 588 585 if Optional then Attributs := '(Opt)' else Attributs := ''; 589 586 if Repetition then Attributs := Attributs + '(Rep)'; … … 595 592 itNonterminal: begin 596 593 if Assigned(Rule) then begin 597 if Rule. Ownership= ARule then594 if Rule.Parent = ARule then 598 595 ShowGrammerRule(NewTreeNode, Rule, Attributs) 599 596 else AddChild(NewTreeNode, '<' + Rule.Name + '>' + Attributs); … … 614 611 TopItem := AddChild(nil, 'Gramatika'); 615 612 for I := 0 to Rules.Count - 1 do with TGrammerRule(Rules[I]) do 616 if Ownership = nilthen ShowGrammerRule(TopItem, TGrammerRule(Rules[I]));613 if not Assigned(Parent) then ShowGrammerRule(TopItem, TGrammerRule(Rules[I])); 617 614 TopItem.Expand(False); 618 615 EndUpdate; … … 651 648 initialization 652 649 {$i UMainForm.lrs} 653 {$i UMainForm.lrs}654 650 655 651 end. -
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.