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

📄 compile_hss.pas

📁 一个多元非线性回归分析源码以及其中的公式列表
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    TF00            :string;    // 比较符号优先级时 Tf00 用来保存上一次的符号

    T_ff_sys_ConstN :integer;   //积分变量 序号

    T_PTrueNow      :TT_PTrue;  //编译优化常数时  当前参数性质
    T_PTrueOld      :TT_PTrue;  //编译优化常数时  上一个参数性质
    T_PTrueNowList  :array  of TT_PTrue; //编译优化常数时  参数性质堆栈
    PT_PTrueNowList :integer;            //当前参数性质堆栈插入位置

    CompileInPFirst :integer;   //第几次调用CompileInP()

    {私有函数}
    procedure Clear();
    function  Compile():boolean; //编译
    function  Parsing(var str:string):boolean;//第一遍翻译
    function  CheckBK(const str:string):boolean;//括号配对检查
    procedure CompileInP(const PName:string); //编译 参数堆栈插入参数
    procedure CompileInPReNew(const dValue:Extended;const Pm:integer); //编译 参数堆栈插入参数 (替换)
    procedure CompileOutP(); //编译 弹出参数
    procedure CompileInF(const FName:string); //编译 函数调用
    function  GetSign(var str:string):string; //返回 str 的第一个算数符
    function  CompareSign(const FName1 : string;const FName2 :string): integer; //比较符号的优先级
    procedure CheckWording(const T1 : string;const T2 : string) ;// 按照先后关系检查语法错误


    procedure ExeAddressCodeIn(const B:Byte);  overload;      //编译插入CPU指令
    procedure ExeAddressCodeIn(const B:array of Byte); overload;
    procedure ExeAddressCodeIn(const sB:string);  overload;
    procedure GetExeAddressCodeInPointerRePm(const PMIndex:integer);  //记录编译指令中插入的参数地址,变更地址时以便更新
    Function  GetExeAddressCodeInPointerReCode():Pointer; //记录编译指令中插入的执行偏移地址,变更地址时以便更新
    procedure RefreshExeAddressCodeInPointer();  //刷新变更地址


    procedure FunctionListIn(const s:string;const F:Pointer;const iCount:integer);//把支持的函数插入函数列表
    procedure GetFunctionList();                                 //获得函数列表
    Function  GetFunctionIndex(const fName:string):integer;      //获得指定名称函数的序号
    function  IfHaveFunction (const fName:string):boolean;       //判断指定名称函数是否已经在函数列表中

    procedure FunctionStackIn(const s:string);    //
    Function  FunctionStackOut():string;          //管理  函数符号调用堆栈
    Function  FunctionStackRead():string;         //

    procedure ParameterListIn(const PName:string);overload;  //将参数插入参数堆栈
    function  GetParameterListConstIndex(const PName:string):integer;
    function  ParameterListIn(const dValue:Extended):string;overload; //将常数插入参数堆栈 并返回由系统定义的别名
    function  GetParameterIndex(const PName:string):integer;       //得到指定名称参数的序号

    procedure T_PTrueNowListIN(const TP:TT_PTrue);  //管理   (编译优化常数时) 参数性质堆栈
    function  T_PTrueNowListOut():TT_PTrue;         //

    //传入参数str,通过s返回
    function  Dbxch(var s:string;var str:string):boolean; // 书写格式转换函数  f(x,y) => ((x)f(y))
    function  Dbxchff_SYS(var s:string;var str:string):boolean; // 书写格式转换函数 ff(a,b,x,N,g(x)) => ( (a) F_FF_SYS_0 (b) F_FF_SYS_1 (N) F_FF_SYS_2 ( g(x) ) )

    procedure DelStrNote(var str:string); // 去掉str注释部分


    function  ifFF_SYS(const fName:string):boolean;  // fName 中是否有 积分函数
    function  getFF_SYS(const fName:string):string;  // 返回积分函数名称

    {编译 函数}
    //约定:  单元函数 通过 st 传参数值 ,通过 st 返回结果值
    //       双元函数 通过 st 传第一参数值,通过 [ecx] 传第二个参数 ,通过 st 返回结果值
    //       函数可以 通过 [edx] 及以后的临时数据交换区来保存、修改或读取数据
    //       函数可以随意使用EAX、EBX

    //数学运算
    Procedure F_Add();
    Procedure F_Sub();
    Procedure F_Mul();
    Procedure F_Div();
    Procedure F_DivE();
    Procedure F_Mod();
    Procedure F_Power();
    Procedure F_Max();
    Procedure F_Min();
    Procedure F_Bracket(); { ()函数 }
    Procedure F_Rev();
    Procedure F_Sqr();
    Procedure F_Sqrt();
    Procedure F_Sin();
    Procedure F_Cos();
    Procedure F_Tan();
    Procedure F_ArcSin();
    Procedure F_ArcCos();
    Procedure F_ArcTan();
    Procedure F_ArcTan2();
    Procedure F_Ln();
    Procedure F_Log();
    Procedure F_Log2();
    Procedure F_Abs();
    Procedure F_Floor();
    Procedure F_Trunc();
    Procedure F_Round();
    Procedure F_Ceil();
    Procedure F_Sgn();
    Procedure F_exp();
    Procedure F_SinH();
    Procedure F_CosH();
    Procedure F_TanH();
    Procedure F_ArcSinH();
    Procedure F_ArcCosH();
    Procedure F_ArcTanH();
    procedure F_Rnd();
    procedure F_Ctg();
    procedure F_Sec();
    procedure F_Csc();
    procedure F_CscH();
    procedure F_SecH();
    procedure F_CtgH();
    procedure F_ArcCsc();
    procedure F_ArcSec();
    procedure F_ArcCtg();
    procedure F_ArcCscH();
    procedure F_ArcSecH();
    procedure F_ArcCtgH();  
    procedure F_Hypot();


    procedure F_FF_SYS_0(const N:integer); //积分函数0
    procedure F_FF_SYS_1(const N:integer); //积分函数1
    procedure F_FF_SYS_2(const N:integer); //积分函数2

    
    //布尔运算
    //procedure FB_True();  //常量函数 true 真=1
    //procedure FB_False(); //常量函数 false 假=0
    procedure FB_AND();   //逻辑 与
    procedure FB_OR();    //逻辑 或
    procedure FB_XOR();   //逻辑 异或
    procedure FB_NOT();   //逻辑 非
    //关系运算(返回布尔值)
    procedure FB_EQ();    //相等
    procedure FB_NE();    //不等于
    procedure FB_LT();    //小于
    procedure FB_GT();    //大于
    procedure FB_LE();    //小于等于
    procedure FB_GE();    //大于等于



    Procedure FF_Fld_X(const x:extended); //载入x

    {有限状态自动机}

    function  Conversion0(var s:string;var str:string):boolean; //得到参数(常数)列表、函数转换
    procedure GetMarker(const Str:string;const iFirst:integer;var iEnd:integer); //含'@'、'&'取出标识符

    procedure GetMarkerValue0(const Str:string;const iFirst:integer;var iEnd:integer);{取出标识符的有限状态自动机}
    procedure GetMarkerValue1(const Str:string;const iFirst:integer;var iEnd:integer);

    procedure GetFloatValue0(const Str:string;const iFirst:integer;var iEnd:integer); {取出常数的有限状态自动机}
    procedure GetFloatValue1(const Str:string;const iFirst:integer;var iEnd:integer);
    procedure GetFloatValue2(const Str:string;const iFirst:integer;var iEnd:integer);
    procedure GetFloatValue3(const Str:string;const iFirst:integer;var iEnd:integer);
    procedure GetFloatValue4(const Str:string;const iFirst:integer;var iEnd:integer);
    procedure GetFloatValue5(const Str:string;const iFirst:integer;var iEnd:integer);
    procedure GetFloatValue6(const Str:string;const iFirst:integer;var iEnd:integer);

    

  public
    { Public declarations }
    constructor Create();
    destructor  Destroy();Override;
  end;

  {$IFDEF MSWINDOWS}

  TSystemTime = record
          wYear   : Word;
          wMonth  : Word;
          wDayOfWeek  : Word;
          wDay    : Word;
          wHour   : Word;
          wMinute : Word;
          wSecond : Word;
          wMilliSeconds: Word;
          reserved    : array [0..7] of char;
  end;
  procedure GetSystemTime(var lpSystemTime: TSystemTime); stdcall;
  {$EXTERNALSYM GetSystemTime}

  {$ENDIF}


  //错误号定义
  const csTCompile_NoError              = 0;
        csTCompile_NoKnownError         = 1;
        csTCompile_NoErrorCode          = 2;

        csTCompile_CompileHexCodeError  = 3;
        csTCompile_HexMod2_EQ_1_Error   = 4;

        csTCompile_PMMarker_Error       = 5;
        csTCompile_FMMarker_Error       = 6;
        csTCompile_Wording_Error        = 7;
        csTCompile_Bracket_Error        = 8;
        csTCompile_Optimize_Error       = 9;
        csTCompile_Define_Error         =10;
        csTCompile_Handwriting_Error    =11;
        csTCompile_FFHandwriting_Error  =12;

        csTCompile_ReadFloat_Error      =13;
        csTCompile_ReadMarker_Error     =14;
        csTCompile_Read_Error           =15;
        csTCompile_Note_Match_Error     =16;


