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

📄 bug.y

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 Y
📖 第 1 页 / 共 4 页
字号:
%{
#include <stdio.h>
#include <string.h>
#include "standard.h"
#include "ppsql.h"
#include "pplang.h"
#include "sqlca.h"
#include "rndbinfo.h"
#include "ppsymtab.h"
#include "rnparsdf.h"
#include "pppars.h"

#include "pppact.def"
#include "ppbuff.def"
#include "parsutil.def"

#include "rnlist.def"
#include "rnhostvr.def"
#include "rnpautil.def"
#include "rnstmt.def"
#include "rnfunc.def"

extern void 		LineInfo();

extern char *		actions[];
extern char		*ProgName;
extern a_statement	*Stmt;
extern bool		SQLStmt;

static a_host_type	hostvar_type = { 0 };
static char		buff[200] = { 0 };

#define PT_COLDEFN	1
#define PT_UNIQUE	2
#define PT_KEY		3

#ifdef __TURBOC__
    #define YYTABTYPE	short far
#else
    #define YYTABTYPE	short const far
#endif

#ifdef PARSTREE
    #define T(x)	x
#else
    #define T(x)
#endif

#define yylex		yygettoken

%}

%start sqlprogram


%token <kwd> T_LBRACE
%token <kwd> T_RBRACE
%token <kwd> T_SEMI_COLON
%token <kwd> T_LPAREN
%token <kwd> T_RPAREN
%token <kwd> T_DOT
%token <kwd> T_COMMA
%token <kwd> T_PLUS
%token <kwd> T_MINUS
%token <kwd> T_TIMES
%token <kwd> T_DIVIDE
%token <kwd> T_EXECSQL 
%token <kwd> T_CBLOCK
%token <kwd> T_INITIALIZER
%token <ptr> T_DSTRING
%token <kwd> T_STATVAR
%token <kwd> T_FIXCHAR
%token <kwd> T_LONGVARCHAR
%token <kwd> T_STATIC
%token <kwd> T_EXTERN
%token <kwd> T_REGISTER
%token <kwd> T_UNSIGNED
%token <kwd> T_SHORT
%token <kwd> T_SQL

%token <kwd> T_TOK

%token <kwd>  T_SELECT	256
%token <kwd>  T_AND	257
%token <kwd>  T_OR	258
%token <kwd>  T_COMMIT	259
%token <kwd>  T_ROLLBACK	260
%token <kwd>  T_WORK	261
%token <kwd>  T_INTO	262
%token <kwd>  T_FROM	263
%token <kwd>  T_WHERE	264
%token <kwd>  T_IN	265
%token <kwd>  T_BETWEEN	266
%token <kwd>  T_IS	267
%token <kwd>  T_NOT	268
%token <kwd>  T_NULL	269
%token <kwd>  T_SOME	270
%token <kwd>  T_ANY	271
%token <kwd>  T_EXISTS	272
%token <kwd>  T_LIKE	273
%token <kwd>  T_IF	274
%token <kwd>  T_THEN	275
%token <kwd>  T_ELSE	276
%token <kwd>  T_ENDIF	277
%token <kwd>  T_GROUP	278
%token <kwd>  T_HAVING	279
%token <kwd>  T_ORDER	280
%token <kwd>  T_BY	281
%token <kwd>  T_DELETE	282
%token <kwd>  T_CURRENT	283
%token <kwd>  T_ALTER	284
%token <kwd>  T_TABLE	285
%token <kwd>  T_RENAME	286
%token <kwd>  T_OF	287
%token <kwd>  T_UPDATE	288
%token <kwd>  T_SET	289
%token <kwd>  T_UNION	290
%token <kwd>  T_INSERT	291
%token <kwd>  T_VALUES	292
%token <kwd>  T_CREATE	293
%token <kwd>  T_VIEW	294
%token <kwd>  T_ADD	295
%token <kwd>  T_MODIFY	296
%token <kwd>  T_CHAR	297
%token <kwd>  T_INTEGER	298
%token <kwd>  T_SMALLINT	299
%token <kwd>  T_DECIMAL	300
%token <kwd>  T_NUMERIC	301
%token <kwd>  T_FLOAT	302
%token <kwd>  T_REAL	303
%token <kwd>  T_DOUBLE	304
%token <kwd>  T_PRECISION	305
%token <kwd>  T_VARCHAR	306
%token <kwd>  T_LONG	307
%token <kwd>  T_DATE	308
%token <kwd>  T_TIME	309
%token <kwd>  T_TIMESTAMP	310
%token <kwd>  T_DAYS	311
%token <kwd>  T_USER	312
%token <kwd>  T_PRIMARY	313
%token <kwd>  T_FOREIGN	314
%token <kwd>  T_REFERENCES	315
%token <kwd>  T_KEY	316
%token <kwd>  T_CHECK	317
%token <kwd>  T_FOR	318
%token <kwd>  T_UNIQUE	319
%token <kwd>  T_ON	320
%token <kwd>  T_ASC	321
%token <kwd>  T_DESC	322
%token <kwd>  T_AS	323
%token <kwd>  T_USING	324
%token <kwd>  T_DISTINCT	325
%token <kwd>  T_ALL	326
%token <kwd>  T_OPTION	327
%token <kwd>  T_DROP	328
%token <kwd>  T_INDEX	329
%token <kwd>  T_GRANT	330
%token <kwd>  T_REVOKE	331
%token <kwd>  T_TO	332
%token <kwd>  T_IDENTIFIED	333
%token <kwd>  T_PRIVILEGES	334
%token <kwd>  T_CONNECT	335
%token <kwd>  T_DBA	336
%token <kwd>  T_RESOURCE	337
%token <kwd>  T_SCHEDULE	338
%token <kwd>  T_WITH	339
%token <kwd>  T_LOCK	340
%token <kwd>  T_MODE	341
%token <kwd>  T_DBSPACE	342
%token <kwd>  T_SHARE	343
%token <kwd>  T_EXCLUSIVE	344
%token <kwd>  T_COLUMN	345
%token <kwd>  T_COMMENT	346
%token <kwd>  T_RELEASE	347
%token <kwd>  T_ACQUIRE	348
%token <kwd>  T_NAMED	349
%token <kwd>  T_PUBLIC	350
%token <kwd>  T_AVG	351
%token <kwd>  T_MAX	352
%token <kwd>  T_MIN	353
%token <kwd>  T_SUM	354
%token <kwd>  T_COUNT	355
%token <kwd>  T_SECOND	356
%token <kwd>  T_MINUTE	357
%token <kwd>  T_HOUR	358
%token <kwd>  T_DAY	359
%token <kwd>  T_MONTH	360
%token <kwd>  T_YEAR	361
%token <kwd>  T_MICROSECOND	362
%token <kwd>  T_LEFT	363
%token <kwd>  T_LENGTH	364
%token <kwd>  T_LOWER	365
%token <kwd>  T_LTRIM	366
%token <kwd>  T_RIGHT	367
%token <kwd>  T_RTRIM	368
%token <kwd>  T_SUBSTRING	369
%token <kwd>  T_SUBSTR	370
%token <kwd>  T_UPPER	371
%token <kwd>  T_MILLISECOND	372
%token <kwd>  T_WEEKDAY	373
%token <kwd>  T_ACCELERATED	374
%token <kwd>  T_AUTOINC	375
%token <kwd>  T_BEGINS	376
%token <kwd>  T_BFLOAT	377
%token <kwd>  T_BINARYNULL	378
%token <kwd>  T_BIT	379
%token <kwd>  T_BLANK	380
%token <kwd>  T_CASE	381
%token <kwd>  T_CONTAINS	382
%token <kwd>  T_CREATETAB	383
%token <kwd>  T_CURDATE	384
%token <kwd>  T_CURTIME	385
%token <kwd>  T_DATAPATH	386
%token <kwd>  T_DCOMPRESS	387
%token <kwd>  T_DDPATH	388
%token <kwd>  T_DECIMALNULL	389
%token <kwd>  T_DICTIONARY	390
%token <kwd>  T_EXEC	391
%token <kwd>  T_LOGICAL	392
%token <kwd>  T_LOGIN	393
%token <kwd>  T_LSTRING	394
%token <kwd>  T_LVAR	395
%token <kwd>  T_MASK	396
%token <kwd>  T_MOD	397
%token <kwd>  T_MONEY	398
%token <kwd>  T_NORMAL	399
%token <kwd>  T_NOTE	400
%token <kwd>  T_OPENMODE	401
%token <kwd>  T_OWNER	402
%token <kwd>  T_OWNERACCESS	403
%token <kwd>  T_PAGESIZE	404
%token <kwd>  T_PREALLOCATE	405
%token <kwd>  T_PROCEDURE	406
%token <kwd>  T_RANGE	407
%token <kwd>  T_READONLY	408
%token <kwd>  T_REPLACE	409
%token <kwd>  T_SECURITY	410
%token <kwd>  T_SEG	411
%token <kwd>  T_START	412
%token <kwd>  T_STRINGNULL	413
%token <kwd>  T_THRESHOLD	414
%token <kwd>  T_TRANSACTION	415
%token <kwd>  T_VERIFY	416
%token <kwd>  T_VIEWPATH	417
%token <kwd>  T_ZSTRING	418
%token <kwd>  T_BEGIN	419
%token <kwd>  T_END	420
%token <kwd>  T_GOTO	421
%token <kwd>  T_GO	422
%token <kwd>  T_INCLUDE	423
%token <kwd>  T_SECTION	424
%token <kwd>  T_PREPARE	425
%token <kwd>  T_DESCRIBE	426
%token <kwd>  T_SETTING	427
%token <kwd>  T_STATEMENT	428
%token <kwd>  T_NAMES	429
%token <kwd>  T_LABELS	430
%token <kwd>  T_BOTH	431
%token <kwd>  T_EXECUTE	432
%token <kwd>  T_IMMEDIATE	433
%token <kwd>  T_WHENEVER	434
%token <kwd>  T_SQLERROR	435
%token <kwd>  T_SQLWARNING	436
%token <kwd>  T_NOTFOUND	437
%token <kwd>  T_FOUND	438
%token <kwd>  T_CONTINUE	439
%token <kwd>  T_STOP	440
%token <kwd>  T_DECLARE	441
%token <kwd>  T_SCROLL	442
%token <kwd>  T_CURSOR	443
%token <kwd>  T_OPEN	444
%token <kwd>  T_REOPEN	445
%token <kwd>  T_DESCRIPTOR	446
%token <kwd>  T_FETCH	447
%token <kwd>  T_NEXT	448
%token <kwd>  T_PRIOR	449
%token <kwd>  T_FIRST	450
%token <kwd>  T_LAST	451
%token <kwd>  T_ABSOLUTE	452
%token <kwd>  T_RELATIVE	453
%token <kwd>  T_PUT	454
%token <kwd>  T_CLOSE	455
%token <kwd>  T_LIST	456
%token <kwd>  T_BIND	457
%token <kwd>  T_VARIABLES	458
%token <kwd>  T_GET	459
%token <kwd>  T_DATABASE	460
%token <kwd>  T_DEFAULT	461
%token <kwd>  T_INSENSITIVE	462
%token <kwd>  T_READ	463
%token <kwd>  T_ONLY	464

