Make the lexer reentrant (to avoid "still reachable" memory).
This allows the final program to be 100% "valgrind clean", (freeing all memory that it allocates). This will make it much easier to ensure that any allocation that parser actions perform are also cleaned up.
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
#include "glcpp-parse.h"
|
||||
%}
|
||||
|
||||
%option noyywrap
|
||||
%option reentrant noyywrap
|
||||
|
||||
%%
|
||||
|
||||
|
@@ -28,10 +28,13 @@
|
||||
#define YYSTYPE int
|
||||
|
||||
void
|
||||
yyerror (const char *error);
|
||||
yyerror (const char *error, void *scanner);
|
||||
|
||||
%}
|
||||
|
||||
%parse-param {void *scanner}
|
||||
%lex-param {void *scanner}
|
||||
|
||||
%token TOKEN
|
||||
|
||||
%%
|
||||
@@ -51,7 +54,7 @@ token: TOKEN
|
||||
%%
|
||||
|
||||
void
|
||||
yyerror (const char *error)
|
||||
yyerror (const char *error, void *scanner)
|
||||
{
|
||||
fprintf (stderr, "Parse error: %s\n", error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user