]> git.draconx.ca Git - cdecl99.git/commitdiff
Use the reentrant scanner API.
authorNick Bowler <nbowler@draconx.ca>
Thu, 7 Jul 2011 22:33:44 +0000 (18:33 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 7 Jul 2011 22:33:44 +0000 (18:33 -0400)
src/parse-decl.c
src/parse.y
src/scan.l

index 059f5f770a2d6ecbb7af799a89f10363d54b93f0..c088471d9e7e4a6a203ab4ccf4edfc5e36284425 100644 (file)
@@ -373,12 +373,18 @@ static bool forall_declarators(struct cdecl *decl,
 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;
index 63d5fa927dc4ec48e1289321798bcb68183a3acf..2b02a5e7d6eb7ad4d6226d09e265bb4f5252219a 100644 (file)
@@ -18,7 +18,9 @@
  */
 }
 
+%parse-param {yyscan_t scanner}
 %parse-param {struct cdecl **out}
+%lex-param {yyscan_t scanner}
 %define api.pure
 %error-verbose
 %locations
@@ -31,7 +33,7 @@
 #include "cdecl.h"
 
 #define FAIL(msg) do { \
-       yyerror(&yylloc, NULL, msg); \
+       yyerror(&yylloc, NULL, NULL, msg); \
        YYERROR; \
 } while (0)
 
@@ -52,8 +54,8 @@
 }
 
 %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 {
@@ -381,7 +383,8 @@ direct_declarator: {
 }
 
 %%
-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;
index f0bf30af01022a2f352dcd69e24818db1abbd994..06647de3170551252f3900b4bc49d59ab29bce62 100644 (file)
  #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)
 %}