%type <ptr>  sqlprogram stmt execsql embsqlstmt 
%type <ptr>  open reopen id_spec id_indspec structure_spec
%type <ptr>  using_sqlda using_sqlda_ne 
%type <ptr>  fetch indhostlist intohostlist put putkwd 
%type <ptr>  close declare declare_tok scroll 
%type <ptr>  insert_stmt select_stmt describe
%type <ptr>  updatecursor delete onetabspec
%type <ptr>  offset
%type <ival> direction 
%type <info> position
%type <ptr>  statement_spec ppprogname prepare prepusing dropstmt
%type <ptr>  execute string_spec
%type <ptr>  indhostvar embhostvar intohostvar
%type <ptr>  whenever when_action when_action2
%type <ptr>  include declarations begin_decl declexecsql
%type <ptr>  end_decl var_decl_list var_decl type_specifier intlist intlist1
%type <ptr>  initializer
%type <ptr>  declarator_list declarator declarator2 connect 
%type <ptr>  defuid database dictionary
%type <ptr>  notfound goto
%type <ptr>  setoption getoption get_using
%type <ptr>  selinto2 

%type <uval> desc_using desc_using_element describe_type

%type <hosttype> pointer



 /************************************************************************
 *	 Copyright (C) 1989, by PACE Computing Solutions Inc. All rights *
 *	 reserved. No part of this software may be reproduced		 *
 *	 in any form or by any means - graphic, electronic or		 *
 *	 mechanical, including photocopying, recording, taping		 *
 *	 or information storage and retrieval systems - except		 *
 *	 with the written permission of PACE Computing Solutions Inc.	 *
 *************************************************************************/


