Ignore:
Timestamp:
Dec 26, 2017, 6:59:40 PM (7 years ago)
Author:
chronos
Message:
  • Added: Support for whitespaces in And rule.
  • Added: Terminals can be specified as escaped strings with slash.
Location:
branches/generator/Forms
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/generator/Forms/UFormGrammer.lfm

    r129 r136  
    77  ClientHeight = 346
    88  ClientWidth = 548
    9   DesignTimePPI = 120
    109  OnShow = FormShow
    11   LCLVersion = '1.8.0.6'
     10  LCLVersion = '1.8.0.4'
    1211  object Label1: TLabel
    1312    Left = 15
    14     Height = 20
     13    Height = 23
    1514    Top = 22
    16     Width = 63
     15    Width = 75
    1716    Caption = 'Start rule:'
    1817    ParentColor = False
    1918  end
    2019  object ComboBoxStartRule: TComboBox
    21     Left = 120
    22     Height = 28
    23     Top = 24
     20    Left = 168
     21    Height = 37
     22    Top = 22
    2423    Width = 272
    25     ItemHeight = 20
     24    ItemHeight = 0
    2625    Style = csDropDownList
    2726    TabOrder = 0
     
    4746    TabOrder = 2
    4847  end
     48  object Label2: TLabel
     49    Left = 16
     50    Height = 23
     51    Top = 80
     52    Width = 130
     53    Caption = 'White space rule:'
     54    ParentColor = False
     55  end
     56  object ComboBoxWhiteSpaceRule: TComboBox
     57    Left = 168
     58    Height = 37
     59    Top = 72
     60    Width = 272
     61    ItemHeight = 0
     62    Style = csDropDownList
     63    TabOrder = 3
     64  end
    4965end
  • branches/generator/Forms/UFormGrammer.pas

    r129 r136  
    1717    ButtonOk: TButton;
    1818    ComboBoxStartRule: TComboBox;
     19    ComboBoxWhiteSpaceRule: TComboBox;
    1920    Label1: TLabel;
     21    Label2: TLabel;
    2022    procedure FormShow(Sender: TObject);
    2123  private
     
    4951  end;
    5052  ComboBoxStartRule.Sorted := True;
     53
     54  ComboBoxWhiteSpaceRule.Items.Clear;
     55  for Rule in Grammer.Rules do begin
     56    ComboBoxWhiteSpaceRule.Items.AddObject(Rule.Name, Rule);
     57  end;
     58  ComboBoxWhiteSpaceRule.Sorted := True;
    5159end;
    5260
     
    5866    ComboBoxStartRule.ItemIndex := ComboBoxStartRule.Items.IndexOfObject(Grammer.TopRule);
    5967  end else ComboBoxStartRule.ItemIndex := -1;
     68  if Assigned(Grammer.WhiteSpaceRule) then begin
     69    ComboBoxWhiteSpaceRule.ItemIndex := ComboBoxWhiteSpaceRule.Items.IndexOfObject(Grammer.WhiteSpaceRule);
     70  end else ComboBoxWhiteSpaceRule.ItemIndex := -1;
    6071end;
    6172
     
    6677    Grammer.TopRule := TRule(ComboBoxStartRule.Items.Objects[ComboBoxStartRule.ItemIndex])
    6778    else Grammer.TopRule := nil;
     79  if ComboBoxWhiteSpaceRule.ItemIndex <> -1 then
     80    Grammer.WhiteSpaceRule := TRule(ComboBoxWhiteSpaceRule.Items.Objects[ComboBoxWhiteSpaceRule.ItemIndex])
     81    else Grammer.WhiteSpaceRule := nil;
    6882end;
    6983
  • branches/generator/Forms/UFormMain.pas

    r131 r136  
    271271procedure TFormMain.AProjectOpenRecentExecute(Sender: TObject);
    272272begin
    273   if Sender is TMenuItem then ProjectOpen(TMenuItem(Sender).Caption);
     273  if Sender is TMenuItem then begin
     274    AProjectClose.Execute;
     275    if not Assigned(Core.Grammer) then begin
     276      ProjectOpen(TMenuItem(Sender).Caption);
     277    end;
     278  end;
    274279end;
    275280
  • branches/generator/Forms/UFormRuleItem.lfm

    r131 r136  
    161161  end
    162162  object CheckBoxRepetitive: TCheckBox
    163     Left = 216
     163    Left = 184
    164164    Height = 27
    165165    Top = 56
     
    169169  end
    170170  object CheckBoxAnyExcept: TCheckBox
    171     Left = 400
     171    Left = 344
    172172    Height = 27
    173173    Top = 56
     
    176176    TabOrder = 6
    177177  end
     178  object CheckBoxEscapedString: TCheckBox
     179    Left = 488
     180    Height = 27
     181    Top = 56
     182    Width = 144
     183    Caption = 'Escaped strings'
     184    TabOrder = 7
     185  end
    178186end
  • branches/generator/Forms/UFormRuleItem.pas

    r129 r136  
    1717    ButtonOk: TButton;
    1818    CheckBoxAnyExcept: TCheckBox;
     19    CheckBoxEscapedString: TCheckBox;
    1920    CheckBoxOptional: TCheckBox;
    2021    CheckBoxRepetitive: TCheckBox;
     
    123124  ListBox1.Visible := RuleItem.RuleItemType = ritNonTerminal;
    124125  LabelNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal;
     126  CheckBoxOptional.Enabled := RuleItem.ParentRule.Items.RuleType = rtAnd;
     127  CheckBoxRepetitive.Enabled := RuleItem.ParentRule.Items.RuleType = rtAnd;
     128  CheckBoxEscapedString.Enabled := (RuleItem.RuleItemType = ritTerminal) or
     129    (RuleItem.RuleItemType = ritTerminalRange);
    125130end;
    126131
     
    138143  CheckBoxAnyExcept.Checked := RuleItem.AnyExcept;
    139144  TFormRuleItems(FormRuleItems).LoadData(RuleItem.SubItems);
     145  CheckBoxEscapedString.Checked := RuleItem.EscapedStrings;
    140146  UpdateInterface;
    141147end;
     
    155161  RuleItem.Repetitive := CheckBoxRepetitive.Checked;
    156162  RuleItem.AnyExcept := CheckBoxAnyExcept.Checked;
     163  RuleItem.EscapedStrings := CheckBoxEscapedString.Checked;
    157164end;
    158165
  • branches/generator/Forms/UFormRuleItems.lfm

    r129 r136  
    77  ClientHeight = 467
    88  ClientWidth = 636
    9   DesignTimePPI = 120
    109  OnCreate = FormCreate
    1110  OnShow = FormShow
    12   LCLVersion = '1.8.0.6'
     11  LCLVersion = '1.8.0.4'
    1312  object ListView1: TListView
    1413    Left = 8
    15     Height = 392
    16     Top = 40
     14    Height = 384
     15    Top = 48
    1716    Width = 624
    1817    Anchors = [akTop, akLeft, akRight, akBottom]
     
    5049    end
    5150    object ToolButton2: TToolButton
    52       Left = 24
     51      Left = 30
    5352      Top = 2
    5453      Action = AModify
    5554    end
    5655    object ToolButton3: TToolButton
    57       Left = 47
     56      Left = 59
    5857      Top = 2
    5958      Action = ARemove
    6059    end
    6160    object ToolButton4: TToolButton
    62       Left = 70
     61      Left = 88
    6362      Top = 2
    6463      Action = AMoveUp
    6564    end
    6665    object ToolButton5: TToolButton
    67       Left = 93
     66      Left = 117
    6867      Top = 2
    6968      Action = AMoveDown
     
    7271  object Label1: TLabel
    7372    Left = 10
    74     Height = 20
     73    Height = 23
    7574    Top = 10
    76     Width = 63
     75    Width = 75
    7776    Caption = 'Operator:'
    7877    ParentColor = False
    7978  end
    80   object ComboBox1: TComboBox
     79  object ComboBoxOperator: TComboBox
    8180    Left = 153
    82     Height = 28
     81    Height = 33
    8382    Top = 9
    8483    Width = 231
    85     ItemHeight = 20
     84    ItemHeight = 0
    8685    Items.Strings = (
    8786      'And'
    8887      'Or'
    8988    )
     89    OnChange = ComboBoxOperatorChange
    9090    Style = csDropDownList
    9191    TabOrder = 2
     92  end
     93  object CheckBoxWhiteSpace: TCheckBox
     94    Left = 408
     95    Height = 27
     96    Top = 10
     97    Width = 161
     98    Caption = 'With white spaces'
     99    TabOrder = 3
    92100  end
    93101  object PopupMenu1: TPopupMenu
  • branches/generator/Forms/UFormRuleItems.pas

    r129 r136  
    2020    AMoveUp: TAction;
    2121    ARemove: TAction;
    22     ComboBox1: TComboBox;
     22    CheckBoxWhiteSpace: TCheckBox;
     23    ComboBoxOperator: TComboBox;
    2324    Label1: TLabel;
    2425    ListView1: TListView;
     
    4041    procedure AMoveUpExecute(Sender: TObject);
    4142    procedure ARemoveExecute(Sender: TObject);
     43    procedure ComboBoxOperatorChange(Sender: TObject);
    4244    procedure FormCreate(Sender: TObject);
    4345    procedure FormShow(Sender: TObject);
     
    8284  NewRuleItem := TRuleItem.Create;
    8385  NewRuleItem.Grammer := RuleItems.Grammer;
     86  NewRuleItem.ParentRule := RuleItems.ParentRule;
    8487  FormRuleItem := TFormRuleItem.Create(nil);
    8588  FormRuleItem.LoadData(NewRuleItem);
     
    141144end;
    142145
     146procedure TFormRuleItems.ComboBoxOperatorChange(Sender: TObject);
     147begin
     148  UpdateInterface;
     149end;
     150
    143151procedure TFormRuleItems.FormCreate(Sender: TObject);
    144152begin
     
    174182  AMoveUp.Enabled := Assigned(ListView1.Selected) and (ListView1.Selected.Index > 0);
    175183  AMoveDown.Enabled := Assigned(ListView1.Selected) and (ListView1.Selected.Index < (ListView1.Items.Count - 1));
     184  CheckBoxWhiteSpace.Enabled := ComboBoxOperator.ItemIndex = 0;
    176185end;
    177186
     
    186195begin
    187196  Self.RuleItems := RuleItems;
    188   ComboBox1.ItemIndex := Integer(RuleItems.RuleType);
     197  ComboBoxOperator.ItemIndex := Integer(RuleItems.RuleType);
     198  CheckBoxWhiteSpace.Checked := RuleItems.WithWhiteSpeaces;
    189199end;
    190200
    191201procedure TFormRuleItems.SaveData(RuleItems: TRuleItems);
    192202begin
    193   RuleItems.RuleType := TRuleType(ComboBox1.ItemIndex);
     203  RuleItems.RuleType := TRuleType(ComboBoxOperator.ItemIndex);
     204  RuleItems.WithWhiteSpeaces := CheckBoxWhiteSpace.Checked;
    194205end;
    195206
Note: See TracChangeset for help on using the changeset viewer.