3 /* disable unused functions so we don't
4 get compiler warnings about them */
6 %option noyywrap nounput noinput
8 /* change our prefix from yy to csv */
12 /* use the pure parser calling convention */
14 %option reentrant bison-bridge
19 #define YY_EXIT_FAILURE ((void)yyscanner, EXIT_FAILURE)
21 /* XOPEN for strdup */
22 #define _XOPEN_SOURCE 600
26 /* seems like a bug that I have to do this, since flex
27 should know prefix=csv and match bison's CSVSTYPE */
28 #define YYSTYPE CSVSTYPE
35 /* yyleng is precomputed strlen(yytext) */
39 s = yylval->str = calloc(n, 1);
43 /* copy yytext, changing "" to " */
44 for (i = 1 /*skip 0="*/; i < n-1; i++)
48 i++; /* skip second one */
53 [^",\r\n]+ { yylval->str = strdup(yytext); return FIELD; }
54 \n|\r\n { return CRLF; }