⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 u_delphi_sql_parser.pas

📁 delphi实现的sql解析器
💻 PAS
字号:
// 002 u_delphi_sql_parser
// 04 feb 2005

// -- (C) Felix John COLIBRI 2004
// -- documentation: http://www.felix-colibri.com

(*$r+*)

unit u_delphi_sql_parser;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, FileCtrl, ExtCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Panel1: TPanel;
    DirectoryListBox1: TDirectoryListBox;
    FileListBox1: TFileListBox;
    exit_: TButton;
    clear_: TButton;
    display_scan_: TCheckBox;
    trace_parser_: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure FileListBox1Click(Sender: TObject);
    procedure clear_Click(Sender: TObject);
    procedure exit_Click(Sender: TObject);
    procedure DirectoryListBox1Change(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
  public
  end;

var
  Form1: TForm1;

  implementation
    uses u_c_log, u_c_display, u_file, u_dir
        , u_c_ini_file
        , u_c_sql_scanner
        , u_c_sql_parser
        ;

 
  
    {$R *.DFM}

    const k_initial_path= '..\_data\';
            k_file_name= 'e.ed';
            k_extension= '.*';

          // -- ini keys
          k_save_path= k_initial_path;
          k_save_name= k_file_name;

          k_load_path_ini_key=      'load_fig_path';
          k_load_file_name_ini_key= 'load_fig_file_name';

    var g_path: String= k_initial_path;
        g_file_name: String= k_file_name;
        g_c_ini_file: c_ini_file= Nil;

    procedure handle_file(p_path, p_file_name: String);
      var l_c_sql_scanner: c_sql_scanner;
      begin
        display(p_file_name);
        l_c_sql_scanner:= c_sql_scanner.create_sql_scanner('sql_scanner', p_path+ p_file_name);

        with l_c_sql_scanner do
        begin
          m_display_symbol_read:= Form1.display_scan_.Checked;
          // test_sql_scanner;
        end; // with l_c_sql_scanner

        with c_sql_parser.create_sql_parser('sql_parser') do
        begin
          m_c_sql_scanner_ref:= l_c_sql_scanner;
          m_pure_parsing:= True;
          m_trace_parser:= Form1.trace_parser_.Checked;
          parse_sql;
          Free;
        end; // with c_sql_parser

        l_c_sql_scanner.Free;
      end; // handle_file

    // -- events

    procedure TForm1.FormCreate(Sender: TObject);
      begin
        initialize_display(Memo1.Lines);
        initialize_default_log;

        g_c_ini_file:= c_ini_file.create_ini_file('aha');
        with g_c_ini_file do
        begin
          // -- whatever is in "fig_ini.txt"
          load_from_default_file;

          // -- initialize the variables with INI or, if none, with constants
          g_path:= f_initialize_parameter(k_load_path_ini_key, k_save_path);
          g_file_name:= f_initialize_parameter(k_load_file_name_ini_key, k_save_name);
        end;

        set_directory_listbox_directory(DirectoryListBox1, g_path);
        FileListBox1.Mask:= '*'+ k_extension;
      end; // FormCreate

    procedure TForm1.clear_Click(Sender: TObject);
      begin
        clear_display;
      end; // clear_Click

    procedure TForm1.DirectoryListBox1Change(Sender: TObject);
      begin
        with DirectoryListBox1 do
          g_path:= GetItemPath(ItemIndex)+ '\';
        g_c_ini_file.set_parameter(k_load_path_ini_key, g_path);
      end; // DirectoryListBox1Change

    // -- file handling

    procedure TForm1.FileListBox1Click(Sender: TObject);
      // -- the file clicked in the bottom list_box
      begin
        with FileListbox1 do
          g_file_name:= Items[ItemIndex];
        display(g_path+ ' '+ g_file_name);
        g_c_ini_file.set_parameter(k_load_file_name_ini_key, g_file_name);

        handle_file(g_path, g_file_name);

        display_line;
        display('finished');
      end; // FileListBox1Click

    procedure TForm1.exit_Click(Sender: TObject);
      begin
        Close;
      end; // exit_Click

    procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
      begin
        g_c_ini_file.save_to_default_file;
      end; // FormClose

end.


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -