summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.trailer4
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.type2
-rw-r--r--src/interfaces/ecpg/preproc/parse.pl1
-rw-r--r--src/interfaces/ecpg/preproc/pgc.l12
4 files changed, 12 insertions, 7 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 6ccc8ab9165..14ad27c3597 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1715,13 +1715,13 @@ cvariable: CVARIABLE
ecpg_param: PARAM { $$ = make_name(); } ;
-ecpg_bconst: BCONST { $$ = make_name(); } ;
+ecpg_bconst: BCONST { $$ = $1; } ;
ecpg_fconst: FCONST { $$ = make_name(); } ;
ecpg_sconst: SCONST { $$ = $1; } ;
-ecpg_xconst: XCONST { $$ = make_name(); } ;
+ecpg_xconst: XCONST { $$ = $1; } ;
ecpg_ident: IDENT { $$ = $1; }
| CSTRING { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
diff --git a/src/interfaces/ecpg/preproc/ecpg.type b/src/interfaces/ecpg/preproc/ecpg.type
index ffafa82af9c..eca298bdb80 100644
--- a/src/interfaces/ecpg/preproc/ecpg.type
+++ b/src/interfaces/ecpg/preproc/ecpg.type
@@ -122,7 +122,9 @@
%type <str> CSTRING
%type <str> CPP_LINE
%type <str> CVARIABLE
+%type <str> BCONST
%type <str> SCONST
+%type <str> XCONST
%type <str> IDENT
%type <struct_union> s_struct_union_symbol
diff --git a/src/interfaces/ecpg/preproc/parse.pl b/src/interfaces/ecpg/preproc/parse.pl
index 1a76b2d326b..52ba7dfa0cd 100644
--- a/src/interfaces/ecpg/preproc/parse.pl
+++ b/src/interfaces/ecpg/preproc/parse.pl
@@ -38,6 +38,7 @@ my %replace_token = (
'BCONST' => 'ecpg_bconst',
'FCONST' => 'ecpg_fconst',
'Sconst' => 'ecpg_sconst',
+ 'XCONST' => 'ecpg_xconst',
'IDENT' => 'ecpg_ident',
'PARAM' => 'ecpg_param',);
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l
index 91d8b635787..1aebac89cd6 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -505,9 +505,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<SQL>{
{xbstart} {
token_start = yytext;
+ state_before_str_start = YYSTATE;
BEGIN(xb);
startlit();
- addlitchar('b');
}
} /* <SQL> */
@@ -519,9 +519,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<SQL>{xhstart} {
token_start = yytext;
+ state_before_str_start = YYSTATE;
BEGIN(xh);
startlit();
- addlitchar('x');
}
<xh><<EOF>> { mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal"); }
@@ -597,12 +597,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
switch (state_before_str_stop)
{
case xb:
- if (literalbuf[strspn(literalbuf, "01") + 1] != '\0')
+ if (literalbuf[strspn(literalbuf, "01")] != '\0')
mmerror(PARSE_ERROR, ET_ERROR, "invalid bit string literal");
- base_yylval.str = mm_strdup(literalbuf);
+ base_yylval.str = psprintf("b'%s'", literalbuf);
return BCONST;
case xh:
- base_yylval.str = mm_strdup(literalbuf);
+ if (literalbuf[strspn(literalbuf, "0123456789abcdefABCDEF")] != '\0')
+ mmerror(PARSE_ERROR, ET_ERROR, "invalid hex string literal");
+ base_yylval.str = psprintf("x'%s'", literalbuf);
return XCONST;
case xq:
/* fallthrough */