Changeset 131


Ignore:
Timestamp:
Dec 24, 2017, 3:54:08 PM (7 years ago)
Author:
chronos
Message:
  • Added: Open recent files menu action.
  • Added: Generate BNF and EBNF output separately.
  • Added: Allow to hide main toolbar.
Location:
branches/generator
Files:
2 added
11 edited

Legend:

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

    r130 r131  
    2929      Height = 28
    3030      Top = 5
    31       Width = 125
     31      Width = 171
    3232      Align = alNone
    3333      AutoSize = True
     
    4242      Transparent = True
    4343      object ToolButton2: TToolButton
    44         Left = 96
     44        Left = 142
    4545        Top = 0
    4646        Action = ABuildCompiler
     
    5555        Top = 0
    5656        Action = AProjectOpen
     57        DropdownMenu = PopupMenuOpenRecent
     58        Style = tbsButtonDrop
    5759      end
    5860      object ToolButton5: TToolButton
    59         Left = 59
     61        Left = 76
    6062        Top = 0
    6163        Action = AProjectSave
    6264      end
    6365      object ToolButton6: TToolButton
    64         Left = 88
     66        Left = 134
    6567        Height = 28
    6668        Top = 0
    6769        Style = tbsSeparator
     70      end
     71      object ToolButton1: TToolButton
     72        Left = 105
     73        Top = 0
     74        Action = AGrammerSettings
    6875      end
    6976    end
     
    124131        Action = AProjectOpen
    125132      end
     133      object MenuItemRecent: TMenuItem
     134        Caption = 'Open recent'
     135      end
    126136      object MenuItem10: TMenuItem
    127137        Action = AProjectSave
     
    151161    object MenuItem1: TMenuItem
    152162      Caption = 'View'
     163      object MenuItemToolbar: TMenuItem
     164        Action = AToolbarVisible
     165        AutoCheck = True
     166      end
    153167    end
    154168  end
     
    175189      OnExecute = AProjectOpenExecute
    176190    end
     191    object AProjectOpenRecent: TAction
     192      Caption = 'Open recent'
     193      OnExecute = AProjectOpenRecentExecute
     194    end
    177195    object AProjectSaveAs: TAction
    178196      Caption = 'Save as...'
     
    181199      OnExecute = AProjectSaveAsExecute
    182200    end
     201    object AProjectSave: TAction
     202      Caption = 'Save'
     203      ImageIndex = 5
     204      OnExecute = AProjectSaveExecute
     205    end
     206    object AProjectNew: TAction
     207      Caption = 'New'
     208      ImageIndex = 10
     209      OnExecute = AProjectNewExecute
     210    end
     211    object AProjectClose: TAction
     212      Caption = 'Close'
     213      OnExecute = AProjectCloseExecute
     214    end
     215    object AGrammerSettings: TAction
     216      Caption = 'Settings'
     217      ImageIndex = 3
     218      OnExecute = AGrammerSettingsExecute
     219    end
    183220    object ABuildCompiler: TAction
    184221      Caption = 'Build compiler'
     
    186223      OnExecute = ABuildCompilerExecute
    187224    end
    188     object AProjectSave: TAction
    189       Caption = 'Save'
    190       ImageIndex = 5
    191       OnExecute = AProjectSaveExecute
    192     end
    193     object AProjectNew: TAction
    194       Caption = 'New'
    195       ImageIndex = 10
    196       OnExecute = AProjectNewExecute
    197     end
    198     object AGrammerSettings: TAction
    199       Caption = 'Settings'
    200       OnExecute = AGrammerSettingsExecute
    201     end
    202     object AProjectClose: TAction
    203       Caption = 'Close'
    204       OnExecute = AProjectCloseExecute
     225    object AToolbarVisible: TAction
     226      AutoCheck = True
     227      Caption = 'Toolbar'
     228      OnExecute = AToolbarVisibleExecute
    205229    end
    206230  end
     
    217241    top = 414
    218242  end
     243  object LastOpenedList1: TLastOpenedList
     244    MaxCount = 10
     245    OnChange = LastOpenedList1Change
     246    left = 155
     247    top = 131
     248  end
     249  object PopupMenuOpenRecent: TPopupMenu
     250    left = 149
     251    top = 234
     252  end
    219253end
  • branches/generator/Forms/UFormMain.pas

    r130 r131  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Menus, ActnList, ComCtrls, UPersistentForm, UGrammer;
     9  Menus, ActnList, ComCtrls, UPersistentForm, ULastOpenedList, UGrammer,
     10  XMLConf;
    1011
    1112type
     
    1516  TFormMain = class(TForm)
    1617    ABuildCompiler: TAction;
     18    AToolbarVisible: TAction;
     19    AProjectOpenRecent: TAction;
    1720    AProjectClose: TAction;
    1821    AGrammerSettings: TAction;
     
    2528    ActionList1: TActionList;
    2629    CoolBar1: TCoolBar;
     30    LastOpenedList1: TLastOpenedList;
    2731    MainMenu1: TMainMenu;
    2832    MemoEbnf: TMemo;
     
    3438    MenuItem13: TMenuItem;
    3539    MenuItem2: TMenuItem;
     40    MenuItemRecent: TMenuItem;
     41    MenuItemToolbar: TMenuItem;
    3642    MenuItem4: TMenuItem;
    3743    MenuItem5: TMenuItem;
     
    4248    OpenDialog1: TOpenDialog;
    4349    PageControl1: TPageControl;
     50    PopupMenuOpenRecent: TPopupMenu;
    4451    SaveDialog1: TSaveDialog;
    4552    TabSheetRules: TTabSheet;
     
    4754    TabSheetEbnf: TTabSheet;
    4855    ToolBar1: TToolBar;
     56    ToolButton1: TToolButton;
    4957    ToolButton2: TToolButton;
    5058    ToolButton3: TToolButton;
     
    5361    ToolButton6: TToolButton;
    5462    procedure ABuildCompilerExecute(Sender: TObject);
     63    procedure AToolbarVisibleExecute(Sender: TObject);
    5564    procedure AExitExecute(Sender: TObject);
    5665    procedure AGrammerSettingsExecute(Sender: TObject);
     
    5867    procedure AProjectNewExecute(Sender: TObject);
    5968    procedure AProjectOpenExecute(Sender: TObject);
     69    procedure AProjectOpenRecentExecute(Sender: TObject);
    6070    procedure AProjectCloseExecute(Sender: TObject);
    6171    procedure AProjectSaveAsExecute(Sender: TObject);
     
    6474    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
    6575    procedure FormShow(Sender: TObject);
     76    procedure LastOpenedList1Change(Sender: TObject);
    6677  private
    67     procedure ReloadMemo;
    68     procedure UpdateInterface;
    6978    procedure GrammerChange(Sender: TObject);
    7079    procedure GrammerDestroy(Sender: TObject);
    7180  public
    72     { public declarations }
     81    procedure ReloadMemo;
     82    procedure UpdateInterface;
     83    procedure ProjectOpen(FileName: string);
     84    procedure ProjectNew;
     85    procedure LoadConfig(XmlConfig: TXmlConfig);
     86    procedure SaveConfig(XmlConfig: TXmlConfig);
    7387  end;
    7488
     
    108122  SaveDialog1.FileName := ExtractFileName(Core.Grammer.FileName);
    109123  if SaveDialog1.Execute then begin
    110     Core.LastOpenedFile := SaveDialog1.FileName;
     124    LastOpenedList1.AddItem(SaveDialog1.FileName);
    111125    Core.Grammer.SaveToXmlFile(SaveDialog1.FileName);
    112126    UpdateInterface;
     
    123137begin
    124138  Core.PersistentForm1.Save(Self);
     139  Core.Finalize;
    125140end;
    126141
     
    145160end;
    146161
     162procedure TFormMain.LastOpenedList1Change(Sender: TObject);
     163begin
     164  LastOpenedList1.LoadToMenuItem(MenuItemRecent, AProjectOpenRecentExecute);
     165  LastOpenedList1.LoadToMenuItem(PopupMenuOpenRecent.Items, AProjectOpenRecentExecute);
     166end;
     167
    147168procedure TFormMain.ReloadMemo;
    148169begin
    149170  if Assigned(Core.Grammer) then begin
    150     MemoBnf.Lines.Text := Core.Grammer.GetString;
    151     MemoEbnf.Lines.Text := Core.Grammer.GetString;
     171    MemoBnf.Lines.Text := Core.Grammer.ExportAsString(gnBnf);
     172    MemoEbnf.Lines.Text := Core.Grammer.ExportAsString(gnEbnf);
    152173  end else begin
    153174    MemoBnf.Lines.Clear;
     
    172193  ABuildCompiler.Enabled := Assigned(Core.Grammer);
    173194  ARules.Enabled := Assigned(Core.Grammer);
     195  CoolBar1.Visible := AToolbarVisible.Checked;
    174196end;
    175197
     
    194216    FormRules.UpdateInterface;
    195217  end;
     218end;
     219
     220procedure TFormMain.ProjectOpen(FileName: string);
     221begin
     222  if Assigned(Core.Grammer) then FreeAndNil(Core.Grammer);
     223  LastOpenedList1.AddItem(FileName);
     224  Core.Grammer := TGrammer.Create;
     225  Core.Grammer.OnChange := GrammerChange;
     226  Core.Grammer.OnDestroy := GrammerDestroy;
     227  Core.Grammer.LoadFromXmlFile(FileName);
     228  Core.Grammer.Change;
     229end;
     230
     231procedure TFormMain.ProjectNew;
     232begin
     233  if Assigned(Core.Grammer) then FreeAndNil(Core.Grammer);
     234  Core.Grammer := TGrammer.Create;
     235  Core.Grammer.OnChange := GrammerChange;
     236  Core.Grammer.OnDestroy := GrammerDestroy;
     237  Core.Grammer.FileName := SNewGrammer;
     238  Core.Grammer.Change;
     239end;
     240
     241procedure TFormMain.LoadConfig(XmlConfig: TXmlConfig);
     242begin
     243  AToolbarVisible.Checked := XmlConfig.GetValue('ToolbarVisible', True);
     244  LastOpenedList1.LoadFromXMLConfig(XMLConfig, 'LastOpenedFiles');
     245end;
     246
     247procedure TFormMain.SaveConfig(XmlConfig: TXmlConfig);
     248begin
     249  XmlConfig.SetValue('ToolbarVisible', AToolbarVisible.Checked);
     250  LastOpenedList1.SaveToXMLConfig(XMLConfig, 'LastOpenedFiles');
    196251end;
    197252
     
    214269end;
    215270
     271procedure TFormMain.AProjectOpenRecentExecute(Sender: TObject);
     272begin
     273  if Sender is TMenuItem then ProjectOpen(TMenuItem(Sender).Caption);
     274end;
     275
    216276procedure TFormMain.AProjectNewExecute(Sender: TObject);
    217277begin
    218278  AProjectClose.Execute;
    219279  if not Assigned(Core.Grammer) then begin
    220     Core.Grammer := TGrammer.Create;
    221     Core.Grammer.FileName := SNewGrammer;
    222     Core.Grammer.OnChange := GrammerChange;
    223     Core.Grammer.OnDestroy := GrammerDestroy;
    224     Core.Grammer.Change;
     280    ProjectNew;
    225281  end;
    226282end;
     
    239295end;
    240296
     297procedure TFormMain.AToolbarVisibleExecute(Sender: TObject);
     298begin
     299  UpdateInterface;
     300end;
     301
    241302procedure TFormMain.AProjectOpenExecute(Sender: TObject);
    242303begin
    243304  AProjectClose.Execute;
    244305  if not Assigned(Core.Grammer) then begin
    245     OpenDialog1.InitialDir := ExtractFileDir(Core.LastOpenedFile);
    246     OpenDialog1.FileName := ExtractFileName(Core.LastOpenedFile);
     306    OpenDialog1.InitialDir := ExtractFileDir(LastOpenedList1.GetFirstFileName);
     307    OpenDialog1.FileName := ExtractFileName(LastOpenedList1.GetFirstFileName);
    247308    if OpenDialog1.Execute then begin
    248       Core.LastOpenedFile := OpenDialog1.FileName;
    249       Core.Grammer := TGrammer.Create;
    250       Core.Grammer.OnChange := GrammerChange;
    251       Core.Grammer.OnDestroy := GrammerDestroy;
    252       Core.Grammer.LoadFromXmlFile(OpenDialog1.FileName);
    253       Core.Grammer.Change;
     309      ProjectOpen(OpenDialog1.FileName);
    254310    end;
    255311  end;
  • branches/generator/Forms/UFormRule.lfm

    r129 r131  
    88  ClientHeight = 514
    99  ClientWidth = 663
    10   DesignTimePPI = 120
    1110  OnCreate = FormCreate
    1211  OnDestroy = FormDestroy
    1312  OnShow = FormShow
    14   LCLVersion = '1.8.0.6'
     13  LCLVersion = '1.8.0.4'
    1514  object ButtonOk: TButton
    1615    Left = 376
     
    3534  object Label1: TLabel
    3635    Left = 16
    37     Height = 20
     36    Height = 23
    3837    Top = 16
    39     Width = 43
     38    Width = 49
    4039    Caption = 'Name:'
    4140    ParentColor = False
     
    5857    object TabSheetUsedBy: TTabSheet
    5958      Caption = 'Used by'
    60       ClientHeight = 359
    61       ClientWidth = 632
     59      ClientHeight = 351
     60      ClientWidth = 634
    6261      object ListView1: TListView
    6362        Left = 0
     
    6968          item
    7069            Caption = 'Name'
    71             Width = 200
     70            Width = 612
    7271          end>
    7372        OwnerData = True
     
    8281  object EditName: TEdit
    8382    Left = 135
    84     Height = 28
     83    Height = 33
    8584    Top = 11
    8685    Width = 433
     
    8988  object CheckBoxCreateNode: TCheckBox
    9089    Left = 16
    91     Height = 24
     90    Height = 27
    9291    Top = 48
    93     Width = 152
     92    Width = 173
    9493    Caption = 'Create source node'
    9594    TabOrder = 4
     
    9796  object Label2: TLabel
    9897    Left = 312
    99     Height = 20
     98    Height = 23
    10099    Top = 52
    101     Width = 37
    102     Caption = 'Lavel:'
     100    Width = 42
     101    Caption = 'Level:'
    103102    ParentColor = False
    104103  end
    105104  object ComboBoxLevel: TComboBox
    106105    Left = 376
    107     Height = 28
     106    Height = 37
    108107    Top = 48
    109108    Width = 125
    110     ItemHeight = 20
     109    ItemHeight = 0
    111110    Style = csDropDownList
    112111    TabOrder = 5
  • branches/generator/Forms/UFormRuleItem.lfm

    r129 r131  
    77  ClientHeight = 400
    88  ClientWidth = 656
    9   DesignTimePPI = 120
    109  OnClose = FormClose
    1110  OnCreate = FormCreate
    1211  OnDestroy = FormDestroy
    1312  OnShow = FormShow
    14   LCLVersion = '1.8.0.6'
     13  LCLVersion = '1.8.0.4'
    1514  object ButtonCancel: TButton
    1615    Left = 176
     
    3534  object ComboBoxType: TComboBox
    3635    Left = 160
    37     Height = 28
     36    Height = 33
    3837    Top = 16
    3938    Width = 400
    40     ItemHeight = 20
     39    ItemHeight = 0
    4140    Items.Strings = (
    4241      'Terminal'
     
    5150  object Label2: TLabel
    5251    Left = 16
    53     Height = 20
     52    Height = 23
    5453    Top = 24
    55     Width = 35
     54    Width = 40
    5655    Caption = 'Type:'
    5756    ParentColor = False
     
    6261    Top = 88
    6362    Width = 632
    64     ActivePage = TabSheetTerminal
     63    ActivePage = TabSheetTerminalRange
    6564    Anchors = [akTop, akLeft, akRight, akBottom]
    6665    ShowTabs = False
    67     TabIndex = 0
     66    TabIndex = 3
    6867    TabOrder = 3
    6968    object TabSheetTerminal: TTabSheet
    7069      Caption = 'Terminal'
    71       ClientHeight = 258
    72       ClientWidth = 624
     70      ClientHeight = 260
     71      ClientWidth = 626
    7372      object EditTerminal: TEdit
    7473        Left = 152
    75         Height = 28
     74        Height = 33
    7675        Top = 16
    7776        Width = 400
     
    8180      object LabelTerminal: TLabel
    8281        Left = 8
    83         Height = 20
     82        Height = 23
    8483        Top = 16
    85         Width = 61
     84        Width = 70
    8685        Caption = 'Terminal:'
    8786        ParentColor = False
     
    9089    object TabSheetNonTerminal: TTabSheet
    9190      Caption = 'NonTerminal'
    92       ClientHeight = 258
    93       ClientWidth = 624
     91      ClientHeight = 260
     92      ClientWidth = 626
    9493      object LabelNonTerminal: TLabel
    9594        Left = 8
     
    107106        Anchors = [akTop, akLeft, akRight, akBottom]
    108107        ItemHeight = 0
     108        ScrollWidth = 482
    109109        TabOrder = 0
     110        TopIndex = -1
    110111      end
    111112    end
     
    114115    end
    115116    object TabSheetTerminalRange: TTabSheet
    116       Caption = 'TabSheetTerminalRange'
    117       ClientHeight = 258
    118       ClientWidth = 624
     117      Caption = 'Terminal range'
     118      ClientHeight = 260
     119      ClientWidth = 626
    119120      object LabelTerminal1: TLabel
    120121        Left = 8
    121         Height = 20
     122        Height = 23
    122123        Top = 16
    123         Width = 97
     124        Width = 112
    124125        Caption = 'Terminal from:'
    125126        ParentColor = False
     
    127128      object EditTerminalFrom: TEdit
    128129        Left = 152
    129         Height = 28
     130        Height = 33
    130131        Top = 16
    131132        Width = 400
     
    135136      object LabelTerminal2: TLabel
    136137        Left = 8
    137         Height = 20
     138        Height = 23
    138139        Top = 56
    139         Width = 79
     140        Width = 90
    140141        Caption = 'Terminal to:'
    141142        ParentColor = False
     
    143144      object EditTerminalTo: TEdit
    144145        Left = 152
    145         Height = 28
     146        Height = 33
    146147        Top = 56
    147148        Width = 400
     
    153154  object CheckBoxOptional: TCheckBox
    154155    Left = 16
    155     Height = 24
     156    Height = 27
    156157    Top = 56
    157     Width = 82
     158    Width = 90
    158159    Caption = 'Optional'
    159160    TabOrder = 4
     
    161162  object CheckBoxRepetitive: TCheckBox
    162163    Left = 216
    163     Height = 24
     164    Height = 27
    164165    Top = 56
    165     Width = 91
     166    Width = 99
    166167    Caption = 'Repetitive'
    167168    TabOrder = 5
     
    169170  object CheckBoxAnyExcept: TCheckBox
    170171    Left = 400
    171     Height = 24
     172    Height = 27
    172173    Top = 56
    173     Width = 97
     174    Width = 106
    174175    Caption = 'Any except'
    175176    TabOrder = 6
  • branches/generator/Languages

    • Property svn:ignore set to
      *.mo
  • branches/generator/Languages/generator.cs.po

    r130 r131  
    1010"Content-Transfer-Encoding: 8bit\n"
    1111"Language: cs\n"
    12 "X-Generator: Poedit 1.8.8\n"
     12"X-Generator: Poedit 2.0.4\n"
    1313
    1414#: tformgrammer.buttoncancel.caption
    1515msgctxt "tformgrammer.buttoncancel.caption"
    1616msgid "Cancel"
    17 msgstr ""
     17msgstr "ZruÅ¡it"
    1818
    1919#: tformgrammer.buttonok.caption
    2020msgid "OK"
    21 msgstr ""
     21msgstr "OK"
    2222
    2323#: tformgrammer.caption
    2424msgid "Grammer settings"
    25 msgstr ""
     25msgstr "Nastavení gramatiky"
    2626
    2727#: tformgrammer.label1.caption
    2828msgid "Start rule:"
    29 msgstr ""
     29msgstr "Počáteční pravidlo:"
    3030
    3131#: tformmain.abuildcompiler.caption
     
    6565msgstr "Otevřít..."
    6666
     67#: tformmain.aprojectopenrecent.caption
     68msgctxt "tformmain.aprojectopenrecent.caption"
     69msgid "Open recent"
     70msgstr "Otevřít nedávnÃœ"
     71
    6772#: tformmain.aprojectsave.caption
    6873msgid "Save"
     
    8994msgstr "Pravidla"
    9095
     96#: tformmain.atoolbarvisible.caption
     97msgctxt "tformmain.atoolbarvisible.caption"
     98msgid "Toolbar"
     99msgstr "NástrojovÃœ panel"
     100
    91101#: tformmain.caption
    92102msgid "Language generator"
     
    105115msgstr "Nástroje"
    106116
     117#: tformmain.menuitemrecent.caption
     118msgctxt "tformmain.menuitemrecent.caption"
     119msgid "Open recent"
     120msgstr "Otevřít nedávnÃœ"
     121
    107122#: tformmain.tabsheetbnf.caption
    108123msgid "BNF"
    109 msgstr ""
     124msgstr "BNF"
    110125
    111126#: tformmain.tabsheetebnf.caption
    112127msgid "EBNF"
    113 msgstr ""
     128msgstr "EBNF"
    114129
    115130#: tformmain.tabsheetrules.caption
    116 #, fuzzy
    117131msgctxt "tformmain.tabsheetrules.caption"
    118132msgid "Rules"
     
    122136msgctxt "tformrule.buttoncancel.caption"
    123137msgid "Cancel"
    124 msgstr ""
     138msgstr "ZruÅ¡it"
    125139
    126140#: tformrule.buttonok.caption
    127141msgctxt "tformrule.buttonok.caption"
    128142msgid "Ok"
    129 msgstr ""
     143msgstr "Ok"
    130144
    131145#: tformrule.caption
    132146msgid "Rule"
    133 msgstr ""
     147msgstr "Pravidlo"
    134148
    135149#: tformrule.checkboxcreatenode.caption
    136150msgid "Create source node"
    137 msgstr ""
     151msgstr "Vytvářet zdrojovÃœ uzel"
    138152
    139153#: tformrule.label1.caption
    140154msgid "Name:"
    141 msgstr ""
     155msgstr "Jméno:"
    142156
    143157#: tformrule.label2.caption
    144 msgid "Lavel:"
    145 msgstr ""
     158msgid "Level:"
     159msgstr "Úroveň:"
    146160
    147161#: tformrule.listview1.columns[0].caption
    148 #, fuzzy
    149162msgctxt "tformrule.listview1.columns[0].caption"
    150163msgid "Name"
     
    152165
    153166#: tformrule.tabsheet1.caption
    154 #, fuzzy
    155167msgctxt "tformrule.tabsheet1.caption"
    156168msgid "Items"
     
    159171#: tformrule.tabsheet2.caption
    160172msgid "Links"
    161 msgstr ""
     173msgstr "Vazby"
    162174
    163175#: tformrule.tabsheetusedby.caption
    164176msgid "Used by"
    165 msgstr ""
     177msgstr "PouÅŸita čím"
    166178
    167179#: tformruleitem.buttoncancel.caption
    168180msgctxt "tformruleitem.buttoncancel.caption"
    169181msgid "Cancel"
    170 msgstr ""
     182msgstr "ZruÅ¡it"
    171183
    172184#: tformruleitem.buttonok.caption
    173185msgctxt "tformruleitem.buttonok.caption"
    174186msgid "Ok"
    175 msgstr ""
     187msgstr "Ok"
    176188
    177189#: tformruleitem.caption
    178190msgid "Rule item"
    179 msgstr ""
     191msgstr "PoloÅŸka pravidla"
    180192
    181193#: tformruleitem.checkboxanyexcept.caption
    182194msgid "Any except"
    183 msgstr ""
     195msgstr "VÅ¡e kromě"
    184196
    185197#: tformruleitem.checkboxoptional.caption
    186198msgid "Optional"
    187 msgstr ""
     199msgstr "VolitelnÃœ"
    188200
    189201#: tformruleitem.checkboxrepetitive.caption
    190202msgid "Repetitive"
    191 msgstr ""
     203msgstr "OpakovanÃœ"
    192204
    193205#: tformruleitem.label2.caption
    194206msgid "Type:"
    195 msgstr ""
     207msgstr "Typ:"
    196208
    197209#: tformruleitem.labelnonterminal.caption
    198210msgid "Non-terminal:"
    199 msgstr ""
     211msgstr "NekoncovÃœ:"
    200212
    201213#: tformruleitem.labelterminal.caption
    202214msgid "Terminal:"
    203 msgstr ""
     215msgstr "KoncovÃœ:"
    204216
    205217#: tformruleitem.labelterminal1.caption
    206218msgid "Terminal from:"
    207 msgstr ""
     219msgstr "KoncovÃœ od:"
    208220
    209221#: tformruleitem.labelterminal2.caption
    210222msgid "Terminal to:"
    211 msgstr ""
     223msgstr "KoncovÃœ do:"
    212224
    213225#: tformruleitem.tabsheetnonterminal.caption
    214226msgid "NonTerminal"
    215 msgstr ""
     227msgstr "NekoncovÃœ"
    216228
    217229#: tformruleitem.tabsheetsubitems.caption
    218230msgid "SubItems"
    219 msgstr ""
     231msgstr "PodpoloÅŸky"
    220232
    221233#: tformruleitem.tabsheetterminal.caption
    222234msgid "Terminal"
    223 msgstr ""
     235msgstr "KoncovÃœ"
    224236
    225237#: tformruleitem.tabsheetterminalrange.caption
    226 msgid "TabSheetTerminalRange"
    227 msgstr ""
     238msgid "Terminal range"
     239msgstr "NekoncovÃœ rozsah"
    228240
    229241#: tformruleitems.aadd.caption
     
    318330#: tformrules.listview1.columns[4].caption
    319331msgid "Level"
    320 msgstr ""
     332msgstr "Úroveň"
    321333
    322334#: uformmain.sdoyouwanttosaveproject
     
    331343msgid "Unsaved changes"
    332344msgstr "NeuloÅŸené změny"
    333 
  • branches/generator/Languages/generator.po

    r130 r131  
    5555msgstr ""
    5656
     57#: tformmain.aprojectopenrecent.caption
     58msgctxt "tformmain.aprojectopenrecent.caption"
     59msgid "Open recent"
     60msgstr ""
     61
    5762#: tformmain.aprojectsave.caption
    5863msgid "Save"
     
    7984msgstr ""
    8085
     86#: tformmain.atoolbarvisible.caption
     87msgctxt "tformmain.atoolbarvisible.caption"
     88msgid "Toolbar"
     89msgstr ""
     90
    8191#: tformmain.caption
    8292msgid "Language generator"
     
    93103#: tformmain.menuitem8.caption
    94104msgid "Tools"
     105msgstr ""
     106
     107#: tformmain.menuitemrecent.caption
     108msgctxt "tformmain.menuitemrecent.caption"
     109msgid "Open recent"
    95110msgstr ""
    96111
     
    131146
    132147#: tformrule.label2.caption
    133 msgid "Lavel:"
     148msgid "Level:"
    134149msgstr ""
    135150
     
    211226
    212227#: tformruleitem.tabsheetterminalrange.caption
    213 msgid "TabSheetTerminalRange"
     228msgid "Terminal range"
    214229msgstr ""
    215230
  • branches/generator/Packages/Common/ULastOpenedList.pas

    r114 r131  
    66
    77uses
    8   Classes, SysUtils, Registry, URegistry, Menus, XMLConf;
     8  Classes, SysUtils, Registry, URegistry, Menus, XMLConf, DOM;
    99
    1010type
     
    3030    procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string);
    3131    procedure AddItem(FileName: string);
     32    function GetFirstFileName: string;
    3233  published
    3334    property MaxCount: Integer read FMaxCount write SetMaxCount;
     
    139140    OpenKey(Context.Key, True);
    140141    for I := 0 to Items.Count - 1 do
    141       WriteString('File' + IntToStr(I), UTF8Decode(Items[I]));
     142      WriteString('File' + IntToStr(I), Items[I]);
    142143  finally
    143144    Free;
     
    153154begin
    154155  with XMLConfig do begin
    155     Count := GetValue(Path + '/Count', 0);
     156    Count := GetValue(DOMString(Path + '/Count'), 0);
    156157    if Count > MaxCount then Count := MaxCount;
    157158    Items.Clear;
    158159    for I := 0 to Count - 1 do begin
    159       Value := GetValue(Path + '/File' + IntToStr(I), '');
     160      Value := string(GetValue(DOMString(Path + '/File' + IntToStr(I)), ''));
    160161      if Trim(Value) <> '' then Items.Add(Value);
    161162    end;
     
    170171begin
    171172  with XMLConfig do begin
    172     SetValue(Path + '/Count', Items.Count);
     173    SetValue(DOMString(Path + '/Count'), Items.Count);
    173174    for I := 0 to Items.Count - 1 do
    174       SetValue(Path + '/File' + IntToStr(I), Items[I]);
     175      SetValue(DOMString(Path + '/File' + IntToStr(I)), DOMString(Items[I]));
    175176    Flush;
    176177  end;
     
    185186end;
    186187
     188function TLastOpenedList.GetFirstFileName: string;
     189begin
     190  if Items.Count > 0 then Result := Items[0]
     191    else Result := '';
     192end;
     193
    187194end.
    188195
  • branches/generator/UCore.lfm

    r129 r131  
    55  Height = 733
    66  HorizontalOffset = 491
    7   VerticalOffset = 297
     7  VerticalOffset = 287
    88  Width = 1180
    9   PPI = 120
    109  object ImageList1: TImageList
    1110    left = 540
  • branches/generator/UCore.pas

    r129 r131  
    66
    77uses
    8   Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, UGrammer, DOM,
    9   UPersistentForm;
     8  Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, UGrammer,
     9  UPersistentForm, ULastOpenedList;
    1010
    1111type
     
    2222    { private declarations }
    2323  public
    24     LastOpenedFile: string;
    2524    ReopenLastFile: Boolean;
    2625    Grammer: TGrammer;
     
    2827    procedure SaveConfig;
    2928    procedure Initialize;
     29    procedure Finalize;
    3030  end;
    3131
     
    4646  ForceDirectories(GetAppConfigDir(False));
    4747  XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
    48   LoadConfig;
    4948end;
    5049
    5150procedure TCore.DataModuleDestroy(Sender: TObject);
    5251begin
    53   SaveConfig;
    5452end;
    5553
     
    5755begin
    5856  with XMLConfig1 do begin
    59     LastOpenedFile := string(GetValue('LastOpenedFile', 'pascal.grm'));
    6057    ReopenLastFile := GetValue('ReopenLastFile', True);
    6158  end;
     
    6562begin
    6663  with XMLConfig1 do begin
    67     SetValue('LastOpenedFile', DOMString(LastOpenedFile));
    6864    SetValue('ReopenLastFile', ReopenLastFile);
    6965    Flush;
     
    7369procedure TCore.Initialize;
    7470begin
    75   FormMain.AProjectNew.Execute;
    76   if ReopenLastFile and FileExists(LastOpenedFile) then
    77     Grammer.LoadFromXmlFile(LastOpenedFile)
     71  LoadConfig;
     72  FormMain.LoadConfig(XMLConfig1);
     73  if ReopenLastFile and FileExists(FormMain.LastOpenedList1.GetFirstFileName) then
     74    FormMain.ProjectOpen(FormMain.LastOpenedList1.GetFirstFileName)
     75    else FormMain.AProjectNew.Execute;
     76end;
     77
     78procedure TCore.Finalize;
     79begin
     80  FormMain.SaveConfig(XMLConfig1);
     81  SaveConfig;
    7882end;
    7983
  • branches/generator/UGrammer.pas

    r130 r131  
    1515
    1616  TRuleItemType = (ritTerminal, ritNonTerminal, ritSubItems, ritTerminalRange);
     17  TGrammerNotation = (gnBnf, gnEbnf);
    1718
    1819  { TRuleItem }
     
    3940    procedure SaveToXmlNode(Node: TDOMNode);
    4041    function GetString: string;
     42    function ExportAsString(Notation: TGrammerNotation): string;
    4143    constructor Create;
    4244    destructor Destroy; override;
     
    6163    procedure UpdateRuleReference;
    6264    function GetString: string;
     65    function ExportAsString(Notation: TGrammerNotation): string;
    6366    property ParentRule: TRule read FParentRule write SetParentRule;
    6467  end;
     
    9598    procedure SaveToXmlNode(Node: TDOMNode);
    9699    function GetString: string;
     100    function ExportAsString(Notation: TGrammerNotation): string;
    97101    property Grammer: TGrammer read FGrammer write SetGrammer;
    98102  end;
     
    106110    procedure SaveToXmlNode(Node: TDOMNode);
    107111    function GetString: string;
     112    function ExportAsString(Notation: TGrammerNotation): string;
    108113  end;
    109114
     
    129134    procedure GetUsedByRule(RefRule: TRule; UsedByRules: TStrings);
    130135    function GetString: string;
     136    function ExportAsString(Notation: TGrammerNotation): string;
    131137    procedure Change;
    132138    property Modified: Boolean read FModified write SetModified;
     
    248254begin
    249255  Result := Rules.GetString;
     256end;
     257
     258function TGrammer.ExportAsString(Notation: TGrammerNotation): string;
     259begin
     260  Result := Rules.ExportAsString(Notation);
    250261end;
    251262
     
    292303  if Repetitive then Result := '*' + Result;
    293304  if AnyExcept then Result := '!' + Result;
     305end;
     306
     307function TRuleItem.ExportAsString(Notation: TGrammerNotation): string;
     308begin
     309  case Notation of
     310    gnBnf: begin
     311      case RuleItemType of
     312        ritTerminal: Result := Terminal;
     313        ritNonTerminal: Result := '<' + NonTerminal.Name + '>';
     314        ritSubItems: begin
     315          if not Optional and not Repetitive then
     316            Result := '(' + SubItems.ExportAsString(Notation) + ')'
     317            else Result := SubItems.ExportAsString(Notation);
     318        end;
     319        ritTerminalRange: Result := '(' + TerminalFrom + ' .. ' + TerminalTo + ')';
     320      end;
     321      if Optional and not Repetitive then Result := '[' + Result + ']';
     322      if Repetitive then Result := '{' + Result + '}';
     323      if AnyExcept then Result := 'other then ' + Result;
     324    end;
     325    gnEbnf: begin
     326      case RuleItemType of
     327        ritTerminal: Result := '"' + Terminal + '"';
     328        ritNonTerminal: Result := NonTerminal.Name;
     329        ritSubItems: begin
     330          if not Optional and not Repetitive then
     331            Result := '(' + SubItems.ExportAsString(Notation) + ')'
     332            else Result := SubItems.ExportAsString(Notation);
     333        end;
     334        ritTerminalRange: Result := '(' + TerminalFrom + ' .. ' + TerminalTo + ')';
     335      end;
     336      if Optional and not Repetitive then Result := '[' + Result + ']';
     337      if Repetitive then Result := '{' + Result + '}';
     338      if AnyExcept then Result := 'other then ' + Result;
     339    end;
     340  end;
    294341end;
    295342
     
    395442end;
    396443
     444function TRuleItems.ExportAsString(Notation: TGrammerNotation): string;
     445var
     446  Item: TRuleItem;
     447begin
     448  Result := '';
     449  for Item in Self do begin
     450    if Item <> First then begin
     451      if RuleType = rtAnd then begin
     452        case Notation of
     453          gnBnf: Result := Result + ' ';
     454          gnEbnf: Result := Result + ', ';
     455        end;
     456      end else
     457      if RuleType = rtOr then begin
     458        case Notation of
     459          gnBnf: Result := Result + ' | ';
     460          gnEbnf: Result := Result + ' | ';
     461        end;
     462      end;
     463    end;
     464    Result := Result + Item.ExportAsString(Notation);
     465  end;
     466end;
     467
    397468procedure TRuleItems.SetParentRule(AValue: TRule);
    398469begin
     
    456527end;
    457528
     529function TRule.ExportAsString(Notation: TGrammerNotation): string;
     530begin
     531  case Notation of
     532    gnBnf: Result := Name + ' ::= ' + Items.ExportAsString(Notation);
     533    gnEbnf: Result := Name + ' = ' + Items.ExportAsString(Notation);
     534  end;
     535end;
     536
    458537procedure TRule.SetGrammer(AValue: TGrammer);
    459538begin
     
    553632end;
    554633
     634function TRules.ExportAsString(Notation: TGrammerNotation): string;
     635var
     636  Rule: TRule;
     637begin
     638  Result := '';
     639  for Rule in Self do begin
     640    Result := Result + Rule.ExportAsString(Notation) + LineEnding;
     641  end;
     642end;
     643
    555644end.
    556645
Note: See TracChangeset for help on using the changeset viewer.