mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
From: Michael Meskes <meskes@topsystem.de>
+Wed May 20 10:46:48 CEST 1998 + + - Fixed handling of preprocessor directives and variable + initialization. + - Added enum datatype. - Set version to 2.3.2
This commit is contained in:
parent
b15b768bfa
commit
c31a80faf0
@ -232,4 +232,10 @@ Tue May 19 11:49:34 CEST 1998
|
|||||||
|
|
||||||
- Tested (and fixed) 'set connection'
|
- Tested (and fixed) 'set connection'
|
||||||
- Fixed string notation in C
|
- Fixed string notation in C
|
||||||
|
|
||||||
|
Wed May 20 10:46:48 CEST 1998
|
||||||
|
|
||||||
|
- Fixed handling of preprocessor directives and variable
|
||||||
|
initialization.
|
||||||
|
- Added enum datatype.
|
||||||
- Set version to 2.3.2
|
- Set version to 2.3.2
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
ecpg does not understand enum datatypes.
|
|
||||||
|
|
||||||
The complete structure definition has to be listed inside the declare
|
The complete structure definition has to be listed inside the declare
|
||||||
section of the structure variable for ecpg to be able to understand it.
|
section of the structure variable for ecpg to be able to understand it.
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ ECPGtype_name(enum ECPGttype typ)
|
|||||||
{
|
{
|
||||||
switch (typ)
|
switch (typ)
|
||||||
{
|
{
|
||||||
case ECPGt_char:return "char";
|
case ECPGt_char:
|
||||||
|
return "char";
|
||||||
case ECPGt_unsigned_char:
|
case ECPGt_unsigned_char:
|
||||||
return "unsigned char";
|
return "unsigned char";
|
||||||
case ECPGt_short:
|
case ECPGt_short:
|
||||||
@ -29,6 +30,8 @@ ECPGtype_name(enum ECPGttype typ)
|
|||||||
return "double";
|
return "double";
|
||||||
case ECPGt_bool:
|
case ECPGt_bool:
|
||||||
return "bool";
|
return "bool";
|
||||||
|
case ECPGt_varchar:
|
||||||
|
return "varchar";
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ static ScanKeyword ScanKeywords[] = {
|
|||||||
{"char", S_CHAR},
|
{"char", S_CHAR},
|
||||||
{"const", S_CONST},
|
{"const", S_CONST},
|
||||||
{"double", S_DOUBLE},
|
{"double", S_DOUBLE},
|
||||||
|
{"enum", S_ENUM},
|
||||||
{"extern", S_EXTERN},
|
{"extern", S_EXTERN},
|
||||||
{"float", S_FLOAT},
|
{"float", S_FLOAT},
|
||||||
{"int", S_INT},
|
{"int", S_INT},
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "y.tab.h"
|
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
#include "y.tab.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of (keyword-name, keyword-token-value) pairs.
|
* List of (keyword-name, keyword-token-value) pairs.
|
||||||
|
@ -25,11 +25,10 @@
|
|||||||
#include "parser/gramparse.h"
|
#include "parser/gramparse.h"
|
||||||
#include "parser/scansup.h"
|
#include "parser/scansup.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
|
#include "extern.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
#include "extern.h"
|
|
||||||
|
|
||||||
/* some versions of lex define this as a macro */
|
/* some versions of lex define this as a macro */
|
||||||
#if defined(yywrap)
|
#if defined(yywrap)
|
||||||
#undef yywrap
|
#undef yywrap
|
||||||
@ -160,6 +159,8 @@ exec [eE][xX][eE][cC]
|
|||||||
include [iI][nN][cC][lL][uU][dD][eE]
|
include [iI][nN][cC][lL][uU][dD][eE]
|
||||||
sql [sS][qQ][lL]
|
sql [sS][qQ][lL]
|
||||||
|
|
||||||
|
cppline {space}*#.*(\\{space}*\n)*\n*
|
||||||
|
|
||||||
/* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION.
|
/* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION.
|
||||||
* AT&T lex does not properly handle C-style comments in this second lex block.
|
* AT&T lex does not properly handle C-style comments in this second lex block.
|
||||||
* So, put comments here. tgl - 1997-09-08
|
* So, put comments here. tgl - 1997-09-08
|
||||||
@ -281,7 +282,7 @@ sql [sS][qQ][lL]
|
|||||||
memcpy(literal+llen, yytext, yyleng+1);
|
memcpy(literal+llen, yytext, yyleng+1);
|
||||||
llen += yyleng;
|
llen += yyleng;
|
||||||
}
|
}
|
||||||
<C>{xdstart} {
|
{xdstart} {
|
||||||
BEGIN(xdc);
|
BEGIN(xdc);
|
||||||
llen = 0;
|
llen = 0;
|
||||||
*literal = '\0';
|
*literal = '\0';
|
||||||
@ -442,6 +443,10 @@ sql [sS][qQ][lL]
|
|||||||
|
|
||||||
<C>{exec}{space}{sql} { BEGIN SQL; return SQL_START; }
|
<C>{exec}{space}{sql} { BEGIN SQL; return SQL_START; }
|
||||||
<C>{ccomment} { /* ignore */ }
|
<C>{ccomment} { /* ignore */ }
|
||||||
|
<C>{cppline} {
|
||||||
|
yylval.str = strdup((char*)yytext);
|
||||||
|
return(CPP_LINE);
|
||||||
|
}
|
||||||
<C>{identifier} {
|
<C>{identifier} {
|
||||||
ScanKeyword *keyword;
|
ScanKeyword *keyword;
|
||||||
|
|
||||||
|
@ -500,6 +500,7 @@ output_statement(char * stmt, int mode)
|
|||||||
whenever_action(mode);
|
whenever_action(mode);
|
||||||
free(stmt);
|
free(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
@ -509,6 +510,7 @@ output_statement(char * stmt, int mode)
|
|||||||
struct when action;
|
struct when action;
|
||||||
struct index index;
|
struct index index;
|
||||||
int tagname;
|
int tagname;
|
||||||
|
struct this_type type;
|
||||||
enum ECPGttype type_enum;
|
enum ECPGttype type_enum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,8 +522,8 @@ output_statement(char * stmt, int mode)
|
|||||||
%token SQL_STOP SQL_WHENEVER
|
%token SQL_STOP SQL_WHENEVER
|
||||||
|
|
||||||
/* C token */
|
/* C token */
|
||||||
%token S_ANYTHING S_AUTO S_BOOL S_CHAR S_CONST S_DOUBLE S_EXTERN
|
%token S_ANYTHING S_AUTO S_BOOL S_CHAR S_CONST S_DOUBLE S_ENUM S_EXTERN
|
||||||
%token S_FLOAT S_INT
|
%token S_FLOAT S_INT S
|
||||||
%token S_LONG S_REGISTER S_SHORT S_SIGNED S_STATIC S_STRUCT
|
%token S_LONG S_REGISTER S_SHORT S_SIGNED S_STATIC S_STRUCT
|
||||||
%token S_UNSIGNED S_VARCHAR
|
%token S_UNSIGNED S_VARCHAR
|
||||||
|
|
||||||
@ -582,7 +584,7 @@ output_statement(char * stmt, int mode)
|
|||||||
%token PASSWORD, CREATEDB, NOCREATEDB, CREATEUSER, NOCREATEUSER, VALID, UNTIL
|
%token PASSWORD, CREATEDB, NOCREATEDB, CREATEUSER, NOCREATEUSER, VALID, UNTIL
|
||||||
|
|
||||||
/* Special keywords, not in the query language - see the "lex" file */
|
/* Special keywords, not in the query language - see the "lex" file */
|
||||||
%token <str> IDENT SCONST Op CSTRING CVARIABLE
|
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE
|
||||||
%token <ival> ICONST PARAM
|
%token <ival> ICONST PARAM
|
||||||
%token <dval> FCONST
|
%token <dval> FCONST
|
||||||
|
|
||||||
@ -676,12 +678,15 @@ output_statement(char * stmt, int mode)
|
|||||||
%type <str> blockend variable_list variable var_anything do_anything
|
%type <str> blockend variable_list variable var_anything do_anything
|
||||||
%type <str> opt_pointer cvariable ECPGDisconnect dis_name
|
%type <str> opt_pointer cvariable ECPGDisconnect dis_name
|
||||||
%type <str> stmt symbol opt_symbol ECPGRelease execstring server_name
|
%type <str> stmt symbol opt_symbol ECPGRelease execstring server_name
|
||||||
%type <str> connection_object opt_server opt_port
|
%type <str> connection_object opt_server opt_port c_thing
|
||||||
%type <str> user_name opt_user char_variable ora_user ident
|
%type <str> user_name opt_user char_variable ora_user ident
|
||||||
%type <str> db_prefix server opt_options opt_connection_name
|
%type <str> db_prefix server opt_options opt_connection_name
|
||||||
%type <str> ECPGSetConnection
|
%type <str> ECPGSetConnection c_line cpp_line s_enum
|
||||||
|
%type <str> enum_type
|
||||||
|
|
||||||
%type <type_enum> simple_type type struct_type
|
%type <type_enum> simple_type
|
||||||
|
|
||||||
|
%type <type> type
|
||||||
|
|
||||||
%type <action> action
|
%type <action> action
|
||||||
|
|
||||||
@ -694,7 +699,8 @@ statements: /* empty */
|
|||||||
|
|
||||||
statement: ecpgstart stmt SQL_SEMI
|
statement: ecpgstart stmt SQL_SEMI
|
||||||
| ECPGDeclaration
|
| ECPGDeclaration
|
||||||
| c_anything { fputs($1, yyout); free($1); }
|
| c_thing { fprintf(yyout, "%s", $1); free($1); }
|
||||||
|
| cpp_line { fprintf(yyout, "%s", $1); free($1); }
|
||||||
| blockstart { fputs($1, yyout); free($1); }
|
| blockstart { fputs($1, yyout); free($1); }
|
||||||
| blockend { fputs($1, yyout); free($1); }
|
| blockend { fputs($1, yyout); free($1); }
|
||||||
|
|
||||||
@ -3795,29 +3801,49 @@ variable_declarations: /* empty */
|
|||||||
declaration: storage_clause type
|
declaration: storage_clause type
|
||||||
{
|
{
|
||||||
actual_storage[struct_level] = $1;
|
actual_storage[struct_level] = $1;
|
||||||
actual_type[struct_level] = $2;
|
actual_type[struct_level] = $2.type_enum;
|
||||||
if ($2 != ECPGt_varchar && $2 != ECPGt_struct)
|
if ($2.type_enum != ECPGt_varchar && $2.type_enum != ECPGt_struct)
|
||||||
fprintf(yyout, "%s %s", $1, ECPGtype_name($2));
|
fprintf(yyout, "%s %s", $1, $2.type_str);
|
||||||
|
free($2.type_str);
|
||||||
}
|
}
|
||||||
variable_list ';' { fputc(';', yyout); }
|
variable_list ';' { fputc(';', yyout); }
|
||||||
|
|
||||||
storage_clause : S_EXTERN { $$ = make1_str("extern"); }
|
storage_clause : S_EXTERN { $$ = "extern"; }
|
||||||
| S_STATIC { $$ = make1_str("static"); }
|
| S_STATIC { $$ = "static"; }
|
||||||
| S_SIGNED { $$ = make1_str("signed"); }
|
| S_SIGNED { $$ = "signed"; }
|
||||||
| S_CONST { $$ = make1_str("const"); }
|
| S_CONST { $$ = "const"; }
|
||||||
| S_REGISTER { $$ = make1_str("register"); }
|
| S_REGISTER { $$ = "register"; }
|
||||||
| S_AUTO { $$ = make1_str("auto"); }
|
| S_AUTO { $$ = "auto"; }
|
||||||
| /* empty */ { $$ = make1_str("") ; }
|
| /* empty */ { $$ = ""; }
|
||||||
|
|
||||||
type: simple_type
|
type: simple_type
|
||||||
|
{
|
||||||
|
$$.type_enum = $1;
|
||||||
|
$$.type_str = strdup(ECPGtype_name($1));
|
||||||
|
}
|
||||||
| struct_type
|
| struct_type
|
||||||
|
{
|
||||||
|
$$.type_enum = ECPGt_struct;
|
||||||
|
$$.type_str = make1_str("");
|
||||||
|
}
|
||||||
|
| enum_type
|
||||||
|
{
|
||||||
|
$$.type_str = $1;
|
||||||
|
$$.type_enum = ECPGt_int;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum_type: s_enum '{' c_line '}'
|
||||||
|
{
|
||||||
|
$$ = cat4_str($1, make1_str("{"), $3, make1_str("}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
s_enum: S_ENUM opt_symbol { $$ = cat2_str(make1_str("enum"), $2); }
|
||||||
|
|
||||||
struct_type: s_struct '{' variable_declarations '}'
|
struct_type: s_struct '{' variable_declarations '}'
|
||||||
{
|
{
|
||||||
ECPGfree_struct_member(struct_member_list[struct_level]);
|
ECPGfree_struct_member(struct_member_list[struct_level]);
|
||||||
free(actual_storage[struct_level--]);
|
free(actual_storage[struct_level--]);
|
||||||
fputs("} ", yyout);
|
fputs("} ", yyout);
|
||||||
$$ = ECPGt_struct;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s_struct : S_STRUCT opt_symbol
|
s_struct : S_STRUCT opt_symbol
|
||||||
@ -3957,7 +3983,7 @@ variable: opt_pointer symbol opt_array_bounds opt_initializer
|
|||||||
if (struct_level == 0)
|
if (struct_level == 0)
|
||||||
new_variable($2, type);
|
new_variable($2, type);
|
||||||
else
|
else
|
||||||
ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]))->typ;
|
ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]));
|
||||||
|
|
||||||
free($1);
|
free($1);
|
||||||
free($2);
|
free($2);
|
||||||
@ -4562,27 +4588,36 @@ civariableonly : cvariable name {
|
|||||||
add_variable(&argsinsert, find_variable($1), &no_indicator);
|
add_variable(&argsinsert, find_variable($1), &no_indicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
cvariable: CVARIABLE { $$ = make1_str($1); }
|
cvariable: CVARIABLE { $$ = $1; }
|
||||||
|
|
||||||
indicator: /* empty */ { $$ = NULL; }
|
indicator: /* empty */ { $$ = NULL; }
|
||||||
| cvariable { check_indicator((find_variable($1))->type); $$ = $1; }
|
| cvariable { check_indicator((find_variable($1))->type); $$ = $1; }
|
||||||
| SQL_INDICATOR cvariable { check_indicator((find_variable($2))->type); $$ = $2; }
|
| SQL_INDICATOR cvariable { check_indicator((find_variable($2))->type); $$ = $2; }
|
||||||
| SQL_INDICATOR name { check_indicator((find_variable($2))->type); $$ = $2; }
|
| SQL_INDICATOR name { check_indicator((find_variable($2))->type); $$ = $2; }
|
||||||
|
|
||||||
ident: IDENT { $$ = make1_str($1); }
|
ident: IDENT { $$ = $1; }
|
||||||
| CSTRING { $$ = $1; }
|
| CSTRING { $$ = $1; }
|
||||||
/*
|
/*
|
||||||
* C stuff
|
* C stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
symbol: IDENT { $$ = make1_str($1); }
|
symbol: IDENT { $$ = $1; }
|
||||||
|
|
||||||
c_anything: IDENT { $$ = make1_str($1); }
|
cpp_line: CPP_LINE { $$ = $1; }
|
||||||
|
|
||||||
|
c_line: c_anything { $$ = $1; }
|
||||||
|
| c_line c_anything
|
||||||
|
{
|
||||||
|
$$ = make2_str($1, $2);
|
||||||
|
}
|
||||||
|
|
||||||
|
c_thing: c_anything | ';' { $$ = make1_str(";"); }
|
||||||
|
|
||||||
|
c_anything: IDENT { $$ = $1; }
|
||||||
| CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); }
|
| CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); }
|
||||||
| Iconst { $$ = $1; }
|
| Iconst { $$ = $1; }
|
||||||
| FCONST { $$ = make_name(); }
|
| FCONST { $$ = make_name(); }
|
||||||
| '*' { $$ = make1_str("*"); }
|
| '*' { $$ = make1_str("*"); }
|
||||||
| ';' { $$ = make1_str(";"); }
|
|
||||||
| S_AUTO { $$ = make1_str("auto"); }
|
| S_AUTO { $$ = make1_str("auto"); }
|
||||||
| S_BOOL { $$ = make1_str("bool"); }
|
| S_BOOL { $$ = make1_str("bool"); }
|
||||||
| S_CHAR { $$ = make1_str("char"); }
|
| S_CHAR { $$ = make1_str("char"); }
|
||||||
@ -4607,19 +4642,17 @@ c_anything: IDENT { $$ = make1_str($1); }
|
|||||||
| '=' { $$ = make1_str("="); }
|
| '=' { $$ = make1_str("="); }
|
||||||
| ',' { $$ = make1_str(","); }
|
| ',' { $$ = make1_str(","); }
|
||||||
|
|
||||||
do_anything: IDENT { $$ = make1_str($1); }
|
do_anything: IDENT { $$ = $1; }
|
||||||
| CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\""));}
|
| CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\""));}
|
||||||
| Iconst { $$ = $1; }
|
| Iconst { $$ = $1; }
|
||||||
| FCONST { $$ = make_name(); }
|
| FCONST { $$ = make_name(); }
|
||||||
| ',' { $$ = make1_str(","); }
|
| ',' { $$ = make1_str(","); }
|
||||||
|
|
||||||
var_anything: IDENT { $$ = make1_str($1); }
|
var_anything: IDENT { $$ = $1; }
|
||||||
| CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); }
|
| CSTRING { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); }
|
||||||
| Iconst { $$ = $1; }
|
| Iconst { $$ = $1; }
|
||||||
| FCONST { $$ = make_name(); }
|
| FCONST { $$ = make_name(); }
|
||||||
/*FIXME: | ',' { $$ = make1_str(","); }*/
|
| '{' c_line '}' { $$ = make3_str(make1_str("{"), $2, make1_str("}")); }
|
||||||
| '{' { $$ = make1_str("{"); }
|
|
||||||
| '}' { $$ = make1_str("}"); }
|
|
||||||
|
|
||||||
blockstart : '{' {
|
blockstart : '{' {
|
||||||
braces_open++;
|
braces_open++;
|
||||||
@ -4635,6 +4668,6 @@ blockend : '}' {
|
|||||||
|
|
||||||
void yyerror(char * error)
|
void yyerror(char * error)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s in line %d\n", error, yylineno);
|
fprintf(stderr, "%s in line %d of file %s\n", error, yylineno, input_filename);
|
||||||
exit(PARSE_ERROR);
|
exit(PARSE_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ struct_member_dup(struct ECPGstruct_member * rm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The NAME argument is copied. The type argument is preserved as a pointer. */
|
/* The NAME argument is copied. The type argument is preserved as a pointer. */
|
||||||
struct ECPGstruct_member *
|
void
|
||||||
ECPGmake_struct_member(char *name, struct ECPGtype * type, struct ECPGstruct_member ** start)
|
ECPGmake_struct_member(char *name, struct ECPGtype * type, struct ECPGstruct_member ** start)
|
||||||
{
|
{
|
||||||
struct ECPGstruct_member *ptr,
|
struct ECPGstruct_member *ptr,
|
||||||
@ -69,7 +69,6 @@ ECPGmake_struct_member(char *name, struct ECPGtype * type, struct ECPGstruct_mem
|
|||||||
ptr->next = ne;
|
ptr->next = ne;
|
||||||
else
|
else
|
||||||
*start = ne;
|
*start = ne;
|
||||||
return ne;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ECPGtype *
|
struct ECPGtype *
|
||||||
|
@ -25,7 +25,7 @@ struct ECPGtype
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Everything is malloced. */
|
/* Everything is malloced. */
|
||||||
struct ECPGstruct_member *ECPGmake_struct_member(char *, struct ECPGtype *, struct ECPGstruct_member **);
|
void ECPGmake_struct_member(char *, struct ECPGtype *, struct ECPGstruct_member **);
|
||||||
struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, long);
|
struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, long);
|
||||||
struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
|
struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
|
||||||
struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, long);
|
struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, long);
|
||||||
@ -81,3 +81,9 @@ struct index
|
|||||||
int index2;
|
int index2;
|
||||||
char *str;
|
char *str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct this_type
|
||||||
|
{
|
||||||
|
enum ECPGttype type_enum;
|
||||||
|
char *type_str;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user