struct cdecl *cdecl_parse_decl(const char *declstr)
{
YY_BUFFER_STATE state;
+ yyscan_t scanner;
struct cdecl *decl;
int rc;
- state = yy_scan_string(declstr);
- rc = yyparse(&decl);
- yy_delete_buffer(state);
+ rc = yylex_init(&scanner);
+ if (rc != 0)
+ return NULL;
+
+ state = yy_scan_string(declstr, scanner);
+ rc = yyparse(scanner, &decl);
+ yy_delete_buffer(state, scanner);
+ yylex_destroy(scanner);
if (rc != 0)
return NULL;
*/
}
+%parse-param {yyscan_t scanner}
%parse-param {struct cdecl **out}
+%lex-param {yyscan_t scanner}
%define api.pure
%error-verbose
%locations
#include "cdecl.h"
#define FAIL(msg) do { \
- yyerror(&yylloc, NULL, msg); \
+ yyerror(&yylloc, NULL, NULL, msg); \
YYERROR; \
} while (0)
}
%code provides {
-void yyerror(YYLTYPE *, struct cdecl **, const char *);
-int yyparse(struct cdecl **out);
+void yyerror(YYLTYPE *, struct cdecl **, void *, const char *);
+int yyparse(void *scanner, struct cdecl **out);
}
%union {
}
%%
-void yyerror(YYLTYPE *loc, struct cdecl **out, const char *err)
+void
+yyerror(YYLTYPE *loc, struct cdecl **out, yyscan_t scanner, const char *err)
{
if (strstr(err, "T_LEX_ERROR"))
return;
#include "parse.h"
}
-%option noyywrap bison-locations
+%option noyywrap bison-locations reentrant
%{
#define lex_error(msg) do { \
- yyerror(yylloc, NULL, (msg)); \
+ yyerror(yylloc, NULL, NULL, (msg)); \
return T_LEX_ERROR; \
} while(0)
%}