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 bison-locations
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
29 #define YYLTYPE CSVLTYPE
37 yylloc->first_line = yylloc->last_line;
38 yylloc->first_column = yylloc->last_column;
39 yylloc->last_column += yyleng;
41 /* yyleng is precomputed strlen(yytext) */
45 s = yylval->str = calloc(n, 1);
49 /* copy yytext, changing "" to " */
50 for (i = 1 /*skip 0="*/; i < n-1; i++)
54 i++; /* skip second one */
61 yylloc->first_line = yylloc->last_line;
62 yylloc->first_column = yylloc->last_column;
63 yylloc->last_column += yyleng;
65 yylval->str = strdup(yytext);
70 /* Update location - newline resets column and increments line */
71 yylloc->first_line = yylloc->last_line;
72 yylloc->first_column = yylloc->last_column;
74 yylloc->last_column = 1;
81 yylloc->first_line = yylloc->last_line;
82 yylloc->first_column = yylloc->last_column;
83 yylloc->last_column++;