Fix missing yyerror arg.

Fixes #1
This commit is contained in:
Jeff Garzik 2018-02-16 23:53:30 -05:00
parent a6595bbf20
commit dd40182dce
6 changed files with 21 additions and 10 deletions

View File

@ -12,7 +12,12 @@ pkgconfig_DATA = libsqlpars.pc
# noinst_PROGRAMS = $(TESTS) # noinst_PROGRAMS = $(TESTS)
EXTRA_DIST = sql.y sql.l \ EXTRA_DIST = sql.y sql.l \
test-ok.sh test-fail.sh \ test-ok.sh test-fail.sh \
fail1.sql ok1.sql fail1.sql \
xfail2.sql \
fail3.sql \
fail4.sql \
ok1.sql \
ok2.sql
sql_SOURCES = exec.c sql-parser.h sql_SOURCES = exec.c sql-parser.h
nodist_sql_SOURCES = sql.c sql.tab.c sql.tab.h sql.lex.h nodist_sql_SOURCES = sql.c sql.tab.c sql.tab.h sql.lex.h

2
fail3.sql Normal file
View File

@ -0,0 +1,2 @@
select (`foo

2
fail4.sql Normal file
View File

@ -0,0 +1,2 @@
select ('foo

1
ok2.sql Normal file
View File

@ -0,0 +1 @@
select [ab] from d;

18
sql.l
View File

@ -26,7 +26,7 @@
#include "sql.tab.h" #include "sql.tab.h"
#include "sql-parser.h" #include "sql-parser.h"
void yyerror(YYLTYPE *, struct psql_state *pstate, const char *s, ...); void yyerror(YYLTYPE *, yyscan_t scanner, struct psql_state *pstate, const char *s, ...);
int oldstate; int oldstate;
@ -297,8 +297,8 @@ FALSE { yylval->intval = 0; return BOOL; }
'(\\.|''|[^'\n])*' | '(\\.|''|[^'\n])*' |
\"(\\.|\"\"|[^"\n])*\" { yylval->strval = strdup(yytext); return STRING; } \"(\\.|\"\"|[^"\n])*\" { yylval->strval = strdup(yytext); return STRING; }
'(\\.|[^'\n])*$ { yyerror(yylloc, pstate, "Unterminated string %s", yytext); } '(\\.|[^'\n])*$ { yyerror(yylloc, pstate->scanner, pstate, "Unterminated string %s", yytext); }
\"(\\.|[^"\n])*$ { yyerror(yylloc, pstate, "Unterminated string %s", yytext); } \"(\\.|[^"\n])*$ { yyerror(yylloc, pstate->scanner, pstate, "Unterminated string %s", yytext); }
/* hex strings */ /* hex strings */
X'[0-9A-F]+' | X'[0-9A-F]+' |
@ -349,7 +349,7 @@ COUNT { int c = input(pstate->scanner); unput(c);
yylval->strval[yyleng-2] = 0; yylval->strval[yyleng-2] = 0;
return NAME; } return NAME; }
`[^`\n]*$ { yyerror(yylloc, pstate, "unterminated quoted name %s", yytext); } `[^`\n]*$ { yyerror(yylloc, pstate->scanner, pstate, "unterminated quoted name %s", yytext); }
/* user variables */ /* user variables */
@[0-9a-z_.$]+ | @[0-9a-z_.$]+ |
@ -357,9 +357,9 @@ COUNT { int c = input(pstate->scanner); unput(c);
@`[^`\n]+` | @`[^`\n]+` |
@'[^'\n]+' { yylval->strval = strdup(yytext+1); return USERVAR; } @'[^'\n]+' { yylval->strval = strdup(yytext+1); return USERVAR; }
@\"[^"\n]*$ { yyerror(yylloc, pstate, "unterminated quoted user variable %s", yytext); } @\"[^"\n]*$ { yyerror(yylloc, pstate->scanner, pstate, "unterminated quoted user variable %s", yytext); }
@`[^`\n]*$ { yyerror(yylloc, pstate, "unterminated quoted user variable %s", yytext); } @`[^`\n]*$ { yyerror(yylloc, pstate->scanner, pstate, "unterminated quoted user variable %s", yytext); }
@'[^'\n]*$ { yyerror(yylloc, pstate, "unterminated quoted user variable %s", yytext); } @'[^'\n]*$ { yyerror(yylloc, pstate->scanner, pstate, "unterminated quoted user variable %s", yytext); }
":=" { return ASSIGN; } ":=" { return ASSIGN; }
@ -372,12 +372,12 @@ COUNT { int c = input(pstate->scanner); unput(c);
<COMMENT>"*/" { BEGIN oldstate; } <COMMENT>"*/" { BEGIN oldstate; }
<COMMENT>. ; <COMMENT>. ;
<COMMENT>\n { yycolumn = 1; } <COMMENT>\n { yycolumn = 1; }
<COMMENT><<EOF>> { yyerror(yylloc, pstate, "unclosed comment"); } <COMMENT><<EOF>> { yyerror(yylloc, pstate->scanner, pstate, "unclosed comment"); }
/* everything else */ /* everything else */
[ \t] /* white space */ [ \t] /* white space */
\n { yycolumn = 1; } \n { yycolumn = 1; }
. { yyerror(yylloc, pstate, "mystery character '%c'", *yytext); } . { yyerror(yylloc, pstate->scanner, pstate, "mystery character '%c'", *yytext); }
%% %%

1
xfail2.sql Normal file
View File

@ -0,0 +1 @@
/*