mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Clean up whitespace and indentation in parser and scanner files
These are not touched by pgindent, so clean them up a bit manually.
This commit is contained in:
@ -308,8 +308,8 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
|
||||
if (strcmp_fn($2, ptr->name) == 0)
|
||||
{
|
||||
if ($2[0] == ':')
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
|
||||
else
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
|
||||
else
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
|
||||
}
|
||||
}
|
||||
@ -362,7 +362,7 @@ ECPG: into_clauseINTOOptTempTableName block
|
||||
FoundInto = 1;
|
||||
$$= cat2_str(mm_strdup("into"), $2);
|
||||
}
|
||||
| ecpg_into { $$ = EMPTY; }
|
||||
| ecpg_into { $$ = EMPTY; }
|
||||
ECPG: table_refselect_with_parens addon
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
|
||||
ECPG: TypenameSimpleTypenameopt_array_bounds block
|
||||
@ -468,9 +468,9 @@ ECPG: FetchStmtMOVEfetch_args rule
|
||||
$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
|
||||
}
|
||||
ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
|
||||
{
|
||||
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
|
||||
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
|
||||
}
|
||||
{
|
||||
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
|
||||
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
|
||||
}
|
||||
ECPG: SignedIconstIconst rule
|
||||
| civar { $$ = $1; }
|
||||
|
@ -11,10 +11,10 @@
|
||||
/* Location tracking support --- simpler than bison's default */
|
||||
#define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do { \
|
||||
if (N) \
|
||||
(Current) = (Rhs)[1]; \
|
||||
else \
|
||||
(Current) = (Rhs)[0]; \
|
||||
if (N) \
|
||||
(Current) = (Rhs)[1]; \
|
||||
else \
|
||||
(Current) = (Rhs)[0]; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
@ -42,10 +42,10 @@ char *input_filename = NULL;
|
||||
static int FoundInto = 0;
|
||||
static int initializer = 0;
|
||||
static int pacounter = 1;
|
||||
static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess at the size we need */
|
||||
static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess at the size we need */
|
||||
static struct this_type actual_type[STRUCT_DEPTH];
|
||||
static char *actual_startline[STRUCT_DEPTH];
|
||||
static int varchar_counter = 1;
|
||||
static int varchar_counter = 1;
|
||||
|
||||
/* temporarily store struct members while creating the data structure */
|
||||
struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
|
||||
@ -105,7 +105,7 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
|
||||
fclose(yyout);
|
||||
|
||||
if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
|
||||
fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
|
||||
fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
|
||||
exit(error_code);
|
||||
}
|
||||
}
|
||||
@ -261,53 +261,111 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
|
||||
newvar = ptr->variable;
|
||||
skip_set_var = true;
|
||||
}
|
||||
else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
|
||||
else if ((ptr->variable->type->type == ECPGt_char_variable)
|
||||
&& (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
|
||||
{
|
||||
newvar = ptr->variable;
|
||||
skip_set_var = true;
|
||||
}
|
||||
else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
|
||||
else if ((ptr->variable->type->type != ECPGt_varchar
|
||||
&& ptr->variable->type->type != ECPGt_char
|
||||
&& ptr->variable->type->type != ECPGt_unsigned_char
|
||||
&& ptr->variable->type->type != ECPGt_string)
|
||||
&& atoi(ptr->variable->type->size) > 1)
|
||||
{
|
||||
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, mm_strdup("1"), ptr->variable->type->u.element->counter), ptr->variable->type->size), 0);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("("),
|
||||
mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
|
||||
mm_strdup("1"),
|
||||
ptr->variable->type->u.element->counter),
|
||||
ptr->variable->type->size),
|
||||
0);
|
||||
sprintf(temp, "%d, (", ecpg_internal_var++);
|
||||
}
|
||||
else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
|
||||
else if ((ptr->variable->type->type == ECPGt_varchar
|
||||
|| ptr->variable->type->type == ECPGt_char
|
||||
|| ptr->variable->type->type == ECPGt_unsigned_char
|
||||
|| ptr->variable->type->type == ECPGt_string)
|
||||
&& atoi(ptr->variable->type->size) > 1)
|
||||
{
|
||||
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("("),
|
||||
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_simple_type(ptr->variable->type->type,
|
||||
ptr->variable->type->size,
|
||||
ptr->variable->type->counter),
|
||||
0);
|
||||
if (ptr->variable->type->type == ECPGt_varchar)
|
||||
sprintf(temp, "%d, &(", ecpg_internal_var++);
|
||||
else
|
||||
sprintf(temp, "%d, (", ecpg_internal_var++);
|
||||
}
|
||||
else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
|
||||
else if (ptr->variable->type->type == ECPGt_struct
|
||||
|| ptr->variable->type->type == ECPGt_union)
|
||||
{
|
||||
sprintf(temp, "%d)))", ecpg_internal_var);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->variable->type->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("(*("),
|
||||
mm_strdup(ptr->variable->type->type_name),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_struct_type(ptr->variable->type->u.members,
|
||||
ptr->variable->type->type,
|
||||
ptr->variable->type->type_name,
|
||||
ptr->variable->type->struct_sizeof),
|
||||
0);
|
||||
sprintf(temp, "%d, &(", ecpg_internal_var++);
|
||||
}
|
||||
else if (ptr->variable->type->type == ECPGt_array)
|
||||
{
|
||||
if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
|
||||
if (ptr->variable->type->u.element->type == ECPGt_struct
|
||||
|| ptr->variable->type->u.element->type == ECPGt_union)
|
||||
{
|
||||
sprintf(temp, "%d)))", ecpg_internal_var);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->variable->type->u.element->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("(*("),
|
||||
mm_strdup(ptr->variable->type->u.element->type_name),
|
||||
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
|
||||
ECPGmake_struct_type(ptr->variable->type->u.element->u.members,
|
||||
ptr->variable->type->u.element->type,
|
||||
ptr->variable->type->u.element->type_name,
|
||||
ptr->variable->type->u.element->struct_sizeof),
|
||||
0);
|
||||
sprintf(temp, "%d, (", ecpg_internal_var++);
|
||||
}
|
||||
else
|
||||
{
|
||||
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->counter), ptr->variable->type->size), 0);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("("),
|
||||
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
|
||||
ptr->variable->type->u.element->size,
|
||||
ptr->variable->type->u.element->counter),
|
||||
ptr->variable->type->size),
|
||||
0);
|
||||
sprintf(temp, "%d, &(", ecpg_internal_var++);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newvar = new_variable(cat_str(4, mm_strdup("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0);
|
||||
newvar = new_variable(cat_str(4, mm_strdup("*("),
|
||||
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_simple_type(ptr->variable->type->type,
|
||||
ptr->variable->type->size,
|
||||
ptr->variable->type->counter),
|
||||
0);
|
||||
sprintf(temp, "%d, &(", ecpg_internal_var++);
|
||||
}
|
||||
|
||||
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
|
||||
if (!skip_set_var)
|
||||
result = cat_str(5, result, mm_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup("), __LINE__);\n"));
|
||||
result = cat_str(5, result, mm_strdup("ECPGset_var("),
|
||||
mm_strdup(temp), mm_strdup(original_var),
|
||||
mm_strdup("), __LINE__);\n"));
|
||||
|
||||
/* now the indicator if there is one and it's not a global variable */
|
||||
if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
|
||||
@ -320,39 +378,79 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
|
||||
original_var = ptr->indicator->name;
|
||||
sprintf(temp, "%d))", ecpg_internal_var);
|
||||
|
||||
if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
|
||||
if (ptr->indicator->type->type == ECPGt_struct
|
||||
|| ptr->indicator->type->type == ECPGt_union)
|
||||
{
|
||||
sprintf(temp, "%d)))", ecpg_internal_var);
|
||||
newind = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->indicator->type->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
|
||||
newind = new_variable(cat_str(4, mm_strdup("(*("),
|
||||
mm_strdup(ptr->indicator->type->type_name),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_struct_type(ptr->indicator->type->u.members,
|
||||
ptr->indicator->type->type,
|
||||
ptr->indicator->type->type_name,
|
||||
ptr->indicator->type->struct_sizeof),
|
||||
0);
|
||||
sprintf(temp, "%d, &(", ecpg_internal_var++);
|
||||
}
|
||||
else if (ptr->indicator->type->type == ECPGt_array)
|
||||
{
|
||||
if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
|
||||
if (ptr->indicator->type->u.element->type == ECPGt_struct
|
||||
|| ptr->indicator->type->u.element->type == ECPGt_union)
|
||||
{
|
||||
sprintf(temp, "%d)))", ecpg_internal_var);
|
||||
newind = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
|
||||
newind = new_variable(cat_str(4, mm_strdup("(*("),
|
||||
mm_strdup(ptr->indicator->type->u.element->type_name),
|
||||
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
|
||||
ECPGmake_struct_type(ptr->indicator->type->u.element->u.members,
|
||||
ptr->indicator->type->u.element->type,
|
||||
ptr->indicator->type->u.element->type_name,
|
||||
ptr->indicator->type->u.element->struct_sizeof),
|
||||
0);
|
||||
sprintf(temp, "%d, (", ecpg_internal_var++);
|
||||
}
|
||||
else
|
||||
{
|
||||
newind = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->counter), ptr->indicator->type->size), 0);
|
||||
newind = new_variable(cat_str(4, mm_strdup("("),
|
||||
mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)),
|
||||
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
|
||||
ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type,
|
||||
ptr->indicator->type->u.element->size,
|
||||
ptr->indicator->type->u.element->counter),
|
||||
ptr->indicator->type->size),
|
||||
0);
|
||||
sprintf(temp, "%d, &(", ecpg_internal_var++);
|
||||
}
|
||||
}
|
||||
else if (atoi(ptr->indicator->type->size) > 1)
|
||||
{
|
||||
newind = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0);
|
||||
newind = new_variable(cat_str(4, mm_strdup("("),
|
||||
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_simple_type(ptr->indicator->type->type,
|
||||
ptr->indicator->type->size,
|
||||
ptr->variable->type->counter),
|
||||
0);
|
||||
sprintf(temp, "%d, (", ecpg_internal_var++);
|
||||
}
|
||||
else
|
||||
{
|
||||
newind = new_variable(cat_str(4, mm_strdup("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0);
|
||||
newind = new_variable(cat_str(4, mm_strdup("*("),
|
||||
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
|
||||
mm_strdup(" *)(ECPGget_var("),
|
||||
mm_strdup(temp)),
|
||||
ECPGmake_simple_type(ptr->indicator->type->type,
|
||||
ptr->indicator->type->size,
|
||||
ptr->variable->type->counter),
|
||||
0);
|
||||
sprintf(temp, "%d, &(", ecpg_internal_var++);
|
||||
}
|
||||
|
||||
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
|
||||
result = cat_str(5, result, mm_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup("), __LINE__);\n"));
|
||||
result = cat_str(5, result, mm_strdup("ECPGset_var("),
|
||||
mm_strdup(temp), mm_strdup(original_var),
|
||||
mm_strdup("), __LINE__);\n"));
|
||||
}
|
||||
|
||||
add_variable_to_tail(&newlist, newvar, newind);
|
||||
@ -407,14 +505,15 @@ add_additional_variables(char *name, bool insert)
|
||||
}
|
||||
|
||||
static void
|
||||
add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enum, char *type_dimension, char *type_index, int initializer, int array)
|
||||
add_typedef(char *name, char *dimension, char *length, enum ECPGttype type_enum,
|
||||
char *type_dimension, char *type_index, int initializer, int array)
|
||||
{
|
||||
/* add entry to list */
|
||||
struct typedefs *ptr, *this;
|
||||
|
||||
if ((type_enum == ECPGt_struct ||
|
||||
type_enum == ECPGt_union) &&
|
||||
initializer == 1)
|
||||
type_enum == ECPGt_union) &&
|
||||
initializer == 1)
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition");
|
||||
else if (INFORMIX_MODE && strcmp(name, "string") == 0)
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "type name \"string\" is reserved in Informix mode");
|
||||
@ -462,7 +561,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
|
||||
%union {
|
||||
double dval;
|
||||
char *str;
|
||||
int ival;
|
||||
int ival;
|
||||
struct when action;
|
||||
struct index index;
|
||||
int tagname;
|
||||
|
@ -1,22 +1,22 @@
|
||||
/* src/interfaces/ecpg/preproc/ecpg.trailer */
|
||||
|
||||
statements: /*EMPTY*/
|
||||
| statements statement
|
||||
;
|
||||
| statements statement
|
||||
;
|
||||
|
||||
statement: ecpgstart at stmt ';' { connection = NULL; }
|
||||
| ecpgstart stmt ';'
|
||||
| ecpgstart ECPGVarDeclaration
|
||||
{
|
||||
fprintf(yyout, "%s", $2);
|
||||
free($2);
|
||||
output_line_number();
|
||||
}
|
||||
| ECPGDeclaration
|
||||
| c_thing { fprintf(yyout, "%s", $1); free($1); }
|
||||
| CPP_LINE { fprintf(yyout, "%s", $1); free($1); }
|
||||
| '{' { braces_open++; fputs("{", yyout); }
|
||||
| '}'
|
||||
statement: ecpgstart at stmt ';' { connection = NULL; }
|
||||
| ecpgstart stmt ';'
|
||||
| ecpgstart ECPGVarDeclaration
|
||||
{
|
||||
fprintf(yyout, "%s", $2);
|
||||
free($2);
|
||||
output_line_number();
|
||||
}
|
||||
| ECPGDeclaration
|
||||
| c_thing { fprintf(yyout, "%s", $1); free($1); }
|
||||
| CPP_LINE { fprintf(yyout, "%s", $1); free($1); }
|
||||
| '{' { braces_open++; fputs("{", yyout); }
|
||||
| '}'
|
||||
{
|
||||
remove_typedefs(braces_open);
|
||||
remove_variables(braces_open--);
|
||||
@ -27,7 +27,7 @@ statement: ecpgstart at stmt ';' { connection = NULL; }
|
||||
}
|
||||
fputs("}", yyout);
|
||||
}
|
||||
;
|
||||
;
|
||||
|
||||
CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
|
||||
{
|
||||
@ -36,20 +36,19 @@ CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectSt
|
||||
|
||||
$$ = cat_str(6, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7);
|
||||
}
|
||||
;
|
||||
;
|
||||
|
||||
at: AT connection_object
|
||||
{
|
||||
connection = $2;
|
||||
/*
|
||||
* Do we have a variable as connection target?
|
||||
* Remove the variable from the variable
|
||||
* list or else it will be used twice
|
||||
*/
|
||||
if (argsinsert != NULL)
|
||||
argsinsert = NULL;
|
||||
}
|
||||
;
|
||||
{
|
||||
connection = $2;
|
||||
/*
|
||||
* Do we have a variable as connection target? Remove the variable
|
||||
* from the variable list or else it will be used twice.
|
||||
*/
|
||||
if (argsinsert != NULL)
|
||||
argsinsert = NULL;
|
||||
}
|
||||
;
|
||||
|
||||
/*
|
||||
* the exec sql connect statement: connect to the given database
|
||||
@ -238,12 +237,14 @@ opt_options: Op connect_options
|
||||
|
||||
$$ = make2_str(mm_strdup("?"), $2);
|
||||
}
|
||||
| /*EMPTY*/ { $$ = EMPTY; }
|
||||
| /*EMPTY*/ { $$ = EMPTY; }
|
||||
;
|
||||
|
||||
connect_options: ColId opt_opt_value
|
||||
{ $$ = make2_str($1, $2); }
|
||||
| ColId opt_opt_value Op connect_options
|
||||
{
|
||||
$$ = make2_str($1, $2);
|
||||
}
|
||||
| ColId opt_opt_value Op connect_options
|
||||
{
|
||||
if (strlen($3) == 0)
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
|
||||
@ -253,7 +254,7 @@ connect_options: ColId opt_opt_value
|
||||
|
||||
$$ = cat_str(3, make2_str($1, $2), $3, $4);
|
||||
}
|
||||
;
|
||||
;
|
||||
|
||||
opt_opt_value: /*EMPTY*/
|
||||
{ $$ = EMPTY; }
|
||||
@ -265,21 +266,22 @@ opt_opt_value: /*EMPTY*/
|
||||
{ $$ = make2_str(mm_strdup("="), $2); }
|
||||
;
|
||||
|
||||
prepared_name: name {
|
||||
if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
|
||||
$$ = $1;
|
||||
else /* not quoted => convert to lowercase */
|
||||
{
|
||||
size_t i;
|
||||
prepared_name: name
|
||||
{
|
||||
if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
|
||||
$$ = $1;
|
||||
else /* not quoted => convert to lowercase */
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i< strlen($1); i++)
|
||||
$1[i] = tolower((unsigned char) $1[i]);
|
||||
for (i = 0; i< strlen($1); i++)
|
||||
$1[i] = tolower((unsigned char) $1[i]);
|
||||
|
||||
$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
|
||||
}
|
||||
}
|
||||
| char_variable { $$ = $1; }
|
||||
;
|
||||
$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
|
||||
}
|
||||
}
|
||||
| char_variable { $$ = $1; }
|
||||
;
|
||||
|
||||
/*
|
||||
* Declare a prepared cursor. The syntax is different from the standard
|
||||
@ -300,8 +302,8 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
|
||||
{
|
||||
/* re-definition is a bug */
|
||||
if ($2[0] == ':')
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
|
||||
else
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
|
||||
else
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
|
||||
}
|
||||
}
|
||||
@ -401,8 +403,8 @@ vt_declarations: single_vt_declaration { $$ = $1; }
|
||||
| vt_declarations CPP_LINE { $$ = cat2_str($1, $2); }
|
||||
;
|
||||
|
||||
variable_declarations: var_declaration { $$ = $1; }
|
||||
| variable_declarations var_declaration { $$ = cat2_str($1, $2); }
|
||||
variable_declarations: var_declaration { $$ = $1; }
|
||||
| variable_declarations var_declaration { $$ = cat2_str($1, $2); }
|
||||
;
|
||||
|
||||
type_declaration: S_TYPEDEF
|
||||
@ -767,7 +769,10 @@ s_struct_union: SQL_STRUCT
|
||||
ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
|
||||
$$ = mm_strdup("struct");
|
||||
}
|
||||
| UNION { $$ = mm_strdup("union"); }
|
||||
| UNION
|
||||
{
|
||||
$$ = mm_strdup("union");
|
||||
}
|
||||
;
|
||||
|
||||
simple_type: unsigned_type { $$=$1; }
|
||||
@ -838,8 +843,8 @@ variable_list: variable
|
||||
variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
|
||||
{
|
||||
struct ECPGtype * type;
|
||||
char *dimension = $3.index1; /* dimension of array */
|
||||
char *length = $3.index2; /* length of string */
|
||||
char *dimension = $3.index1; /* dimension of array */
|
||||
char *length = $3.index2; /* length of string */
|
||||
char *dim_str;
|
||||
char *vcn;
|
||||
|
||||
@ -991,8 +996,8 @@ opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
|
||||
| ecpg_using { $$ = $1; }
|
||||
;
|
||||
|
||||
ecpg_using: USING using_list { $$ = EMPTY; }
|
||||
| using_descriptor { $$ = $1; }
|
||||
ecpg_using: USING using_list { $$ = EMPTY; }
|
||||
| using_descriptor { $$ = $1; }
|
||||
;
|
||||
|
||||
using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
|
||||
@ -1041,10 +1046,10 @@ UsingValue: UsingConst
|
||||
|
||||
UsingConst: Iconst { $$ = $1; }
|
||||
| '+' Iconst { $$ = cat_str(2, mm_strdup("+"), $2); }
|
||||
| '-' Iconst { $$ = cat_str(2, mm_strdup("-"), $2); }
|
||||
| '-' Iconst { $$ = cat_str(2, mm_strdup("-"), $2); }
|
||||
| ecpg_fconst { $$ = $1; }
|
||||
| '+' ecpg_fconst { $$ = cat_str(2, mm_strdup("+"), $2); }
|
||||
| '-' ecpg_fconst { $$ = cat_str(2, mm_strdup("-"), $2); }
|
||||
| '-' ecpg_fconst { $$ = cat_str(2, mm_strdup("-"), $2); }
|
||||
| ecpg_sconst { $$ = $1; }
|
||||
| ecpg_bconst { $$ = $1; }
|
||||
| ecpg_xconst { $$ = $1; }
|
||||
@ -1094,7 +1099,7 @@ ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
|
||||
;
|
||||
|
||||
opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
|
||||
| /* EMPTY */ { $$ = EMPTY; }
|
||||
| /* EMPTY */ { $$ = EMPTY; }
|
||||
;
|
||||
|
||||
/*
|
||||
@ -1106,7 +1111,7 @@ opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
|
||||
/*
|
||||
* allocate a descriptor
|
||||
*/
|
||||
ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
|
||||
ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
|
||||
{
|
||||
add_descriptor($3,connection);
|
||||
$$ = $3;
|
||||
@ -1155,16 +1160,19 @@ ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
|
||||
}
|
||||
;
|
||||
|
||||
IntConstVar: Iconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
IntConstVar: Iconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
|
||||
sprintf(length, "%d", (int) strlen($1));
|
||||
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = $1;
|
||||
}
|
||||
| cvariable { $$ = $1; }
|
||||
;
|
||||
sprintf(length, "%d", (int) strlen($1));
|
||||
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = $1;
|
||||
}
|
||||
| cvariable
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
|
||||
;
|
||||
@ -1198,49 +1206,56 @@ ECPGSetDescItem: descriptor_item '=' AllConstVar
|
||||
}
|
||||
;
|
||||
|
||||
AllConstVar: ecpg_fconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
AllConstVar: ecpg_fconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
|
||||
sprintf(length, "%d", (int) strlen($1));
|
||||
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = $1;
|
||||
}
|
||||
| IntConstVar { $$ = $1; }
|
||||
| '-' ecpg_fconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var = cat2_str(mm_strdup("-"), $2);
|
||||
sprintf(length, "%d", (int) strlen($1));
|
||||
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
sprintf(length, "%d", (int) strlen(var));
|
||||
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = var;
|
||||
}
|
||||
| '-' Iconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var = cat2_str(mm_strdup("-"), $2);
|
||||
| IntConstVar
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
sprintf(length, "%d", (int) strlen(var));
|
||||
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = var;
|
||||
}
|
||||
| ecpg_sconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var = $1 + 1;
|
||||
| '-' ecpg_fconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var = cat2_str(mm_strdup("-"), $2);
|
||||
|
||||
var[strlen(var) - 1] = '\0';
|
||||
sprintf(length, "%d", (int) strlen(var));
|
||||
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = var;
|
||||
}
|
||||
sprintf(length, "%d", (int) strlen(var));
|
||||
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = var;
|
||||
}
|
||||
|
||||
| '-' Iconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var = cat2_str(mm_strdup("-"), $2);
|
||||
|
||||
sprintf(length, "%d", (int) strlen(var));
|
||||
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = var;
|
||||
}
|
||||
|
||||
| ecpg_sconst
|
||||
{
|
||||
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var = $1 + 1;
|
||||
|
||||
var[strlen(var) - 1] = '\0';
|
||||
sprintf(length, "%d", (int) strlen(var));
|
||||
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
|
||||
$$ = var;
|
||||
}
|
||||
;
|
||||
|
||||
descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
|
||||
| DATA_P { $$ = ECPGd_data; }
|
||||
| SQL_DATETIME_INTERVAL_CODE { $$ = ECPGd_di_code; }
|
||||
| SQL_DATETIME_INTERVAL_PRECISION { $$ = ECPGd_di_precision; }
|
||||
| SQL_DATETIME_INTERVAL_PRECISION { $$ = ECPGd_di_precision; }
|
||||
| SQL_INDICATOR { $$ = ECPGd_indicator; }
|
||||
| SQL_KEY_MEMBER { $$ = ECPGd_key_member; }
|
||||
| SQL_LENGTH { $$ = ECPGd_length; }
|
||||
@ -1295,8 +1310,8 @@ ECPGTypedef: TYPE_P
|
||||
}
|
||||
;
|
||||
|
||||
opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); }
|
||||
| /*EMPTY*/ { $$ = EMPTY; }
|
||||
opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); }
|
||||
| /*EMPTY*/ { $$ = EMPTY; }
|
||||
;
|
||||
|
||||
/*
|
||||
@ -1452,7 +1467,7 @@ action : CONTINUE_P
|
||||
|
||||
/* additional unreserved keywords */
|
||||
ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
|
||||
| ECPGKeywords_rest { $$ = $1; }
|
||||
| ECPGKeywords_rest { $$ = $1; }
|
||||
;
|
||||
|
||||
ECPGKeywords_vanames: SQL_BREAK { $$ = mm_strdup("break"); }
|
||||
@ -1730,8 +1745,8 @@ ecpg_sconst:
|
||||
$$[strlen($1)+3]='\0';
|
||||
free($1);
|
||||
}
|
||||
| UCONST { $$ = $1; }
|
||||
| DOLCONST { $$ = $1; }
|
||||
| UCONST { $$ = $1; }
|
||||
| DOLCONST { $$ = $1; }
|
||||
;
|
||||
|
||||
ecpg_xconst: XCONST { $$ = make_name(); } ;
|
||||
@ -1832,7 +1847,7 @@ c_anything: ecpg_ident { $$ = $1; }
|
||||
| '[' { $$ = mm_strdup("["); }
|
||||
| ']' { $$ = mm_strdup("]"); }
|
||||
| '=' { $$ = mm_strdup("="); }
|
||||
| ':' { $$ = mm_strdup(":"); }
|
||||
| ':' { $$ = mm_strdup(":"); }
|
||||
;
|
||||
|
||||
DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; }
|
||||
@ -1855,12 +1870,12 @@ Iresult: Iconst { $$ = $1; }
|
||||
execute_rest: /* EMPTY */ { $$ = EMPTY; }
|
||||
| ecpg_using ecpg_into { $$ = EMPTY; }
|
||||
| ecpg_into ecpg_using { $$ = EMPTY; }
|
||||
| ecpg_using { $$ = EMPTY; }
|
||||
| ecpg_into { $$ = EMPTY; }
|
||||
| ecpg_using { $$ = EMPTY; }
|
||||
| ecpg_into { $$ = EMPTY; }
|
||||
;
|
||||
|
||||
ecpg_into: INTO into_list { $$ = EMPTY; }
|
||||
| into_descriptor { $$ = $1; }
|
||||
| into_descriptor { $$ = $1; }
|
||||
;
|
||||
|
||||
ecpg_fetch_into: ecpg_into { $$ = $1; }
|
||||
|
@ -27,7 +27,7 @@
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
static int xcdepth = 0; /* depth of nesting in slash-star comments */
|
||||
static char *dolqstart; /* current $foo$ quote start string */
|
||||
static char *dolqstart; /* current $foo$ quote start string */
|
||||
static YY_BUFFER_STATE scanbufhandle;
|
||||
static char *scanbuf;
|
||||
|
||||
@ -37,7 +37,7 @@ static char *scanbuf;
|
||||
* to empty, addlit to add text. Note that the buffer is permanently
|
||||
* malloc'd to the largest size needed so far in the current run.
|
||||
*/
|
||||
static char *literalbuf = NULL; /* expandable buffer */
|
||||
static char *literalbuf = NULL; /* expandable buffer */
|
||||
static int literallen; /* actual current length */
|
||||
static int literalalloc; /* current allocated buffer size */
|
||||
|
||||
@ -62,8 +62,8 @@ struct _yy_buffer
|
||||
{
|
||||
YY_BUFFER_STATE buffer;
|
||||
long lineno;
|
||||
char *filename;
|
||||
struct _yy_buffer *next;
|
||||
char *filename;
|
||||
struct _yy_buffer *next;
|
||||
} *yy_buffer = NULL;
|
||||
|
||||
static char *old;
|
||||
@ -142,7 +142,7 @@ xhinside [^']*
|
||||
xnstart [nN]{quote}
|
||||
|
||||
/* Quoted string that allows backslash escapes */
|
||||
xestart [eE]{quote}
|
||||
xestart [eE]{quote}
|
||||
xeinside [^\\']+
|
||||
xeescape [\\][^0-7]
|
||||
xeoctesc [\\][0-7]{1,3}
|
||||
@ -317,14 +317,14 @@ other .
|
||||
|
||||
/* some stuff needed for ecpg */
|
||||
exec [eE][xX][eE][cC]
|
||||
sql [sS][qQ][lL]
|
||||
sql [sS][qQ][lL]
|
||||
define [dD][eE][fF][iI][nN][eE]
|
||||
include [iI][nN][cC][lL][uU][dD][eE]
|
||||
include_next [iI][nN][cC][lL][uU][dD][eE]_[nN][eE][xX][tT]
|
||||
import [iI][mM][pP][oO][rR][tT]
|
||||
include [iI][nN][cC][lL][uU][dD][eE]
|
||||
include_next [iI][nN][cC][lL][uU][dD][eE]_[nN][eE][xX][tT]
|
||||
import [iI][mM][pP][oO][rR][tT]
|
||||
undef [uU][nN][dD][eE][fF]
|
||||
|
||||
if [iI][fF]
|
||||
if [iI][fF]
|
||||
ifdef [iI][fF][dD][eE][fF]
|
||||
ifndef [iI][fF][nN][dD][eE][fF]
|
||||
else [eE][lL][sS][eE]
|
||||
@ -335,10 +335,10 @@ struct [sS][tT][rR][uU][cC][tT]
|
||||
|
||||
exec_sql {exec}{space}*{sql}{space}*
|
||||
ipdigit ({digit}|{digit}{digit}|{digit}{digit}{digit})
|
||||
ip {ipdigit}\.{ipdigit}\.{ipdigit}\.{ipdigit}
|
||||
ip {ipdigit}\.{ipdigit}\.{ipdigit}\.{ipdigit}
|
||||
|
||||
/* we might want to parse all cpp include files */
|
||||
cppinclude {space}*#{include}{space}*
|
||||
cppinclude {space}*#{include}{space}*
|
||||
cppinclude_next {space}*#{include_next}{space}*
|
||||
|
||||
/* take care of cpp lines, they may also be continuated */
|
||||
@ -380,8 +380,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
}
|
||||
<xc>{xcstart} {
|
||||
xcdepth++;
|
||||
/* Put back any characters past slash-star; see above */
|
||||
yyless(2);
|
||||
/* Put back any characters past slash-star; see above */
|
||||
yyless(2);
|
||||
fputs("/*", yyout);
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
|
||||
<xc>{xcinside} { ECHO; }
|
||||
<xc>{op_chars} { ECHO; }
|
||||
<xc>\*+ { ECHO; }
|
||||
<xc>\*+ { ECHO; }
|
||||
|
||||
<xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated /* comment"); }
|
||||
|
||||
@ -431,7 +431,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
addlitchar('x');
|
||||
}
|
||||
<xh>{quotestop} |
|
||||
<xh>{quotefail} {
|
||||
<xh>{quotefail} {
|
||||
yyless(1);
|
||||
BEGIN(SQL);
|
||||
yylval.str = mm_strdup(literalbuf);
|
||||
@ -439,7 +439,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
}
|
||||
|
||||
<xh><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated hexadecimal string literal"); }
|
||||
<SQL>{xnstart} {
|
||||
<SQL>{xnstart} {
|
||||
/* National character.
|
||||
* Transfer it as-is to the backend.
|
||||
*/
|
||||
@ -508,11 +508,11 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
<xq,xqc,xn,xus>{xqinside} { addlit(yytext, yyleng); }
|
||||
<xe>{xeinside} { addlit(yytext, yyleng); }
|
||||
<xe>{xeunicode} { addlit(yytext, yyleng); }
|
||||
<xe>{xeescape} { addlit(yytext, yyleng); }
|
||||
<xe>{xeescape} { addlit(yytext, yyleng); }
|
||||
<xe>{xeoctesc} { addlit(yytext, yyleng); }
|
||||
<xe>{xehexesc} { addlit(yytext, yyleng); }
|
||||
<xq,xqc,xe,xn,xus>{quotecontinue} { /* ignore */ }
|
||||
<xe>. {
|
||||
<xe>. {
|
||||
/* This is only needed for \ just before EOF */
|
||||
addlitchar(yytext[0]);
|
||||
}
|
||||
@ -523,14 +523,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
/* and treat it as {other} */
|
||||
return yytext[0];
|
||||
}
|
||||
<SQL>{dolqdelim} {
|
||||
<SQL>{dolqdelim} {
|
||||
token_start = yytext;
|
||||
dolqstart = mm_strdup(yytext);
|
||||
BEGIN(xdolq);
|
||||
startlit();
|
||||
addlit(yytext, yyleng);
|
||||
}
|
||||
<xdolq>{dolqdelim} {
|
||||
<xdolq>{dolqdelim} {
|
||||
if (strcmp(yytext, dolqstart) == 0)
|
||||
{
|
||||
addlit(yytext, yyleng);
|
||||
@ -541,22 +541,22 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* When we fail to match $...$ to dolqstart, transfer
|
||||
* the $... part to the output, but put back the final
|
||||
* $ for rescanning. Consider $delim$...$junk$delim$
|
||||
*/
|
||||
addlit(yytext, yyleng-1);
|
||||
yyless(yyleng-1);
|
||||
addlit(yytext, yyleng-1);
|
||||
yyless(yyleng-1);
|
||||
}
|
||||
}
|
||||
<xdolq>{dolqinside} { addlit(yytext, yyleng); }
|
||||
<xdolq>{dolqinside} { addlit(yytext, yyleng); }
|
||||
<xdolq>{dolqfailed} { addlit(yytext, yyleng); }
|
||||
<xdolq>{other} {
|
||||
/* single quote or dollar sign */
|
||||
addlitchar(yytext[0]);
|
||||
}
|
||||
<xdolq><<EOF>> { base_yyerror("unterminated dollar-quoted string"); }
|
||||
<xdolq><<EOF>> { base_yyerror("unterminated dollar-quoted string"); }
|
||||
<SQL>{xdstart} {
|
||||
state_before = YYSTATE;
|
||||
BEGIN(xd);
|
||||
@ -739,7 +739,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
return(CVARIABLE);
|
||||
}
|
||||
<SQL>{identifier} {
|
||||
const ScanKeyword *keyword;
|
||||
const ScanKeyword *keyword;
|
||||
|
||||
if (!isdefine())
|
||||
{
|
||||
@ -798,10 +798,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
BEGIN(incl);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
yylval.str = mm_strdup(yytext);
|
||||
return(CPP_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
<C>{cppinclude_next} {
|
||||
if (system_includes)
|
||||
@ -810,16 +810,16 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
BEGIN(incl);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
yylval.str = mm_strdup(yytext);
|
||||
return(CPP_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
<C,SQL>{cppline} {
|
||||
yylval.str = mm_strdup(yytext);
|
||||
return(CPP_LINE);
|
||||
}
|
||||
<C>{identifier} {
|
||||
<C>{identifier} {
|
||||
const ScanKeyword *keyword;
|
||||
|
||||
/*
|
||||
@ -893,7 +893,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
}
|
||||
}
|
||||
<C>{exec_sql}{undef}{space}* { BEGIN(undef); }
|
||||
<C>{informix_special}{undef}{space}* {
|
||||
<C>{informix_special}{undef}{space}* {
|
||||
/* are we simulating Informix? */
|
||||
if (INFORMIX_MODE)
|
||||
{
|
||||
@ -937,9 +937,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
|
||||
BEGIN(C);
|
||||
}
|
||||
<undef>{other}|\n {
|
||||
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command");
|
||||
yyterminate();
|
||||
<undef>{other}|\n {
|
||||
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command");
|
||||
yyterminate();
|
||||
}
|
||||
<C>{exec_sql}{include}{space}* { BEGIN(incl); }
|
||||
<C>{informix_special}{include}{space}* {
|
||||
@ -1171,17 +1171,17 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
if (yy_buffer == NULL)
|
||||
if (yy_buffer == NULL)
|
||||
{
|
||||
if ( preproc_tos > 0 )
|
||||
if ( preproc_tos > 0 )
|
||||
{
|
||||
preproc_tos = 0;
|
||||
preproc_tos = 0;
|
||||
mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\"");
|
||||
}
|
||||
}
|
||||
yyterminate();
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
struct _yy_buffer *yb = yy_buffer;
|
||||
int i;
|
||||
struct _defines *ptr;
|
||||
@ -1213,9 +1213,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
|
||||
if (i != 0)
|
||||
output_line_number();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
<INITIAL>{other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); }
|
||||
<INITIAL>{other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); }
|
||||
%%
|
||||
void
|
||||
lex_init(void)
|
||||
@ -1278,24 +1278,24 @@ parse_include(void)
|
||||
{
|
||||
/* got the include file name */
|
||||
struct _yy_buffer *yb;
|
||||
struct _include_path *ip;
|
||||
char inc_file[MAXPGPATH];
|
||||
unsigned int i;
|
||||
struct _include_path *ip;
|
||||
char inc_file[MAXPGPATH];
|
||||
unsigned int i;
|
||||
|
||||
yb = mm_alloc(sizeof(struct _yy_buffer));
|
||||
yb = mm_alloc(sizeof(struct _yy_buffer));
|
||||
|
||||
yb->buffer = YY_CURRENT_BUFFER;
|
||||
yb->lineno = yylineno;
|
||||
yb->filename = input_filename;
|
||||
yb->next = yy_buffer;
|
||||
yb->buffer = YY_CURRENT_BUFFER;
|
||||
yb->lineno = yylineno;
|
||||
yb->filename = input_filename;
|
||||
yb->next = yy_buffer;
|
||||
|
||||
yy_buffer = yb;
|
||||
yy_buffer = yb;
|
||||
|
||||
/*
|
||||
/*
|
||||
* skip the ";" if there is one and trailing whitespace. Note that
|
||||
* yytext contains at least one non-space character plus the ";"
|
||||
*/
|
||||
for (i = strlen(yytext)-2;
|
||||
for (i = strlen(yytext)-2;
|
||||
i > 0 && ecpg_isspace(yytext[i]);
|
||||
i--)
|
||||
;
|
||||
@ -1310,7 +1310,7 @@ parse_include(void)
|
||||
/* If file name is enclosed in '"' remove these and look only in '.' */
|
||||
/* Informix does look into all include paths though, except filename starts with '/' */
|
||||
if (yytext[0] == '"' && yytext[i] == '"' &&
|
||||
((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/'))
|
||||
((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/'))
|
||||
{
|
||||
yytext[i] = '\0';
|
||||
memmove(yytext, yytext+1, strlen(yytext));
|
||||
@ -1335,8 +1335,8 @@ parse_include(void)
|
||||
memmove(yytext, yytext+1, strlen(yytext));
|
||||
}
|
||||
|
||||
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
|
||||
{
|
||||
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
|
||||
{
|
||||
if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
|
||||
{
|
||||
fprintf(stderr, _("Error: include path \"%s/%s\" is too long on line %d, skipping\n"), ip->path, yytext, yylineno);
|
||||
@ -1368,7 +1368,7 @@ parse_include(void)
|
||||
yylineno = 1;
|
||||
output_line_number();
|
||||
|
||||
BEGIN(C);
|
||||
BEGIN(C);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1421,9 +1421,9 @@ static bool isinformixdefine(void)
|
||||
if (strcmp(yytext, "dec_t") == 0)
|
||||
new = "decimal";
|
||||
else if (strcmp(yytext, "intrvl_t") == 0)
|
||||
new = "interval";
|
||||
new = "interval";
|
||||
else if (strcmp(yytext, "dtime_t") == 0)
|
||||
new = "timestamp";
|
||||
new = "timestamp";
|
||||
|
||||
if (new)
|
||||
{
|
||||
|
Reference in New Issue
Block a user