提交 23db70bf 编写于 作者: B Bruce Momjian

Lex/yacc source cleanup like indent.

上级 319dbfa7
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.4 1996/11/13 20:47:45 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.5 1997/09/08 03:19:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -57,10 +57,12 @@
#include "miscadmin.h"
#define DO_START { StartTransactionCommand();\
#define DO_START { \
StartTransactionCommand();\
}
#define DO_END { CommitTransactionCommand();\
#define DO_END { \
CommitTransactionCommand();\
if (!Quiet) { EMITPROMPT; }\
fflush(stdout); \
}
......@@ -70,7 +72,8 @@ static Oid objectid;
%}
%union {
%union
{
List *list;
IndexElem *ielem;
char *str;
......@@ -146,18 +149,21 @@ CreateStmt:
}
typelist
{
if (!Quiet) putchar('\n');
if (!Quiet)
putchar('\n');
DO_END;
}
RPAREN
{
DO_START;
if ($2) {
if ($2)
{
extern Relation reldesc;
TupleDesc tupdesc;
if (reldesc) {
if (reldesc)
{
puts("create bootstrap: Warning, open relation");
puts("exists, closing first");
closerel(NULL);
......@@ -170,7 +176,9 @@ CreateStmt:
tupdesc);
if (DebugMode)
puts("bootstrap relation created ok");
} else {
}
else
{
Oid id;
TupleDesc tupdesc;
/* extern Oid heap_create();*/
......@@ -203,7 +211,8 @@ InsertStmt:
{
if (num_tuples_read != numattr)
elog(WARN,"incorrect number of values for tuple");
if (reldesc == (Relation)NULL) {
if (reldesc == (Relation)NULL)
{
elog(WARN,"must OPEN RELATION before INSERT\n");
err_out();
}
......@@ -213,7 +222,8 @@ InsertStmt:
InsertOneTuple(objectid);
if (DebugMode)
puts("Insert End");
if (!Quiet) { putchar('\n'); }
if (!Quiet)
putchar('\n');
DO_END;
if (DebugMode)
puts("Transaction End");
......@@ -319,5 +329,3 @@ ident :
ID { $$=yylval.ival; }
;
%%
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.6 1997/01/10 20:16:26 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.7 1997/09/08 03:19:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.42 1997/09/04 13:24:25 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.43 1997/09/08 03:19:57 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -71,7 +71,8 @@ static Node *makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr);
%}
%union {
%union
{
double dval;
int ival;
char chr;
......@@ -407,8 +408,7 @@ OptDefault: DEFAULT default_expr
char *defval;
defval = (char*) palloc (deflen + 1);
memcpy (defval,
parseString + DefaultStartPosition,
memcpy (defval, parseString + DefaultStartPosition,
deflen);
defval[deflen] = 0;
$$ = defval;
......@@ -456,21 +456,19 @@ default_expr: AexprConst
| AexprConst TYPECAST Typename
{
/* AexprConst can be either A_Const or ParamNo */
if (nodeTag($1) == T_A_Const) {
if (nodeTag($1) == T_A_Const)
((A_Const *)$1)->typename = $3;
}else {
else
elog (WARN, "Cannot handle parameter in DEFAULT");
}
$$ = (Node *)$1;
}
| CAST AexprConst AS Typename
{
/* AexprConst can be either A_Const or ParamNo */
if (nodeTag($2) == T_A_Const) {
if (nodeTag($2) == T_A_Const)
((A_Const *)$2)->typename = $4;
}else {
else
elog (WARN, "Cannot handle parameter in DEFAULT");
}
$$ = (Node *)$2;
}
| '(' default_expr ')'
......@@ -661,7 +659,8 @@ ConstraintElem:
| ConstraintDef { $$ = $1; }
;
ConstraintDef: CHECK a_expr {
ConstraintDef: CHECK a_expr
{
ConstraintDef *constr = palloc (sizeof(ConstraintDef));
int chklen = CurScanPosition() - CheckStartPosition;
char *check;
......@@ -956,12 +955,14 @@ privileges: ALL PRIVILEGES
{
$$ = aclmakepriv("rwaR",0);
}
| operation_commalist {
| operation_commalist
{
$$ = $1;
}
;
operation_commalist: operation {
operation_commalist: operation
{
$$ = aclmakepriv("",$1);
}
| operation_commalist ',' operation
......@@ -971,30 +972,38 @@ operation_commalist: operation {
}
;
operation: SELECT {
operation: SELECT
{
$$ = ACL_MODE_RD_CHR;
}
| INSERT {
| INSERT
{
$$ = ACL_MODE_AP_CHR;
}
| UPDATE {
| UPDATE
{
$$ = ACL_MODE_WR_CHR;
}
| DELETE {
| DELETE
{
$$ = ACL_MODE_WR_CHR;
}
| RULE {
| RULE
{
$$ = ACL_MODE_RU_CHR;
}
;
grantee: PUBLIC {
grantee: PUBLIC
{
$$ = aclmakeuser("A","");
}
| GROUP Id {
| GROUP Id
{
$$ = aclmakeuser("G",$2);
}
| Id {
| Id
{
$$ = aclmakeuser("U",$1);
}
;
......@@ -1005,6 +1014,7 @@ opt_with_grant : /* empty */
yyerror("WITH GRANT OPTION is not supported. Only relation owners can set privileges");
}
;
/*****************************************************************************
*
* QUERY:
......@@ -2246,22 +2256,20 @@ typname: txname
/* Is this the name of a complex type? If so, implement
* it as a set.
*/
if (!strcmp(saved_relname, tname)) {
if (!strcmp(saved_relname, tname))
/* This attr is the same type as the relation
* being defined. The classic example: create
* emp(name=text,mgr=emp)
*/
$$->setof = TRUE;
}else if (get_typrelid((Type)type(tname))
!= InvalidOid) {
else if (get_typrelid((Type)type(tname)) != InvalidOid)
/* (Eventually add in here that the set can only
* contain one element.)
*/
$$->setof = TRUE;
} else {
else
$$->setof = FALSE;
}
}
| SETOF txname
{
char *tname = xlateSqlType($2);
......@@ -2305,7 +2313,8 @@ Typename: typname opt_array_bounds
* here, and do nothing if so. This seems to fix the problem.
* - thomas 1997-07-13
*/
if (strlen($1) > 0) {
if (strlen($1) > 0)
{
/*
* The following implements char() and varchar().
......@@ -2315,25 +2324,22 @@ Typename: typname opt_array_bounds
* - ay 6/95
*/
$$ = makeNode(TypeName);
if (!strcasecmp($1, "char")) {
if (!strcasecmp($1, "char"))
$$->name = "bpchar"; /* strdup("bpchar"); */
} else if (!strcasecmp($1, "varchar")) {
else if (!strcasecmp($1, "varchar"))
$$->name = "varchar"; /* strdup("varchar"); */
} else {
else
yyerror("parse error");
}
if ($3 < 1) {
elog(WARN, "length for '%s' type must be at least 1",
$1);
} else if ($3 > 4096) {
if ($3 < 1)
elog(WARN, "length for '%s' type must be at least 1",$1);
else if ($3 > 4096)
/* we can store a char() of length up to the size
* of a page (8KB) - page headers and friends but
* just to be safe here... - ay 6/95
* XXX note this hardcoded limit - thomas 1997-07-13
*/
elog(WARN, "length for '%s' type cannot exceed 4096",
$1);
}
elog(WARN, "length for '%s' type cannot exceed 4096",$1);
/* we actually implement this sort of like a varlen, so
* the first 4 bytes is the length. (the difference
* between this and "text" is that we blank-pad and
......@@ -2393,21 +2399,19 @@ a_expr: attr opt_indirection
| AexprConst TYPECAST Typename
{
/* AexprConst can be either A_Const or ParamNo */
if (nodeTag($1) == T_A_Const) {
if (nodeTag($1) == T_A_Const)
((A_Const *)$1)->typename = $3;
}else {
else
((ParamNo *)$1)->typename = $3;
}
$$ = (Node *)$1;
}
| CAST AexprConst AS Typename
{
/* AexprConst can be either A_Const or ParamNo */
if (nodeTag($2) == T_A_Const) {
if (nodeTag($2) == T_A_Const)
((A_Const *)$2)->typename = $4;
}else {
else
((ParamNo *)$2)->typename = $4;
}
$$ = (Node *)$2;
}
| '(' a_expr_or_null ')'
......@@ -2423,7 +2427,8 @@ a_expr: attr opt_indirection
| a_expr Op
{ $$ = makeA_Expr(OP, $2, $1, NULL); }
| Id
{ /* could be a column name or a relation_name */
{
/* could be a column name or a relation_name */
Ident *n = makeNode(Ident);
n->name = $1;
n->indirection = NULL;
......@@ -2523,12 +2528,14 @@ a_expr: attr opt_indirection
| a_expr IS NOT PNULL
{ $$ = makeA_Expr(NOTNULL, NULL, $1, NULL); }
| a_expr BETWEEN AexprConst AND AexprConst
{ $$ = makeA_Expr(AND, NULL,
{
$$ = makeA_Expr(AND, NULL,
makeA_Expr(OP, ">=", $1, $3),
makeA_Expr(OP, "<=", $1, $5));
}
| a_expr NOT BETWEEN AexprConst AND AexprConst
{ $$ = makeA_Expr(OR, NULL,
{
$$ = makeA_Expr(OR, NULL,
makeA_Expr(OP, "<", $1, $4),
makeA_Expr(OP, ">", $1, $6));
}
......@@ -2583,9 +2590,7 @@ printf( "string is %s\n", $1);
;
position_list: a_expr IN expr_list
{
$$ = lappend($3, $1);
}
{ $$ = lappend($3, $1); }
| /* EMPTY */
{ $$ = NIL; }
;
......@@ -2790,11 +2795,10 @@ relation_name: SpecialRuleRelation
if (strcmp(LogRelationName, $1) == 0
|| strcmp(VariableRelationName, $1) == 0
|| strcmp(TimeRelationName, $1) == 0
|| strcmp(MagicRelationName, $1) == 0) {
|| strcmp(MagicRelationName, $1) == 0)
elog(WARN, "%s cannot be accessed by users", $1);
} else {
else
$$ = $1;
}
strNcpy(saved_relname, $1, NAMEDATALEN-1);
}
;
......@@ -2913,4 +2917,3 @@ void parser_init(Oid *typev, int nargs)
param_type_init(typev, nargs);
}
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.18 1997/09/05 09:05:48 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.19 1997/09/08 03:20:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -155,18 +155,14 @@ other .
}
<xq>{xqdouble} |
<xq>{xqinside} {
if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1)) {
if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1))
elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
/* not reached */
}
memcpy(literal+llen, yytext, yyleng+1);
llen += yyleng;
}
<xq>{xqliteral} {
if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1)) {
if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1))
elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
/* not reached */
}
memcpy(literal+llen, yytext+1, yyleng);
llen += yyleng-1;
}
......@@ -191,7 +187,8 @@ other .
yylval.str = pstrdup((char*)yytext);
return (Op);
}
{param} { yylval.ival = atoi((char*)&yytext[1]);
{param} {
yylval.ival = atoi((char*)&yytext[1]);
return (PARAM);
}
{integer} {
......@@ -200,6 +197,7 @@ other .
}
{real} {
char* endptr;
errno = 0;
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE)
......@@ -217,18 +215,20 @@ other .
keyword = ScanKeywordLookup((char*)yytext);
if (keyword != NULL) {
if ( keyword->value == DEFAULT ) {
if ( keyword->value == DEFAULT )
{
DefaultStartPosition = CurScanPosition () + yyleng + 1;
printf( "default offset is %d\n", DefaultStartPosition);
} else if ( keyword->value == CHECK ) {
printf( "default offset is %d\n", DefaultStartPosition);
}
else if ( keyword->value == CHECK )
{
CheckStartPosition = CurScanPosition () + yyleng + 1;
printf( "check offset is %d\n", CheckStartPosition);
};
printf( "check offset is %d\n", CheckStartPosition);
}
return (keyword->value);
} else {
}
else
{
yylval.str = pstrdup((char*)yytext);
return (IDENT);
}
......@@ -274,25 +274,25 @@ init_io()
int
input()
{
if (parseCh == NULL) {
if (parseCh == NULL)
{
parseCh = parseString;
return(*parseCh++);
} else if (*parseCh == '\0') {
}
else if (*parseCh == '\0')
return(0);
} else {
else
return(*parseCh++);
}
}
/* undo lex input from a string instead of from stdin */
void
unput(char c)
{
if (parseCh == NULL) {
if (parseCh == NULL)
elog(FATAL, "Unput() failed.\n");
} else if (c != 0) {
else if (c != 0)
*--parseCh = c;
}
}
int
......@@ -309,7 +309,8 @@ myinput(char* buf, int max)
{
int len, copylen;
if (parseCh == NULL) {
if (parseCh == NULL)
{
len = strlen(parseString);
if (len >= max)
copylen = max - 1;
......@@ -320,16 +321,15 @@ myinput(char* buf, int max)
buf[copylen] = '\0';
parseCh = parseString;
return copylen;
} else {
return 0; /* end of string */
}
else
return 0; /* end of string */
}
int
CurScanPosition(void)
{
printf( "current position is %d\n", yy_c_buf_p - yy_current_buffer->yy_ch_buf - yyleng);
printf( "current position is %d\n", yy_c_buf_p - yy_current_buffer->yy_ch_buf - yyleng);
return (yy_c_buf_p - yy_current_buffer->yy_ch_buf - yyleng);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册