@ -541,7 +541,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xb>{xbinside} {
addlit(yytext, yyleng);
}
<xb><<EOF>> { mmfatal(PARSE_ERROR, "unterminated bit string literal"); }
<xb><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated bit string literal");
}
<SQL>{xhstart} {
token_start = yytext;
@ -549,7 +551,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(xh);
startlit();
}
<xh><<EOF>> { mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal"); }
<xh><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal");
}
<C>{xqstart} {
token_start = yytext;
@ -560,9 +564,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<SQL>{
{xnstart} {
/* National character.
* Transfer it as-is to the backend.
*/
/* National character. Transfer it as-is to the backend. */
token_start = yytext;
state_before_str_start = YYSTATE;
BEGIN(xn);
@ -651,9 +653,15 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
<xq,xe,xn,xus>{xqdouble} { addlit(yytext, yyleng); }
<xqc>{xqcquote} { addlit(yytext, yyleng); }
<xq,xqc,xn,xus>{xqinside} { addlit(yytext, yyleng); }
<xq,xe,xn,xus>{xqdouble} {
addlit(yytext, yyleng);
}
<xqc>{xqcquote} {
addlit(yytext, yyleng);
}
<xq,xqc,xn,xus>{xqinside} {
addlit(yytext, yyleng);
}
<xe>{xeinside} {
addlit(yytext, yyleng);
}
@ -673,7 +681,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
}
<xq,xqc,xe,xn,xus><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted string"); }
<xq,xqc,xe,xn,xus><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted string");
}
<SQL>{
{dolqdelim} {
@ -724,7 +734,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* single quote or dollar sign */
addlitchar(yytext[0]);
}
<xdolq><<EOF>> { mmfatal(PARSE_ERROR, "unterminated dollar-quoted string"); }
<xdolq><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated dollar-quoted string");
}
<SQL>{
{xdstart} {
@ -743,6 +755,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(state_before_str_start);
if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
/*
* The server will truncate the identifier here. We do
* not, as (1) it does not change the result; (2) we don't
@ -763,7 +776,11 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(state_before_str_start);
if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
/* The backend will truncate the identifier here. We do not as it does not change the result. */
/*
* The backend will truncate the identifier here. We do
* not as it does not change the result.
*/
base_yylval.str = psprintf("U&\"%s\"", literalbuf);
return UIDENT;
}
@ -773,7 +790,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xd,xui>{xdinside} {
addlit(yytext, yyleng);
}
<xd,xui><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted identifier"); }
<xd,xui><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted identifier");
}
<C>{xdstart} {
state_before_str_start = YYSTATE;
BEGIN(xdc);
@ -782,7 +801,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xdc>{xdcinside} {
addlit(yytext, yyleng);
}
<xdc><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted string"); }
<xdc><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted string");
}
<SQL>{
{typecast} {
@ -831,9 +852,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
{self} {
/*
* We may find a ';' inside a structure
* definition in a TYPE or VAR statement.
* This is not an EOL marker.
* We may find a ';' inside a structure definition in a
* TYPE or VAR statement. This is not an EOL marker.
*/
if (yytext[0] == ';' && struct_level == 0)
BEGIN(C);
@ -879,6 +899,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
for (ic = nchars - 2; ic >= 0; ic--)
{
char c = yytext[ic];
if (c == '~' || c == '!' || c == '@' ||
c == '#' || c == '^' || c == '&' ||
c == '|' || c == '`' || c == '?' ||
@ -891,7 +912,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
* didn't find a qualifying character, so remove
* all trailing [+-]
*/
do {
do
{
nchars--;
} while (nchars > 1 &&
(yytext[nchars - 1] == '+' ||
@ -903,6 +925,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
{
/* Strip the unwanted chars from the token */
yyless(nchars);
/*
* If what we have left is only one char, and it's
* one of the characters matching "self", then
@ -912,6 +935,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
if (nchars == 1 &&
strchr(",()[].;:+-*/%^<>=", yytext[0]))
return yytext[0];
/*
* Likewise, if what we have left is two chars, and
* those match the tokens ">=", "<=", "=>", "<>" or
@ -1053,8 +1077,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
*
* The backend will attempt to truncate and case-fold
* the identifier, but I see no good reason for ecpg
* to do so; that's just another way that ecpg could get
* out of step with the backend.
* to do so; that's just another way that ecpg could
* get out of step with the backend.
*/
base_yylval.str = mm_strdup(yytext);
return IDENT;
@ -1070,7 +1094,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
* Begin ECPG-specific rules
*/
<C>{exec_sql} { BEGIN(SQL); return SQL_START; }
<C>{exec_sql} {
BEGIN(SQL);
return SQL_START;
}
<C>{informix_special} {
/* are we simulating Informix? */
if (INFORMIX_MODE)
@ -1081,7 +1108,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
else
return S_ANYTHING;
}
<C>{ccomment} { ECHO; }
<C>{ccomment} {
ECHO;
}
<C>{cppinclude} {
if (system_includes)
{
@ -1138,7 +1167,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
}
<C>{xcstop} { mmerror(PARSE_ERROR, ET_ERROR, "nested /* ... */ comments"); }
<C>{xcstop} {
mmerror(PARSE_ERROR, ET_ERROR, "nested /* ... */ comments");
}
<C>":" { return ':'; }
<C>";" { return ';'; }
<C>"," { return ','; }
@ -1185,7 +1216,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
return S_ANYTHING;
}
}
<C>{exec_sql}{undef}{space}* { BEGIN(undef); }
<C>{exec_sql}{undef}{space}* {
BEGIN(undef);
}
<C>{informix_special}{undef}{space}* {
/* are we simulating Informix? */
if (INFORMIX_MODE)
@ -1199,7 +1232,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
<undef>{identifier}{space}*";" {
struct _defines *ptr, *ptr2 = NULL;
struct _defines *ptr,
*ptr2 = NULL;
int i;
/*
@ -1212,7 +1246,6 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
;
yytext[i + 1] = '\0';
/* Find and unset any matching define; should be only 1 */
for (ptr = defines; ptr; ptr2 = ptr, ptr = ptr->next)
{
@ -1240,7 +1273,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL UNDEF command");
yyterminate();
}
<C>{exec_sql}{include}{space}* { BEGIN(incl); }
<C>{exec_sql}{include}{space}* {
BEGIN(incl);
}
<C>{informix_special}{include}{space}* {
/* are we simulating Informix? */
if (INFORMIX_MODE)
@ -1337,7 +1372,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
<C,xskip>{exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */
<C,xskip>{exec_sql}{else}{space}*";" {
/* only exec sql endif pops the stack, so take care of duplicated 'else' */
if (preproc_tos == 0)
mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
else if (stacked_if_value[preproc_tos].else_branch)
@ -1425,13 +1461,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
bool this_active;
/*
* Skip the ";" and trailing whitespace. Note that yytext
* contains at least one non-space character plus the ";"
* Skip the ";" and trailing whitespace. Note that
* yytext contains at least one non-space character
* plus the ";"
*/
for (i = strlen(yytext) - 2;
i > 0 && ecpg_isspace(yytext[i]);
i--)
;
/* skip */ ;
yytext[i + 1] = '\0';
/* Does a definition exist? */
@ -1559,11 +1596,12 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
if (i != 0)
output_line_number();
}
}
<INITIAL>{other}|\n { mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to <%s>", PACKAGE_BUGREPORT); }
<INITIAL>{other}|\n {
mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to <%s>", PACKAGE_BUGREPORT);
}
%%
@ -1668,8 +1706,8 @@ parse_include(void)
yy_buffer = yb;
/*
* skip the ";" if there is one and trailing whitespace. Note that
* yytext contains at least one non-space character plus the ";"
* 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;
i > 0 && ecpg_isspace(yytext[i]);
@ -1684,7 +1722,11 @@ parse_include(void)
yyin = NULL;
/* If file name is enclosed in '"' remove these and look only in '.' */
/* Informix does look into all include paths though, except filename starts with '/' */
/*
* 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] == '/'))
{
@ -1728,7 +1770,11 @@ parse_include(void)
yyin = fopen(inc_file, "r");
}
}
/* if the command was "include_next" we have to disregard the first hit */
/*
* if the command was "include_next" we have to disregard the
* first hit
*/
if (yyin && include_next)
{
fclose(yyin);