mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-12 23:50:33 +01:00
* fcl-db: dbase/bufdataset expression parser: match function signatures with given arguments; fixes mismatch for some
long integer+integer long integer+long integer field expressions (+, -, *, / etc) and long integer <> float field expressions * fcl-db: dbase/bufdataset parser: cosmetic: language/clarity in comments git-svn-id: trunk@25755 -
This commit is contained in:
parent
cc5b720bfd
commit
89e6d1aee3
@ -31,11 +31,11 @@ uses
|
|||||||
|
|
||||||
{$define ENG_NUMBERS}
|
{$define ENG_NUMBERS}
|
||||||
|
|
||||||
// ENG_NUMBERS will force the use of english style numbers 8.1 instead of 8,1
|
// ENG_NUMBERS will force the use of English style numbers 8.1 instead of 8,1
|
||||||
// (if the comma is your decimal separator)
|
// (if the comma is your decimal separator)
|
||||||
// the advantage is that arguments can be separated with a comma which is
|
// The advantage is that arguments can be separated with a comma which is
|
||||||
// fairly common, otherwise there is ambuigity: what does 'var1,8,4,4,5' mean?
|
// fairly common, otherwise there is ambiguity: what does 'var1,8,4,4,5' mean?
|
||||||
// if you don't define ENG_NUMBERS and DecimalSeparator is a comma then
|
// If you don't define ENG_NUMBERS and DecimalSeparator is a comma then
|
||||||
// the argument separator will be a semicolon ';'
|
// the argument separator will be a semicolon ';'
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -106,13 +106,13 @@ type
|
|||||||
property Optimize: Boolean read FOptimize write FOptimize;
|
property Optimize: Boolean read FOptimize write FOptimize;
|
||||||
property ResultType: TExpressionType read GetResultType;
|
property ResultType: TExpressionType read GetResultType;
|
||||||
|
|
||||||
|
//If optimize is selected, the code tries to remove constant expressions
|
||||||
//if optimize is selected, constant expressions are tried to remove
|
//Examples: 4*4*x is evaluated as 16*x and exp(1)-4*x is replaced by 2.17 -4*x
|
||||||
//such as: 4*4*x is evaluated as 16*x and exp(1)-4*x is repaced by 2.17 -4*x
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//--Expression functions-----------------------------------------------------
|
//--Expression functions-----------------------------------------------------
|
||||||
|
//I: integer; L: Long Integer
|
||||||
|
|
||||||
procedure FuncFloatToStr(Param: PExpressionRec);
|
procedure FuncFloatToStr(Param: PExpressionRec);
|
||||||
procedure FuncIntToStr_Gen(Param: PExpressionRec; Val: {$ifdef SUPPORT_INT64}Int64{$else}Integer{$endif});
|
procedure FuncIntToStr_Gen(Param: PExpressionRec; Val: {$ifdef SUPPORT_INT64}Int64{$else}Integer{$endif});
|
||||||
@ -2167,6 +2167,8 @@ initialization
|
|||||||
Add(TComma.Create(',', nil));
|
Add(TComma.Create(',', nil));
|
||||||
|
|
||||||
// operators - name, param types, result type, func addr, precedence
|
// operators - name, param types, result type, func addr, precedence
|
||||||
|
// note that the parameter types in the second column must match with
|
||||||
|
// the function signature in the function address
|
||||||
Add(TFunction.CreateOper('+', 'SS', etString, nil, 40));
|
Add(TFunction.CreateOper('+', 'SS', etString, nil, 40));
|
||||||
Add(TFunction.CreateOper('+', 'FF', etFloat, FuncAdd_F_FF, 40));
|
Add(TFunction.CreateOper('+', 'FF', etFloat, FuncAdd_F_FF, 40));
|
||||||
Add(TFunction.CreateOper('+', 'FI', etFloat, FuncAdd_F_FI, 40));
|
Add(TFunction.CreateOper('+', 'FI', etFloat, FuncAdd_F_FI, 40));
|
||||||
@ -2176,8 +2178,8 @@ initialization
|
|||||||
Add(TFunction.CreateOper('+', 'FL', etFloat, FuncAdd_F_FL, 40));
|
Add(TFunction.CreateOper('+', 'FL', etFloat, FuncAdd_F_FL, 40));
|
||||||
Add(TFunction.CreateOper('+', 'IL', etLargeInt, FuncAdd_F_IL, 40));
|
Add(TFunction.CreateOper('+', 'IL', etLargeInt, FuncAdd_F_IL, 40));
|
||||||
Add(TFunction.CreateOper('+', 'LF', etFloat, FuncAdd_F_LF, 40));
|
Add(TFunction.CreateOper('+', 'LF', etFloat, FuncAdd_F_LF, 40));
|
||||||
Add(TFunction.CreateOper('+', 'LL', etLargeInt, FuncAdd_F_LI, 40));
|
Add(TFunction.CreateOper('+', 'LL', etLargeInt, FuncAdd_F_LL, 40));
|
||||||
Add(TFunction.CreateOper('+', 'LI', etLargeInt, FuncAdd_F_LL, 40));
|
Add(TFunction.CreateOper('+', 'LI', etLargeInt, FuncAdd_F_LI, 40));
|
||||||
{$endif}
|
{$endif}
|
||||||
Add(TFunction.CreateOper('-', 'FF', etFloat, FuncSub_F_FF, 40));
|
Add(TFunction.CreateOper('-', 'FF', etFloat, FuncSub_F_FF, 40));
|
||||||
Add(TFunction.CreateOper('-', 'FI', etFloat, FuncSub_F_FI, 40));
|
Add(TFunction.CreateOper('-', 'FI', etFloat, FuncSub_F_FI, 40));
|
||||||
@ -2187,8 +2189,8 @@ initialization
|
|||||||
Add(TFunction.CreateOper('-', 'FL', etFloat, FuncSub_F_FL, 40));
|
Add(TFunction.CreateOper('-', 'FL', etFloat, FuncSub_F_FL, 40));
|
||||||
Add(TFunction.CreateOper('-', 'IL', etLargeInt, FuncSub_F_IL, 40));
|
Add(TFunction.CreateOper('-', 'IL', etLargeInt, FuncSub_F_IL, 40));
|
||||||
Add(TFunction.CreateOper('-', 'LF', etFloat, FuncSub_F_LF, 40));
|
Add(TFunction.CreateOper('-', 'LF', etFloat, FuncSub_F_LF, 40));
|
||||||
Add(TFunction.CreateOper('-', 'LL', etLargeInt, FuncSub_F_LI, 40));
|
Add(TFunction.CreateOper('-', 'LL', etLargeInt, FuncSub_F_LL, 40));
|
||||||
Add(TFunction.CreateOper('-', 'LI', etLargeInt, FuncSub_F_LL, 40));
|
Add(TFunction.CreateOper('-', 'LI', etLargeInt, FuncSub_F_LI, 40));
|
||||||
{$endif}
|
{$endif}
|
||||||
Add(TFunction.CreateOper('*', 'FF', etFloat, FuncMul_F_FF, 40));
|
Add(TFunction.CreateOper('*', 'FF', etFloat, FuncMul_F_FF, 40));
|
||||||
Add(TFunction.CreateOper('*', 'FI', etFloat, FuncMul_F_FI, 40));
|
Add(TFunction.CreateOper('*', 'FI', etFloat, FuncMul_F_FI, 40));
|
||||||
@ -2198,8 +2200,8 @@ initialization
|
|||||||
Add(TFunction.CreateOper('*', 'FL', etFloat, FuncMul_F_FL, 40));
|
Add(TFunction.CreateOper('*', 'FL', etFloat, FuncMul_F_FL, 40));
|
||||||
Add(TFunction.CreateOper('*', 'IL', etLargeInt, FuncMul_F_IL, 40));
|
Add(TFunction.CreateOper('*', 'IL', etLargeInt, FuncMul_F_IL, 40));
|
||||||
Add(TFunction.CreateOper('*', 'LF', etFloat, FuncMul_F_LF, 40));
|
Add(TFunction.CreateOper('*', 'LF', etFloat, FuncMul_F_LF, 40));
|
||||||
Add(TFunction.CreateOper('*', 'LL', etLargeInt, FuncMul_F_LI, 40));
|
Add(TFunction.CreateOper('*', 'LL', etLargeInt, FuncMul_F_LL, 40));
|
||||||
Add(TFunction.CreateOper('*', 'LI', etLargeInt, FuncMul_F_LL, 40));
|
Add(TFunction.CreateOper('*', 'LI', etLargeInt, FuncMul_F_LI, 40));
|
||||||
{$endif}
|
{$endif}
|
||||||
Add(TFunction.CreateOper('/', 'FF', etFloat, FuncDiv_F_FF, 40));
|
Add(TFunction.CreateOper('/', 'FF', etFloat, FuncDiv_F_FF, 40));
|
||||||
Add(TFunction.CreateOper('/', 'FI', etFloat, FuncDiv_F_FI, 40));
|
Add(TFunction.CreateOper('/', 'FI', etFloat, FuncDiv_F_FI, 40));
|
||||||
@ -2209,8 +2211,8 @@ initialization
|
|||||||
Add(TFunction.CreateOper('/', 'FL', etFloat, FuncDiv_F_FL, 40));
|
Add(TFunction.CreateOper('/', 'FL', etFloat, FuncDiv_F_FL, 40));
|
||||||
Add(TFunction.CreateOper('/', 'IL', etLargeInt, FuncDiv_F_IL, 40));
|
Add(TFunction.CreateOper('/', 'IL', etLargeInt, FuncDiv_F_IL, 40));
|
||||||
Add(TFunction.CreateOper('/', 'LF', etFloat, FuncDiv_F_LF, 40));
|
Add(TFunction.CreateOper('/', 'LF', etFloat, FuncDiv_F_LF, 40));
|
||||||
Add(TFunction.CreateOper('/', 'LL', etLargeInt, FuncDiv_F_LI, 40));
|
Add(TFunction.CreateOper('/', 'LL', etLargeInt, FuncDiv_F_LL, 40));
|
||||||
Add(TFunction.CreateOper('/', 'LI', etLargeInt, FuncDiv_F_LL, 40));
|
Add(TFunction.CreateOper('/', 'LI', etLargeInt, FuncDiv_F_LI, 40));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
Add(TFunction.CreateOper('=', 'FF', etBoolean, Func_FF_EQ , 80));
|
Add(TFunction.CreateOper('=', 'FF', etBoolean, Func_FF_EQ , 80));
|
||||||
@ -2249,7 +2251,7 @@ initialization
|
|||||||
Add(TFunction.CreateOper('>', 'LF', etBoolean, Func_LF_GT , 80));
|
Add(TFunction.CreateOper('>', 'LF', etBoolean, Func_LF_GT , 80));
|
||||||
Add(TFunction.CreateOper('<=','LF', etBoolean, Func_LF_LTE, 80));
|
Add(TFunction.CreateOper('<=','LF', etBoolean, Func_LF_LTE, 80));
|
||||||
Add(TFunction.CreateOper('>=','LF', etBoolean, Func_LF_GTE, 80));
|
Add(TFunction.CreateOper('>=','LF', etBoolean, Func_LF_GTE, 80));
|
||||||
Add(TFunction.CreateOper('<>','FI', etBoolean, Func_LF_NEQ, 80));
|
Add(TFunction.CreateOper('<>','LF', etBoolean, Func_LF_NEQ, 80));
|
||||||
Add(TFunction.CreateOper('=', 'LI', etBoolean, Func_LI_EQ , 80));
|
Add(TFunction.CreateOper('=', 'LI', etBoolean, Func_LI_EQ , 80));
|
||||||
Add(TFunction.CreateOper('<', 'LI', etBoolean, Func_LI_LT , 80));
|
Add(TFunction.CreateOper('<', 'LI', etBoolean, Func_LI_LT , 80));
|
||||||
Add(TFunction.CreateOper('>', 'LI', etBoolean, Func_LI_GT , 80));
|
Add(TFunction.CreateOper('>', 'LI', etBoolean, Func_LI_GT , 80));
|
||||||
|
|||||||
@ -324,6 +324,7 @@ type
|
|||||||
AExprFunc: TExprFunc; AIsOperator: Boolean; AOperPrec: Integer);
|
AExprFunc: TExprFunc; AIsOperator: Boolean; AOperPrec: Integer);
|
||||||
public
|
public
|
||||||
constructor Create(AName, AShortName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType; AExprFunc: TExprFunc; Descr: string);
|
constructor Create(AName, AShortName, ATypeSpec: string; AMinFuncArg: Integer; AResultType: TExpressionType; AExprFunc: TExprFunc; Descr: string);
|
||||||
|
// Create operator: name, param types used, result type, func addr, operator precedence
|
||||||
constructor CreateOper(AName, ATypeSpec: string; AResultType: TExpressionType; AExprFunc: TExprFunc; AOperPrec: Integer);
|
constructor CreateOper(AName, ATypeSpec: string; AResultType: TExpressionType; AExprFunc: TExprFunc; AOperPrec: Integer);
|
||||||
|
|
||||||
function IsFunction: Boolean; override;
|
function IsFunction: Boolean; override;
|
||||||
|
|||||||
@ -30,8 +30,9 @@ BUGS & WARNINGS
|
|||||||
- no codepage conversion available other than oem<->ansi
|
- no codepage conversion available other than oem<->ansi
|
||||||
- storedefs is not updated automatically when fielddefs are changed
|
- storedefs is not updated automatically when fielddefs are changed
|
||||||
|
|
||||||
|
Changelog:
|
||||||
FreePascal trunk (future V7.0.0):
|
------------------------
|
||||||
|
FreePascal trunk (future V7.0.0): (r* referes to FPC subversion revision/commit)
|
||||||
- add support for memo and index stream so no disk files are needed when using streams
|
- add support for memo and index stream so no disk files are needed when using streams
|
||||||
- clarification on field types; remove some workarounds (r24169) todo: reinstate depending on test set
|
- clarification on field types; remove some workarounds (r24169) todo: reinstate depending on test set
|
||||||
- initial support for (Visual) FoxPro files (r24139)
|
- initial support for (Visual) FoxPro files (r24139)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user