Ignore:
Timestamp:
Aug 9, 2017, 12:09:47 AM (7 years ago)
Author:
chronos
Message:
  • Added: RuleItem can be selected as terminal or non-terminal node.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/generator/Forms/UFormRule.pas

    r110 r111  
    2020    ButtonOk: TButton;
    2121    ButtonCancel: TButton;
     22    ComboBox1: TComboBox;
    2223    EditName: TEdit;
    2324    Label1: TLabel;
     25    Label2: TLabel;
    2426    ListView: TListView;
    2527    MenuItem1: TMenuItem;
     
    3941    { private declarations }
    4042  public
    41     RuleItems: TRuleItems;
     43    Rule: TRule;
    4244    procedure UpdateInterface;
    4345    procedure ReloadList;
     
    6870procedure TFormRule.ListViewData(Sender: TObject; Item: TListItem);
    6971begin
    70   if (Item.Index >= 0) and (Item.Index < RuleItems.Count) then begin
    71     Item.Caption := RuleItems[Item.Index].Name;
    72     Item.Data := RuleItems[Item.Index];
     72  if (Item.Index >= 0) and (Item.Index < Rule.Items.Count) then begin
     73    Item.Caption := Rule.Items[Item.Index].GetBNF;
     74    Item.Data := Rule.Items[Item.Index];
    7375  end;
    7476end;
     
    9597begin
    9698  NewRuleItem := TRuleItem.Create;
     99  NewRuleItem.Grammer := Rule.Grammer;
    97100  FormRuleItem.LoadData(NewRuleItem);
    98101  if FormRuleItem.ShowModal = mrOk then begin
    99102    FormRuleItem.SaveData(NewRuleItem);
    100     RuleItems.Add(NewRuleItem);
     103    NewRuleItem.ParentRule := Rule;
     104    Rule.Items.Add(NewRuleItem);
    101105    ReloadList;
    102106  end else FreeAndNil(NewRuleItem);
     
    121125  for Item in ListView.Items do
    122126  if Item.Selected then
    123     RuleItems.Remove(TRuleItem(Item.Data));
     127    Rule.Items.Remove(TRuleItem(Item.Data));
    124128  ReloadList;
    125129end;
     
    133137procedure TFormRule.ReloadList;
    134138begin
    135   ListView.Items.Count := RuleItems.Count;
     139  ListView.Items.Count := Rule.Items.Count;
    136140  ListView.Refresh;
    137141end;
     
    139143procedure TFormRule.LoadData(Rule: TRule);
    140144begin
     145  Self.Rule := Rule;
     146  ComboBox1.ItemIndex := Integer(Rule.RuleType);
    141147  EditName.Text := Rule.Name;
    142   RuleItems := Rule.Items;
     148  Rule.Items := Rule.Items;
    143149end;
    144150
    145151procedure TFormRule.SaveData(Rule: TRule);
    146152begin
     153  Rule.RuleType := TRuleType(ComboBox1.ItemIndex);
    147154  Rule.Name := EditName.Text;
    148155end;
Note: See TracChangeset for help on using the changeset viewer.