Ignore:
Timestamp:
Nov 27, 2017, 1:09:38 PM (7 years ago)
Author:
chronos
Message:
  • Added: Rule can be set as optional or repetitive.
  • Added: Support for nested rule item sublist.
Location:
branches/generator
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/generator

    • Property svn:ignore
      •  

        old new  
        22generator.lps
        33lib
         4heaptrclog.trc
  • branches/generator/Forms/UFormRuleItem.pas

    r111 r117  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   URules;
     9  ComCtrls, URules;
    1010
    1111type
     
    1616    ButtonCancel: TButton;
    1717    ButtonOk: TButton;
     18    CheckBoxOptional: TCheckBox;
     19    CheckBoxRepetitive: TCheckBox;
     20    ComboBoxNonTerminal: TComboBox;
    1821    ComboBoxType: TComboBox;
    19     ComboBoxNonTerminal: TComboBox;
    2022    EditName: TEdit;
    21     LabelTerminal: TLabel;
    2223    Label2: TLabel;
    2324    LabelNonTerminal: TLabel;
     25    LabelTerminal: TLabel;
     26    PageControl1: TPageControl;
     27    TabSheetTerminal: TTabSheet;
     28    TabSheetNonTerminal: TTabSheet;
     29    TabSheetSubItems: TTabSheet;
    2430    procedure ComboBoxTypeChange(Sender: TObject);
     31    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     32    procedure FormCreate(Sender: TObject);
     33    procedure FormDestroy(Sender: TObject);
     34    procedure FormShow(Sender: TObject);
    2535  private
     36    FormRuleItems: TForm;
    2637    procedure ReloadNonTerminals(Grammer: TGrammer);
    2738  public
     
    3546  FormRuleItem: TFormRuleItem;
    3647
     48
    3749implementation
     50
     51uses
     52  UCore, UFormRuleItems;
    3853
    3954{$R *.lfm}
     
    4560  RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex);
    4661  UpdateInterface;
     62end;
     63
     64procedure TFormRuleItem.FormClose(Sender: TObject; var CloseAction: TCloseAction
     65  );
     66begin
     67  Core.PersistentForm1.Save(Self);
     68end;
     69
     70procedure TFormRuleItem.FormCreate(Sender: TObject);
     71begin
     72  FormRuleItems := TFormRuleItems.Create(nil);
     73  FormRuleItems.ManualDock(TabSheetSubItems);
     74  FormRuleItems.Align := alClient;
     75  FormRuleItems.Show;
     76end;
     77
     78procedure TFormRuleItem.FormDestroy(Sender: TObject);
     79begin
     80  FreeAndNil(FormRuleItems);
     81end;
     82
     83procedure TFormRuleItem.FormShow(Sender: TObject);
     84begin
     85  Core.PersistentForm1.Load(Self);
    4786end;
    4887
     
    5998procedure TFormRuleItem.UpdateInterface;
    6099begin
     100  PageControl1.PageIndex := Integer(RuleItem.RuleItemType);
    61101  EditName.Visible := RuleItem.RuleItemType = ritTerminal;
    62102  LabelTerminal.Visible := RuleItem.RuleItemType = ritTerminal;
     
    72112  ComboBoxNonTerminal.ItemIndex := ComboBoxNonTerminal.Items.IndexOfObject(RuleItem.NonTerminal);
    73113  EditName.Text := RuleItem.Terminal;
     114  CheckBoxOptional.Checked := RuleItem.Optional;
     115  CheckBoxRepetitive.Checked := RuleItem.Repetitive;
     116  TFormRuleItems(FormRuleItems).LoadData(RuleItem.SubItems);
    74117  UpdateInterface;
    75118end;
     
    77120procedure TFormRuleItem.SaveData(RuleItem: TRuleItem);
    78121begin
     122  TFormRuleItems(FormRuleItems).SaveData(RuleItem.SubItems);
    79123  RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex);
    80124  if RuleItem.RuleItemType = ritTerminal then RuleItem.Terminal := EditName.Text
    81125  else if RuleItem.RuleItemType = ritNonTerminal then
    82126    RuleItem.NonTerminal := TRule(ComboBoxNonTerminal.Items.Objects[ComboBoxNonTerminal.ItemIndex]);
     127  RuleItem.Optional := CheckBoxOptional.Checked;
     128  RuleItem.Repetitive := CheckBoxRepetitive.Checked;
    83129end;
    84130
Note: See TracChangeset for help on using the changeset viewer.