The EgStrParser library is contained in a single unit:
EgStrParser. It has no dependency on VCL, FMX, or any
external library. It can be used in any Delphi application — desktop,
service, or console — by adding it to the uses clause.
uses
EgStrParser;The library exposes ParseInput, which accepts a raw text
string and a declared data type, and returns a TParseResult
record containing the parsed values and the corresponding SQL
fragment.
var
R: TParseResult;
begin
R := ParseInput(Edit1.Text, itDate);
if R.ResultType <> otInvalid then
Query1.SQL.Text := 'SELECT * FROM Orders WHERE OrderDate ' + R.SQLExpression;
end;ParseInput always returns a fully populated
TParseResult and never raises an exception for invalid
input. ResultType indicates what the parser found;
ErrorCode gives the reason when ResultType is
otInvalid. See Types and constants for the
complete field reference and Error
codes for error handling guidance.
The format of date, time, datetime, and boolean literals in
SQLExpression depends on the target database. The dialect
is set once per application with SetSQLDialect, or supplied
per call via the full overload of ParseInput. The default
is sqlElevateDB. See SQL
dialects for the complete format reference.
The TEgStrParser component (unit
EgStrParserComp) wraps the library and adds design-time
configuration of the dialect, default options, default range separator,
and default operator. Use the library directly when no component
infrastructure is needed, or when calling from worker threads with an
explicit dialect per call. See The
TEgStrParser component for details.