Ignore:
Timestamp:
Apr 22, 2020, 12:02:17 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Implemented generic access to fields in source tree.
  • Added: Generator to XML.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter2/UFormMain.pas

    r207 r208  
    1515  TFormMain = class(TForm)
    1616    ACompile: TAction;
     17    AGenerateXml: TAction;
    1718    AOptimize: TAction;
    1819    AExit: TAction;
     
    2223    AGeneratePascal: TAction;
    2324    ActionList1: TActionList;
    24     Label2: TLabel;
    2525    MainMenu1: TMainMenu;
    26     MemoOutput: TMemo;
    2726    MenuItem1: TMenuItem;
    2827    MenuItem2: TMenuItem;
     
    3130    MenuItem5: TMenuItem;
    3231    MenuItem6: TMenuItem;
     32    MenuItem7: TMenuItem;
    3333    MenuItemRun: TMenuItem;
    3434    MenuItemGenerate: TMenuItem;
    3535    MenuItemFile: TMenuItem;
     36    PanelOutput: TPanel;
    3637    PanelSource: TPanel;
    3738    PanelMessages: TPanel;
     
    4142    procedure AGeneratePascalExecute(Sender: TObject);
    4243    procedure AGeneratePhpExecute(Sender: TObject);
     44    procedure AGenerateXmlExecute(Sender: TObject);
    4345    procedure AOptimizeExecute(Sender: TObject);
    4446    procedure ARunExecute(Sender: TObject);
     
    6870uses
    6971  UParser, UExecutor, UGeneratorPascal, UGeneratorPhp, UFormMessages, UFormSource,
    70   UGeneratorCSharp, UOptimizer;
     72  UGeneratorCSharp, UOptimizer, UGeneratorXml, UFormOutput;
    7173
    7274{ TFormMain }
     
    9597  DockForm(FormMessages, PanelMessages);
    9698  DockForm(FormSource, PanelSource);
     99  DockForm(FormOutput, PanelOutput);
    97100  UpdateInterface;
    98101end;
     
    124127  ACompile.Execute;
    125128  AOptimize.Execute;
    126   MemoOutput.Lines.Clear;
     129  FormOutput.SynEditOutput.Highlighter := FormOutput.SynCppSyn1;
     130  FormOutput.Clear;
    127131  if Assigned(Prog) then begin
    128132    Generator := TGeneratorCSharp.Create;
    129133    Generator.Prog := Prog;
    130134    Generator.Generate;
    131     MemoOutput.Lines.Text := Generator.Output;
    132     Generator.Free;
    133     MemoOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.cs');
     135    FormOutput.SetText(Generator.Output);
     136    Generator.Free;
     137    FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.cs');
    134138  end;
    135139end;
     
    141145  ACompile.Execute;
    142146  AOptimize.Execute;
    143   MemoOutput.Lines.Clear;
     147  FormOutput.SynEditOutput.Highlighter := FormOutput.SynPasSyn1;
     148  FormOutput.SynEditOutput.Lines.Clear;
    144149  if Assigned(Prog) then begin
    145150    Generator := TGeneratorPascal.Create;
    146151    Generator.Prog := Prog;
    147152    Generator.Generate;
    148     MemoOutput.Lines.Text := Generator.Output;
    149     Generator.Free;
    150     MemoOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.pas');
     153    FormOutput.SynEditOutput.Lines.Text := Generator.Output;
     154    Generator.Free;
     155    FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.pas');
    151156  end;
    152157end;
     
    157162begin
    158163  ACompile.Execute;
    159   MemoOutput.Lines.Clear;
     164  FormOutput.SynEditOutput.Highlighter := FormOutput.SynPhpSyn1;
     165  FormOutput.SynEditOutput.Lines.Clear;
    160166  if Assigned(Prog) then begin
    161167    Generator := TGeneratorPhp.Create;
    162168    Generator.Prog := Prog;
    163169    Generator.Generate;
    164     MemoOutput.Lines.Text := Generator.Output;
    165     Generator.Free;
    166     MemoOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.php');
     170    FormOutput.SynEditOutput.Lines.Text := Generator.Output;
     171    Generator.Free;
     172    FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.php');
     173  end;
     174end;
     175
     176procedure TFormMain.AGenerateXmlExecute(Sender: TObject);
     177var
     178  Generator: TGeneratorXml;
     179begin
     180  ACompile.Execute;
     181  FormOutput.SynEditOutput.Highlighter := FormOutput.SynXmlSyn1;
     182  FormOutput.SynEditOutput.Lines.Clear;
     183  if Assigned(Prog) then begin
     184    Generator := TGeneratorXml.Create;
     185    Generator.Prog := Prog;
     186    Generator.Generate;
     187    FormOutput.SynEditOutput.Lines.Text := Generator.Output;
     188    Generator.Free;
     189    FormOutput.SynEditOutput.Lines.SaveToFile('Generated' + DirectorySeparator + 'Test.xml');
    167190  end;
    168191end;
     
    186209  ACompile.Execute;
    187210  //AOptimize.Execute;
    188   MemoOutput.Lines.Clear;
     211  FormOutput.SynEditOutput.Highlighter := nil;
     212  FormOutput.SynEditOutput.Lines.Clear;
    189213  if Assigned(Prog) then begin
    190214    Executor := TExecutor.Create;
     
    214238procedure TFormMain.ExecutorOutput(Text: string);
    215239begin
    216   MemoOutput.Text := MemoOutput.Text + Text;
     240  FormOutput.SynEditOutput.Text := FormOutput.SynEditOutput.Text + Text;
    217241end;
    218242
Note: See TracChangeset for help on using the changeset viewer.