📄 jvquibsqlparser.pas
字号:
{******************************************************************************}
{* WARNING: JEDI VCL To CLX Converter generated unit. *}
{* Manual modifications will be lost on next release. *}
{******************************************************************************}
(* Yacc parser template (TP Yacc V3.0), V1.2 6-17-91 AG *)
(* global definitions: *)
{******************************************************************************}
{ }
{ UNIFIED INTERBASE (UIB) }
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version }
{ 1.0 (the "License"); you may not use this file except in compliance with the }
{ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License. }
{ }
{ The Original Code is JvUIBSQLParser.pas. }
{ }
{ The Initial Developer of the Original Code is documented in the accompanying }
{ help file JCL.chm. Portions created by these individuals are Copyright (C) }
{ 2000 of these individuals. }
{ }
{ SQL Script parser (grammar from Firebird 2 "Parse.y" cvs revision 1.101) }
{ }
{ Unit owner: Henri Gourvest }
{ Last modified: September 7, 2003 }
{ }
{******************************************************************************}
unit JvQUIBSQLParser;
{$I jvcl.inc}
{$I JvUIB.inc}
interface
uses
Classes,
SysUtils;
const
nl = #10;
max_chars = 2048;
max_matches = 1024;
max_rules = 500;
eol : array[0..1] of char = (#13, #10);
yymaxdepth = 1024;
type
TSQLNodeType = (
NodeList,
NodeSelect,
NOdeAlterException,
NodeAlterTable,
NodeAlterTrigger,
NodeAlterProcedure,
NodeAlterDatabase,
NodeAlterDomain,
NodeAlterIndex,
NodeReadBlob,
NodeInsertBlob,
NodeCommit,
NodeRollback,
NodeCreateException,
NodeCreateIndex,
NodeCreateProcedure,
NodeCreateTable,
NodeCreateTrigger,
NodeCreateView,
NodeCreateGenerator,
NodeCreateDatabase,
NodeCreateDomain,
NodeCreateShadow,
NodeCreateRole,
NodeDeclareFilter,
NodeDeclareFunction,
NodeDeleteSearched,
NodeDeletePositioned,
NodeDropException,
NodeDropIndex,
NodeDropProcedure,
NodeDropTable,
NodeDropTrigger,
NodeDropView,
NodeDropFilter,
NodeDropDomain,
NodeDropExternal,
NodeDropShadow,
NodeDropRole,
NodeDropGenerator,
NodeGrant,
NodeRevoke,
NodeInsert,
NodeInvokeProcedure,
NodeRecreateProcedure,
NodeRecreateTable,
NodeRecreateView,
NodeReplace,
NodeSavepointSet,
NodeSavepointRelease,
NodeSavepointUndo,
NodeSetTransaction,
NodeSetGenerator,
NodeSetStatistics,
NodeUpdateSearched,
NodeUpdatePositioned,
NodeDebug,
NodeSetNames,
NodeSetSqlDialect,
NodeSetAutoDDL,
NodeConnect,
NodeName,
NodeUsername,
NodePassWord,
NodePageSize,
NodeLength
);
TPosition = record
line, column, Pos: Integer;
end;
TLexer = class
private
bufptr : Integer;
buf : array [1..max_chars] of Char;
yystext : String;
yysstate, yylstate : Integer;
yymatches : Integer;
yystack : array [1..max_matches] of Integer;
yypos : array [1..max_rules] of Integer;
yysleng : Byte;
public
yyinput{, yyoutput} : TStream;
yyline : String;
yylineno, yycolno : Integer;
yytext : String;
yystate : Integer;
yyactchar : Char;
yylastchar : Char;
yyrule : Integer;
yyreject : Boolean;
yydone : Boolean;
yyretval : Integer;
constructor Create(Stream: TStream); virtual;
function get_char: Char;
procedure unget_char(c: Char );
procedure put_char (c: Char );
procedure echo;
procedure yymore;
procedure yyless (n: Integer);
procedure reject;
procedure returnn(n: Integer);
procedure returnc(c: Char);
procedure start(state: Integer);
function yywrap: Boolean;
procedure yynew;
procedure yyscan;
procedure yymark(n: Integer);
procedure yymatch(n: Integer);
function yyfind(var n: Integer): Boolean;
function yydefault: Boolean;
procedure yyclear;
function yylex : Integer; virtual; abstract;
end;
TSQLNode = class
private
FNodeArg: TList; // array of TSQLNode
FOwner: TSQLNode;
FIndex: Integer;
function GetNodeArg(const Index: Word): TSQLNode;
function GetNodCount: Word;
function GetPosFrom: TPosition;
public
NodeType: TSQLNodeType;
PosTo: TPosition;
Value: string;
property PosFrom: TPosition read GetPosFrom;
constructor Create(NodeType: TSQLNodeType; Childs: array of TSQLNode);
destructor Destroy; override;
property NodesCount: Word read GetNodCount;
property Nodes[const Index: Word]: TSQLNode read GetNodeArg;
end;
TSQLNodeClass = class of TSQLNode;
TNodeTypeInfo = record
Name: string;
Classe: TSQLNodeClass;
end;
TUIBLexer = class(TLexer)
private
FTerm: string;
FInTerm: boolean;
public
function yylex : Integer; override;
constructor Create(Stream: TStream); override;
end;
Tyyflag = (
yyfnone,
yyfaccept,
yyfabort,
yyferror
);
YYSType = TSQLNode;
TOnMessage = procedure(Sender: TObject; const Msg: string) of object;
TGrammar = class
private
FLexer: TLexer;
FOnMessage: TOnMessage;
protected
procedure yyerror(const msg: String); virtual;
public
yychar : Integer;
yynerrs : Integer;
yydebug : Boolean;
yyflag : Tyyflag;
yyerrflag: Integer;
constructor Create(Lexer: TLexer); virtual;
procedure yyclearin;
procedure yyaccept;
procedure yyabort;
procedure yyerrlab;
procedure yyerrok;
property Lexer: TLexer read FLexer;
property OnMessage: TOnMessage read FOnMessage write FOnMessage;
end;
TUIBGrammar = class(TGrammar)
private
FLastPos: TPosition;
function MakeNode(NodeType: TSQLNodeType; Childs: array of TSQLNode;
Value: string = ''): TSQLNode;
public
RootNode: TSQLNode;
function yyparse: Integer;
destructor Destroy; override;
constructor Create(Lexer: TLexer); override;
end;
const ACTIVE = 257;
const ADD = 258;
const AFTER = 259;
const ALL = 260;
const ALTER = 261;
const KW_AND = 262;
const ANY = 263;
const KW_AS = 264;
const ASC = 265;
const AT = 266;
const AVG = 267;
const AUTO = 268;
const BASENAME = 269;
const BEFORE = 270;
const KW_BEGIN = 271;
const BETWEEN = 272;
const BLOB = 273;
const BY = 274;
const CACHE = 275;
const CAST = 276;
const CHARACTER = 277;
const CHECK = 278;
const CHECK_POINT_LEN = 279;
const COLLATE = 280;
const COMMA = 281;
const COMMIT = 282;
const COMMITTED = 283;
const COMPUTED = 284;
const CONCATENATE = 285;
const CONDITIONAL = 286;
const CONSTRAINT = 287;
const CONTAINING = 288;
const COUNT = 289;
const KW_CREATE = 290;
const CSTRING = 291;
const CURRENT = 292;
const CURSOR = 293;
const DATABASE = 294;
const KW_DATE = 295;
const DB_KEY = 296;
const KW_DEBUG = 297;
const DECIMAL = 298;
const DECLARE = 299;
const DEFAULT = 300;
const KW_DELETE = 301;
const DESC = 302;
const DISTINCT = 303;
const KW_DO = 304;
const DOMAIN = 305;
const DROP = 306;
const KW_ELSE = 307;
const KW_END = 308;
const ENTRY_POINT = 309;
const EQL = 310;
const ESCAPE = 311;
const KW_EXCEPTION = 312;
const EXECUTE = 313;
const EXISTS = 314;
const KW_EXIT = 315;
const EXTERNAL = 316;
const FILTER = 317;
const KW_FOR = 318;
const FOREIGN = 319;
const FROM = 320;
const FULL = 321;
const KW_FUNCTION = 322;
const GDSCODE = 323;
const GEQ = 324;
const GENERATOR = 325;
const GEN_ID = 326;
const GRANT = 327;
const GROUP = 328;
const GROUP_COMMIT_WAIT = 329;
const GTR = 330;
const HAVING = 331;
const KW_IF = 332;
const KW_IN = 333;
const INACTIVE = 334;
const INNER = 335;
const INPUT_TYPE = 336;
const INDEX = 337;
const INSERT = 338;
const KW_INTEGER = 339;
const INTO = 340;
const KW_IS = 341;
const ISOLATION = 342;
const JOIN = 343;
const KEY = 344;
const KW_CHAR = 345;
const KW_DEC = 346;
const KW_DOUBLE = 347;
const KW_FILE = 348;
const KW_FLOAT = 349;
const KW_INT = 350;
const KW_LONG = 351;
const KW_NULL = 352;
const KW_NUMERIC = 353;
const KW_UPPER = 354;
const KW_VALUE = 355;
const KW_LENGTH = 356;
const LOGFILE = 357;
const LPAREN = 358;
const LEFT = 359;
const LEQ = 360;
const LEVEL = 361;
const LIKE = 362;
const LOG_BUF_SIZE = 363;
const LSS = 364;
const MANUAL = 365;
const MAXIMUM = 366;
const MAX_SEGMENT = 367;
const MERGE = 368;
const MESSAGE_ = 369;
const MINIMUM = 370;
const MODULE_NAME = 371;
const NAMES = 372;
const NATIONAL = 373;
const NATURAL = 374;
const NCHAR = 375;
const NEQ = 376;
const NO = 377;
const KW_NOT = 378;
const NOT_GTR = 379;
const NOT_LSS = 380;
const NUM_LOG_BUFS = 381;
const KW_OF = 382;
const ON_ = 383;
const ONLY = 384;
const OPTION = 385;
const KW_OR = 386;
const ORDER = 387;
const OUTER = 388;
const OUTPUT_TYPE = 389;
const OVERFLOW = 390;
const PAGE = 391;
const PAGES = 392;
const PAGE_SIZE = 393;
const PARAMETER = 394;
const PASSWORD = 395;
const PLAN = 396;
const POSITION = 397;
const POST_EVENT = 398;
const PRECISION = 399;
const PRIMARY = 400;
const PRIVILEGES = 401;
const KW_PROCEDURE = 402;
const PROTECTED = 403;
const RAW_PARTITIONS = 404;
const READ = 405;
const REAL = 406;
const REFERENCES = 407;
const RESERVING = 408;
const RETAIN = 409;
const RETURNING_VALUES = 410;
const RETURNS = 411;
const REVOKE = 412;
const RIGHT = 413;
const RPAREN = 414;
const ROLLBACK = 415;
const SEGMENT = 416;
const SELECT = 417;
const KW_SET = 418;
const SHADOW = 419;
const KW_SHARED = 420;
const SINGULAR = 421;
const KW_SIZE = 422;
const KW_SMALLINT = 423;
const SNAPSHOT = 424;
const SOME = 425;
const SORT = 426;
const SQLCODE = 427;
const STABILITY = 428;
const STARTING = 429;
const STATISTICS = 430;
const SUB_TYPE = 431;
const SUSPEND = 432;
const SUM = 433;
const TABLE = 434;
const KW_THEN = 435;
const KW_TO = 436;
const TRANSACTION = 437;
const TRIGGER = 438;
const UNCOMMITTED = 439;
const UNION = 440;
const UNIQUE = 441;
const UPDATE = 442;
const USER = 443;
const VALUES = 444;
const VARCHAR = 445;
const VARIABLE = 446;
const VARYING = 447;
const VERSION = 448;
const VIEW = 449;
const WAIT = 450;
const WHEN = 451;
const WHERE = 452;
const KW_WHILE = 453;
const KW_WITH = 454;
const WORK = 455;
const WRITE = 456;
const FLOAT_NUMBER = 457;
const NUMBER = 458;
const NUMERIC = 459;
const SYMBOL = 460;
const KW_STRING = 461;
const INTRODUCER = 462;
const ACTION = 463;
const ADMIN = 464;
const CASCADE = 465;
const FREE_IT = 466;
const RESTRICT = 467;
const ROLE = 468;
const COLUMN = 469;
const KW_TYPE = 470;
const EXTRACT = 471;
const YEAR = 472;
const MONTH = 473;
const DAY = 474;
const HOUR = 475;
const MINUTE = 476;
const SECOND = 477;
const WEEKDAY = 478;
const YEARDAY = 479;
const KW_TIME = 480;
const TIMESTAMP = 481;
const CURRENT_DATE = 482;
const CURRENT_TIME = 483;
const CURRENT_TIMESTAMP = 484;
const NUMBER64BIT = 485;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -