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
1005c993
Commit
1005c993
authored
Feb 14, 2003
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In Informix mode ecpg should still be able to parse preprocessor directives.
parent
e9551212
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
4 deletions
+142
-4
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+142
-4
No files found.
src/interfaces/ecpg/preproc/pgc.l
View file @
1005c993
...
...
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.10
4 2003/02/14 13:17:13
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.10
5 2003/02/14 16:40:01
meskes Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -43,6 +43,7 @@ static int literalalloc; /* current allocated buffer size */
#define startlit() (literalbuf[0] = '\0', literallen = 0)
static void addlit(char *ytext, int yleng);
static void addlitchar (unsigned char);
static void string_unput (char *);
char *token_start;
int state_before;
...
...
@@ -701,12 +702,67 @@ cppline {space}*#(.*\\{space})*.*
<C>{other} { return S_ANYTHING; }
<C>{exec_sql}{define}{space}* { BEGIN(def_ident); }
<C>{informix_special}{define}{space}* {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
BEGIN(def_ident);
}
else
{
string_unput("define ");
/* remove the "define " part of the text */
yytext[1] = '\0';
return (S_ANYTHING);
}
}
<C>{exec_sql}{include}{space}* { BEGIN(incl); }
<C>{informix_special}{include}{space}* { BEGIN(incl); }
<C>{informix_special}{include}{space}* {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
BEGIN(incl);
}
else
{
string_unput("include ");
/* remove the "include " part of the text */
yytext[1] = '\0';
return (S_ANYTHING);
}
}
<C,xskip>{exec_sql}{ifdef}{space}* { ifcond = TRUE; BEGIN(xcond); }
<C,xskip>{informix_special}{ifdef}{space}* {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
ifcond = TRUE;
BEGIN(xcond);
}
else
{
string_unput("ifdef ");
/* remove the "ifdef " part of the text */
yytext[1] = '\0';
return (S_ANYTHING);
}
}
<C,xskip>{exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); }
<C,xskip>{informix_special}{ifndef}{space}* {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
ifcond = FALSE;
BEGIN(xcond);
}
else
{
string_unput("ifndef ");
/* remove the "ifndef " part of the text */
yytext[1] = '\0';
return (S_ANYTHING);
}
}
<C,xskip>{exec_sql}{elif}{space}* { /* pop stack */
if ( preproc_tos == 0 ) {
mmerror(PARSE_ERROR, ET_FATAL, "Missing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");
...
...
@@ -718,6 +774,28 @@ cppline {space}*#(.*\\{space})*.*
ifcond = TRUE; BEGIN(xcond);
}
<C,xskip>{informix_special}{elif}{space}* {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
if ( preproc_tos == 0 ) {
mmerror(PARSE_ERROR, ET_FATAL, "Missing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");
}
else if ( stacked_if_value[preproc_tos].else_branch )
mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");
else
preproc_tos--;
ifcond = TRUE; BEGIN(xcond);
}
else
{
string_unput("elif ");
/* remove the "elif " part of the text */
yytext[1] = '\0';
return (S_ANYTHING);
}
}
<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 ) {
...
...
@@ -735,6 +813,33 @@ cppline {space}*#(.*\\{space})*.*
BEGIN(xskip);
}
}
<C,xskip>{informix_special}{else}{space}* {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
if ( stacked_if_value[preproc_tos].else_branch ) {
mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");
}
else {
stacked_if_value[preproc_tos].else_branch = TRUE;
stacked_if_value[preproc_tos].condition =
(stacked_if_value[preproc_tos-1].condition &&
! stacked_if_value[preproc_tos].condition);
if ( stacked_if_value[preproc_tos].condition )
BEGIN(C);
else
BEGIN(xskip);
}
}
else
{
string_unput("else ");
/* remove the "else " part of the text */
yytext[1] = '\0';
return (S_ANYTHING);
}
}
<C,xskip>{exec_sql}{endif}{space}*";" {
if ( preproc_tos == 0 )
mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");
...
...
@@ -746,6 +851,28 @@ cppline {space}*#(.*\\{space})*.*
else
BEGIN(xskip);
}
<C,xskip>{informix_special}{endif}{space}* {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
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);
}
else
{
string_unput("endif ");
/* remove the "endif " part of the text */
yytext[1] = '\0';
return (S_ANYTHING);
}
}
<xskip>{other} { /* ignore */ }
...
...
@@ -983,3 +1110,14 @@ addlitchar(unsigned char ychar)
literallen += 1;
literalbuf[literallen] = '\0';
}
/* put string back on stack */
static void
string_unput (char *string)
{
int i;
for (i = strlen(string)-1; i>=0; i--)
unput(string[i]);
}
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