%{
static void		*update_collist = NULL;
static void		*tabrefs = NULL;
extern bool		SelectStmt;
extern bool		StoredProcedure;
extern bool		GotHostVar;

#define	yyparse		paceparse
%}

%token <kwd>  T_BADTOK
%token <kwd>  T_EQ
%token <kwd>  T_NE
%token <kwd>  T_GT
%token <kwd>  T_LT
%token <kwd>  T_LE
%token <kwd>  T_GE
%token <kwd>  T_DOTSTAR
%token <ptr>  T_IDENTIFIER
%token <ptr>  T_NUMBER
%token <ptr>  T_STRING
%token <ptr>  T_HOSTVAR
%token <ptr>  T_SPPARM
%token <ptr>  T_LONGINT

%type <ptr>  hostvar selinto
%type <ptr>  sqlstmt 
%type <ptr>  select selectlist sellist selvalue expression
%type <ptr>  expression_nosub expression_notnull
%type <ptr>  query_expr query_term query_spec query_union query_unionall
%type <ptr>  order_by_clause orderbylistrev orderbylist orderbyitem
%type <ptr>  for_update_clause
%type <ptr>  builtin constant string special_register
%type <ptr>  from tabspec tabexprlist tabexprlistrev tabexpr onetabspec tabref
%type <ptr>  corrname tabname indexname colname colref colreflist colreflistrev
%type <ptr>  where searchcond
%type <ptr>  boolterm boolfactor boolprimary srchpred
%type <ptr>  vallist vallistrev valitem
%type <ptr>  subquery single_subquery quantified_subquery
%type <ptr>  groupby having
%type <ptr>  delete wherecurrentof
%type <ptr>  update sets setlist setitem
%type <ptr>  insert insertvalues 
%type <ptr>  ins_vallist ins_vallistrev ins_valitem
%type <ptr>  columns collist collistrev
%type <ptr>  commenton
%type <ptr>  createtable tblelmtlist rolename fgnkeycols fgnkeycollist fgnkeycol
%type <ptr>  inclause optcomma
%type <info> createclause
%type <ptr>  createindex indexlist indexlistrev indexcol 
%type <ival> indexattr indexattrlist indexattrlist1
/* 
%type <ptr>  createprogram create_options dropprogram
%type <ival> op_keep op_describe op_replace op_modify op_block
*/
%type <ptr>  createview
%type <ptr>  alter alter_delete alter_clause coldefn modcoldefn data_type
%type <ptr>  number integer
%type <ptr>  droptable dropindex dropview 
%type <ptr>  grant granttok revoketok 
%type <ptr>  userlist userlistrev userid
%type <ptr>  passwdlist passwdlistrev password priv_columns
%type <ptr>  revoke dbspacename
%type <ptr>  lock lockmode
%type <ptr>  commit rollback parameter parmlist
%type <ptr>  distinct runid_spec

%type <ival> not summarizer unique
%type <ival> comp_op quantifier duration
%type <ival> grantoption checkclause notnull 
%type <ival> tableprivileges tableprivlist tablepriv specialpriv

%type <uval> char_type integer_type exact_num_type float_type


%right T_CONCAT
%left T_PLUS T_MINUS
%left T_TIMES T_DIVIDE
%left T_JOIN

%%

sqlstmt:	alter
		    { T($$ = pa_make_stmt( STMT_ALTER, $1 ); )}
	    |	commenton
		    { T($$ = pa_make_stmt( STMT_COMMENTON, $1 ); )}
	    |	createtable
		    { T($$ = pa_make_stmt( STMT_CREATETABLE, $1 ); )}
	    |	createindex
		    { T($$ = pa_make_stmt( STMT_CREATEINDEX, $1 ); )}
	    |	createview
		    { T($$ = pa_make_stmt( STMT_CREATEVIEW, $1 ); )}
	    /*
	    |	createprogram
		    { T($$ = pa_make_stmt( STMT_CREATEPROGRAM, $1 ); )}
	    |	dropprogram
		    { T($$ = pa_make_stmt( STMT_DROPPROGRAM, $1 ); )}
            */
	    |	delete
		    { T($$ = pa_make_stmt( STMT_DELETE, $1 ); )}
	    |	droptable
		    { T($$ = pa_make_stmt( STMT_DROPTABLE, $1 ); )}
	    |	dropindex
		    { T($$ = pa_make_stmt( STMT_DROPINDEX, $1 ); )}
	    |	dropview
		    { T($$ = pa_make_stmt( STMT_DROPVIEW, $1 ); )}
	    |	grant
		    { T($$ = pa_make_stmt( STMT_GRANT, $1 ); )}
	    |	revoke
		    { T($$ = pa_make_stmt( STMT_REVOKE, $1 ); )}
	    |	insert
		    { T($$ = pa_make_stmt( STMT_INSERT, $1 ); )}
	    |	lock
		    { T($$ = pa_make_stmt( STMT_LOCK, $1 ); )}
	    |	{SelectStmt=TRUE;}  select
		    { T($$ = pa_make_stmt( STMT_SELECT, $2 ); )}
	    |	update
		    { T($$ = pa_make_stmt( STMT_UPDATE, $1 ); )}
	    |	commit
		    { T($$ = pa_make_stmt( STMT_COMMIT, $1 ); )}
	    |	rollback
		    { T($$ = pa_make_stmt( STMT_ROLLBACK, $1 ); )}
	    ;

select: 	query_expr  order_by_clause  for_update_clause
		    {T( $$ = pa_query( $1, $2 ); )}
	    ;

order_by_clause:    /* empty */
		    {T( $$ = NULL; )}
	    |	T_ORDER  T_BY  orderbylist
		    {T( $$ = $3; )}
	    ;

for_update_clause:  /* empty */
		    {T( $$ = NULL; )}
	    |	T_FOR  T_UPDATE  T_OF  colreflist
		    {  pa_specific( L_SAA );
		    T( $$ = $4; 
		    )}
	    ;

orderbylist:	orderbylistrev	optcomma
		    {T( $$ = pa_reverse_plist( $1 ); )}
	    ;

orderbylistrev: orderbyitem
		    {T( $$ = pa_iadd_plist( NULL, $1 ); )}
	    |	orderbylistrev	T_COMMA  orderbyitem
		    {T( $$ = pa_iadd_plist( $1, $3 ); )}
	    ;

orderbyitem:	expression
		    {T( $$ = pa_orderitem( $1, IA_ASC ); )}
	    |	expression  T_ASC
		    {T( $$ = pa_orderitem( $1, IA_ASC ); )}
	    |	expression  T_DESC
		    {T( $$ = pa_orderitem( $1, IA_DESC ); )}
	    ;

query_expr:	query_term
	    |	query_union
	    |	query_unionall
	    ;

query_unionall: query_unionall	T_UNION  T_ALL	query_term
		    {T( $$ = pa_binary_expr( E_UNIONALL, $1, $4 ); )}

⌨️ 快捷键说明

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