No more <<EOF>>
Started by Peter Eisentrautover 25 years ago2 messages
On the road to sanitary lex files I finally found a simple answer for the
non-portable <<EOF>>. Patch attached. Any objections/concerns/comments?
--
Peter Eisentraut Sernanders v�g 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
Attachments:
lexer-patchtext/plain; CHARSET=US-ASCII; NAME=lexer-patchDownload
*** pgsql-cvs/src/backend/parser/scan.l Sat Mar 18 23:49:15 2000
--- pgsql/src/backend/parser/scan.l Sat May 20 19:44:04 2000
***************
*** 255,262 ****
<xc>{xcinside} { /* ignore */ }
- <xc><<EOF>> { elog(ERROR, "Unterminated /* comment"); }
-
{xbstart} {
BEGIN(xb);
startlit();
--- 255,260 ----
***************
*** 280,286 ****
<xb>{xbcat} {
/* ignore */
}
- <xb><<EOF>> { elog(ERROR, "Unterminated binary integer"); }
{xhstart} {
BEGIN(xh);
--- 278,283 ----
***************
*** 297,303 ****
literalbuf);
return ICONST;
}
- <xh><<EOF>> { elog(ERROR, "Unterminated hexadecimal integer"); }
{xqstart} {
BEGIN(xq);
--- 294,299 ----
***************
*** 316,322 ****
<xq>{xqcat} {
/* ignore */
}
- <xq><<EOF>> { elog(ERROR, "Unterminated quoted string"); }
{xdstart} {
--- 312,317 ----
***************
*** 331,337 ****
<xd>{xdinside} {
addlit(yytext, yyleng);
}
- <xd><<EOF>> { elog(ERROR, "Unterminated quoted identifier"); }
{typecast} { return TYPECAST; }
--- 326,331 ----
***************
*** 468,477 ****
elog(ERROR, "parser: %s at or near \"%s\"", message, yytext);
}
int yywrap()
{
! return(1);
}
/*
init_io:
--- 462,501 ----
elog(ERROR, "parser: %s at or near \"%s\"", message, yytext);
}
+
+ /*
+ * POSIX stores the active start condition in YY_START, AT&T in YYSTATE
+ */
+ #ifndef YY_START
+ # define YY_START YYSTATE
+ #endif
+
int yywrap()
{
! if (YY_START == INITIAL)
! return 1;
!
! /*
! * If there's still a start condition active at the end of input,
! * then someone must have forgotten to close a delimited block.
! */
! switch (YY_START)
! {
! case xc:
! elog(ERROR, "Unterminated /* comment");
! case xb:
! elog(ERROR, "Unterminated binary integer");
! case xh:
! elog(ERROR, "Unterminated hexadecimal integer");
! case xq:
! elog(ERROR, "Unterminated quoted string");
! case xd:
! elog(ERROR, "Unterminated quoted identifier");
! }
!
! return 1;
}
+
/*
init_io:
Re: No more <<EOF>>
Peter Eisentraut <peter_e@gmx.net> writes:
On the road to sanitary lex files I finally found a simple answer for the
non-portable <<EOF>>. Patch attached. Any objections/concerns/comments?
Seems reasonable --- but is it worth worrying about? I had pretty
much concluded that we have no hope of working with non-flex lexers
anyway...
regards, tom lane