Changeset 8 for UMainForm.pas
- Timestamp:
- Oct 15, 2007, 8:28:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
UMainForm.pas
r7 r8 9 9 const 10 10 DefaultGrammerFileName: string = 'grammer/test.grm'; 11 DefaultPascalFileName: string = 'pascal/test.pas'; 11 12 12 13 type … … 18 19 Label1: TLabel; 19 20 Button2: TButton; 21 Memo2: TMemo; 22 Button3: TButton; 20 23 procedure FormCreate(Sender: TObject); 21 24 procedure FormDestroy(Sender: TObject); 22 25 procedure Button1Click(Sender: TObject); 23 26 procedure Button2Click(Sender: TObject); 27 procedure Button3Click(Sender: TObject); 24 28 private 25 29 procedure ShowProgramNode(Node: TTreeNode; SourceProgram: TProgramItem); … … 29 33 PascalGrammer: TGrammer; 30 34 SourceProgram: TProgram; 35 PascalProgram: TProgram; 31 36 procedure ShowProgramTree(SourceProgram: TProgram); 32 37 procedure ShowGrammerTree(Grammer: TGrammer); … … 69 74 end; 70 75 76 procedure TMainForm.Button3Click(Sender: TObject); 77 begin 78 PascalProgram.Free; 79 PascalProgram := TProgram.Create; 80 PascalGrammer.Parse(Memo2.Text, PascalProgram); 81 with PascalProgram.TopItem, PascalGrammer do begin 82 // MergeNonterminal(TGrammerRule(Rules[7])); 83 // MergeNonterminal(TGrammerRule(Rules[9])); 84 // DeleteNonterminal(TGrammerRule(Rules[0])); 85 // DeleteEmpty; 86 // Join(TGrammerRule(Rules[17]), 1); 87 // Join(TGrammerRule(Rules[15]), 0); 88 // Join(TGrammerRule(Rules[14]), 0); 89 end; 90 ShowProgramTree(PascalProgram); 91 end; 92 71 93 procedure TMainForm.FormCreate(Sender: TObject); 72 94 var … … 311 333 SourceProgram := TProgram.Create; 312 334 Memo1.Lines.LoadFromFile(DefaultGrammerFileName); 335 Memo2.Lines.LoadFromFile(DefaultPascalFileName); 313 336 SourceCode := ''; 314 337 // with Memo1.Lines do … … 317 340 // end; 318 341 319 Grammer.Parse(Memo1.Text, SourceProgram);320 ShowProgramTree(SourceProgram);342 //Grammer.Parse(Memo1.Text, SourceProgram); 343 //ShowProgramTree(SourceProgram); 321 344 end; 322 345 … … 324 347 begin 325 348 Memo1.Lines.SaveToFile(DefaultGrammerFileName); 349 Memo2.Lines.SaveToFile(DefaultPascalFileName); 326 350 PascalGrammer.Free; 327 351 Grammer.Free; … … 386 410 PascalGrammer.Rules.Add(NewRule); 387 411 RuleItem.Repetition := True; 412 RuleItem.Optional := True; 388 413 RuleItem.ItemType := itNonterminal; 389 414 RuleItem.Rule := NewRule; … … 454 479 end; 455 480 NewTreeNode := AddChild(TreeNode, ARule.Name + Attributs); 456 for II := 0 to Length(Items)- 1 do457 with Items[II]do begin481 for II := 0 to Items.Count - 1 do 482 with TGrammerItem(Items[II]) do begin 458 483 if Optional then Attributs := '(Opt)' else Attributs := ''; 459 484 if Repetition then Attributs := Attributs + '(Rep)';
Note:
See TracChangeset
for help on using the changeset viewer.