implementation

function  TCompile.GetError():string;
begin
  result:=GetErrorGB(ErrorCode);
end;

function  TCompile.GetErrorGB(const xErrorCode:integer):string;     //返回错误描述
begin
  case xErrorCode of
    csTCompile_NoError              :result:='';//没有发现错误!
    csTCompile_NoKnownError         :result:='不知道的错误!';
    csTCompile_NoErrorCode          :result:='找不到错误号所对应的错误描述!';
    csTCompile_CompileHexCodeError  :result:='编译时指令的十六进制代码错误!';
    csTCompile_HexMod2_EQ_1_Error   :result:='编译时传入指令长度错误!';
    csTCompile_PMMarker_Error       :result:='编译得到参数名称时发生错误!';
    csTCompile_FMMarker_Error       :result:='编译得到函数名称时发生错误!';
    csTCompile_Wording_Error        :result:='语法发生错误!';
    csTCompile_Bracket_Error        :result:='语法错误,在 ( ) 处!';
    csTCompile_Optimize_Error       :result:='编译优化时发生错误!';
    csTCompile_Define_Error         :result:='函数编译错误(或超出定义域)!';
    csTCompile_Handwriting_Error    :result:='函数书写格式错误!';
    csTCompile_FFHandwriting_Error  :result:='积分函数书写格式错误!';
    csTCompile_ReadFloat_Error      :result:='编译读取常数数字时发生错误!';
    csTCompile_ReadMarker_Error     :result:='编译读取标识符时发生错误!';
    csTCompile_Read_Error           :result:='语法错误,有不识别的字符!';
    csTCompile_Note_Match_Error     :result:='注释符号不匹配!  { } 或 /*  */';
  else result:=GetErrorGB(csTCompile_NoErrorCode);
  end;
end;

function  TCompile.GetErrorBIG5(const xErrorCode:integer):string;     //返回错误描述
begin
  //注意:以下使用的是中文繁体BIG5码,要使用内码转换器才能察看
  case xErrorCode of
    csTCompile_NoError              :result:='';//⊿Τ祇瞷岿粇!
    csTCompile_NoKnownError         :result:='ぃ

⌨️ 快捷键说明

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