Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
71b9df2b
Commit
71b9df2b
authored
Feb 01, 2006
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make pgc.l source code alignment consistent.
parent
bd5d12a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
224 additions
and
220 deletions
+224
-220
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+224
-220
No files found.
src/interfaces/ecpg/preproc/pgc.l
View file @
71b9df2b
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.13
7 2005/10/05 14:58:36 meskes
Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.13
8 2006/02/01 20:56:44 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -28,9 +28,9 @@
...
@@ -28,9 +28,9 @@
extern YYSTYPE yylval;
extern YYSTYPE yylval;
static int xcdepth = 0; /* depth of nesting in slash-star comments */
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 */
bool
escape_string_warning;
bool
escape_string_warning;
static bool
warn_on_first_escape;
static bool
warn_on_first_escape;
/*
/*
* literalbuf is used to accumulate literal values when multiple rules
* literalbuf is used to accumulate literal values when multiple rules
...
@@ -121,13 +121,13 @@ xhstart [xX]{quote}
...
@@ -121,13 +121,13 @@ xhstart [xX]{quote}
xhinside [^']*
xhinside [^']*
/* National character */
/* National character */
xnstart
[nN]{quote}
xnstart
[nN]{quote}
/* Quoted string that allows backslash escapes */
/* Quoted string that allows backslash escapes */
xestart [eE]{quote}
xestart [eE]{quote}
/* C version of hex number */
/* C version of hex number */
xch 0[xX][0-9A-Fa-f]*
xch
0[xX][0-9A-Fa-f]*
/* Extended quote
/* Extended quote
* xqdouble implements embedded quote, ''''
* xqdouble implements embedded quote, ''''
...
@@ -148,11 +148,11 @@ xqhexesc [\\]x[0-9A-Fa-f]{1,2}
...
@@ -148,11 +148,11 @@ xqhexesc [\\]x[0-9A-Fa-f]{1,2}
* {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
* {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
* fails to match its trailing "$".
* fails to match its trailing "$".
*/
*/
dolq_start
[A-Za-z\200-\377_]
dolq_start
[A-Za-z\200-\377_]
dolq_cont
[A-Za-z\200-\377_0-9]
dolq_cont
[A-Za-z\200-\377_0-9]
dolqdelim
\$({dolq_start}{dolq_cont}*)?\$
dolqdelim
\$({dolq_start}{dolq_cont}*)?\$
dolqfailed
\${dolq_start}{dolq_cont}*
dolqfailed
\${dolq_start}{dolq_cont}*
dolqinside
[^$]+
dolqinside
[^$]+
/* Double quote
/* Double quote
* Allows embedded spaces and other special characters into identifiers.
* Allows embedded spaces and other special characters into identifiers.
...
@@ -224,9 +224,9 @@ operator {op_chars}+
...
@@ -224,9 +224,9 @@ operator {op_chars}+
integer {digit}+
integer {digit}+
decimal (({digit}*\.{digit}+)|({digit}+\.{digit}*))
decimal (({digit}*\.{digit}+)|({digit}+\.{digit}*))
real
({integer}|{decimal})[Ee][-+]?{digit}+
real
({integer}|{decimal})[Ee][-+]?{digit}+
realfail1
({integer}|{decimal})[Ee]
realfail1
({integer}|{decimal})[Ee]
realfail2
({integer}|{decimal})[Ee][-+]
realfail2
({integer}|{decimal})[Ee][-+]
param \${integer}
param \${integer}
...
@@ -268,7 +268,7 @@ whitespace_with_newline ({horiz_whitespace}*{newline}{whitespace}*)
...
@@ -268,7 +268,7 @@ whitespace_with_newline ({horiz_whitespace}*{newline}{whitespace}*)
quote '
quote '
quotestop {quote}{whitespace}*
quotestop {quote}{whitespace}*
quotecontinue
{quote}{whitespace_with_newline}{quote}
quotecontinue {quote}{whitespace_with_newline}{quote}
quotefail {quote}{whitespace}*"-"
quotefail {quote}{whitespace}*"-"
/* special characters for other dbms */
/* special characters for other dbms */
...
@@ -293,7 +293,7 @@ struct [sS][tT][rR][uU][cC][tT]
...
@@ -293,7 +293,7 @@ struct [sS][tT][rR][uU][cC][tT]
exec_sql {exec}{space}*{sql}{space}*
exec_sql {exec}{space}*{sql}{space}*
ipdigit ({digit}|{digit}{digit}|{digit}{digit}{digit})
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 */
/* we might want to parse all cpp include files */
cppinclude {space}*#{include}{space}*
cppinclude {space}*#{include}{space}*
...
@@ -317,8 +317,8 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -317,8 +317,8 @@ cppline {space}*#(.*\\{space})*.*{newline}
%%
%%
%{
%{
/* code to execute during start of each call of yylex() */
/* code to execute during start of each call of yylex() */
token_start = NULL;
token_start = NULL;
%}
%}
<SQL>{whitespace} { /* ignore */ }
<SQL>{whitespace} { /* ignore */ }
...
@@ -350,27 +350,27 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -350,27 +350,27 @@ cppline {space}*#(.*\\{space})*.*{newline}
xcdepth--;
xcdepth--;
}
}
<xc>{xcinside}
{ ECHO; }
<xc>{xcinside} { ECHO; }
<xc>{op_chars}
{ ECHO; }
<xc>{op_chars} { ECHO; }
<xc>\*+ { ECHO; }
<xc>\*+ { ECHO; }
<xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated /* comment"); }
<xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated /* comment"); }
<SQL>{xbstart} {
<SQL>{xbstart} {
token_start = yytext;
token_start = yytext;
BEGIN(xb);
BEGIN(xb);
startlit();
startlit();
addlitchar('b');
addlitchar('b');
}
}
<xb>{quotestop} |
<xb>{quotestop} |
<xb>{quotefail} {
<xb>{quotefail} {
yyless(1);
yyless(1);
BEGIN(SQL);
BEGIN(SQL);
if (literalbuf[strspn(literalbuf, "01") + 1] != '\0')
if (literalbuf[strspn(literalbuf, "01") + 1] != '\0')
mmerror(PARSE_ERROR, ET_ERROR, "invalid bit string input.");
mmerror(PARSE_ERROR, ET_ERROR, "invalid bit string input.");
yylval.str = mm_strdup(literalbuf);
yylval.str = mm_strdup(literalbuf);
return BCONST;
return BCONST;
}
}
<xh>{xhinside} |
<xh>{xhinside} |
<xb>{xbinside} { addlit(yytext, yyleng); }
<xb>{xbinside} { addlit(yytext, yyleng); }
...
@@ -378,12 +378,12 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -378,12 +378,12 @@ cppline {space}*#(.*\\{space})*.*{newline}
<xb>{quotecontinue} { /* ignore */ }
<xb>{quotecontinue} { /* ignore */ }
<xb><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated bit string"); }
<xb><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated bit string"); }
<SQL>{xhstart}
{
<SQL>{xhstart} {
token_start = yytext;
token_start = yytext;
BEGIN(xh);
BEGIN(xh);
startlit();
startlit();
addlitchar('x');
addlitchar('x');
}
}
<xh>{quotestop} |
<xh>{quotestop} |
<xh>{quotefail} {
<xh>{quotefail} {
yyless(1);
yyless(1);
...
@@ -395,9 +395,9 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -395,9 +395,9 @@ cppline {space}*#(.*\\{space})*.*{newline}
<xh><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated hexadecimal integer"); }
<xh><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated hexadecimal integer"); }
<SQL>{xnstart} {
<SQL>{xnstart} {
/* National character.
/* National character.
* Transfer it as-is to the backend.
* Transfer it as-is to the backend.
*/
*/
token_start = yytext;
token_start = yytext;
BEGIN(xq);
BEGIN(xq);
startlit();
startlit();
}
}
...
@@ -437,10 +437,10 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -437,10 +437,10 @@ cppline {space}*#(.*\\{space})*.*{newline}
addlit(yytext, yyleng);
addlit(yytext, yyleng);
}
}
<xq>{quotecontinue} { /* ignore */ }
<xq>{quotecontinue} { /* ignore */ }
<xq>.
{
<xq>.
{
/* This is only needed for \ just before EOF */
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
addlitchar(yytext[0]);
}
}
<xq><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated quoted string"); }
<xq><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "Unterminated quoted string"); }
<SQL>{dolqfailed} {
<SQL>{dolqfailed} {
/* throw back all but the initial "$" */
/* throw back all but the initial "$" */
...
@@ -464,18 +464,18 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -464,18 +464,18 @@ cppline {space}*#(.*\\{space})*.*{newline}
}
}
else
else
{
{
/*
/*
* When we fail to match $...$ to dolqstart, transfer
* When we fail to match $...$ to dolqstart, transfer
* the $... part to the output, but put back the final
* the $... part to the output, but put back the final
* $ for rescanning. Consider $delim$...$junk$delim$
* $ for rescanning. Consider $delim$...$junk$delim$
*/
*/
addlit(yytext, yyleng-1);
addlit(yytext, yyleng-1);
yyless(yyleng-1);
yyless(yyleng-1);
}
}
}
}
<xdolq>{dolqinside} { addlit(yytext, yyleng); }
<xdolq>{dolqinside} { addlit(yytext, yyleng); }
<xdolq>{dolqfailed} { addlit(yytext, yyleng); }
<xdolq>{dolqfailed} { addlit(yytext, yyleng); }
<xdolq>.
{
<xdolq>. {
/* This is only needed for $ inside the quoted text */
/* This is only needed for $ inside the quoted text */
addlitchar(yytext[0]);
addlitchar(yytext[0]);
}
}
...
@@ -511,13 +511,13 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -511,13 +511,13 @@ cppline {space}*#(.*\\{space})*.*{newline}
<SQL>{typecast} { return TYPECAST; }
<SQL>{typecast} { return TYPECAST; }
<SQL>{informix_special} {
<SQL>{informix_special} {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
unput(':');
unput(':');
}
}
else
else
return yytext[0];
return yytext[0];
}
}
<SQL>{self} { /*
<SQL>{self} { /*
* We may find a ';' inside a structure
* We may find a ';' inside a structure
* definition in a TYPE or VAR statement.
* definition in a TYPE or VAR statement.
...
@@ -632,15 +632,15 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -632,15 +632,15 @@ cppline {space}*#(.*\\{space})*.*{newline}
return FCONST;
return FCONST;
}
}
<SQL>{realfail1} {
<SQL>{realfail1} {
yyless(yyleng-1);
yyless(yyleng-1);
yylval.str = mm_strdup(yytext);
yylval.str = mm_strdup(yytext);
return FCONST;
return FCONST;
}
}
<SQL>{realfail2} {
<SQL>{realfail2} {
yyless(yyleng-2);
yyless(yyleng-2);
yylval.str = mm_strdup(yytext);
yylval.str = mm_strdup(yytext);
return FCONST;
return FCONST;
}
}
<SQL>:{identifier}((("->"|\.){identifier})|(\[{array}\]))* {
<SQL>:{identifier}((("->"|\.){identifier})|(\[{array}\]))* {
yylval.str = mm_strdup(yytext+1);
yylval.str = mm_strdup(yytext+1);
return(CVARIABLE);
return(CVARIABLE);
...
@@ -701,16 +701,16 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -701,16 +701,16 @@ cppline {space}*#(.*\\{space})*.*{newline}
<SQL>{other} { return yytext[0]; }
<SQL>{other} { return yytext[0]; }
<C>{exec_sql} { BEGIN SQL; return SQL_START; }
<C>{exec_sql} { BEGIN SQL; return SQL_START; }
<C>{informix_special} {
<C>{informix_special} {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
BEGIN SQL;
BEGIN SQL;
return SQL_START;
return SQL_START;
}
}
else
else
return S_ANYTHING;
return S_ANYTHING;
}
}
<C>{ccomment}
{ ECHO; }
<C>{ccomment} { ECHO; }
<C>{xch} {
<C>{xch} {
char* endptr;
char* endptr;
...
@@ -725,17 +725,17 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -725,17 +725,17 @@ cppline {space}*#(.*\\{space})*.*{newline}
return ICONST;
return ICONST;
}
}
<C>{cppinclude} {
<C>{cppinclude} {
if (system_includes)
if (system_includes)
{
{
BEGIN(incl);
BEGIN(incl);
}
}
else
else
{
{
yylval.str = mm_strdup(yytext);
yylval.str = mm_strdup(yytext);
return(CPP_LINE);
return(CPP_LINE);
}
}
}
}
<C,SQL>{cppline}
{
<C,SQL>{cppline} {
yylval.str = mm_strdup(yytext);
yylval.str = mm_strdup(yytext);
return(CPP_LINE);
return(CPP_LINE);
}
}
...
@@ -743,7 +743,7 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -743,7 +743,7 @@ cppline {space}*#(.*\\{space})*.*{newline}
ScanKeyword *keyword;
ScanKeyword *keyword;
struct _defines *ptr;
struct _defines *ptr;
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
/* Informix uses SQL defines only in SQL space */
/* Informix uses SQL defines only in SQL space */
ptr = NULL;
ptr = NULL;
...
@@ -777,8 +777,8 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -777,8 +777,8 @@ cppline {space}*#(.*\\{space})*.*{newline}
keyword = ScanCKeywordLookup(yytext);
keyword = ScanCKeywordLookup(yytext);
if (keyword != NULL)
if (keyword != NULL)
return keyword->value;
return keyword->value;
else
else
{
{
yylval.str = mm_strdup(yytext);
yylval.str = mm_strdup(yytext);
return IDENT;
return IDENT;
}
}
...
@@ -793,7 +793,7 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -793,7 +793,7 @@ cppline {space}*#(.*\\{space})*.*{newline}
<C>"-" { return('-'); }
<C>"-" { return('-'); }
<C>"(" { return('('); }
<C>"(" { return('('); }
<C>")" { return(')'); }
<C>")" { return(')'); }
<C,xskip>{space}
{ ECHO; }
<C,xskip>{space} { ECHO; }
<C>\{ { return('{'); }
<C>\{ { return('{'); }
<C>\} { return('}'); }
<C>\} { return('}'); }
<C>\[ { return('['); }
<C>\[ { return('['); }
...
@@ -883,133 +883,136 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -883,133 +883,136 @@ cppline {space}*#(.*\\{space})*.*{newline}
ifcond = TRUE; BEGIN(xcond);
ifcond = TRUE; BEGIN(xcond);
}
}
<C,xskip>{informix_special}{elif}{space}* {
<C,xskip>{informix_special}{elif}{space}* {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
if (
preproc_tos == 0 ) {
if (
preproc_tos == 0)
mmerror(PARSE_ERROR, ET_FATAL, "Missing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");
mmerror(PARSE_ERROR, ET_FATAL, "Missing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");
}
else if (stacked_if_value[preproc_tos].else_branch)
else if ( stacked_if_value[preproc_tos].else_branch )
mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");
mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");
else
else
preproc_tos--;
preproc_tos--;
ifcond = TRUE; BEGIN(xcond);
ifcond = TRUE;
}
BEGIN(xcond);
else
{
yyless(1);
return (S_ANYTHING);
}
}
}
else
{
yyless(1);
return (S_ANYTHING);
}
}
<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 ( stacked_if_value[preproc_tos].else_branch ) {
if (stacked_if_value[preproc_tos].else_branch)
mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");
mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");
}
else
else
{
{
stacked_if_value[preproc_tos].else_branch = TRUE;
stacked_if_value[preproc_tos].else_branch = TRUE;
stacked_if_value[preproc_tos].condition =
stacked_if_value[preproc_tos].condition =
(stacked_if_value[preproc_tos-1].condition &&
(stacked_if_value[preproc_tos-1].condition &&
!
stacked_if_value[preproc_tos].condition);
!stacked_if_value[preproc_tos].condition);
if ( stacked_if_value[preproc_tos].condition )
if (stacked_if_value[preproc_tos].condition)
BEGIN(C);
BEGIN(C);
else
else
BEGIN(xskip);
BEGIN(xskip);
}
}
}
}
<C,xskip>{informix_special}{else}{space}* {
<C,xskip>{informix_special}{else}{space}* {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
if (
stacked_if_value[preproc_tos].else_branch ) {
if (
stacked_if_value[preproc_tos].else_branch)
mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");
mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");
}
else
else
{
{
stacked_if_value[preproc_tos].else_branch = TRUE;
stacked_if_value[preproc_tos].else_branch = TRUE;
stacked_if_value[preproc_tos].condition =
stacked_if_value[preproc_tos].condition =
(stacked_if_value[preproc_tos-1].condition &&
(stacked_if_value[preproc_tos-1].condition &&
!
stacked_if_value[preproc_tos].condition);
!stacked_if_value[preproc_tos].condition);
if (
stacked_if_value[preproc_tos].condition
)
if (
stacked_if_value[preproc_tos].condition
)
BEGIN(C);
BEGIN(C);
else
else
BEGIN(xskip);
BEGIN(xskip);
}
}
}
else
{
yyless(1);
return (S_ANYTHING);
}
}
}
<C,xskip>{exec_sql}{endif}{space}*";" {
else
if ( preproc_tos == 0 )
{
mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");
yyless(1);
else
return (S_ANYTHING);
preproc_tos--;
if ( stacked_if_value[preproc_tos].condition )
BEGIN(C);
else
BEGIN(xskip);
}
}
}
<C,xskip>{exec_sql}{endif}{space}*";" {
if (preproc_tos == 0)
mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");
else
preproc_tos--;
if (stacked_if_value[preproc_tos].condition)
BEGIN(C);
else
BEGIN(xskip);
}
<C,xskip>{informix_special}{endif}{space}*";" {
<C,xskip>{informix_special}{endif}{space}*";" {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
if (
preproc_tos == 0
)
if (
preproc_tos == 0
)
mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");
mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");
else
else
preproc_tos--;
preproc_tos--;
if (
stacked_if_value[preproc_tos].condition
)
if (
stacked_if_value[preproc_tos].condition
)
BEGIN(C);
BEGIN(C);
else
else
BEGIN(xskip);
BEGIN(xskip);
}
}
else
else
{
{
yyless(1);
yyless(1);
return (S_ANYTHING);
return (S_ANYTHING);
}
}
}
}
<xskip>{other} { /* ignore */ }
<xskip>{other} { /* ignore */ }
<xcond>{identifier}{space}*";" {
<xcond>{identifier}{space}*";" {
if ( preproc_tos >= MAX_NESTED_IF-1 ) {
if (preproc_tos >= MAX_NESTED_IF-1)
mmerror(PARSE_ERROR, ET_FATAL, "Too many nested 'EXEC SQL IFDEF' conditions");
mmerror(PARSE_ERROR, ET_FATAL, "Too many nested 'EXEC SQL IFDEF' conditions");
}
else
else
{
{
struct _defines *defptr;
struct _defines *defptr;
unsigned int i;
unsigned int i;
/* skip the ";" and trailing whitespace. Note that yytext contains
at least one non-space character plus the ";" */
for ( i = strlen(yytext)-2;
i > 0 && isspace((unsigned char) yytext[i]);
i-- )
{}
yytext[i+1] = '\0';
for ( defptr = defines; defptr != NULL &&
( strcmp(yytext, defptr->old) != 0 ); defptr = defptr->next );
preproc_tos++;
stacked_if_value[preproc_tos].else_branch = FALSE;
stacked_if_value[preproc_tos].condition =
( (defptr ? ifcond : !ifcond) && stacked_if_value[preproc_tos-1].condition );
}
if ( stacked_if_value[preproc_tos].condition )
/*
BEGIN C;
* Skip the ";" and trailing whitespace. Note that yytext
else
* contains at least one non-space character plus the ";"
BEGIN(xskip);
*/
for (i = strlen(yytext)-2;
i > 0 && isspace((unsigned char) yytext[i]);
i-- )
;
yytext[i+1] = '\0';
for (defptr = defines;
defptr != NULL && strcmp(yytext, defptr->old) != 0;
defptr = defptr->next)
;
preproc_tos++;
stacked_if_value[preproc_tos].else_branch = FALSE;
stacked_if_value[preproc_tos].condition =
(defptr ? ifcond : !ifcond) && stacked_if_value[preproc_tos-1].condition;
}
}
if (stacked_if_value[preproc_tos].condition)
BEGIN C;
else
BEGIN(xskip);
}
<def_ident>{identifier} {
<def_ident>{identifier} {
old = mm_strdup(yytext);
old = mm_strdup(yytext);
BEGIN(def);
BEGIN(def);
...
@@ -1048,49 +1051,50 @@ cppline {space}*#(.*\\{space})*.*{newline}
...
@@ -1048,49 +1051,50 @@ cppline {space}*#(.*\\{space})*.*{newline}
<incl>[^;\<\>\"]+";" { parse_include(); }
<incl>[^;\<\>\"]+";" { parse_include(); }
<<EOF>> {
<<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;'");
mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");
}
}
yyterminate();
yyterminate();
}
}
else
else
{
{
struct _yy_buffer *yb = yy_buffer;
struct _yy_buffer *yb = yy_buffer;
int i;
int i;
struct _defines *ptr;
struct _defines *ptr;
for (ptr = defines; ptr; ptr = ptr->next)
for (ptr = defines; ptr; ptr = ptr->next)
if (ptr->used == yy_buffer)
if (ptr->used == yy_buffer)
{
{
ptr->used = NULL;
ptr->used = NULL;
break;
break;
}
}
if (yyin != NULL)
if (yyin != NULL)
fclose(yyin);
fclose(yyin);
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer(yy_buffer->buffer);
yy_switch_to_buffer(yy_buffer->buffer);
yylineno = yy_buffer->lineno;
yylineno = yy_buffer->lineno;
/* We have to output the filename only if we change files here */
/* We have to output the filename only if we change files here */
i = strcmp(input_filename, yy_buffer->filename);
i = strcmp(input_filename, yy_buffer->filename);
free(input_filename);
free(input_filename);
input_filename = yy_buffer->filename;
input_filename = yy_buffer->filename;
yy_buffer = yy_buffer->next;
yy_buffer = yy_buffer->next;
free(yb);
free(yb);
if (i != 0)
if (i != 0)
output_line_number();
output_line_number();
}
}
}
}
%%
%%
void
void
lex_init(void)
lex_init(void)
...
@@ -1168,10 +1172,10 @@ parse_include(void)
...
@@ -1168,10 +1172,10 @@ parse_include(void)
* skip the ";" if there is one and trailing whitespace. Note that
* skip the ";" if there is one and trailing whitespace. Note that
* yytext contains at least one non-space character plus the ";"
* yytext contains at least one non-space character plus the ";"
*/
*/
for (
i = strlen(yytext)-2;
for (i = strlen(yytext)-2;
i > 0 && isspace((unsigned char) yytext[i]);
i > 0 && isspace((unsigned char) yytext[i]);
i--
)
i--
)
{}
;
if (yytext[i] == ';')
if (yytext[i] == ';')
i--;
i--;
...
@@ -1182,7 +1186,7 @@ parse_include(void)
...
@@ -1182,7 +1186,7 @@ parse_include(void)
/* If file name is enclosed in '"' remove these and look only in '.' */
/* 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] == '"')
&&
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';
yytext[i] = '\0';
...
@@ -1243,5 +1247,5 @@ check_escape_warning(void)
...
@@ -1243,5 +1247,5 @@ check_escape_warning(void)
{
{
if (warn_on_first_escape && escape_string_warning)
if (warn_on_first_escape && escape_string_warning)
mmerror (PARSE_ERROR, ET_WARNING, "nonstandard use of escape in a string literal");
mmerror (PARSE_ERROR, ET_WARNING, "nonstandard use of escape in a string literal");
warn_on_first_escape = false; /* warn only once per string */
warn_on_first_escape = false; /* warn only once per string */
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment