egg: Fix egg lexer state not being cleaned up after error

This commit is contained in:
rdb 2021-01-01 15:52:42 +01:00
parent 339331c1ad
commit 152d317c8c
5 changed files with 25 additions and 0 deletions

View File

@ -971,6 +971,7 @@ extern "C" int eggyywrap(void); // declared below.
static int yyinput(void); // declared by flex.
int eggyylex_destroy(void);
////////////////////////////////////////////////////////////////////
// Static variables
@ -1018,6 +1019,15 @@ egg_init_lexer(istream &in, const string &filename) {
initial_token = START_EGG;
}
void
egg_cleanup_lexer() {
// Reset the lexer state.
eggyylex_destroy();
input_p = nullptr;
egg_filename.clear();
}
void
egg_start_group_body() {
/* Set the initial state to begin within a group_body context,

View File

@ -26,6 +26,7 @@ extern "C" int eggyywrap(void); // declared below.
static int yyinput(void); // declared by flex.
int eggyylex_destroy(void);
////////////////////////////////////////////////////////////////////
// Static variables
@ -73,6 +74,15 @@ egg_init_lexer(istream &in, const string &filename) {
initial_token = START_EGG;
}
void
egg_cleanup_lexer() {
// Reset the lexer state.
yylex_destroy();
input_p = nullptr;
egg_filename.clear();
}
void
egg_start_group_body() {
/* Set the initial state to begin within a group_body context,

View File

@ -21,6 +21,7 @@
#include <string>
void egg_init_lexer(std::istream &in, const std::string &filename);
void egg_cleanup_lexer();
void egg_start_group_body();
void egg_start_texture_body();
void egg_start_primitive_body();

View File

@ -223,6 +223,8 @@ egg_cleanup_parser() {
textures.clear();
materials.clear();
groups.clear();
egg_cleanup_lexer();
}

View File

@ -153,6 +153,8 @@ egg_cleanup_parser() {
textures.clear();
materials.clear();
groups.clear();
egg_cleanup_lexer();
}
%}