📄 jvquibsqlparser.pas
字号:
const SCALEDINT = 486;
const CURRENT_USER = 487;
const CURRENT_ROLE = 488;
const KW_BREAK = 489;
const SUBSTRING = 490;
const RECREATE = 491;
const KW_DESCRIPTOR = 492;
const FIRST = 493;
const SKIP = 494;
const CURRENT_CONNECTION = 495;
const CURRENT_TRANSACTION = 496;
const BIGINT = 497;
const KW_CASE = 498;
const NULLIF = 499;
const COALESCE = 500;
const USING = 501;
const NULLS = 502;
const LAST = 503;
const ROW_COUNT = 504;
const LOCK = 505;
const SAVEPOINT = 506;
const RELEASE = 507;
const STATEMENT = 508;
const LEAVE = 509;
const INSERTING = 510;
const UPDATING = 511;
const DELETING = 512;
const KW_INSERTING = 513;
const KW_UPDATING = 514;
const KW_DELETING = 515;
const BACKUP = 516;
const KW_DIFFERENCE = 517;
const LARRAY = 518;
const RARRAY = 519;
const COLON = 520;
const SCOLON = 521;
const PLUS = 522;
const MINUS = 523;
const STAR = 524;
const SLASH = 525;
const DOT = 526;
const VPARAM = 527;
const SQL = 528;
const DIALECT = 529;
const AUTODDL = 530;
const CONNECT = 531;
implementation
{$IFDEF UNITVERSIONING}
uses
JclUnitVersioning;
{$ENDIF UNITVERSIONING}
function TLexer.get_char: Char;
var
i: Integer;
c: char;
function eof(stream: TStream): boolean;
begin
Result := stream.Position = stream.Size
end;
begin
if (bufptr = 0) and not eof(yyinput) then
begin
yyline := '';
repeat
if (yyinput.Read(c, 1) = 1) and (not (c in [#13, #10, #0])) then
yyline := yyline + c else
begin
// if (c = #13) then
// yyinput.Read(c, 1); // read #10
Break;
end;
until False;
inc(yylineno);
yycolno := 1;
buf[1] := nl;
for i := 1 to length(yyline) do
buf[i+1] := yyline[length(yyline)-i+1];
inc(bufptr, length(yyline)+1);
end;
if (bufptr > 0) then
begin
get_char := buf[bufptr];
dec(bufptr);
inc(yycolno);
end
else
get_char := #0;
end;
procedure TLexer.unget_char(c: Char);
begin
if (bufptr = max_chars) then
raise Exception.Create('input buffer overflow');
inc(bufptr);
dec(yycolno);
buf[bufptr] := c;
end;
procedure TLexer.put_char(c: Char);
begin
end;
(* Utilities: *)
procedure TLexer.echo;
var i : Integer;
begin
for i := 1 to length(yytext) do
put_char(yytext[i])
end;
procedure TLexer.yymore;
begin
yystext := yytext;
end;
procedure TLexer.yyless(n: Integer);
var i : Integer;
begin
for i := length(yytext) downto n+1 do
unget_char(yytext[i]);
setlength(yytext, n)
end;
procedure TLexer.reject;
var i : Integer;
begin
yyreject := true;
for i := length(yytext) + 1 to yysleng do
yytext := yytext + get_char;
dec(yymatches);
end;
procedure TLexer.returnn ( n : Integer );
begin
yyretval := n;
yydone := true;
end;
procedure TLexer.returnc(c: Char);
begin
yyretval := ord(c);
yydone := true;
end;
procedure TLexer.start(state: Integer);
begin
yysstate := state;
end;
function TLexer.yywrap: Boolean;
begin
yyinput.Seek(0, soFromBeginning);
yywrap := true;
end;
(* Internal routines: *)
procedure TLexer.yynew;
begin
if yylastchar <> #0 then
if yylastchar = nl then
yylstate := 1
else
yylstate := 0;
yystate := yysstate+yylstate;
yytext := yystext;
yystext := '';
yymatches := 0;
yydone := false;
end;
procedure TLexer.yyscan;
begin
yyactchar := get_char;
setlength(yytext, length(yytext) + 1);
yytext[length(yytext)] := yyactchar;
end;
procedure TLexer.yymark(n: Integer);
begin
if (n > max_rules) then
raise Exception.Create('too many rules');
yypos[n] := length(yytext);
end;
procedure TLexer.yymatch(n: Integer);
begin
inc(yymatches);
if (yymatches > max_matches) then
raise Exception.Create('match stack overflow');
yystack[yymatches] := n;
end;
function TLexer.yyfind(var n: Integer): Boolean;
begin
yyreject := false;
while (yymatches > 0) and
(yypos[yystack[yymatches]] = 0) do
dec(yymatches);
if (yymatches > 0) then
begin
yysleng := length(yytext);
n := yystack[yymatches];
yyless(yypos[n]);
yypos[n] := 0;
if (length(yytext) > 0) then
yylastchar := yytext[length(yytext)]
else
yylastchar := #0;
yyfind := true;
end
else
begin
yyless(0);
yylastchar := #0;
yyfind := false;
end
end;
function TLexer.yydefault: Boolean;
begin
yyreject := false;
yyactchar := get_char;
if (yyactchar <> #0) then
begin
put_char(yyactchar);
yydefault := true;
end
else
begin
yylstate := 1;
yydefault := false;
end;
yylastchar := yyactchar;
end;
procedure TLexer.yyclear;
begin
bufptr := 0;
yysstate := 0;
yylstate := 1;
yylastchar := #0;
yytext := '';
yystext := '';
end;
constructor TLexer.Create(Stream: TStream);
begin
Assert(Stream <> nil);
yyinput := Stream;
yylineno := 0;
yyclear;
end;
{ TGrammar }
procedure TGrammar.yyclearin;
begin
yychar := -1;
end;
procedure TGrammar.yyaccept;
begin
yyflag := yyfaccept;
end;
procedure TGrammar.yyabort;
begin
yyflag := yyfabort;
end;
procedure TGrammar.yyerrlab;
begin
yyflag := yyferror;
end;
procedure TGrammar.yyerrok;
begin
yyerrflag := 0;
end;
constructor TGrammar.Create(Lexer: TLexer);
begin
FLexer := Lexer;
end;
procedure TGrammar.yyerror(const msg: String);
begin
if Assigned(FOnMessage) then
FOnMessage(Self, msg);
end;
(* lexical analyzer template (TP Lex V3.0), V1.0 3-2-91 AG *)
(* global definitions: *)
type
tok = record
tok_ident: word;
tok_string: string;
tok_version: word;
end;
const
MaxTokens = 247;
tokens: array[0..MaxTokens - 1] of tok =
((tok_ident: SQL; tok_string: 'SQL'; tok_version: 0),
(tok_ident: DIALECT; tok_string: 'DIALECT'; tok_version: 0),
(tok_ident: AUTODDL; tok_string: 'AUTODDL'; tok_version: 0),
(tok_ident: CONNECT; tok_string: 'CONNECT'; tok_version: 0),
(tok_ident: ACTION; tok_string: 'ACTION'; tok_version: 1),
(tok_ident: ACTIVE; tok_string: 'ACTIVE'; tok_version: 1),
(tok_ident: ADD; tok_string: 'ADD'; tok_version: 1),
(tok_ident: ADMIN; tok_string: 'ADMIN'; tok_version: 1),
(tok_ident: AFTER; tok_string: 'AFTER'; tok_version: 1),
(tok_ident: ALL; tok_string: 'ALL'; tok_version: 1),
(tok_ident: ALTER; tok_string: 'ALTER'; tok_version: 1),
(tok_ident: KW_AND; tok_string: 'AND'; tok_version: 1),
(tok_ident: ANY; tok_string: 'ANY'; tok_version: 1),
(tok_ident: KW_AS; tok_string: 'AS'; tok_version: 1),
(tok_ident: ASC; tok_string: 'ASC'; tok_version: 1), (* Alias of ASCENDING *)
(tok_ident: ASC; tok_string: 'ASCENDING'; tok_version: 1),
(tok_ident: AT; tok_string: 'AT'; tok_version: 1),
(tok_ident: AUTO; tok_string: 'AUTO'; tok_version: 1),
(tok_ident: AVG; tok_string: 'AVG'; tok_version: 1),
(tok_ident: BACKUP; tok_string: 'BACKUP'; tok_version: 2),
(tok_ident: BASENAME; tok_string: 'BASE_NAME'; tok_version: 1), (* ??? *)
(tok_ident: BEFORE; tok_string: 'BEFORE'; tok_version: 1),
(tok_ident: KW_BEGIN; tok_string: 'BEGIN'; tok_version: 1),
(tok_ident: BETWEEN; tok_string: 'BETWEEN'; tok_version: 1),
(tok_ident: BIGINT; tok_string: 'BIGINT'; tok_version: 2),
(tok_ident: BLOB; tok_string: 'BLOB'; tok_version: 1),
(tok_ident: KW_BREAK; tok_string: 'BREAK'; tok_version: 2),
(tok_ident: BY; tok_string: 'BY'; tok_version: 1),
(tok_ident: CACHE; tok_string: 'CACHE'; tok_version: 1),
(tok_ident: CASCADE; tok_string: 'CASCADE'; tok_version: 1),
(tok_ident: KW_CASE; tok_string: 'CASE'; tok_version: 2),
(tok_ident: CAST; tok_string: 'CAST'; tok_version: 1),
(tok_ident: KW_CHAR; tok_string: 'CHAR'; tok_version: 1),
(tok_ident: CHARACTER; tok_string: 'CHARACTER'; tok_version: 1),
(tok_ident: CHECK; tok_string: 'CHECK'; tok_version: 1),
(tok_ident: CHECK_POINT_LEN; tok_string: 'CHECK_POINT_LENGTH'; tok_version: 1),
(tok_ident: COALESCE; tok_string: 'COALESCE'; tok_version: 2),
(tok_ident: COLLATE; tok_string: 'COLLATE'; tok_version: 1),
(tok_ident: COLUMN; tok_string: 'COLUMN'; tok_version: 2),
(tok_ident: COMMIT; tok_string: 'COMMIT'; tok_version: 1),
(tok_ident: COMMITTED; tok_string: 'COMMITTED'; tok_version: 1),
(tok_ident: COMPUTED; tok_string: 'COMPUTED'; tok_version: 1),
(tok_ident: CONDITIONAL; tok_string: 'CONDITIONAL'; tok_version: 1),
(tok_ident: CONSTRAINT; tok_string: 'CONSTRAINT'; tok_version: 1),
(tok_ident: CONTAINING; tok_string: 'CONTAINING'; tok_version: 1),
(tok_ident: COUNT; tok_string: 'COUNT'; tok_version: 1),
(tok_ident: KW_CREATE; tok_string: 'CREATE'; tok_version: 1),
(tok_ident: CSTRING; tok_string: 'CSTRING'; tok_version: 1),
(tok_ident: CURRENT; tok_string: 'CURRENT'; tok_version: 1),
(tok_ident: CURRENT_CONNECTION; tok_string: 'CURRENT_CONNECTION'; tok_version: 2),
(tok_ident: CURRENT_DATE; tok_string: 'CURRENT_DATE'; tok_version: 2),
(tok_ident: CURRENT_ROLE; tok_string: 'CURRENT_ROLE'; tok_version: 2),
(tok_ident: CURRENT_TIME; tok_string: 'CURRENT_TIME'; tok_version: 2),
(tok_ident: CURRENT_TIMESTAMP; tok_string: 'CURRENT_TIMESTAMP'; tok_version: 2),
(tok_ident: CURRENT_TRANSACTION; tok_string: 'CURRENT_TRANSACTION'; tok_version: 2),
(tok_ident: CURRENT_USER; tok_string: 'CURRENT_USER'; tok_version: 2),
(tok_ident: CURSOR; tok_string: 'CURSOR'; tok_version: 1),
(tok_ident: DATABASE; tok_string: 'DATABASE'; tok_version: 1),
(tok_ident: KW_DATE; tok_string: 'DATE'; tok_version: 1),
(tok_ident: DAY; tok_string: 'DAY'; tok_version: 2),
(tok_ident: KW_DEBUG; tok_string: 'DEBUG'; tok_version: 1),
(tok_ident: KW_DEC; tok_string: 'DEC'; tok_version: 1),
(tok_ident: DECIMAL; tok_string: 'DECIMAL'; tok_version: 1),
(tok_ident: DECLARE; tok_string: 'DECLARE'; tok_version: 1),
(tok_ident: DEFAULT; tok_string: 'DEFAULT'; tok_version: 1),
(tok_ident: KW_DELETE; tok_string: 'DELETE'; tok_version: 1),
(tok_ident: DELETING; tok_string: 'DELETING'; tok_version: 2),
(tok_ident: DESC; tok_string: 'DESC'; tok_version: 1), (* Alias of DESCENDING *)
(tok_ident: DESC; tok_string: 'DESCENDING'; tok_version: 1),
(tok_ident: KW_DESCRIPTOR; tok_string: 'DESCRIPTOR'; tok_version: 2),
(tok_ident: KW_DIFFERENCE; tok_string: 'DIFFERENCE'; tok_version: 2),
(tok_ident: DISTINCT; tok_string: 'DISTINCT'; tok_version: 1),
(tok_ident: KW_DO; tok_string: 'DO'; tok_version: 1),
(tok_ident: DOMAIN; tok_string: 'DOMAIN'; tok_version: 1),
(tok_ident: KW_DOUBLE; tok_string: 'DOUBLE'; tok_version: 1),
(tok_ident: DROP; tok_string: 'DROP'; tok_version: 1),
(tok_ident: KW_ELSE; tok_string: 'ELSE'; tok_version: 1),
(tok_ident: KW_END; tok_string: 'END'; tok_version: 1),
(tok_ident: ENTRY_POINT; tok_string: 'ENTRY_POINT'; tok_version: 1),
(tok_ident: ESCAPE; tok_string: 'ESCAPE'; tok_version: 1),
(tok_ident: KW_EXCEPTION; tok_string: 'EXCEPTION'; tok_version: 1),
(tok_ident: EXECUTE; tok_string: 'EXECUTE'; tok_version: 1),
(tok_ident: EXISTS; tok_string: 'EXISTS'; tok_version: 1),
(tok_ident: KW_EXIT; tok_string: 'EXIT'; tok_version: 1),
(tok_ident: EXTERNAL; tok_string: 'EXTERNAL'; tok_version: 1),
(tok_ident: EXTRACT; tok_string: 'EXTRACT'; tok_version: 2),
(tok_ident: KW_FILE; tok_string: 'FILE'; tok_version: 1),
(tok_ident: FILTER; tok_string: 'FILTER'; tok_version: 1),
(tok_ident: FIRST; tok_string: 'FIRST'; tok_version: 2),
(tok_ident: KW_FLOAT; tok_string: 'FLOAT'; tok_version: 1),
(tok_ident: KW_FOR; tok_string: 'FOR'; tok_version: 1),
(tok_ident: FOREIGN; tok_string: 'FOREIGN'; tok_version: 1),
(tok_ident: FREE_IT; tok_string: 'FREE_IT'; tok_version: 1),
(tok_ident: FROM; tok_string: 'FROM'; tok_version: 1),
(tok_ident: FULL; tok_string: 'FULL'; tok_version: 1),
(tok_ident: KW_FUNCTION; tok_string: 'FUNCTION'; tok_version: 1),
(tok_ident: GDSCODE; tok_string: 'GDSCODE'; tok_version: 1),
(tok_ident: GENERATOR; tok_string: 'GENERATOR'; tok_version: 1),
(tok_ident: GEN_ID; tok_string: 'GEN_ID'; tok_version: 1),
(tok_ident: GRANT; tok_string: 'GRANT'; tok_version: 1),
(tok_ident: GROUP; tok_string: 'GROUP'; tok_version: 1),
(tok_ident: GROUP_COMMIT_WAIT; tok_string: 'GROUP_COMMIT_WAIT_TIME'; tok_version: 1),
(tok_ident: HAVING; tok_string: 'HAVING'; tok_version: 1),
(tok_ident: HOUR; tok_string: 'HOUR'; tok_version: 2),
(tok_ident: KW_IF; tok_string: 'IF'; tok_version: 1),
(tok_ident: KW_IN; tok_string: 'IN'; tok_version: 1),
(tok_ident: INACTIVE; tok_string: 'INACTIVE'; tok_version: 1),
(tok_ident: INDEX; tok_string: 'INDEX'; tok_version: 1),
(tok_ident: INNER; tok_string: 'INNER'; tok_version: 1),
(tok_ident: INPUT_TYPE; tok_string: 'INPUT_TYPE'; tok_version: 1),
(tok_ident: INSERT; tok_string: 'INSERT'; tok_version: 1),
(tok_ident: INSERTING; tok_string: 'INSERTING'; tok_version: 2),
(tok_ident: KW_INT; tok_string: 'INT'; tok_version: 1),
(tok_ident: KW_INTEGER; tok_string: 'INTEGER'; tok_version: 1),
(tok_ident: INTO; tok_string: 'INTO'; tok_version: 1),
(tok_ident: KW_IS; tok_string: 'IS'; tok_version: 1),
(tok_ident: ISOLATION; tok_string: 'ISOLATION'; tok_version: 1),
(tok_ident: JOIN; tok_string: 'JOIN'; tok_version: 1),
(tok_ident: KEY; tok_string: 'KEY'; tok_version: 1),
(tok_ident: LAST; tok_string: 'LAST'; tok_version: 2),
(tok_ident: LEAVE; tok_string: 'LEAVE'; tok_version: 2),
(tok_ident: LEFT; tok_string: 'LEFT'; tok_version: 1),
(tok_ident: KW_LENGTH; tok_string: 'LENGTH'; tok_version: 1),
(tok_ident: LEVEL; tok_string: 'LEVEL'; tok_version: 1),
(tok_ident: LIKE; tok_string: 'LIKE'; tok_version: 1),
(tok_ident: LOGFILE; tok_string: 'LOGFILE'; tok_version: 1),
(tok_ident: LOG_BUF_SIZE; tok_string: 'LOG_BUFFER_SIZE'; tok_version: 1),
(tok_ident: KW_LONG; tok_string: 'LONG'; tok_version: 1),
(tok_ident: MANUAL; tok_string: 'MANUAL'; tok_version: 1),
(tok_ident: MAXIMUM; tok_string: 'MAX'; tok_version: 1),
(tok_ident: MAX_SEGMENT; tok_string: 'MAXIMUM_SEGMENT'; tok_version: 1),
(tok_ident: MERGE; tok_string: 'MERGE'; tok_version: 1),
(tok_ident: MESSAGE_; tok_string: 'MESSAGE'; tok_version: 1),
(tok_ident: MINIMUM; tok_string: 'MIN'; tok_version: 1),
(tok_ident: MINUTE; tok_string: 'MINUTE'; tok_version: 2),
(tok_ident: MODULE_NAME; tok_string: 'MODULE_NAME'; tok_version: 1),
(tok_ident: MONTH; tok_string: 'MONTH'; tok_version: 2),
(tok_ident: NAMES; tok_string: 'NAMES'; tok_version: 1),
(tok_ident: NATIONAL; tok_string: 'NATIONAL'; tok_version: 1),
(tok_ident: NATURAL; tok_string: 'NATURAL'; tok_version: 1),
(tok_ident: NCHAR; tok_string: 'NCHAR'; tok_version: 1),
(tok_ident: NO; tok_string: 'NO'; tok_version: 1),
(tok_ident: KW_NOT; tok_string: 'NOT'; tok_version: 1),
(tok_ident: NULLIF; tok_string: 'NULLIF'; tok_version: 2),
(tok_ident: KW_NULL; tok_string: 'NULL'; tok_version: 1),
(tok_ident: NULLS; tok_string: 'NULLS'; tok_version: 2),
(tok_ident: LOCK; tok_string: 'LOCK'; tok_version: 2),
(tok_ident: KW_NUMERIC; tok_string: 'NUMERIC'; tok_version: 1),
(tok_ident: NUM_LOG_BUFS; tok_string: 'NUM_LOG_BUFFERS'; tok_version: 1),
(tok_ident: KW_OF; tok_string: 'OF'; tok_version: 1),
(tok_ident: ON_; tok_string: 'ON'; tok_version: 1),
(tok_ident: ONLY; tok_string: 'ONLY'; tok_version: 1),
(tok_ident: OPTION; tok_string: 'OPTION'; tok_version: 1),
(tok_ident: KW_OR; tok_string: 'OR'; tok_version: 1),
(tok_ident: ORDER; tok_string: 'ORDER'; tok_version: 1),
(tok_ident: OUTER; tok_string: 'OUTER'; tok_version: 1),
(tok_ident: OUTPUT_TYPE; tok_string: 'OUTPUT_TYPE'; tok_version: 1),
(tok_ident: OVERFLOW; tok_string: 'OVERFLOW'; tok_version: 1),
(tok_ident: PAGE; tok_string: 'PAGE'; tok_version: 1),
(tok_ident: PAGES; tok_string: 'PAGES'; tok_version: 1),
(tok_ident: PAGE_SIZE; tok_string: 'PAGE_SIZE'; tok_version: 1),
(tok_ident: PARAMETER; tok_string: 'PARAMETER'; tok_version: 1),
(tok_ident: PASSWORD; tok_string: 'PASSWORD'; tok_version: 1),
(tok_ident: PLAN; tok_string: 'PLAN'; tok_version: 1),
(tok_ident: POSITION; tok_string: 'POSITION'; tok_version: 1),
(tok_ident: POST_EVENT; tok_string: 'POST_EVENT'; tok_version: 1),
(tok_ident: PRECISION; tok_string: 'PRECISION'; tok_version: 1),
(tok_ident: PRIMARY; tok_string: 'PRIMARY'; tok_version: 1),
(tok_ident: PRIVILEGES; tok_string: 'PRIVILEGES'; tok_version: 1),
(tok_ident: KW_PROCEDURE; tok_string: 'PROCEDURE'; tok_version: 1),
(tok_ident: PROTECTED; tok_string: 'PROTECTED'; tok_version: 1),
(tok_ident: RAW_PARTITIONS; tok_string: 'RAW_PARTITIONS'; tok_version: 1),
(tok_ident: DB_KEY; tok_string: 'RDB$DB_KEY'; tok_version: 1),
(tok_ident: READ; tok_string: 'READ'; tok_version: 1),
(tok_ident: REAL; tok_string: 'REAL'; tok_version: 1),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -